From: Hans Verkuil Date: Wed, 12 Jun 2013 08:46:30 +0000 (-0300) Subject: [media] sn9c102_core: add v4l2_device and replace parent with v4l2_dev X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f1741fa8dd4a561e883cf60f103c40eda8790d80;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [media] sn9c102_core: add v4l2_device and replace parent with v4l2_dev 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 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/sn9c102/sn9c102.h b/drivers/media/usb/sn9c102/sn9c102.h index 2bc153e869be..8a917f060503 100644 --- a/drivers/media/usb/sn9c102/sn9c102.h +++ b/drivers/media/usb/sn9c102/sn9c102.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,8 @@ static DECLARE_RWSEM(sn9c102_dev_lock); struct sn9c102_device { struct video_device* v4ldev; + struct v4l2_device v4l2_dev; + enum sn9c102_bridge bridge; struct sn9c102_sensor sensor; diff --git a/drivers/media/usb/sn9c102/sn9c102_core.c b/drivers/media/usb/sn9c102/sn9c102_core.c index c957e9aa6077..2cb44de2b92c 100644 --- a/drivers/media/usb/sn9c102/sn9c102_core.c +++ b/drivers/media/usb/sn9c102/sn9c102_core.c @@ -1737,6 +1737,7 @@ static void sn9c102_release_resources(struct kref *kref) video_device_node_name(cam->v4ldev)); video_set_drvdata(cam->v4ldev, NULL); video_unregister_device(cam->v4ldev); + v4l2_device_unregister(&cam->v4l2_dev); usb_put_dev(cam->usbdev); kfree(cam->control_buffer); kfree(cam); @@ -3254,6 +3255,13 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) cam->usbdev = udev; + /* register v4l2_device early so it can be used for printks */ + if (v4l2_device_register(&intf->dev, &cam->v4l2_dev)) { + dev_err(&intf->dev, "v4l2_device_register failed\n"); + err = -ENOMEM; + goto fail; + } + if (!(cam->control_buffer = kzalloc(8, GFP_KERNEL))) { DBG(1, "kzalloc() failed"); err = -ENOMEM; @@ -3325,7 +3333,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) strcpy(cam->v4ldev->name, "SN9C1xx PC Camera"); cam->v4ldev->fops = &sn9c102_fops; cam->v4ldev->release = video_device_release; - cam->v4ldev->parent = &udev->dev; + cam->v4ldev->v4l2_dev = &cam->v4l2_dev; init_completion(&cam->probe); @@ -3377,6 +3385,7 @@ fail: kfree(cam->control_buffer); if (cam->v4ldev) video_device_release(cam->v4ldev); + v4l2_device_unregister(&cam->v4l2_dev); kfree(cam); } return err; @@ -3407,6 +3416,8 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) wake_up_interruptible_all(&cam->wait_open); + v4l2_device_disconnect(&cam->v4l2_dev); + kref_put(&cam->kref, sn9c102_release_resources); up_write(&sn9c102_dev_lock);