aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-04-09 11:52:31 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 13:57:30 -0400
commit341487a837c02cbd674d4751061e7d098b0b8e98 (patch)
tree58166480d534a86f7b096b81572bd51c8dad031d /drivers
parentb7bb125dc3d0ca3f72c9116525ce0f018a9844e1 (diff)
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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/devices.c2
-rw-r--r--drivers/usb/core/devio.c13
-rw-r--r--drivers/usb/core/driver.c12
-rw-r--r--drivers/usb/core/message.c2
4 files changed, 7 insertions, 22 deletions
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index aefc7987120d..6753ca059ee4 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -246,7 +246,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end,
246 246
247 if (start > end) 247 if (start > end)
248 return start; 248 return start;
249 down_read(&usb_bus_type.subsys.rwsem);
250 if (iface) { 249 if (iface) {
251 driver_name = (iface->dev.driver 250 driver_name = (iface->dev.driver
252 ? iface->dev.driver->name 251 ? iface->dev.driver->name
@@ -263,7 +262,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end,
263 desc->bInterfaceSubClass, 262 desc->bInterfaceSubClass,
264 desc->bInterfaceProtocol, 263 desc->bInterfaceProtocol,
265 driver_name); 264 driver_name);
266 up_read(&usb_bus_type.subsys.rwsem);
267 return start; 265 return start;
268} 266}
269 267
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 36e7a843bf91..fc3545ddb06e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -421,14 +421,11 @@ static int claimintf(struct dev_state *ps, unsigned int ifnum)
421 if (test_bit(ifnum, &ps->ifclaimed)) 421 if (test_bit(ifnum, &ps->ifclaimed))
422 return 0; 422 return 0;
423 423
424 /* lock against other changes to driver bindings */
425 down_write(&usb_bus_type.subsys.rwsem);
426 intf = usb_ifnum_to_if(dev, ifnum); 424 intf = usb_ifnum_to_if(dev, ifnum);
427 if (!intf) 425 if (!intf)
428 err = -ENOENT; 426 err = -ENOENT;
429 else 427 else
430 err = usb_driver_claim_interface(&usbfs_driver, intf, ps); 428 err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
431 up_write(&usb_bus_type.subsys.rwsem);
432 if (err == 0) 429 if (err == 0)
433 set_bit(ifnum, &ps->ifclaimed); 430 set_bit(ifnum, &ps->ifclaimed);
434 return err; 431 return err;
@@ -444,8 +441,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum)
444 if (ifnum >= 8*sizeof(ps->ifclaimed)) 441 if (ifnum >= 8*sizeof(ps->ifclaimed))
445 return err; 442 return err;
446 dev = ps->dev; 443 dev = ps->dev;
447 /* lock against other changes to driver bindings */
448 down_write(&usb_bus_type.subsys.rwsem);
449 intf = usb_ifnum_to_if(dev, ifnum); 444 intf = usb_ifnum_to_if(dev, ifnum);
450 if (!intf) 445 if (!intf)
451 err = -ENOENT; 446 err = -ENOENT;
@@ -453,7 +448,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum)
453 usb_driver_release_interface(&usbfs_driver, intf); 448 usb_driver_release_interface(&usbfs_driver, intf);
454 err = 0; 449 err = 0;
455 } 450 }
456 up_write(&usb_bus_type.subsys.rwsem);
457 return err; 451 return err;
458} 452}
459 453
@@ -813,7 +807,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg)
813 807
814 if (copy_from_user(&gd, arg, sizeof(gd))) 808 if (copy_from_user(&gd, arg, sizeof(gd)))
815 return -EFAULT; 809 return -EFAULT;
816 down_read(&usb_bus_type.subsys.rwsem);
817 intf = usb_ifnum_to_if(ps->dev, gd.interface); 810 intf = usb_ifnum_to_if(ps->dev, gd.interface);
818 if (!intf || !intf->dev.driver) 811 if (!intf || !intf->dev.driver)
819 ret = -ENODATA; 812 ret = -ENODATA;
@@ -822,7 +815,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg)
822 sizeof(gd.driver)); 815 sizeof(gd.driver));
823 ret = (copy_to_user(arg, &gd, sizeof(gd)) ? -EFAULT : 0); 816 ret = (copy_to_user(arg, &gd, sizeof(gd)) ? -EFAULT : 0);
824 } 817 }
825 up_read(&usb_bus_type.subsys.rwsem);
826 return ret; 818 return ret;
827} 819}
828 820
@@ -1351,15 +1343,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
1351 1343
1352 /* disconnect kernel driver from interface */ 1344 /* disconnect kernel driver from interface */
1353 case USBDEVFS_DISCONNECT: 1345 case USBDEVFS_DISCONNECT:
1354
1355 down_write(&usb_bus_type.subsys.rwsem);
1356 if (intf->dev.driver) { 1346 if (intf->dev.driver) {
1357 driver = to_usb_driver(intf->dev.driver); 1347 driver = to_usb_driver(intf->dev.driver);
1358 dev_dbg (&intf->dev, "disconnect by usbfs\n"); 1348 dev_dbg (&intf->dev, "disconnect by usbfs\n");
1359 usb_driver_release_interface(driver, intf); 1349 usb_driver_release_interface(driver, intf);
1360 } else 1350 } else
1361 retval = -ENODATA; 1351 retval = -ENODATA;
1362 up_write(&usb_bus_type.subsys.rwsem);
1363 break; 1352 break;
1364 1353
1365 /* let kernel drivers try to (re)bind to the interface */ 1354 /* 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 1360
1372 /* talk directly to the interface's driver */ 1361 /* talk directly to the interface's driver */
1373 default: 1362 default:
1374 down_read(&usb_bus_type.subsys.rwsem);
1375 if (intf->dev.driver) 1363 if (intf->dev.driver)
1376 driver = to_usb_driver(intf->dev.driver); 1364 driver = to_usb_driver(intf->dev.driver);
1377 if (driver == NULL || driver->ioctl == NULL) { 1365 if (driver == NULL || driver->ioctl == NULL) {
@@ -1381,7 +1369,6 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
1381 if (retval == -ENOIOCTLCMD) 1369 if (retval == -ENOIOCTLCMD)
1382 retval = -ENOTTY; 1370 retval = -ENOTTY;
1383 } 1371 }
1384 up_read(&usb_bus_type.subsys.rwsem);
1385 } 1372 }
1386 1373
1387 /* cleanup and return */ 1374 /* cleanup and return */
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 9e3e943f313c..e6dd2b9210f6 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -287,9 +287,9 @@ static int usb_unbind_interface(struct device *dev)
287 * way to bind to an interface is to return the private data from 287 * way to bind to an interface is to return the private data from
288 * the driver's probe() method. 288 * the driver's probe() method.
289 * 289 *
290 * Callers must own the device lock and the driver model's usb_bus_type.subsys 290 * Callers must own the device lock, so driver probe() entries don't need
291 * writelock. So driver probe() entries don't need extra locking, 291 * extra locking, but other call contexts may need to explicitly claim that
292 * but other call contexts may need to explicitly claim those locks. 292 * lock.
293 */ 293 */
294int usb_driver_claim_interface(struct usb_driver *driver, 294int usb_driver_claim_interface(struct usb_driver *driver,
295 struct usb_interface *iface, void* priv) 295 struct usb_interface *iface, void* priv)
@@ -330,9 +330,9 @@ EXPORT_SYMBOL(usb_driver_claim_interface);
330 * also causes the driver disconnect() method to be called. 330 * also causes the driver disconnect() method to be called.
331 * 331 *
332 * This call is synchronous, and may not be used in an interrupt context. 332 * This call is synchronous, and may not be used in an interrupt context.
333 * Callers must own the device lock and the driver model's usb_bus_type.subsys 333 * Callers must own the device lock, so driver disconnect() entries don't
334 * writelock. So driver disconnect() entries don't need extra locking, 334 * need extra locking, but other call contexts may need to explicitly claim
335 * but other call contexts may need to explicitly claim those locks. 335 * that lock.
336 */ 336 */
337void usb_driver_release_interface(struct usb_driver *driver, 337void usb_driver_release_interface(struct usb_driver *driver,
338 struct usb_interface *iface) 338 struct usb_interface *iface)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 217a3d6d0a06..c359ccb32998 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1349,7 +1349,7 @@ static void release_interface(struct device *dev)
1349 * 1349 *
1350 * This call is synchronous. The calling context must be able to sleep, 1350 * This call is synchronous. The calling context must be able to sleep,
1351 * must own the device lock, and must not hold the driver model's USB 1351 * must own the device lock, and must not hold the driver model's USB
1352 * bus rwsem; usb device driver probe() methods cannot use this routine. 1352 * bus mutex; usb device driver probe() methods cannot use this routine.
1353 * 1353 *
1354 * Returns zero on success, or else the status code returned by the 1354 * Returns zero on success, or else the status code returned by the
1355 * underlying call that failed. On successful completion, each interface 1355 * underlying call that failed. On successful completion, each interface