Kobject: change drivers/base/sys.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: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/sys.c

index 29eadc656bd170c6f52a0b0f6155380441f0b6c2..47fc6eb6473f0c1d6bfb7f216b7abeacc8aed36b 100644 (file)
@@ -224,20 +224,15 @@ int sysdev_register(struct sys_device * sysdev)
        if (!cls)
                return -EINVAL;
 
+       pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
+
        /* Make sure the kset is set */
        sysdev->kobj.kset = &cls->kset;
 
-       /* But make sure we point to the right type for sysfs translation */
-       sysdev->kobj.ktype = &ktype_sysdev;
-       error = kobject_set_name(&sysdev->kobj, "%s%d",
-                        kobject_name(&cls->kset.kobj), sysdev->id);
-       if (error)
-               return error;
-
-       pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
-
        /* Register the object */
-       error = kobject_register(&sysdev->kobj);
+       error = kobject_init_and_add(&sysdev->kobj, &ktype_sysdev, NULL,
+                                    "%s%d", kobject_name(&cls->kset.kobj),
+                                    sysdev->id);
 
        if (!error) {
                struct sysdev_driver * drv;
@@ -254,6 +249,7 @@ int sysdev_register(struct sys_device * sysdev)
                }
                mutex_unlock(&sysdev_drivers_lock);
        }
+       kobject_uevent(&sysdev->kobj, KOBJ_ADD);
        return error;
 }