[media] f_uvc: add v4l2_device and replace parent with v4l2_dev
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 12 Jun 2013 09:02:38 +0000 (06:02 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 21 Jun 2013 14:04:47 +0000 (11:04 -0300)
This driver did not yet support struct v4l2_device, so add it. This
make it possible to replace the deprecated parent field with the
v4l2_dev field, allowing the eventual removal of the parent field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/usb/gadget/f_uvc.c
drivers/usb/gadget/uvc.h

index 38dcedddc52c0bb43b70e6c5faa8ac3857d5c466..1d06567ff41e6892cc668fbb58c8b4f8d83ca9f4 100644 (file)
@@ -413,7 +413,7 @@ uvc_register_video(struct uvc_device *uvc)
        if (video == NULL)
                return -ENOMEM;
 
-       video->parent = &cdev->gadget->dev;
+       video->v4l2_dev = &uvc->v4l2_dev;
        video->fops = &uvc_v4l2_fops;
        video->release = video_device_release;
        strlcpy(video->name, cdev->gadget->name, sizeof(video->name));
@@ -570,6 +570,7 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
        INFO(cdev, "uvc_function_unbind\n");
 
        video_unregister_device(uvc->vdev);
+       v4l2_device_unregister(&uvc->v4l2_dev);
        uvc->control_ep->driver_data = NULL;
        uvc->video.ep->driver_data = NULL;
 
@@ -697,6 +698,11 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
        if ((ret = usb_function_deactivate(f)) < 0)
                goto error;
 
+       if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
+               printk(KERN_INFO "v4l2_device_register failed\n");
+               goto error;
+       }
+
        /* Initialise video. */
        ret = uvc_video_init(&uvc->video);
        if (ret < 0)
@@ -712,6 +718,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
        return 0;
 
 error:
+       v4l2_device_unregister(&uvc->v4l2_dev);
        if (uvc->vdev)
                video_device_release(uvc->vdev);
 
index 817e9e19cecf75c34253f0ebbb75d7e9282e383a..7a9111de80542b0877f9cef36a1f788353b4e2ab 100644 (file)
@@ -57,6 +57,7 @@ struct uvc_event
 #include <linux/videodev2.h>
 #include <linux/version.h>
 #include <media/v4l2-fh.h>
+#include <media/v4l2-device.h>
 
 #include "uvc_queue.h"
 
@@ -145,6 +146,7 @@ enum uvc_state
 struct uvc_device
 {
        struct video_device *vdev;
+       struct v4l2_device v4l2_dev;
        enum uvc_state state;
        struct usb_function func;
        struct uvc_video video;