From: Hans Verkuil Date: Tue, 17 Feb 2015 08:44:06 +0000 (-0300) Subject: [media] uvc gadget: switch to v4l2 core locking X-Git-Tag: omap-for-v4.2/o2_dc~62^2~1^2~327 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8e96c4bf6e3cdb6580381fdad2bfd93fae36ff1;p=pandora-kernel.git [media] uvc gadget: switch to v4l2 core locking Switch this driver over to the V4L2 core locking mechanism in preparation for switching to unlocked_ioctl. Suggested by Laurent Pinchart. This patch introduces a new mutex at the struct uvc_video level and drops the old mutex at the queue level. The new lock is now used for all ioctl locking and in the release file operation (the driver always has to take care of locking in file operations, the core only serializes ioctls). Note that the mmap and get_unmapped_area file operations no longer take a lock. Commit f035eb4e976ef5a059e30bc91cfd310ff030a7d3 fixed a AB-BA deadlock by moving all the locking down into vb2, so the mmap and get_unmapped_area file operations should no longer do any locking before calling into vb2. Signed-off-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index 76891adfba7a..3242bc684e2d 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -447,6 +447,7 @@ uvc_register_video(struct uvc_device *uvc) video->ioctl_ops = &uvc_v4l2_ioctl_ops; video->release = video_device_release; video->vfl_dir = VFL_DIR_TX; + video->lock = &uvc->video.mutex; strlcpy(video->name, cdev->gadget->name, sizeof(video->name)); uvc->vdev = video; @@ -918,6 +919,7 @@ static struct usb_function *uvc_alloc(struct usb_function_instance *fi) if (uvc == NULL) return ERR_PTR(-ENOMEM); + mutex_init(&uvc->video.mutex); uvc->state = UVC_STATE_DISCONNECTED; opts = fi_to_f_uvc_opts(fi); diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h index f67695cb28f8..3390ecd1a1f3 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -115,6 +115,7 @@ struct uvc_video unsigned int width; unsigned int height; unsigned int imagesize; + struct mutex mutex; /* protects frame parameters */ /* Requests */ unsigned int req_size; Reading git-diff-tree failed