upstream: [media] em28xx: always call em28xx_release_resources() in the usb disconnec...
authorFrank Schaefer <fschaefer.oss@googlemail.com>
Sun, 12 Jan 2014 16:24:24 +0000 (13:24 -0300)
committerChanho Park <chanho61.park@samsung.com>
Thu, 7 Aug 2014 05:26:43 +0000 (14:26 +0900)
When the usb device is disconnected, the resources are no longer available,
so there is no reason to keep them registered.

This will also fix the various sysfs group removal warnings which we can see
since kernel 3.13.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/usb/em28xx/em28xx-cards.c
drivers/media/usb/em28xx/em28xx-video.c

index a44d781..57c3895 100644 (file)
@@ -2896,6 +2896,8 @@ void em28xx_release_resources(struct em28xx *dev)
 {
        /*FIXME: I2C IR should be disconnected */
 
+       mutex_lock(&dev->lock);
+
        if (dev->def_i2c_bus)
                em28xx_i2c_unregister(dev, 1);
        em28xx_i2c_unregister(dev, 0);
@@ -2904,6 +2906,8 @@ void em28xx_release_resources(struct em28xx *dev)
 
        /* Mark device as unused */
        clear_bit(dev->devno, &em28xx_devused);
+
+       mutex_unlock(&dev->lock);
 };
 EXPORT_SYMBOL_GPL(em28xx_release_resources);
 
@@ -3401,13 +3405,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
 
        em28xx_close_extension(dev);
 
-       /* NOTE: must be called BEFORE the resources are released */
-
-       mutex_lock(&dev->lock);
-       if (!dev->users)
-               em28xx_release_resources(dev);
-
-       mutex_unlock(&dev->lock);
+       em28xx_release_resources(dev);
 
        if (!dev->users) {
                kfree(dev->alt_max_pkt_size_isoc);
index e48e1eb..a4fb0bd 100644 (file)
@@ -1987,7 +1987,6 @@ static int em28xx_v4l2_close(struct file *filp)
                   free the remaining resources */
 
                if (dev->disconnected) {
-                       em28xx_release_resources(dev);
                        kfree(dev->alt_max_pkt_size_isoc);
                        goto exit;
                }