]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
USB: core: Remove usbfs_mutex
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 25 Jun 2019 20:03:58 +0000 (16:03 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Jun 2019 02:28:09 +0000 (10:28 +0800)
Commit 4a2a8a2cce86 ("usbfs: private mutex for open, release, and
remove") is now obsolete.  The commit was created back when we had
to handle both usbfs device nodes and the old usbdevfs filesystem
(/proc/bus/usb/), but usbdevfs no longer exists.

This means there's no longer any need to hold a mutex during two
separate removal operations (and thus during an entire notifier chain
call).  Furthermore, the one remaining remove/release pair doesn't
race with open thanks to the synchronization provided by the device
model core in bus_find_device().  Remove and release don't race with
each other because they both run with the device lock held.

The upshot is that usbfs_mutex isn't needed any more.  This patch
removes it entirely.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/devio.c
drivers/usb/core/notify.c
drivers/usb/core/usb.h

index 186790b06b11aad70f464ee99692792a98df7e79..0100a54165cd1bf7a37faafbdbf5079d6fa5f37f 100644 (file)
@@ -48,9 +48,6 @@
 #define USB_DEVICE_MAX                 (USB_MAXBUS * 128)
 #define USB_SG_SIZE                    16384 /* split-size for large txs */
 
-/* Mutual exclusion for removal, open, and release */
-DEFINE_MUTEX(usbfs_mutex);
-
 struct usb_dev_state {
        struct list_head list;      /* state list */
        struct usb_device *dev;
@@ -979,15 +976,9 @@ static int usbdev_open(struct inode *inode, struct file *file)
 
        ret = -ENODEV;
 
-       /* Protect against simultaneous removal or release */
-       mutex_lock(&usbfs_mutex);
-
        /* usbdev device-node */
        if (imajor(inode) == USB_DEVICE_MAJOR)
                dev = usbdev_lookup_by_devt(inode->i_rdev);
-
-       mutex_unlock(&usbfs_mutex);
-
        if (!dev)
                goto out_free_ps;
 
index ab474b11523ee8f901a48dcbc18a3434c573e3d5..e6143663778fbeaf456a67044ad7a369c3a656cc 100644 (file)
@@ -53,11 +53,8 @@ void usb_notify_add_device(struct usb_device *udev)
 
 void usb_notify_remove_device(struct usb_device *udev)
 {
-       /* Protect against simultaneous usbfs open */
-       mutex_lock(&usbfs_mutex);
        blocking_notifier_call_chain(&usb_notifier_list,
                        USB_DEVICE_REMOVE, udev);
-       mutex_unlock(&usbfs_mutex);
 }
 
 void usb_notify_add_bus(struct usb_bus *ubus)
index d95a5358f73df21ea3b1ba4cdea97bc0ad07c7ee..bd8d01f85a1371dffa8f32e522ecaa4ae5e8e23e 100644 (file)
@@ -169,7 +169,6 @@ extern const struct attribute_group *usb_device_groups[];
 extern const struct attribute_group *usb_interface_groups[];
 
 /* usbfs stuff */
-extern struct mutex usbfs_mutex;
 extern struct usb_driver usbfs_driver;
 extern const struct file_operations usbfs_devices_fops;
 extern const struct file_operations usbdev_file_operations;