linux-stable/drivers/usb
Thomas Haemmerle 518c3f98e5 usb: gadget: uvc: fix multiple opens
commit 72ee48ee89 upstream.

Currently, the UVC function is activated when open on the corresponding
v4l2 device is called.  On another open the activation of the function
fails since the deactivation counter in `usb_function_activate` equals
0. However the error is not returned to userspace since the open of the
v4l2 device is successful.

On a close the function is deactivated (since deactivation counter still
equals 0) and the video is disabled in `uvc_v4l2_release`, although the
UVC application potentially is streaming.

Move activation of UVC function to subscription on UVC_EVENT_SETUP
because there we can guarantee for a userspace application utilizing
UVC.  Block subscription on UVC_EVENT_SETUP while another application
already is subscribed to it, indicated by `bool func_connected` in
`struct uvc_device`.  Extend the `struct uvc_file_handle` with member
`bool is_uvc_app_handle` to tag it as the handle used by the userspace
UVC application.

With this a process is able to check capabilities of the v4l2 device
without deactivating the function for the actual UVC application.

Reviewed-By: Michael Tretter <m.tretter@pengutronix.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Acked-by: Felipe Balbi <balbi@kernel.org>
Link: https://lore.kernel.org/r/20211003201355.24081-1-m.grzeschik@pengutronix.de
Cc: Dan Vacura <W36195@motorola.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-12-14 11:32:33 +01:00
..
atm
c67x00
cdns3 usb: cdns3: fix race condition before setting doorbell 2021-10-06 15:55:46 +02:00
chipidea usb: chipidea: ci_hdrc_imx: fix potential error pointer dereference in probe 2021-12-01 09:18:59 +01:00
class USB: cdc-acm: fix break reporting 2021-10-13 10:04:23 +02:00
common Partially revert "usb: Kconfig: using select for USB_COMMON dependency" 2021-10-13 10:04:22 +02:00
core USB: NO_LPM quirk Lenovo Powered USB-C Travel Hub 2021-12-08 09:03:28 +01:00
dwc2 usb: dwc2: hcd_queue: Fix use of floating point literal 2021-12-01 09:18:58 +01:00
dwc3 usb: dwc3: gadget: Fix null pointer exception 2021-12-01 09:18:59 +01:00
early
gadget usb: gadget: uvc: fix multiple opens 2021-12-14 11:32:33 +01:00
host xhci: Fix commad ring abort, write all 64 bits to CRCR register. 2021-12-08 09:03:28 +01:00
image
isp1760
misc USB: iowarrior: fix control-message timeouts 2021-11-18 14:03:51 +01:00
mon
mtu3 usb: mtu3: fix the wrong HS mult value 2021-09-12 08:58:28 +02:00
musb usb: musb: tusb6010: check return value after calling platform_get_resource() 2021-11-26 10:39:08 +01:00
phy usb: phy: tahvo: add IRQ check 2021-09-15 09:50:40 +02:00
renesas_usbhs usb: renesas_usbhs: Fix superfluous irqs happen after usb_pkt_pop() 2021-07-28 14:35:44 +02:00
roles usb: roles: Call try_module_get() from usb_role_switch_find_by_fwnode() 2021-05-14 09:49:55 +02:00
serial USB: serial: option: add Fibocom FM101-GL variants 2021-12-01 09:18:58 +01:00
storage usb-storage: Add compatibility quirk flags for iODD 2531/2541 2021-11-12 14:58:32 +01:00
typec usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect 2021-12-08 09:03:28 +01:00
usbip usbip:vhci_hcd USB port can get stuck in the disabled state 2021-09-18 13:40:33 +02:00
Kconfig
Makefile
usb-skeleton.c