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

USB: core: Remove usbfs_mutex

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>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
ffed6097 58ee0100

-13
-9
drivers/usb/core/devio.c
··· 48 48 #define USB_DEVICE_MAX (USB_MAXBUS * 128) 49 49 #define USB_SG_SIZE 16384 /* split-size for large txs */ 50 50 51 - /* Mutual exclusion for removal, open, and release */ 52 - DEFINE_MUTEX(usbfs_mutex); 53 - 54 51 struct usb_dev_state { 55 52 struct list_head list; /* state list */ 56 53 struct usb_device *dev; ··· 976 979 977 980 ret = -ENODEV; 978 981 979 - /* Protect against simultaneous removal or release */ 980 - mutex_lock(&usbfs_mutex); 981 - 982 982 /* usbdev device-node */ 983 983 if (imajor(inode) == USB_DEVICE_MAJOR) 984 984 dev = usbdev_lookup_by_devt(inode->i_rdev); 985 - 986 - mutex_unlock(&usbfs_mutex); 987 - 988 985 if (!dev) 989 986 goto out_free_ps; 990 987
-3
drivers/usb/core/notify.c
··· 53 53 54 54 void usb_notify_remove_device(struct usb_device *udev) 55 55 { 56 - /* Protect against simultaneous usbfs open */ 57 - mutex_lock(&usbfs_mutex); 58 56 blocking_notifier_call_chain(&usb_notifier_list, 59 57 USB_DEVICE_REMOVE, udev); 60 - mutex_unlock(&usbfs_mutex); 61 58 } 62 59 63 60 void usb_notify_add_bus(struct usb_bus *ubus)
-1
drivers/usb/core/usb.h
··· 169 169 extern const struct attribute_group *usb_interface_groups[]; 170 170 171 171 /* usbfs stuff */ 172 - extern struct mutex usbfs_mutex; 173 172 extern struct usb_driver usbfs_driver; 174 173 extern const struct file_operations usbfs_devices_fops; 175 174 extern const struct file_operations usbdev_file_operations;