aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/usb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:58:13 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:58:13 -0500
commit7f6cd5408a8ace522ca7f15893243e94ccc913e0 (patch)
treeaa84ba9df6b7f9af26c84162a455f9010bd8d285 /drivers/usb/core/usb.c
parente956e6b77054f91580deb81ba6389cc8c8ce67ef (diff)
parentc2d284ee04ab6f6718de2ddcf1b43160e046c41d (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: USB: Close usb_find_interface race v3 Revert "USB: Close usb_find_interface race"
Diffstat (limited to 'drivers/usb/core/usb.c')
-rw-r--r--drivers/usb/core/usb.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 043fa833eeca..2fb42043b305 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -167,18 +167,23 @@ struct usb_host_interface *usb_altnum_to_altsetting(
167} 167}
168EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); 168EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);
169 169
170struct find_interface_arg {
171 int minor;
172 struct device_driver *drv;
173};
174
170static int __find_interface(struct device *dev, void *data) 175static int __find_interface(struct device *dev, void *data)
171{ 176{
172 int *minor = data; 177 struct find_interface_arg *arg = data;
173 struct usb_interface *intf; 178 struct usb_interface *intf;
174 179
175 if (!is_usb_interface(dev)) 180 if (!is_usb_interface(dev))
176 return 0; 181 return 0;
177 182
183 if (dev->driver != arg->drv)
184 return 0;
178 intf = to_usb_interface(dev); 185 intf = to_usb_interface(dev);
179 if (intf->minor != -1 && intf->minor == *minor) 186 return intf->minor == arg->minor;
180 return 1;
181 return 0;
182} 187}
183 188
184/** 189/**
@@ -187,14 +192,18 @@ static int __find_interface(struct device *dev, void *data)
187 * @minor: the minor number of the desired device 192 * @minor: the minor number of the desired device
188 * 193 *
189 * This walks the bus device list and returns a pointer to the interface 194 * This walks the bus device list and returns a pointer to the interface
190 * 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
191 * USB major number. 196 * that share the USB major number.
192 */ 197 */
193struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) 198struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
194{ 199{
200 struct find_interface_arg argb;
195 struct device *dev; 201 struct device *dev;
196 202
197 dev = bus_find_device(&usb_bus_type, NULL, &minor, __find_interface); 203 argb.minor = minor;
204 argb.drv = &drv->drvwrap.driver;
205
206 dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface);
198 207
199 /* Drop reference count from bus_find_device */ 208 /* Drop reference count from bus_find_device */
200 put_device(dev); 209 put_device(dev);