drivers/base/driver.c: remove unused to_dev() macro
[pandora-kernel.git] / drivers / base / driver.c
index ba75184..1e2bda7 100644 (file)
@@ -16,9 +16,6 @@
 #include <linux/string.h>
 #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;