]> err.no Git - linux-2.6/blobdiff - drivers/pci/hotplug/pci_hotplug_core.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg...
[linux-2.6] / drivers / pci / hotplug / pci_hotplug_core.c
index 175e0c8599e347ab328e26fe1cbb0c2e4ac504b8..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,30 +619,35 @@ 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;
        }
 
-       kobject_set_name(&slot->kobj, "%s", slot->name);
-       slot->kobj.kset = pci_hotplug_slots_kset;
-       slot->kobj.ktype = &hotplug_slot_ktype;
+       /* Check if we have already registered a slot with the same name. */
+       tmp = get_slot_from_name(slot->name);
+       if (tmp)
+               return -EEXIST;
 
-       /* this can fail if we have already registered a slot with the same name */
-       if (kobject_register(&slot->kobj)) {
-               err("Unable to register kobject");
+       slot->kobj.kset = pci_hotplug_slots_kset;
+       result = kobject_init_and_add(&slot->kobj, &hotplug_slot_ktype, NULL,
+                                     "%s", slot->name);
+       if (result) {
+               err("Unable to register kobject '%s'", slot->name);
                return -EINVAL;
        }
-               
+
        list_add (&slot->slot_list, &pci_hotplug_slot_list);
 
        result = fs_add_slot (slot);
+       kobject_uevent(&slot->kobj, KOBJ_ADD);
        dbg ("Added slot %s to the list\n", slot->name);
        return result;
 }
@@ -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;
 }
 
@@ -699,9 +704,12 @@ int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot,
 static int __init pci_hotplug_init (void)
 {
        int result;
+       struct kset *pci_bus_kset;
+
+       pci_bus_kset = bus_get_kset(&pci_bus_type);
 
        pci_hotplug_slots_kset = kset_create_and_add("slots", NULL,
-                                                    &pci_bus_type.subsys.kobj);
+                                                    &pci_bus_kset->kobj);
        if (!pci_hotplug_slots_kset) {
                result = -ENOMEM;
                err("Register subsys error\n");