aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2008-11-04 11:29:27 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 12:59:52 -0500
commit011b15df465745474e3ec85482633685933ed5a7 (patch)
tree97df5cb516672f0a6fae5b993840beb667c76bd0 /drivers/usb/core
parent857cc4dfb6420ec0a67b3cda559aaa7c429ddce7 (diff)
USB: change interface to usb_lock_device_for_reset()
This patch (as1161) changes the interface to usb_lock_device_for_reset(). The existing interface is apparently not very clear, judging from the fact that several of its callers don't use it correctly. The new interface always returns 0 for success and it always requires the caller to unlock the device afterward. The new routine will not return immediately if it is called while the driver's probe method is running. Instead it will wait until the probe is over and the device has been unlocked. This shouldn't cause any problems; I don't know of any cases where drivers call usb_lock_device_for_reset() during probe. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/usb.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 399e15fc5052..400fa4cc9a34 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -513,10 +513,7 @@ EXPORT_SYMBOL_GPL(usb_put_intf);
513 * disconnect; in some drivers (such as usb-storage) the disconnect() 513 * disconnect; in some drivers (such as usb-storage) the disconnect()
514 * or suspend() method will block waiting for a device reset to complete. 514 * or suspend() method will block waiting for a device reset to complete.
515 * 515 *
516 * Returns a negative error code for failure, otherwise 1 or 0 to indicate 516 * Returns a negative error code for failure, otherwise 0.
517 * that the device will or will not have to be unlocked. (0 can be
518 * returned when an interface is given and is BINDING, because in that
519 * case the driver already owns the device lock.)
520 */ 517 */
521int usb_lock_device_for_reset(struct usb_device *udev, 518int usb_lock_device_for_reset(struct usb_device *udev,
522 const struct usb_interface *iface) 519 const struct usb_interface *iface)
@@ -527,16 +524,9 @@ int usb_lock_device_for_reset(struct usb_device *udev,
527 return -ENODEV; 524 return -ENODEV;
528 if (udev->state == USB_STATE_SUSPENDED) 525 if (udev->state == USB_STATE_SUSPENDED)
529 return -EHOSTUNREACH; 526 return -EHOSTUNREACH;
530 if (iface) { 527 if (iface && (iface->condition == USB_INTERFACE_UNBINDING ||
531 switch (iface->condition) { 528 iface->condition == USB_INTERFACE_UNBOUND))
532 case USB_INTERFACE_BINDING: 529 return -EINTR;
533 return 0;
534 case USB_INTERFACE_BOUND:
535 break;
536 default:
537 return -EINTR;
538 }
539 }
540 530
541 while (usb_trylock_device(udev) != 0) { 531 while (usb_trylock_device(udev) != 0) {
542 532
@@ -550,10 +540,11 @@ int usb_lock_device_for_reset(struct usb_device *udev,
550 return -ENODEV; 540 return -ENODEV;
551 if (udev->state == USB_STATE_SUSPENDED) 541 if (udev->state == USB_STATE_SUSPENDED)
552 return -EHOSTUNREACH; 542 return -EHOSTUNREACH;
553 if (iface && iface->condition != USB_INTERFACE_BOUND) 543 if (iface && (iface->condition == USB_INTERFACE_UNBINDING ||
544 iface->condition == USB_INTERFACE_UNBOUND))
554 return -EINTR; 545 return -EINTR;
555 } 546 }
556 return 1; 547 return 0;
557} 548}
558EXPORT_SYMBOL_GPL(usb_lock_device_for_reset); 549EXPORT_SYMBOL_GPL(usb_lock_device_for_reset);
559 550