[media] hdpvr: embed video_device
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 9 Mar 2015 16:34:09 +0000 (13:34 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 3 Apr 2015 02:36:54 +0000 (23:36 -0300)
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>
drivers/media/usb/hdpvr/hdpvr-core.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/hdpvr/hdpvr.h

index 42b4cdf28cfd9d24e89e38a7ca3eb84a0354b57e..3fc64197b4e6a6475c89b61d580bf3a4317e4b35 100644 (file)
@@ -69,10 +69,6 @@ MODULE_DEVICE_TABLE(usb, hdpvr_table);
 void hdpvr_delete(struct hdpvr_device *dev)
 {
        hdpvr_free_buffers(dev);
-
-       if (dev->video_dev)
-               video_device_release(dev->video_dev);
-
        usb_put_dev(dev->udev);
 }
 
@@ -397,7 +393,7 @@ static int hdpvr_probe(struct usb_interface *interface,
 
        /* let the user know what node this device is now attached to */
        v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
-                 video_device_node_name(dev->video_dev));
+                 video_device_node_name(&dev->video_dev));
        return 0;
 
 reg_fail:
@@ -420,7 +416,7 @@ static void hdpvr_disconnect(struct usb_interface *interface)
        struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface));
 
        v4l2_info(&dev->v4l2_dev, "device %s disconnected\n",
-                 video_device_node_name(dev->video_dev));
+                 video_device_node_name(&dev->video_dev));
        /* prevent more I/O from starting and stop any ongoing */
        mutex_lock(&dev->io_mutex);
        dev->status = STATUS_DISCONNECTED;
@@ -436,7 +432,7 @@ static void hdpvr_disconnect(struct usb_interface *interface)
 #if IS_ENABLED(CONFIG_I2C)
        i2c_del_adapter(&dev->i2c_adapter);
 #endif
-       video_unregister_device(dev->video_dev);
+       video_unregister_device(&dev->video_dev);
        atomic_dec(&dev_nr);
 }
 
index 59d15fd242ba04b8c38147225c538907b9cab4cc..d8d8c0f519fc2484edc04a4aa07f29154957ad9b 100644 (file)
@@ -797,7 +797,7 @@ static int vidioc_s_input(struct file *file, void *_fh,
                 * Comment this out for now, but if the legacy mode can be
                 * removed in the future, then this code should be enabled
                 * again.
-               dev->video_dev->tvnorms =
+               dev->video_dev.tvnorms =
                        (index != HDPVR_COMPONENT) ? V4L2_STD_ALL : 0;
                 */
        }
@@ -1228,19 +1228,12 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
        }
 
        /* setup and register video device */
-       dev->video_dev = video_device_alloc();
-       if (!dev->video_dev) {
-               v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n");
-               res = -ENOMEM;
-               goto error;
-       }
-
-       *dev->video_dev = hdpvr_video_template;
-       strcpy(dev->video_dev->name, "Hauppauge HD PVR");
-       dev->video_dev->v4l2_dev = &dev->v4l2_dev;
-       video_set_drvdata(dev->video_dev, dev);
+       dev->video_dev = hdpvr_video_template;
+       strcpy(dev->video_dev.name, "Hauppauge HD PVR");
+       dev->video_dev.v4l2_dev = &dev->v4l2_dev;
+       video_set_drvdata(&dev->video_dev, dev);
 
-       res = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum);
+       res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum);
        if (res < 0) {
                v4l2_err(&dev->v4l2_dev, "video_device registration failed\n");
                goto error;
index dc685d44cb3e4ef24284f9807c966af7e85a35a8..a3194304182d03b453959d4c068d3ecdc422afac 100644 (file)
@@ -66,7 +66,7 @@ struct hdpvr_options {
 /* Structure to hold all of our device specific stuff */
 struct hdpvr_device {
        /* the v4l device for this device */
-       struct video_device     *video_dev;
+       struct video_device     video_dev;
        /* the control handler for this device */
        struct v4l2_ctrl_handler hdl;
        /* the usb device for this device */