diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2012-10-26 06:26:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:34:19 -0500 |
commit | e45a00d679a788217f35ee4214a32d6d1924160b (patch) | |
tree | fd8e431856bf3df54b5af7352d026997d551d015 /drivers/cpuidle | |
parent | 1aef40e288acfb3cc28ff77528b34ef66683bed6 (diff) |
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')
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 4 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index b511ac39cc85..f4b8fc50c0f2 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -399,8 +399,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
399 | if (!try_module_get(cpuidle_driver->owner)) | 399 | if (!try_module_get(cpuidle_driver->owner)) |
400 | return -EINVAL; | 400 | return -EINVAL; |
401 | 401 | ||
402 | init_completion(&dev->kobj_unregister); | ||
403 | |||
404 | per_cpu(cpuidle_devices, dev->cpu) = dev; | 402 | per_cpu(cpuidle_devices, dev->cpu) = dev; |
405 | list_add(&dev->device_list, &cpuidle_detected_devices); | 403 | list_add(&dev->device_list, &cpuidle_detected_devices); |
406 | ret = cpuidle_add_sysfs(dev); | 404 | ret = cpuidle_add_sysfs(dev); |
@@ -416,7 +414,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
416 | 414 | ||
417 | err_coupled: | 415 | err_coupled: |
418 | cpuidle_remove_sysfs(dev); | 416 | cpuidle_remove_sysfs(dev); |
419 | wait_for_completion(&dev->kobj_unregister); | ||
420 | err_sysfs: | 417 | err_sysfs: |
421 | list_del(&dev->device_list); | 418 | list_del(&dev->device_list); |
422 | per_cpu(cpuidle_devices, dev->cpu) = NULL; | 419 | per_cpu(cpuidle_devices, dev->cpu) = NULL; |
@@ -470,7 +467,6 @@ void cpuidle_unregister_device(struct cpuidle_device *dev) | |||
470 | 467 | ||
471 | cpuidle_remove_sysfs(dev); | 468 | cpuidle_remove_sysfs(dev); |
472 | list_del(&dev->device_list); | 469 | list_del(&dev->device_list); |
473 | wait_for_completion(&dev->kobj_unregister); | ||
474 | per_cpu(cpuidle_devices, dev->cpu) = NULL; | 470 | per_cpu(cpuidle_devices, dev->cpu) = NULL; |
475 | 471 | ||
476 | cpuidle_coupled_unregister_device(dev); | 472 | cpuidle_coupled_unregister_device(dev); |
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) | |||
374 | kobj->state_usage = &device->states_usage[i]; | 374 | kobj->state_usage = &device->states_usage[i]; |
375 | init_completion(&kobj->kobj_unregister); | 375 | init_completion(&kobj->kobj_unregister); |
376 | 376 | ||
377 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, | 377 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, |
378 | "state%d", i); | 378 | &device->kobj, "state%d", i); |
379 | if (ret) { | 379 | if (ret) { |
380 | kfree(kobj); | 380 | kfree(kobj); |
381 | goto error_state; | 381 | goto error_state; |
@@ -413,6 +413,8 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) | |||
413 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); | 413 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); |
414 | int error; | 414 | int error; |
415 | 415 | ||
416 | init_completion(&dev->kobj_unregister); | ||
417 | |||
416 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, | 418 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, |
417 | "cpuidle"); | 419 | "cpuidle"); |
418 | if (!error) | 420 | if (!error) |
@@ -427,4 +429,5 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) | |||
427 | void cpuidle_remove_sysfs(struct cpuidle_device *dev) | 429 | void cpuidle_remove_sysfs(struct cpuidle_device *dev) |
428 | { | 430 | { |
429 | kobject_put(&dev->kobj); | 431 | kobject_put(&dev->kobj); |
432 | wait_for_completion(&dev->kobj_unregister); | ||
430 | } | 433 | } |