diff options
author | Stas Sergeev <stsp@aknet.ru> | 2008-04-26 19:52:35 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-30 16:52:47 -0700 |
commit | 16dc42e018c2868211b4928f20a957c0c216126c (patch) | |
tree | 2551571326e4927e70485159fafdc8ee7a3eb2ca /drivers/base/driver.c | |
parent | 93dd40013f4f7f4b18d19d0d77855f025bcc57c3 (diff) | |
download | op-kernel-dev-16dc42e018c2868211b4928f20a957c0c216126c.zip op-kernel-dev-16dc42e018c2868211b4928f20a957c0c216126c.tar.gz |
driver core: warn about duplicate driver names on the same bus
Currently an attempt to register multiple
drivers with the same name causes the
stack trace with some cryptic error message.
The attached patch adds the necessary check
and the clear error message.
Signed-off-by: Stas Sergeev <stsp@aknet.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/driver.c')
-rw-r--r-- | drivers/base/driver.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 9a6537f..2ef5acf 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -217,12 +217,22 @@ static void driver_remove_groups(struct device_driver *drv, int driver_register(struct device_driver *drv) { int ret; + struct device_driver *other; 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); + + other = driver_find(drv->name, drv->bus); + if (other) { + put_driver(other); + printk(KERN_ERR "Error: Driver '%s' is already registered, " + "aborting...\n", drv->name); + return -EEXIST; + } + ret = bus_add_driver(drv); if (ret) return ret; |