diff mbox

media: v4l2-dev: fix video device index assignment

Message ID 1386076469-26761-1-git-send-email-m.szyprowski@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marek Szyprowski Dec. 3, 2013, 1:14 p.m. UTC
The side effect of commit 1056e4388b045 ("v4l2-dev: Fix race condition on
__video_register_device") is the increased number of index value assigned
on video_device registration. Before that commit video_devices were
numbered from 0, after it, the indexes starts from 1, because get_index()
always count the device, which is being registered. Some device drivers
rely on video_device index number for internal purposes, i.e. s5p-mfc
driver stopped working after that patch. This patch restores the old method
of numbering the video_device indexes.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
In my opinion this patch should be applied also to stable v3.12 series.
---
 drivers/media/v4l2-core/v4l2-dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sakari Ailus Dec. 3, 2013, 1:23 p.m. UTC | #1
Hi, Marek!

Thanks for the patch.

On Tue, Dec 03, 2013 at 02:14:29PM +0100, Marek Szyprowski wrote:
> The side effect of commit 1056e4388b045 ("v4l2-dev: Fix race condition on
> __video_register_device") is the increased number of index value assigned
> on video_device registration. Before that commit video_devices were
> numbered from 0, after it, the indexes starts from 1, because get_index()
> always count the device, which is being registered. Some device drivers
> rely on video_device index number for internal purposes, i.e. s5p-mfc
> driver stopped working after that patch. This patch restores the old method
> of numbering the video_device indexes.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> In my opinion this patch should be applied also to stable v3.12 series.

I agree.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Ricardo Ribalda Delgado Dec. 3, 2013, 1:30 p.m. UTC | #2
Acked-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>

On Tue, Dec 3, 2013 at 2:23 PM, Sakari Ailus <sakari.ailus@iki.fi> wrote:
> Hi, Marek!
>
> Thanks for the patch.
>
> On Tue, Dec 03, 2013 at 02:14:29PM +0100, Marek Szyprowski wrote:
>> The side effect of commit 1056e4388b045 ("v4l2-dev: Fix race condition on
>> __video_register_device") is the increased number of index value assigned
>> on video_device registration. Before that commit video_devices were
>> numbered from 0, after it, the indexes starts from 1, because get_index()
>> always count the device, which is being registered. Some device drivers
>> rely on video_device index number for internal purposes, i.e. s5p-mfc
>> driver stopped working after that patch. This patch restores the old method
>> of numbering the video_device indexes.
>>
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> ---
>> In my opinion this patch should be applied also to stable v3.12 series.
>
> I agree.
>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> --
> Cheers,
>
> Sakari Ailus
> e-mail: sakari.ailus@iki.fi     XMPP: sailus@retiisi.org.uk
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index b5aaaac427ad..0a30dbf3d05c 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -872,8 +872,8 @@  int __video_register_device(struct video_device *vdev, int type, int nr,
 
 	/* Should not happen since we thought this minor was free */
 	WARN_ON(video_device[vdev->minor] != NULL);
-	video_device[vdev->minor] = vdev;
 	vdev->index = get_index(vdev);
+	video_device[vdev->minor] = vdev;
 	mutex_unlock(&videodev_lock);
 
 	if (vdev->ioctl_ops)