Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] uvcvideo: Remove unneeded device disconnected flag

The UVC_DEV_DISCONNECTED flag is set when the USB device is
disconnected, and checked in the open() handler to refuse opening a
device that has been disconnected.

This is inherently racy, but the race condition is taken care of in the
V4L2 core, which also fails open() calls when the V4L2 device node has
been unregistered. As the uvcvideo USB disconnect handler unregisters
all its video device nodes, the UVC_DEV_DISCONNECTED flag doesn't serve
any purpose anymore and can be removed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
d511eb7d 37f85b27

-10
-2
drivers/media/usb/uvc/uvc_driver.c
··· 1967 1967 UVC_SC_VIDEOSTREAMING) 1968 1968 return; 1969 1969 1970 - dev->state |= UVC_DEV_DISCONNECTED; 1971 - 1972 1970 uvc_unregister_video(dev); 1973 1971 } 1974 1972
-3
drivers/media/usb/uvc/uvc_v4l2.c
··· 483 483 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n"); 484 484 stream = video_drvdata(file); 485 485 486 - if (stream->dev->state & UVC_DEV_DISCONNECTED) 487 - return -ENODEV; 488 - 489 486 ret = usb_autopm_get_interface(stream->dev->intf); 490 487 if (ret < 0) 491 488 return ret;
-5
drivers/media/usb/uvc/uvcvideo.h
··· 517 517 } clock; 518 518 }; 519 519 520 - enum uvc_device_state { 521 - UVC_DEV_DISCONNECTED = 1, 522 - }; 523 - 524 520 struct uvc_device { 525 521 struct usb_device *udev; 526 522 struct usb_interface *intf; ··· 525 529 int intfnum; 526 530 char name[32]; 527 531 528 - enum uvc_device_state state; 529 532 struct mutex lock; /* Protects users */ 530 533 unsigned int users; 531 534 atomic_t nmappings;