summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-12-15 07:47:28 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-15 07:47:28 -0800
commitab7cd8c76cb47f1bda0ad964d309b4efce81b5e9 (patch)
treeb9fb10c6af24b475164a75c9ec8f411f933e467d /drivers/usb
parent3ea6b3d0e6d0ffd91c0f8cadeb69b7133c038b32 (diff)
downloadlinux-ab7cd8c76cb47f1bda0ad964d309b4efce81b5e9.tar.gz
linux-ab7cd8c76cb47f1bda0ad964d309b4efce81b5e9.tar.bz2
linux-ab7cd8c76cb47f1bda0ad964d309b4efce81b5e9.zip
Revert "USB: Close usb_find_interface race"
This reverts commit a2582bd478c13c574d4c16ef1209d333f2a25935. It turned out to be buggy and broke USB printers from working. Cc: Russ Dill <Russ.Dill@gmail.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/usb.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4e2c6df8d3cc..932f68e6ad19 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -167,17 +167,24 @@ struct usb_host_interface *usb_altnum_to_altsetting(
}
EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);
+struct find_interface_arg {
+ int minor;
+ struct usb_interface *interface;
+};
+
static int __find_interface(struct device *dev, void *data)
{
- int *minor = data;
+ struct find_interface_arg *arg = data;
struct usb_interface *intf;
if (!is_usb_interface(dev))
return 0;
intf = to_usb_interface(dev);
- if (intf->minor != -1 && intf->minor == *minor)
+ if (intf->minor != -1 && intf->minor == arg->minor) {
+ arg->interface = intf;
return 1;
+ }
return 0;
}
@@ -186,20 +193,21 @@ static int __find_interface(struct device *dev, void *data)
* @drv: the driver whose current configuration is considered
* @minor: the minor number of the desired device
*
- * This walks the bus device list and returns a pointer to the interface
+ * This walks the driver device list and returns a pointer to the interface
* with the matching minor. Note, this only works for devices that share the
* USB major number.
*/
struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
{
- struct device *dev;
-
- dev = bus_find_device(&usb_bus_type, NULL, &minor, __find_interface);
-
- /* Drop reference count from bus_find_device */
- put_device(dev);
+ struct find_interface_arg argb;
+ int retval;
- return dev ? to_usb_interface(dev) : NULL;
+ argb.minor = minor;
+ argb.interface = NULL;
+ /* eat the error, it will be in argb.interface */
+ retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb,
+ __find_interface);
+ return argb.interface;
}
EXPORT_SYMBOL_GPL(usb_find_interface);