X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fbase%2Fdriver.c;h=1e2bda780e48268eb38b834f7078644689b5dc7b;hb=7aeb6d7d20185b7cede1ce5f6bd8d762e49bda6d;hp=ba75184c653c32794e3ac60283369a1bd39ea461;hpb=26b6f2236615649a0ae6a0de2e9e71a2f9ffeba7;p=linux-2.6-omap-h63xx.git diff --git a/drivers/base/driver.c b/drivers/base/driver.c index ba75184c653..1e2bda780e4 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -16,9 +16,6 @@ #include #include "base.h" -#define to_dev(node) container_of(node, struct device, driver_list) - - static struct device *next_device(struct klist_iter *i) { struct klist_node *n = klist_next(i); @@ -120,6 +117,9 @@ EXPORT_SYMBOL_GPL(driver_remove_file); /** * driver_add_kobj - add a kobject below the specified driver + * @drv: requesting device driver + * @kobj: kobject to add below this driver + * @fmt: format string that names the kobject * * You really don't want to do this, this is only here due to one looney * iseries driver, go poke those developers if you are annoyed about @@ -130,6 +130,7 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj, { va_list args; char *name; + int ret; va_start(args, fmt); name = kvasprintf(GFP_KERNEL, fmt, args); @@ -138,7 +139,9 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj, if (!name) return -ENOMEM; - return kobject_add(kobj, &drv->p->kobj, "%s", name); + ret = kobject_add(kobj, &drv->p->kobj, "%s", name); + kfree(name); + return ret; } EXPORT_SYMBOL_GPL(driver_add_kobj); @@ -211,12 +214,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;