summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/v4l2-dev.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-06-12 11:15:12 -0300
committerChanho Park <chanho61.park@samsung.com>2014-11-18 11:48:34 +0900
commit8c390941f79ffc1141d107b4931a1253fa545aa3 (patch)
treebf20fe566bff9667f7c026a97a781546171545b7 /drivers/media/v4l2-core/v4l2-dev.c
parent3f68dec2db34e197851f35c6e0cd7e084595989a (diff)
downloadlinux-3.10-8c390941f79ffc1141d107b4931a1253fa545aa3.tar.gz
linux-3.10-8c390941f79ffc1141d107b4931a1253fa545aa3.tar.bz2
linux-3.10-8c390941f79ffc1141d107b4931a1253fa545aa3.zip
upstream: [media] v4l2: always require v4l2_dev, rename parent to dev_parent
The last set of drivers still using the parent field of video_device instead of the v4l2_dev field have been converted, so v4l2_dev is now always set. A proper pointer to v4l2_dev is necessary these days otherwise the advanced debugging ioctls will not work when addressing sub-devices. It also ensures that the core can always go from a video_device struct to the top-level v4l2_device struct. There is still one single use case for the parent pointer: if there are multiple busses, each being the parent of one or more video nodes, and if they all share the same v4l2_device struct. In that case one still needs a parent pointer since the v4l2_device struct can only refer to a single parent device. The cx88 driver is one such case. Unfortunately, the cx88 failed to set the parent pointer since 3.6. The next patch will correct this. In order to support this use-case the parent pointer is only renamed to dev_parent, not removed altogether. It has been renamed to ensure that the compiler will catch any (possibly out-of-tree) drivers that were missed during the conversion. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-dev.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-dev.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 2f3fac5345d..8856ef171c5 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -495,8 +495,8 @@ static const struct file_operations v4l2_fops = {
};
/**
- * get_index - assign stream index number based on parent device
- * @vdev: video_device to assign index number to, vdev->parent should be assigned
+ * get_index - assign stream index number based on v4l2_dev
+ * @vdev: video_device to assign index number to, vdev->v4l2_dev should be assigned
*
* Note that when this is called the new device has not yet been registered
* in the video_device array, but it was able to obtain a minor number.
@@ -514,15 +514,11 @@ static int get_index(struct video_device *vdev)
static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES);
int i;
- /* Some drivers do not set the parent. In that case always return 0. */
- if (vdev->parent == NULL)
- return 0;
-
bitmap_zero(used, VIDEO_NUM_DEVICES);
for (i = 0; i < VIDEO_NUM_DEVICES; i++) {
if (video_device[i] != NULL &&
- video_device[i]->parent == vdev->parent) {
+ video_device[i]->v4l2_dev == vdev->v4l2_dev) {
set_bit(video_device[i]->index, used);
}
}
@@ -776,6 +772,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
/* the release callback MUST be present */
if (WARN_ON(!vdev->release))
return -EINVAL;
+ /* the v4l2_dev pointer MUST be present */
+ if (WARN_ON(!vdev->v4l2_dev))
+ return -EINVAL;
/* v4l2_fh support */
spin_lock_init(&vdev->fh_lock);
@@ -803,16 +802,14 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
vdev->vfl_type = type;
vdev->cdev = NULL;
- if (vdev->v4l2_dev) {
- if (vdev->v4l2_dev->dev)
- vdev->parent = vdev->v4l2_dev->dev;
- if (vdev->ctrl_handler == NULL)
- vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler;
- /* If the prio state pointer is NULL, then use the v4l2_device
- prio state. */
- if (vdev->prio == NULL)
- vdev->prio = &vdev->v4l2_dev->prio;
- }
+ if (vdev->dev_parent == NULL)
+ vdev->dev_parent = vdev->v4l2_dev->dev;
+ if (vdev->ctrl_handler == NULL)
+ vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler;
+ /* If the prio state pointer is NULL, then use the v4l2_device
+ prio state. */
+ if (vdev->prio == NULL)
+ vdev->prio = &vdev->v4l2_dev->prio;
/* Part 2: find a free minor, device node number and device index. */
#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
@@ -897,8 +894,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
/* Part 4: register the device with sysfs */
vdev->dev.class = &video_class;
vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
- if (vdev->parent)
- vdev->dev.parent = vdev->parent;
+ vdev->dev.parent = vdev->dev_parent;
dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
ret = device_register(&vdev->dev);
if (ret < 0) {