Skip to content

Commit

Permalink
Kobject: change drivers/cpuidle/sysfs.c to use kobject_init_and_add
Browse files Browse the repository at this point in the history
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: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Jan 25, 2008
1 parent b2ed215 commit 94f57f3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/cpuidle/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,13 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device)
kobj->state = &device->states[i];
init_completion(&kobj->kobj_unregister);

kobj->kobj.parent = &device->kobj;
kobj->kobj.ktype = &ktype_state_cpuidle;
kobject_set_name(&kobj->kobj, "state%d", i);
ret = kobject_register(&kobj->kobj);
ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj,
"state%d", i);
if (ret) {
kfree(kobj);
goto error_state;
}
kobject_uevent(&kobj->kobj, KOBJ_ADD);
device->kobjs[i] = kobj;
}

Expand Down Expand Up @@ -339,12 +338,14 @@ int cpuidle_add_sysfs(struct sys_device *sysdev)
{
int cpu = sysdev->id;
struct cpuidle_device *dev;
int error;

dev = per_cpu(cpuidle_devices, cpu);
dev->kobj.parent = &sysdev->kobj;
dev->kobj.ktype = &ktype_cpuidle;
kobject_set_name(&dev->kobj, "%s", "cpuidle");
return kobject_register(&dev->kobj);
error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &sysdev->kobj,
"cpuidle");
if (!error)
kobject_uevent(&dev->kobj, KOBJ_ADD);
return error;
}

/**
Expand Down

0 comments on commit 94f57f3

Please sign in to comment.