aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-03-09 12:34:09 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-02 22:36:54 -0400
commit4b30409b1b77975ed6197e3494662eedc7a1e26f (patch)
tree16b141f0b8123b49b953ad3cb4fe3ea01d0c80bc /drivers/media
parentdbe98b30d3a0d703369fef9712482e12fc685805 (diff)
[media] hdpvr: embed video_device
Embed the video_device struct to simplify the error handling and in order to (eventually) get rid of video_device_alloc/release. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c10
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-video.c19
-rw-r--r--drivers/media/usb/hdpvr/hdpvr.h2
3 files changed, 10 insertions, 21 deletions
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index 42b4cdf28cfd..3fc64197b4e6 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -69,10 +69,6 @@ MODULE_DEVICE_TABLE(usb, hdpvr_table);
69void hdpvr_delete(struct hdpvr_device *dev) 69void hdpvr_delete(struct hdpvr_device *dev)
70{ 70{
71 hdpvr_free_buffers(dev); 71 hdpvr_free_buffers(dev);
72
73 if (dev->video_dev)
74 video_device_release(dev->video_dev);
75
76 usb_put_dev(dev->udev); 72 usb_put_dev(dev->udev);
77} 73}
78 74
@@ -397,7 +393,7 @@ static int hdpvr_probe(struct usb_interface *interface,
397 393
398 /* let the user know what node this device is now attached to */ 394 /* let the user know what node this device is now attached to */
399 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n", 395 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
400 video_device_node_name(dev->video_dev)); 396 video_device_node_name(&dev->video_dev));
401 return 0; 397 return 0;
402 398
403reg_fail: 399reg_fail:
@@ -420,7 +416,7 @@ static void hdpvr_disconnect(struct usb_interface *interface)
420 struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface)); 416 struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface));
421 417
422 v4l2_info(&dev->v4l2_dev, "device %s disconnected\n", 418 v4l2_info(&dev->v4l2_dev, "device %s disconnected\n",
423 video_device_node_name(dev->video_dev)); 419 video_device_node_name(&dev->video_dev));
424 /* prevent more I/O from starting and stop any ongoing */ 420 /* prevent more I/O from starting and stop any ongoing */
425 mutex_lock(&dev->io_mutex); 421 mutex_lock(&dev->io_mutex);
426 dev->status = STATUS_DISCONNECTED; 422 dev->status = STATUS_DISCONNECTED;
@@ -436,7 +432,7 @@ static void hdpvr_disconnect(struct usb_interface *interface)
436#if IS_ENABLED(CONFIG_I2C) 432#if IS_ENABLED(CONFIG_I2C)
437 i2c_del_adapter(&dev->i2c_adapter); 433 i2c_del_adapter(&dev->i2c_adapter);
438#endif 434#endif
439 video_unregister_device(dev->video_dev); 435 video_unregister_device(&dev->video_dev);
440 atomic_dec(&dev_nr); 436 atomic_dec(&dev_nr);
441} 437}
442 438
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 59d15fd242ba..d8d8c0f519fc 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -797,7 +797,7 @@ static int vidioc_s_input(struct file *file, void *_fh,
797 * Comment this out for now, but if the legacy mode can be 797 * Comment this out for now, but if the legacy mode can be
798 * removed in the future, then this code should be enabled 798 * removed in the future, then this code should be enabled
799 * again. 799 * again.
800 dev->video_dev->tvnorms = 800 dev->video_dev.tvnorms =
801 (index != HDPVR_COMPONENT) ? V4L2_STD_ALL : 0; 801 (index != HDPVR_COMPONENT) ? V4L2_STD_ALL : 0;
802 */ 802 */
803 } 803 }
@@ -1228,19 +1228,12 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
1228 } 1228 }
1229 1229
1230 /* setup and register video device */ 1230 /* setup and register video device */
1231 dev->video_dev = video_device_alloc(); 1231 dev->video_dev = hdpvr_video_template;
1232 if (!dev->video_dev) { 1232 strcpy(dev->video_dev.name, "Hauppauge HD PVR");
1233 v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n"); 1233 dev->video_dev.v4l2_dev = &dev->v4l2_dev;
1234 res = -ENOMEM; 1234 video_set_drvdata(&dev->video_dev, dev);
1235 goto error;
1236 }
1237
1238 *dev->video_dev = hdpvr_video_template;
1239 strcpy(dev->video_dev->name, "Hauppauge HD PVR");
1240 dev->video_dev->v4l2_dev = &dev->v4l2_dev;
1241 video_set_drvdata(dev->video_dev, dev);
1242 1235
1243 res = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum); 1236 res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum);
1244 if (res < 0) { 1237 if (res < 0) {
1245 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); 1238 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n");
1246 goto error; 1239 goto error;
diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h
index dc685d44cb3e..a3194304182d 100644
--- a/drivers/media/usb/hdpvr/hdpvr.h
+++ b/drivers/media/usb/hdpvr/hdpvr.h
@@ -66,7 +66,7 @@ struct hdpvr_options {
66/* Structure to hold all of our device specific stuff */ 66/* Structure to hold all of our device specific stuff */
67struct hdpvr_device { 67struct hdpvr_device {
68 /* the v4l device for this device */ 68 /* the v4l device for this device */
69 struct video_device *video_dev; 69 struct video_device video_dev;
70 /* the control handler for this device */ 70 /* the control handler for this device */
71 struct v4l2_ctrl_handler hdl; 71 struct v4l2_ctrl_handler hdl;
72 /* the usb device for this device */ 72 /* the usb device for this device */