diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-dev.c | 34 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 7 |
2 files changed, 16 insertions, 25 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 0c061e16502e..c8859d6ff6ad 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 = { | |||
495 | }; | 495 | }; |
496 | 496 | ||
497 | /** | 497 | /** |
498 | * get_index - assign stream index number based on parent device | 498 | * get_index - assign stream index number based on v4l2_dev |
499 | * @vdev: video_device to assign index number to, vdev->parent should be assigned | 499 | * @vdev: video_device to assign index number to, vdev->v4l2_dev should be assigned |
500 | * | 500 | * |
501 | * Note that when this is called the new device has not yet been registered | 501 | * Note that when this is called the new device has not yet been registered |
502 | * in the video_device array, but it was able to obtain a minor number. | 502 | * 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) | |||
514 | static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES); | 514 | static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES); |
515 | int i; | 515 | int i; |
516 | 516 | ||
517 | /* Some drivers do not set the parent. In that case always return 0. */ | ||
518 | if (vdev->parent == NULL) | ||
519 | return 0; | ||
520 | |||
521 | bitmap_zero(used, VIDEO_NUM_DEVICES); | 517 | bitmap_zero(used, VIDEO_NUM_DEVICES); |
522 | 518 | ||
523 | for (i = 0; i < VIDEO_NUM_DEVICES; i++) { | 519 | for (i = 0; i < VIDEO_NUM_DEVICES; i++) { |
524 | if (video_device[i] != NULL && | 520 | if (video_device[i] != NULL && |
525 | video_device[i]->parent == vdev->parent) { | 521 | video_device[i]->v4l2_dev == vdev->v4l2_dev) { |
526 | set_bit(video_device[i]->index, used); | 522 | set_bit(video_device[i]->index, used); |
527 | } | 523 | } |
528 | } | 524 | } |
@@ -775,6 +771,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr, | |||
775 | /* the release callback MUST be present */ | 771 | /* the release callback MUST be present */ |
776 | if (WARN_ON(!vdev->release)) | 772 | if (WARN_ON(!vdev->release)) |
777 | return -EINVAL; | 773 | return -EINVAL; |
774 | /* the v4l2_dev pointer MUST be present */ | ||
775 | if (WARN_ON(!vdev->v4l2_dev)) | ||
776 | return -EINVAL; | ||
778 | 777 | ||
779 | /* v4l2_fh support */ | 778 | /* v4l2_fh support */ |
780 | spin_lock_init(&vdev->fh_lock); | 779 | spin_lock_init(&vdev->fh_lock); |
@@ -802,16 +801,14 @@ int __video_register_device(struct video_device *vdev, int type, int nr, | |||
802 | 801 | ||
803 | vdev->vfl_type = type; | 802 | vdev->vfl_type = type; |
804 | vdev->cdev = NULL; | 803 | vdev->cdev = NULL; |
805 | if (vdev->v4l2_dev) { | 804 | if (vdev->dev_parent == NULL) |
806 | if (vdev->v4l2_dev->dev) | 805 | vdev->dev_parent = vdev->v4l2_dev->dev; |
807 | vdev->parent = vdev->v4l2_dev->dev; | 806 | if (vdev->ctrl_handler == NULL) |
808 | if (vdev->ctrl_handler == NULL) | 807 | vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; |
809 | vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; | 808 | /* If the prio state pointer is NULL, then use the v4l2_device |
810 | /* If the prio state pointer is NULL, then use the v4l2_device | 809 | prio state. */ |
811 | prio state. */ | 810 | if (vdev->prio == NULL) |
812 | if (vdev->prio == NULL) | 811 | vdev->prio = &vdev->v4l2_dev->prio; |
813 | vdev->prio = &vdev->v4l2_dev->prio; | ||
814 | } | ||
815 | 812 | ||
816 | /* Part 2: find a free minor, device node number and device index. */ | 813 | /* Part 2: find a free minor, device node number and device index. */ |
817 | #ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES | 814 | #ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES |
@@ -896,8 +893,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr, | |||
896 | /* Part 4: register the device with sysfs */ | 893 | /* Part 4: register the device with sysfs */ |
897 | vdev->dev.class = &video_class; | 894 | vdev->dev.class = &video_class; |
898 | vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); | 895 | vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); |
899 | if (vdev->parent) | 896 | vdev->dev.parent = vdev->dev_parent; |
900 | vdev->dev.parent = vdev->parent; | ||
901 | dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); | 897 | dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); |
902 | ret = device_register(&vdev->dev); | 898 | ret = device_register(&vdev->dev); |
903 | if (ret < 0) { | 899 | if (ret < 0) { |
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index c9d9f01d21bc..68e6b5e912ff 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -1813,12 +1813,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, | |||
1813 | p->flags |= V4L2_CHIP_FL_WRITABLE; | 1813 | p->flags |= V4L2_CHIP_FL_WRITABLE; |
1814 | if (ops->vidioc_g_register) | 1814 | if (ops->vidioc_g_register) |
1815 | p->flags |= V4L2_CHIP_FL_READABLE; | 1815 | p->flags |= V4L2_CHIP_FL_READABLE; |
1816 | if (vfd->v4l2_dev) | 1816 | strlcpy(p->name, vfd->v4l2_dev->name, sizeof(p->name)); |
1817 | strlcpy(p->name, vfd->v4l2_dev->name, sizeof(p->name)); | ||
1818 | else if (vfd->parent) | ||
1819 | strlcpy(p->name, vfd->parent->driver->name, sizeof(p->name)); | ||
1820 | else | ||
1821 | strlcpy(p->name, "bridge", sizeof(p->name)); | ||
1822 | if (ops->vidioc_g_chip_info) | 1817 | if (ops->vidioc_g_chip_info) |
1823 | return ops->vidioc_g_chip_info(file, fh, arg); | 1818 | return ops->vidioc_g_chip_info(file, fh, arg); |
1824 | if (p->match.addr) | 1819 | if (p->match.addr) |