[patch 02/18] Driver Core: add helper device_is_registered()

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

 



From: Daniel Ritz <[email protected]>

[PATCH] driver core: add helper device_is_registered()

add the helper and use it instead of open coding the klist_node_attached() check
(which is a layering violation IMHO)

idea by Alan Stern.

Signed-off-by: Daniel Ritz <[email protected]>
Cc: Alan Stern <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/s390/cio/ccwgroup.c |    2 +-
 drivers/usb/core/message.c  |    2 +-
 drivers/usb/core/usb.c      |    6 +++---
 include/linux/device.h      |    5 +++++
 4 files changed, 10 insertions(+), 5 deletions(-)

--- scsi-2.6.orig/drivers/s390/cio/ccwgroup.c	2005-09-21 17:37:54.000000000 -0700
+++ scsi-2.6/drivers/s390/cio/ccwgroup.c	2005-09-21 17:37:59.000000000 -0700
@@ -437,7 +437,7 @@
 	if (cdev->dev.driver_data) {
 		gdev = (struct ccwgroup_device *)cdev->dev.driver_data;
 		if (get_device(&gdev->dev)) {
-			if (klist_node_attached(&gdev->dev.knode_bus))
+			if (device_is_registered(&gdev->dev))
 				return gdev;
 			put_device(&gdev->dev);
 		}
--- scsi-2.6.orig/drivers/usb/core/message.c	2005-09-21 17:37:54.000000000 -0700
+++ scsi-2.6/drivers/usb/core/message.c	2005-09-21 17:37:59.000000000 -0700
@@ -987,7 +987,7 @@
 
 			/* remove this interface if it has been registered */
 			interface = dev->actconfig->interface[i];
-			if (!klist_node_attached(&interface->dev.knode_bus))
+			if (!device_is_registered(&interface->dev))
 				continue;
 			dev_dbg (&dev->dev, "unregistering interface %s\n",
 				interface->dev.bus_id);
--- scsi-2.6.orig/drivers/usb/core/usb.c	2005-09-21 17:37:54.000000000 -0700
+++ scsi-2.6/drivers/usb/core/usb.c	2005-09-21 17:37:59.000000000 -0700
@@ -303,7 +303,7 @@
 	/* if interface was already added, bind now; else let
 	 * the future device_add() bind it, bypassing probe()
 	 */
-	if (klist_node_attached(&dev->knode_bus))
+	if (device_is_registered(dev))
 		device_bind_driver(dev);
 
 	return 0;
@@ -336,8 +336,8 @@
 	if (iface->condition != USB_INTERFACE_BOUND)
 		return;
 
-	/* release only after device_add() */
-	if (klist_node_attached(&dev->knode_bus)) {
+	/* don't release if the interface hasn't been added yet */
+	if (device_is_registered(dev)) {
 		iface->condition = USB_INTERFACE_UNBINDING;
 		device_release_driver(dev);
 	}
--- scsi-2.6.orig/include/linux/device.h	2005-09-21 17:37:54.000000000 -0700
+++ scsi-2.6/include/linux/device.h	2005-09-21 17:38:29.000000000 -0700
@@ -317,6 +317,11 @@
 	dev->driver_data = data;
 }
 
+static inline int device_is_registered(struct device *dev)
+{
+	return klist_node_attached(&dev->knode_bus);
+}
+
 /*
  * High level routines for use by the bus drivers
  */

--
-
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]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux