Skip to content

Commit

Permalink
driver core: warn about duplicate driver names on the same bus
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Stas Sergeev authored and gregkh committed Apr 30, 2008
1 parent 93dd400 commit 16dc42e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/base/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 16dc42e

Please sign in to comment.