Commit d305ef5d authored by Daniel Ritz's avatar Daniel Ritz Committed by Linus Torvalds

[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: default avatarDaniel Ritz <daniel.ritz@gmx.ch>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4c898c7f
...@@ -437,7 +437,7 @@ __ccwgroup_get_gdev_by_cdev(struct ccw_device *cdev) ...@@ -437,7 +437,7 @@ __ccwgroup_get_gdev_by_cdev(struct ccw_device *cdev)
if (cdev->dev.driver_data) { if (cdev->dev.driver_data) {
gdev = (struct ccwgroup_device *)cdev->dev.driver_data; gdev = (struct ccwgroup_device *)cdev->dev.driver_data;
if (get_device(&gdev->dev)) { if (get_device(&gdev->dev)) {
if (klist_node_attached(&gdev->dev.knode_bus)) if (device_is_registered(&gdev->dev))
return gdev; return gdev;
put_device(&gdev->dev); put_device(&gdev->dev);
} }
......
...@@ -987,7 +987,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) ...@@ -987,7 +987,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
/* remove this interface if it has been registered */ /* remove this interface if it has been registered */
interface = dev->actconfig->interface[i]; interface = dev->actconfig->interface[i];
if (!klist_node_attached(&interface->dev.knode_bus)) if (!device_is_registered(&interface->dev))
continue; continue;
dev_dbg (&dev->dev, "unregistering interface %s\n", dev_dbg (&dev->dev, "unregistering interface %s\n",
interface->dev.bus_id); interface->dev.bus_id);
......
...@@ -303,7 +303,7 @@ int usb_driver_claim_interface(struct usb_driver *driver, ...@@ -303,7 +303,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
/* if interface was already added, bind now; else let /* if interface was already added, bind now; else let
* the future device_add() bind it, bypassing probe() * the future device_add() bind it, bypassing probe()
*/ */
if (klist_node_attached(&dev->knode_bus)) if (device_is_registered(dev))
device_bind_driver(dev); device_bind_driver(dev);
return 0; return 0;
...@@ -336,8 +336,8 @@ void usb_driver_release_interface(struct usb_driver *driver, ...@@ -336,8 +336,8 @@ void usb_driver_release_interface(struct usb_driver *driver,
if (iface->condition != USB_INTERFACE_BOUND) if (iface->condition != USB_INTERFACE_BOUND)
return; return;
/* release only after device_add() */ /* don't release if the interface hasn't been added yet */
if (klist_node_attached(&dev->knode_bus)) { if (device_is_registered(dev)) {
iface->condition = USB_INTERFACE_UNBINDING; iface->condition = USB_INTERFACE_UNBINDING;
device_release_driver(dev); device_release_driver(dev);
} }
......
...@@ -317,6 +317,11 @@ dev_set_drvdata (struct device *dev, void *data) ...@@ -317,6 +317,11 @@ dev_set_drvdata (struct device *dev, void *data)
dev->driver_data = 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 * High level routines for use by the bus drivers
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment