aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2006-01-05 14:29:51 +0000
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-13 11:26:04 -0800
commit594c8281f90560faf9632d91bb9d402cbe560e63 (patch)
treeabeb32df086cfd204accad33b11040381c31689d /drivers/base
parentbd37e5a951ad2123d3f51f59c407b5242946b6ba (diff)
downloadlinux-594c8281f90560faf9632d91bb9d402cbe560e63.tar.gz
[PATCH] Add bus_type probe, remove, shutdown methods.
Add bus_type probe, remove and shutdown methods to replace the corresponding methods in struct device_driver. This matches the way we handle the suspend/resume methods. Since the bus methods override the device_driver methods, warn if a device driver is registered whose methods will not be called. The long-term idea is to remove the device_driver methods entirely. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/dd.c12
-rw-r--r--drivers/base/driver.c5
-rw-r--r--drivers/base/power/shutdown.c5
3 files changed, 19 insertions, 3 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 2b905016664d97..730a9ce0a14a44 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -78,7 +78,13 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
pr_debug("%s: Matched Device %s with Driver %s\n",
drv->bus->name, dev->bus_id, drv->name);
dev->driver = drv;
- if (drv->probe) {
+ if (dev->bus->probe) {
+ ret = dev->bus->probe(dev);
+ if (ret) {
+ dev->driver = NULL;
+ goto ProbeFailed;
+ }
+ } else if (drv->probe) {
ret = drv->probe(dev);
if (ret) {
dev->driver = NULL;
@@ -203,7 +209,9 @@ static void __device_release_driver(struct device * dev)
sysfs_remove_link(&dev->kobj, "driver");
klist_remove(&dev->knode_driver);
- if (drv->remove)
+ if (dev->bus->remove)
+ dev->bus->remove(dev);
+ else if (drv->remove)
drv->remove(dev);
dev->driver = NULL;
put_driver(drv);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 161f3a390d9065..b400314e1c62d4 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -171,6 +171,11 @@ static void klist_devices_put(struct klist_node *n)
*/
int driver_register(struct device_driver * drv)
{
+ if ((drv->bus->probe && drv->probe) ||
+ (drv->bus->remove && drv->remove) ||
+ (drv->bus->shutdown && drv->shutdown)) {
+ printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name);
+ }
klist_init(&drv->klist_devices, klist_devices_get, klist_devices_put);
init_completion(&drv->unloaded);
return bus_add_driver(drv);
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index f50a08be424b1c..a47bb74da72b93 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -40,7 +40,10 @@ void device_shutdown(void)
down_write(&devices_subsys.rwsem);
list_for_each_entry_reverse(dev, &devices_subsys.kset.list,
kobj.entry) {
- if (dev->driver && dev->driver->shutdown) {
+ if (dev->bus && dev->bus->shutdown) {
+ dev_dbg(dev, "shutdown\n");
+ dev->bus->shutdown(dev);
+ } else if (dev->driver && dev->driver->shutdown) {
dev_dbg(dev, "shutdown\n");
dev->driver->shutdown(dev);
}