diff options
-rw-r--r-- | drivers/usb/core/usb.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 932f68e6ad19..d86276c639c1 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -169,7 +169,7 @@ EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); | |||
169 | 169 | ||
170 | struct find_interface_arg { | 170 | struct find_interface_arg { |
171 | int minor; | 171 | int minor; |
172 | struct usb_interface *interface; | 172 | struct device_driver *drv; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | static int __find_interface(struct device *dev, void *data) | 175 | static int __find_interface(struct device *dev, void *data) |
@@ -180,12 +180,10 @@ static int __find_interface(struct device *dev, void *data) | |||
180 | if (!is_usb_interface(dev)) | 180 | if (!is_usb_interface(dev)) |
181 | return 0; | 181 | return 0; |
182 | 182 | ||
183 | if (dev->driver != arg->drv) | ||
184 | return 0; | ||
183 | intf = to_usb_interface(dev); | 185 | intf = to_usb_interface(dev); |
184 | if (intf->minor != -1 && intf->minor == arg->minor) { | 186 | return intf->minor == arg->minor; |
185 | arg->interface = intf; | ||
186 | return 1; | ||
187 | } | ||
188 | return 0; | ||
189 | } | 187 | } |
190 | 188 | ||
191 | /** | 189 | /** |
@@ -193,21 +191,24 @@ static int __find_interface(struct device *dev, void *data) | |||
193 | * @drv: the driver whose current configuration is considered | 191 | * @drv: the driver whose current configuration is considered |
194 | * @minor: the minor number of the desired device | 192 | * @minor: the minor number of the desired device |
195 | * | 193 | * |
196 | * This walks the driver device list and returns a pointer to the interface | 194 | * This walks the bus device list and returns a pointer to the interface |
197 | * with the matching minor. Note, this only works for devices that share the | 195 | * with the matching minor and driver. Note, this only works for devices |
198 | * USB major number. | 196 | * that share the USB major number. |
199 | */ | 197 | */ |
200 | struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) | 198 | struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) |
201 | { | 199 | { |
202 | struct find_interface_arg argb; | 200 | struct find_interface_arg argb; |
203 | int retval; | 201 | struct device *dev; |
204 | 202 | ||
205 | argb.minor = minor; | 203 | argb.minor = minor; |
206 | argb.interface = NULL; | 204 | argb.drv = &drv->drvwrap.driver; |
207 | /* eat the error, it will be in argb.interface */ | 205 | |
208 | retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb, | 206 | dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface); |
209 | __find_interface); | 207 | |
210 | return argb.interface; | 208 | /* Drop reference count from bus_find_device */ |
209 | put_device(dev); | ||
210 | |||
211 | return dev ? to_usb_interface(dev) : NULL; | ||
211 | } | 212 | } |
212 | EXPORT_SYMBOL_GPL(usb_find_interface); | 213 | EXPORT_SYMBOL_GPL(usb_find_interface); |
213 | 214 | ||