aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-03 06:27:57 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-17 08:26:36 -0400
commitcf9033f9b5d867ae040d37a148cf1c1e645ffe96 (patch)
tree729f8c1c7821f2879f9d596cce959ee2b1fafb54
parent099f88ee20c4d387a7bd76e0a5765533b1f5b6b0 (diff)
[media] radio-tea5764: embed struct video_device
This simplifies the code as it removes a memory allocation check. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: Fabio Belavenuto <belavenuto@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/radio/radio-tea5764.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index f6a5471e51aa..4e0bf644b4f9 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -141,7 +141,7 @@ static int use_xtal = RADIO_TEA5764_XTAL;
141struct tea5764_device { 141struct tea5764_device {
142 struct v4l2_device v4l2_dev; 142 struct v4l2_device v4l2_dev;
143 struct i2c_client *i2c_client; 143 struct i2c_client *i2c_client;
144 struct video_device *videodev; 144 struct video_device vdev;
145 struct tea5764_regs regs; 145 struct tea5764_regs regs;
146 struct mutex mutex; 146 struct mutex mutex;
147}; 147};
@@ -303,7 +303,7 @@ static int vidioc_querycap(struct file *file, void *priv,
303 struct v4l2_capability *v) 303 struct v4l2_capability *v)
304{ 304{
305 struct tea5764_device *radio = video_drvdata(file); 305 struct tea5764_device *radio = video_drvdata(file);
306 struct video_device *dev = radio->videodev; 306 struct video_device *dev = &radio->vdev;
307 307
308 strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); 308 strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver));
309 strlcpy(v->card, dev->name, sizeof(v->card)); 309 strlcpy(v->card, dev->name, sizeof(v->card));
@@ -491,7 +491,7 @@ static struct video_device tea5764_radio_template = {
491 .name = "TEA5764 FM-Radio", 491 .name = "TEA5764 FM-Radio",
492 .fops = &tea5764_fops, 492 .fops = &tea5764_fops,
493 .ioctl_ops = &tea5764_ioctl_ops, 493 .ioctl_ops = &tea5764_ioctl_ops,
494 .release = video_device_release, 494 .release = video_device_release_empty,
495}; 495};
496 496
497/* I2C probe: check if the device exists and register with v4l if it is */ 497/* I2C probe: check if the device exists and register with v4l if it is */
@@ -528,17 +528,12 @@ static int tea5764_i2c_probe(struct i2c_client *client,
528 goto errunreg; 528 goto errunreg;
529 } 529 }
530 530
531 radio->videodev = video_device_alloc(); 531 radio->vdev = tea5764_radio_template;
532 if (!(radio->videodev)) {
533 ret = -ENOMEM;
534 goto errunreg;
535 }
536 *radio->videodev = tea5764_radio_template;
537 532
538 i2c_set_clientdata(client, radio); 533 i2c_set_clientdata(client, radio);
539 video_set_drvdata(radio->videodev, radio); 534 video_set_drvdata(&radio->vdev, radio);
540 radio->videodev->lock = &radio->mutex; 535 radio->vdev.lock = &radio->mutex;
541 radio->videodev->v4l2_dev = v4l2_dev; 536 radio->vdev.v4l2_dev = v4l2_dev;
542 537
543 /* initialize and power off the chip */ 538 /* initialize and power off the chip */
544 tea5764_i2c_read(radio); 539 tea5764_i2c_read(radio);
@@ -546,16 +541,14 @@ static int tea5764_i2c_probe(struct i2c_client *client,
546 tea5764_mute(radio, 1); 541 tea5764_mute(radio, 1);
547 tea5764_power_down(radio); 542 tea5764_power_down(radio);
548 543
549 ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); 544 ret = video_register_device(&radio->vdev, VFL_TYPE_RADIO, radio_nr);
550 if (ret < 0) { 545 if (ret < 0) {
551 PWARN("Could not register video device!"); 546 PWARN("Could not register video device!");
552 goto errrel; 547 goto errunreg;
553 } 548 }
554 549
555 PINFO("registered."); 550 PINFO("registered.");
556 return 0; 551 return 0;
557errrel:
558 video_device_release(radio->videodev);
559errunreg: 552errunreg:
560 v4l2_device_unregister(v4l2_dev); 553 v4l2_device_unregister(v4l2_dev);
561errfr: 554errfr:
@@ -570,7 +563,7 @@ static int tea5764_i2c_remove(struct i2c_client *client)
570 PDEBUG("remove"); 563 PDEBUG("remove");
571 if (radio) { 564 if (radio) {
572 tea5764_power_down(radio); 565 tea5764_power_down(radio);
573 video_unregister_device(radio->videodev); 566 video_unregister_device(&radio->vdev);
574 v4l2_device_unregister(&radio->v4l2_dev); 567 v4l2_device_unregister(&radio->v4l2_dev);
575 kfree(radio); 568 kfree(radio);
576 } 569 }