summaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle/sysfs.c
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2012-10-26 12:26:32 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-15 00:34:19 +0100
commite45a00d679a788217f35ee4214a32d6d1924160b (patch)
treefd8e431856bf3df54b5af7352d026997d551d015 /drivers/cpuidle/sysfs.c
parent1aef40e288acfb3cc28ff77528b34ef66683bed6 (diff)
downloadlinux-stable-e45a00d679a788217f35ee4214a32d6d1924160b.tar.gz
linux-stable-e45a00d679a788217f35ee4214a32d6d1924160b.tar.bz2
linux-stable-e45a00d679a788217f35ee4214a32d6d1924160b.zip
cpuidle / sysfs: move kobj initialization in the syfs file
Move the kobj initialization and completion in the sysfs.c and encapsulate the code more. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle/sysfs.c')
-rw-r--r--drivers/cpuidle/sysfs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 84e62852e50a..ed87399bb02b 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -374,8 +374,8 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device)
kobj->state_usage = &device->states_usage[i];
init_completion(&kobj->kobj_unregister);
- ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj,
- "state%d", i);
+ ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle,
+ &device->kobj, "state%d", i);
if (ret) {
kfree(kobj);
goto error_state;
@@ -413,6 +413,8 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
int error;
+ init_completion(&dev->kobj_unregister);
+
error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj,
"cpuidle");
if (!error)
@@ -427,4 +429,5 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
void cpuidle_remove_sysfs(struct cpuidle_device *dev)
{
kobject_put(&dev->kobj);
+ wait_for_completion(&dev->kobj_unregister);
}