aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authormochel@digitalimplant.org <mochel@digitalimplant.org>2005-03-21 14:09:40 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-20 18:15:13 -0400
commit6034a080f98b0bbc0a058e2ac65a538f75cffeee (patch)
tree3e3bb5b4afcce4aafd4cf287377c5298bd7211b2 /drivers
parent8d618afdd61ccaacbab4976a556c0ddcf36e2d8a (diff)
[PATCH] Use driver_for_each_device() instead of manually walking list.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Index: gregkh-2.6/drivers/usb/core/usb.c ===================================================================
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/usb.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 25cf7e9eccfa..4453cce7eb24 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -462,6 +462,25 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
462 return NULL; 462 return NULL;
463} 463}
464 464
465
466static int __find_interface(struct device * dev, void * data)
467{
468 struct usb_interface ** ret = (struct usb_interface **)data;
469 struct usb_interface * intf = *ret;
470 int *minor = (int *)data;
471
472 /* can't look at usb devices, only interfaces */
473 if (dev->driver == &usb_generic_driver)
474 return 0;
475
476 intf = to_usb_interface(dev);
477 if (intf->minor != -1 && intf->minor == *minor) {
478 *ret = intf;
479 return 1;
480 }
481 return 0;
482}
483
465/** 484/**
466 * usb_find_interface - find usb_interface pointer for driver and device 485 * usb_find_interface - find usb_interface pointer for driver and device
467 * @drv: the driver whose current configuration is considered 486 * @drv: the driver whose current configuration is considered
@@ -473,26 +492,12 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
473 */ 492 */
474struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) 493struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
475{ 494{
476 struct list_head *entry; 495 struct usb_interface *intf = (struct usb_interface *)minor;
477 struct device *dev; 496 int ret;
478 struct usb_interface *intf;
479
480 list_for_each(entry, &drv->driver.devices) {
481 dev = container_of(entry, struct device, driver_list);
482 497
483 /* can't look at usb devices, only interfaces */ 498 ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface);
484 if (dev->driver == &usb_generic_driver)
485 continue;
486
487 intf = to_usb_interface(dev);
488 if (intf->minor == -1)
489 continue;
490 if (intf->minor == minor)
491 return intf;
492 }
493 499
494 /* no device found that matches */ 500 return ret ? intf : NULL;
495 return NULL;
496} 501}
497 502
498static int usb_device_match (struct device *dev, struct device_driver *drv) 503static int usb_device_match (struct device *dev, struct device_driver *drv)