Commit 94f57f33 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Kobject: change drivers/cpuidle/sysfs.c to use kobject_init_and_add

Stop using kobject_register, as this way we can control the sending of
the uevent properly, after everything is properly initialized.

Cc: Shaohua Li <shaohua.li@intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b2ed215a
...@@ -300,14 +300,13 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) ...@@ -300,14 +300,13 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device)
kobj->state = &device->states[i]; kobj->state = &device->states[i];
init_completion(&kobj->kobj_unregister); init_completion(&kobj->kobj_unregister);
kobj->kobj.parent = &device->kobj; ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj,
kobj->kobj.ktype = &ktype_state_cpuidle; "state%d", i);
kobject_set_name(&kobj->kobj, "state%d", i);
ret = kobject_register(&kobj->kobj);
if (ret) { if (ret) {
kfree(kobj); kfree(kobj);
goto error_state; goto error_state;
} }
kobject_uevent(&kobj->kobj, KOBJ_ADD);
device->kobjs[i] = kobj; device->kobjs[i] = kobj;
} }
...@@ -339,12 +338,14 @@ int cpuidle_add_sysfs(struct sys_device *sysdev) ...@@ -339,12 +338,14 @@ int cpuidle_add_sysfs(struct sys_device *sysdev)
{ {
int cpu = sysdev->id; int cpu = sysdev->id;
struct cpuidle_device *dev; struct cpuidle_device *dev;
int error;
dev = per_cpu(cpuidle_devices, cpu); dev = per_cpu(cpuidle_devices, cpu);
dev->kobj.parent = &sysdev->kobj; error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &sysdev->kobj,
dev->kobj.ktype = &ktype_cpuidle; "cpuidle");
kobject_set_name(&dev->kobj, "%s", "cpuidle"); if (!error)
return kobject_register(&dev->kobj); kobject_uevent(&dev->kobj, KOBJ_ADD);
return error;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment