diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2012-10-26 06:26:24 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:34:19 -0500 |
commit | 1aef40e288acfb3cc28ff77528b34ef66683bed6 (patch) | |
tree | c62a1d0448a07aef5a987dac44135de3c74522b9 /drivers/cpuidle | |
parent | 77b67063bb6bce6d475e910d3b886a606d0d91f7 (diff) |
cpuidle / sysfs: change function parameter
The function needs the cpuidle_device which is initially passed to the
caller.
The current code gets the struct device from the struct cpuidle_device,
pass it the cpuidle_add_sysfs function. This function calls
per_cpu(cpuidle_devices, cpu) to get the cpuidle_device.
This patch pass the cpuidle_device instead and simplify the code.
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 | 8 | ||||
-rw-r--r-- | drivers/cpuidle/cpuidle.h | 4 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 12 |
3 files changed, 8 insertions, 16 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 7f15b8514a18..b511ac39cc85 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -394,7 +394,6 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device); | |||
394 | static int __cpuidle_register_device(struct cpuidle_device *dev) | 394 | static int __cpuidle_register_device(struct cpuidle_device *dev) |
395 | { | 395 | { |
396 | int ret; | 396 | int ret; |
397 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); | ||
398 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); | 397 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); |
399 | 398 | ||
400 | if (!try_module_get(cpuidle_driver->owner)) | 399 | if (!try_module_get(cpuidle_driver->owner)) |
@@ -404,7 +403,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
404 | 403 | ||
405 | per_cpu(cpuidle_devices, dev->cpu) = dev; | 404 | per_cpu(cpuidle_devices, dev->cpu) = dev; |
406 | list_add(&dev->device_list, &cpuidle_detected_devices); | 405 | list_add(&dev->device_list, &cpuidle_detected_devices); |
407 | ret = cpuidle_add_sysfs(cpu_dev); | 406 | ret = cpuidle_add_sysfs(dev); |
408 | if (ret) | 407 | if (ret) |
409 | goto err_sysfs; | 408 | goto err_sysfs; |
410 | 409 | ||
@@ -416,7 +415,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
416 | return 0; | 415 | return 0; |
417 | 416 | ||
418 | err_coupled: | 417 | err_coupled: |
419 | cpuidle_remove_sysfs(cpu_dev); | 418 | cpuidle_remove_sysfs(dev); |
420 | wait_for_completion(&dev->kobj_unregister); | 419 | wait_for_completion(&dev->kobj_unregister); |
421 | err_sysfs: | 420 | err_sysfs: |
422 | list_del(&dev->device_list); | 421 | list_del(&dev->device_list); |
@@ -460,7 +459,6 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device); | |||
460 | */ | 459 | */ |
461 | void cpuidle_unregister_device(struct cpuidle_device *dev) | 460 | void cpuidle_unregister_device(struct cpuidle_device *dev) |
462 | { | 461 | { |
463 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); | ||
464 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); | 462 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); |
465 | 463 | ||
466 | if (dev->registered == 0) | 464 | if (dev->registered == 0) |
@@ -470,7 +468,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev) | |||
470 | 468 | ||
471 | cpuidle_disable_device(dev); | 469 | cpuidle_disable_device(dev); |
472 | 470 | ||
473 | cpuidle_remove_sysfs(cpu_dev); | 471 | cpuidle_remove_sysfs(dev); |
474 | list_del(&dev->device_list); | 472 | list_del(&dev->device_list); |
475 | wait_for_completion(&dev->kobj_unregister); | 473 | wait_for_completion(&dev->kobj_unregister); |
476 | per_cpu(cpuidle_devices, dev->cpu) = NULL; | 474 | per_cpu(cpuidle_devices, dev->cpu) = NULL; |
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h index 76e7f696ad8c..2120d9e937c7 100644 --- a/drivers/cpuidle/cpuidle.h +++ b/drivers/cpuidle/cpuidle.h | |||
@@ -29,8 +29,8 @@ extern int cpuidle_add_interface(struct device *dev); | |||
29 | extern void cpuidle_remove_interface(struct device *dev); | 29 | extern void cpuidle_remove_interface(struct device *dev); |
30 | extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); | 30 | extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); |
31 | extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); | 31 | extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); |
32 | extern int cpuidle_add_sysfs(struct device *dev); | 32 | extern int cpuidle_add_sysfs(struct cpuidle_device *dev); |
33 | extern void cpuidle_remove_sysfs(struct device *dev); | 33 | extern void cpuidle_remove_sysfs(struct cpuidle_device *dev); |
34 | 34 | ||
35 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED | 35 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED |
36 | bool cpuidle_state_is_coupled(struct cpuidle_device *dev, | 36 | bool cpuidle_state_is_coupled(struct cpuidle_device *dev, |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 5f809e337b89..84e62852e50a 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -408,13 +408,11 @@ void cpuidle_remove_state_sysfs(struct cpuidle_device *device) | |||
408 | * cpuidle_add_sysfs - creates a sysfs instance for the target device | 408 | * cpuidle_add_sysfs - creates a sysfs instance for the target device |
409 | * @dev: the target device | 409 | * @dev: the target device |
410 | */ | 410 | */ |
411 | int cpuidle_add_sysfs(struct device *cpu_dev) | 411 | int cpuidle_add_sysfs(struct cpuidle_device *dev) |
412 | { | 412 | { |
413 | int cpu = cpu_dev->id; | 413 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); |
414 | struct cpuidle_device *dev; | ||
415 | int error; | 414 | int error; |
416 | 415 | ||
417 | dev = per_cpu(cpuidle_devices, cpu); | ||
418 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, | 416 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, |
419 | "cpuidle"); | 417 | "cpuidle"); |
420 | if (!error) | 418 | if (!error) |
@@ -426,11 +424,7 @@ int cpuidle_add_sysfs(struct device *cpu_dev) | |||
426 | * cpuidle_remove_sysfs - deletes a sysfs instance on the target device | 424 | * cpuidle_remove_sysfs - deletes a sysfs instance on the target device |
427 | * @dev: the target device | 425 | * @dev: the target device |
428 | */ | 426 | */ |
429 | void cpuidle_remove_sysfs(struct device *cpu_dev) | 427 | void cpuidle_remove_sysfs(struct cpuidle_device *dev) |
430 | { | 428 | { |
431 | int cpu = cpu_dev->id; | ||
432 | struct cpuidle_device *dev; | ||
433 | |||
434 | dev = per_cpu(cpuidle_devices, cpu); | ||
435 | kobject_put(&dev->kobj); | 429 | kobject_put(&dev->kobj); |
436 | } | 430 | } |