]> err.no Git - linux-2.6/blobdiff - drivers/pci/hotplug/pci_hotplug_core.c
Merge branch 'linus' into x86/kconfig
[linux-2.6] / drivers / pci / hotplug / pci_hotplug_core.c
index 3606d5b52a70ffd6c6b3c85e859e2d6220f4b1fd..a11021e8ce37bb0cc3e76f182dfbd84027ff8d9f 100644 (file)
@@ -43,7 +43,7 @@
 
 #define MY_NAME        "pci_hotplug"
 
-#define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __FUNCTION__ , ## arg); } while (0)
+#define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0)
 #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg)
 #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg)
@@ -137,7 +137,7 @@ static int get_##name (struct hotplug_slot *slot, type *value)              \
        int retval = 0;                                                 \
        if (try_module_get(ops->owner)) {                               \
                if (ops->get_##name)                                    \
-                       retval = ops->get_##name (slot, value);         \
+                       retval = ops->get_##name(slot, value);          \
                else                                                    \
                        *value = slot->info->name;                      \
                module_put(ops->owner);                                 \
@@ -619,18 +619,23 @@ static struct hotplug_slot *get_slot_from_name (const char *name)
 int pci_hp_register (struct hotplug_slot *slot)
 {
        int result;
+       struct hotplug_slot *tmp;
 
        if (slot == NULL)
                return -ENODEV;
        if ((slot->info == NULL) || (slot->ops == NULL))
                return -EINVAL;
        if (slot->release == NULL) {
-               dbg("Why are you trying to register a hotplug slot"
+               dbg("Why are you trying to register a hotplug slot "
                    "without a proper release function?\n");
                return -EINVAL;
        }
 
-       /* this can fail if we have already registered a slot with the same name */
+       /* Check if we have already registered a slot with the same name. */
+       tmp = get_slot_from_name(slot->name);
+       if (tmp)
+               return -EEXIST;
+
        slot->kobj.kset = pci_hotplug_slots_kset;
        result = kobject_init_and_add(&slot->kobj, &hotplug_slot_ktype, NULL,
                                      "%s", slot->name);
@@ -671,7 +676,7 @@ int pci_hp_deregister (struct hotplug_slot *slot)
 
        fs_remove_slot (slot);
        dbg ("Removed slot %s from the list\n", slot->name);
-       kobject_unregister(&slot->kobj);
+       kobject_put(&slot->kobj);
        return 0;
 }