Commit 341487a8 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: remove use of the bus rwsem, as it doesn't really protect anything.

The driver core stopped using the rwsem a long time ago, yet the USB
core still grabbed the lock, thinking it protected something.  This
patch removes that useless use.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: David Brownell <david-b@pacbell.net>
Cc: linux-usb-devel <linux-usb-devel@lists.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b7bb125d
...@@ -246,7 +246,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end, ...@@ -246,7 +246,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end,
if (start > end) if (start > end)
return start; return start;
down_read(&usb_bus_type.subsys.rwsem);
if (iface) { if (iface) {
driver_name = (iface->dev.driver driver_name = (iface->dev.driver
? iface->dev.driver->name ? iface->dev.driver->name
...@@ -263,7 +262,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end, ...@@ -263,7 +262,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end,
desc->bInterfaceSubClass, desc->bInterfaceSubClass,
desc->bInterfaceProtocol, desc->bInterfaceProtocol,
driver_name); driver_name);
up_read(&usb_bus_type.subsys.rwsem);
return start; return start;
} }
......
...@@ -421,14 +421,11 @@ static int claimintf(struct dev_state *ps, unsigned int ifnum) ...@@ -421,14 +421,11 @@ static int claimintf(struct dev_state *ps, unsigned int ifnum)
if (test_bit(ifnum, &ps->ifclaimed)) if (test_bit(ifnum, &ps->ifclaimed))
return 0; return 0;
/* lock against other changes to driver bindings */
down_write(&usb_bus_type.subsys.rwsem);
intf = usb_ifnum_to_if(dev, ifnum); intf = usb_ifnum_to_if(dev, ifnum);
if (!intf) if (!intf)
err = -ENOENT; err = -ENOENT;
else else
err = usb_driver_claim_interface(&usbfs_driver, intf, ps); err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
up_write(&usb_bus_type.subsys.rwsem);
if (err == 0) if (err == 0)
set_bit(ifnum, &ps->ifclaimed); set_bit(ifnum, &ps->ifclaimed);
return err; return err;
...@@ -444,8 +441,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum) ...@@ -444,8 +441,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum)
if (ifnum >= 8*sizeof(ps->ifclaimed)) if (ifnum >= 8*sizeof(ps->ifclaimed))
return err; return err;
dev = ps->dev; dev = ps->dev;
/* lock against other changes to driver bindings */
down_write(&usb_bus_type.subsys.rwsem);
intf = usb_ifnum_to_if(dev, ifnum); intf = usb_ifnum_to_if(dev, ifnum);
if (!intf) if (!intf)
err = -ENOENT; err = -ENOENT;
...@@ -453,7 +448,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum) ...@@ -453,7 +448,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum)
usb_driver_release_interface(&usbfs_driver, intf); usb_driver_release_interface(&usbfs_driver, intf);
err = 0; err = 0;
} }
up_write(&usb_bus_type.subsys.rwsem);
return err; return err;
} }
...@@ -813,7 +807,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg) ...@@ -813,7 +807,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg)
if (copy_from_user(&gd, arg, sizeof(gd))) if (copy_from_user(&gd, arg, sizeof(gd)))
return -EFAULT; return -EFAULT;
down_read(&usb_bus_type.subsys.rwsem);
intf = usb_ifnum_to_if(ps->dev, gd.interface); intf = usb_ifnum_to_if(ps->dev, gd.interface);
if (!intf || !intf->dev.driver) if (!intf || !intf->dev.driver)
ret = -ENODATA; ret = -ENODATA;
...@@ -822,7 +815,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg) ...@@ -822,7 +815,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg)
sizeof(gd.driver)); sizeof(gd.driver));
ret = (copy_to_user(arg, &gd, sizeof(gd)) ? -EFAULT : 0); ret = (copy_to_user(arg, &gd, sizeof(gd)) ? -EFAULT : 0);
} }
up_read(&usb_bus_type.subsys.rwsem);
return ret; return ret;
} }
...@@ -1351,15 +1343,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) ...@@ -1351,15 +1343,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
/* disconnect kernel driver from interface */ /* disconnect kernel driver from interface */
case USBDEVFS_DISCONNECT: case USBDEVFS_DISCONNECT:
down_write(&usb_bus_type.subsys.rwsem);
if (intf->dev.driver) { if (intf->dev.driver) {
driver = to_usb_driver(intf->dev.driver); driver = to_usb_driver(intf->dev.driver);
dev_dbg (&intf->dev, "disconnect by usbfs\n"); dev_dbg (&intf->dev, "disconnect by usbfs\n");
usb_driver_release_interface(driver, intf); usb_driver_release_interface(driver, intf);
} else } else
retval = -ENODATA; retval = -ENODATA;
up_write(&usb_bus_type.subsys.rwsem);
break; break;
/* let kernel drivers try to (re)bind to the interface */ /* let kernel drivers try to (re)bind to the interface */
...@@ -1371,7 +1360,6 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) ...@@ -1371,7 +1360,6 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
/* talk directly to the interface's driver */ /* talk directly to the interface's driver */
default: default:
down_read(&usb_bus_type.subsys.rwsem);
if (intf->dev.driver) if (intf->dev.driver)
driver = to_usb_driver(intf->dev.driver); driver = to_usb_driver(intf->dev.driver);
if (driver == NULL || driver->ioctl == NULL) { if (driver == NULL || driver->ioctl == NULL) {
...@@ -1381,7 +1369,6 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) ...@@ -1381,7 +1369,6 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
if (retval == -ENOIOCTLCMD) if (retval == -ENOIOCTLCMD)
retval = -ENOTTY; retval = -ENOTTY;
} }
up_read(&usb_bus_type.subsys.rwsem);
} }
/* cleanup and return */ /* cleanup and return */
......
...@@ -287,9 +287,9 @@ static int usb_unbind_interface(struct device *dev) ...@@ -287,9 +287,9 @@ static int usb_unbind_interface(struct device *dev)
* way to bind to an interface is to return the private data from * way to bind to an interface is to return the private data from
* the driver's probe() method. * the driver's probe() method.
* *
* Callers must own the device lock and the driver model's usb_bus_type.subsys * Callers must own the device lock, so driver probe() entries don't need
* writelock. So driver probe() entries don't need extra locking, * extra locking, but other call contexts may need to explicitly claim that
* but other call contexts may need to explicitly claim those locks. * lock.
*/ */
int usb_driver_claim_interface(struct usb_driver *driver, int usb_driver_claim_interface(struct usb_driver *driver,
struct usb_interface *iface, void* priv) struct usb_interface *iface, void* priv)
...@@ -330,9 +330,9 @@ EXPORT_SYMBOL(usb_driver_claim_interface); ...@@ -330,9 +330,9 @@ EXPORT_SYMBOL(usb_driver_claim_interface);
* also causes the driver disconnect() method to be called. * also causes the driver disconnect() method to be called.
* *
* This call is synchronous, and may not be used in an interrupt context. * This call is synchronous, and may not be used in an interrupt context.
* Callers must own the device lock and the driver model's usb_bus_type.subsys * Callers must own the device lock, so driver disconnect() entries don't
* writelock. So driver disconnect() entries don't need extra locking, * need extra locking, but other call contexts may need to explicitly claim
* but other call contexts may need to explicitly claim those locks. * that lock.
*/ */
void usb_driver_release_interface(struct usb_driver *driver, void usb_driver_release_interface(struct usb_driver *driver,
struct usb_interface *iface) struct usb_interface *iface)
......
...@@ -1349,7 +1349,7 @@ static void release_interface(struct device *dev) ...@@ -1349,7 +1349,7 @@ static void release_interface(struct device *dev)
* *
* This call is synchronous. The calling context must be able to sleep, * This call is synchronous. The calling context must be able to sleep,
* must own the device lock, and must not hold the driver model's USB * must own the device lock, and must not hold the driver model's USB
* bus rwsem; usb device driver probe() methods cannot use this routine. * bus mutex; usb device driver probe() methods cannot use this routine.
* *
* Returns zero on success, or else the status code returned by the * Returns zero on success, or else the status code returned by the
* underlying call that failed. On successful completion, each interface * underlying call that failed. On successful completion, each interface
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment