]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
[PATCH] driver core: add helper device_is_registered()
authorDaniel Ritz <daniel.ritz@gmx.ch>
Thu, 22 Sep 2005 07:47:24 +0000 (00:47 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 22 Sep 2005 14:58:24 +0000 (07:58 -0700)
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 <daniel.ritz@gmx.ch>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/s390/cio/ccwgroup.c
drivers/usb/core/message.c
drivers/usb/core/usb.c
include/linux/device.h

index 91ea8e4777f340b2c47fe76ac5f68cab43e54ffa..dbb3eb0e330b00d017ca7b98817d8f2fde5f4932 100644 (file)
@@ -437,7 +437,7 @@ __ccwgroup_get_gdev_by_cdev(struct ccw_device *cdev)
        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);
                }
index c47c8052b4866f536b7482e4452d7f99ec221051..f1fb67fe22a82806533a4875801fd14a7f180833 100644 (file)
@@ -987,7 +987,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
 
                        /* 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);
index 087af73a59dd70aa270694abde9e9233a51fe241..7d131509e41909a0aa92bac2665cf1acbccb2d1b 100644 (file)
@@ -303,7 +303,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
        /* 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 @@ void usb_driver_release_interface(struct usb_driver *driver,
        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);
        }
index 06e5d42f2c7b4f9cb4f5186b15da49e46068746f..95d607a48f06edd22c6be64e0feaf74d1aa63467 100644 (file)
@@ -317,6 +317,11 @@ dev_set_drvdata (struct device *dev, void *data)
        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
  */