[media] uvcvideo: Remove unneeded device disconnected flag
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 24 May 2015 22:45:38 +0000 (19:45 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 30 May 2015 15:12:58 +0000 (12:12 -0300)
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>
drivers/media/usb/uvc/uvc_driver.c
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/usb/uvc/uvcvideo.h

index 5970dd6a1c1cf491fe7ff64dbc6aedcfb957c55f..4b5b3e8fb7d38358c53a3eb806f56639e18eaebb 100644 (file)
@@ -1967,8 +1967,6 @@ static void uvc_disconnect(struct usb_interface *intf)
            UVC_SC_VIDEOSTREAMING)
                return;
 
-       dev->state |= UVC_DEV_DISCONNECTED;
-
        uvc_unregister_video(dev);
 }
 
index 69d01803e0aae628dcc0d05f46891101b1025880..2764f43607c146a454a4bcbd89e6d5edc472acfc 100644 (file)
@@ -483,9 +483,6 @@ static int uvc_v4l2_open(struct file *file)
        uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n");
        stream = video_drvdata(file);
 
-       if (stream->dev->state & UVC_DEV_DISCONNECTED)
-               return -ENODEV;
-
        ret = usb_autopm_get_interface(stream->dev->intf);
        if (ret < 0)
                return ret;
index ead00a83df04a8a270716a3f4b60ce89168bd904..816dd1a0fd81de34329aef1f72a62bf9f9980deb 100644 (file)
@@ -517,10 +517,6 @@ struct uvc_streaming {
        } clock;
 };
 
-enum uvc_device_state {
-       UVC_DEV_DISCONNECTED = 1,
-};
-
 struct uvc_device {
        struct usb_device *udev;
        struct usb_interface *intf;
@@ -529,7 +525,6 @@ struct uvc_device {
        int intfnum;
        char name[32];
 
-       enum uvc_device_state state;
        struct mutex lock;              /* Protects users */
        unsigned int users;
        atomic_t nmappings;