]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
driver core: warn about duplicate driver names on the same bus
authorStas Sergeev <stsp@aknet.ru>
Sat, 26 Apr 2008 15:52:35 +0000 (19:52 +0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 30 Apr 2008 23:52:47 +0000 (16:52 -0700)
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>
drivers/base/driver.c

index 9a6537f14401df5aae7a81842c7bd7a145c2f849..2ef5acf4368b9e8deef4440d865a87cef8d0b0a6 100644 (file)
@@ -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;