Kobject: change drivers/pci/hotplug/pci_hotplug_core.c to use kobject_init_and_add
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 17 Dec 2007 19:54:39 +0000 (15:54 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:28 +0000 (20:40 -0800)
Stop using kobject_register, as this way we can control the sending of
the uevent properly, after everything is properly initialized.

Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/hotplug/pci_hotplug_core.c

index 175e0c8599e347ab328e26fe1cbb0c2e4ac504b8..0f05e6a68b3b7bcac5ec636266d2cb6288a12789 100644 (file)
@@ -630,19 +630,19 @@ int pci_hp_register (struct hotplug_slot *slot)
                return -EINVAL;
        }
 
-       kobject_set_name(&slot->kobj, "%s", slot->name);
-       slot->kobj.kset = pci_hotplug_slots_kset;
-       slot->kobj.ktype = &hotplug_slot_ktype;
-
        /* 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;
 }