mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 16:29:59 +00:00
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"
This commit is contained in:
commit
7f6cd5408a
1 changed files with 16 additions and 7 deletions
|
@ -167,18 +167,23 @@ struct usb_host_interface *usb_altnum_to_altsetting(
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);
|
EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);
|
||||||
|
|
||||||
|
struct find_interface_arg {
|
||||||
|
int minor;
|
||||||
|
struct device_driver *drv;
|
||||||
|
};
|
||||||
|
|
||||||
static int __find_interface(struct device *dev, void *data)
|
static int __find_interface(struct device *dev, void *data)
|
||||||
{
|
{
|
||||||
int *minor = data;
|
struct find_interface_arg *arg = data;
|
||||||
struct usb_interface *intf;
|
struct usb_interface *intf;
|
||||||
|
|
||||||
if (!is_usb_interface(dev))
|
if (!is_usb_interface(dev))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (dev->driver != arg->drv)
|
||||||
|
return 0;
|
||||||
intf = to_usb_interface(dev);
|
intf = to_usb_interface(dev);
|
||||||
if (intf->minor != -1 && intf->minor == *minor)
|
return intf->minor == arg->minor;
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,14 +192,18 @@ static int __find_interface(struct device *dev, void *data)
|
||||||
* @minor: the minor number of the desired device
|
* @minor: the minor number of the desired device
|
||||||
*
|
*
|
||||||
* This walks the bus device list and returns a pointer to the interface
|
* This walks the bus device list and returns a pointer to the interface
|
||||||
* with the matching minor. Note, this only works for devices that share the
|
* with the matching minor and driver. Note, this only works for devices
|
||||||
* USB major number.
|
* that share the USB major number.
|
||||||
*/
|
*/
|
||||||
struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
|
struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
|
||||||
{
|
{
|
||||||
|
struct find_interface_arg argb;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
dev = bus_find_device(&usb_bus_type, NULL, &minor, __find_interface);
|
argb.minor = minor;
|
||||||
|
argb.drv = &drv->drvwrap.driver;
|
||||||
|
|
||||||
|
dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface);
|
||||||
|
|
||||||
/* Drop reference count from bus_find_device */
|
/* Drop reference count from bus_find_device */
|
||||||
put_device(dev);
|
put_device(dev);
|
||||||
|
|
Loading…
Reference in a new issue