[PATCH] Use driver_for_each_device() instead of manually walking list.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[PATCH] Use driver_for_each_device() instead of manually walking list.

Signed-off-by: Patrick Mochel <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

Index: gregkh-2.6/drivers/usb/core/usb.c
===================================================================

---
commit 6034a080f98b0bbc0a058e2ac65a538f75cffeee
tree 3e3bb5b4afcce4aafd4cf287377c5298bd7211b2
parent 8d618afdd61ccaacbab4976a556c0ddcf36e2d8a
author [email protected] <[email protected]> Mon, 21 Mar 2005 11:09:40 -0800
committer Greg Kroah-Hartman <[email protected]> Mon, 20 Jun 2005 15:15:13 -0700

 drivers/usb/core/usb.c |   41 +++++++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -462,6 +462,25 @@ usb_match_id(struct usb_interface *inter
 	return NULL;
 }
 
+
+static int __find_interface(struct device * dev, void * data)
+{
+	struct usb_interface ** ret = (struct usb_interface **)data;
+	struct usb_interface * intf = *ret;
+	int *minor = (int *)data;
+
+	/* can't look at usb devices, only interfaces */
+	if (dev->driver == &usb_generic_driver)
+		return 0;
+
+	intf = to_usb_interface(dev);
+	if (intf->minor != -1 && intf->minor == *minor) {
+		*ret = intf;
+		return 1;
+	}
+	return 0;
+}
+
 /**
  * usb_find_interface - find usb_interface pointer for driver and device
  * @drv: the driver whose current configuration is considered
@@ -473,26 +492,12 @@ usb_match_id(struct usb_interface *inter
  */
 struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
 {
-	struct list_head *entry;
-	struct device *dev;
-	struct usb_interface *intf;
-
-	list_for_each(entry, &drv->driver.devices) {
-		dev = container_of(entry, struct device, driver_list);
+	struct usb_interface *intf = (struct usb_interface *)minor;
+	int ret;
 
-		/* can't look at usb devices, only interfaces */
-		if (dev->driver == &usb_generic_driver)
-			continue;
-
-		intf = to_usb_interface(dev);
-		if (intf->minor == -1)
-			continue;
-		if (intf->minor == minor)
-			return intf;
-	}
+	ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface);
 
-	/* no device found that matches */
-	return NULL;	
+	return ret ? intf : NULL;
 }
 
 static int usb_device_match (struct device *dev, struct device_driver *drv)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux