Commit f1741fa8 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 9592bd0a
......@@ -25,6 +25,7 @@
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-device.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/spinlock.h>
......@@ -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;
......
......@@ -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 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment