diff options
author | Sudeep Holla <Sudeep.Holla@arm.com> | 2016-07-19 13:52:56 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-07-21 17:29:38 -0400 |
commit | 220276e09bd1ccf7563b8092f7bd794336420eb1 (patch) | |
tree | d480d8d2dd714cb6e538e943e64b901bdd0f7f07 | |
parent | ce3ad71026b10f12b46cb88226e547be886b2251 (diff) |
cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32, 64}
The function arm_enter_idle_state is exactly the same in both generic
ARM{32,64} CPUIdle driver and will be the same even on ARM64 backend
for ACPI processor idle driver. So we can unify it and move it to a
common place by introducing CPU_PM_CPU_IDLE_ENTER macro that can be
used in all places avoiding duplication.
This is in preparation of reuse of the generic cpuidle entry function
for ACPI LPI support on ARM64.
Suggested-by: Rafael J. Wysocki <rjw@rjwysocki.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpuidle/cpuidle-arm.c | 26 | ||||
-rw-r--r-- | include/linux/cpuidle.h | 18 |
2 files changed, 24 insertions, 20 deletions
diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index e342565e8715..4ba3d3fe142f 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c | |||
@@ -36,26 +36,12 @@ | |||
36 | static int arm_enter_idle_state(struct cpuidle_device *dev, | 36 | static int arm_enter_idle_state(struct cpuidle_device *dev, |
37 | struct cpuidle_driver *drv, int idx) | 37 | struct cpuidle_driver *drv, int idx) |
38 | { | 38 | { |
39 | int ret; | 39 | /* |
40 | 40 | * Pass idle state index to arm_cpuidle_suspend which in turn | |
41 | if (!idx) { | 41 | * will call the CPU ops suspend protocol with idle index as a |
42 | cpu_do_idle(); | 42 | * parameter. |
43 | return idx; | 43 | */ |
44 | } | 44 | return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx); |
45 | |||
46 | ret = cpu_pm_enter(); | ||
47 | if (!ret) { | ||
48 | /* | ||
49 | * Pass idle state index to cpu_suspend which in turn will | ||
50 | * call the CPU ops suspend protocol with idle index as a | ||
51 | * parameter. | ||
52 | */ | ||
53 | ret = arm_cpuidle_suspend(idx); | ||
54 | |||
55 | cpu_pm_exit(); | ||
56 | } | ||
57 | |||
58 | return ret ? -1 : idx; | ||
59 | } | 45 | } |
60 | 46 | ||
61 | static struct cpuidle_driver arm_idle_driver = { | 47 | static struct cpuidle_driver arm_idle_driver = { |
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 07b83d32f66c..bb31373c3478 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
@@ -252,4 +252,22 @@ static inline int cpuidle_register_governor(struct cpuidle_governor *gov) | |||
252 | #define CPUIDLE_DRIVER_STATE_START 0 | 252 | #define CPUIDLE_DRIVER_STATE_START 0 |
253 | #endif | 253 | #endif |
254 | 254 | ||
255 | #define CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx) \ | ||
256 | ({ \ | ||
257 | int __ret; \ | ||
258 | \ | ||
259 | if (!idx) { \ | ||
260 | cpu_do_idle(); \ | ||
261 | return idx; \ | ||
262 | } \ | ||
263 | \ | ||
264 | __ret = cpu_pm_enter(); \ | ||
265 | if (!__ret) { \ | ||
266 | __ret = low_level_idle_enter(idx); \ | ||
267 | cpu_pm_exit(); \ | ||
268 | } \ | ||
269 | \ | ||
270 | __ret ? -1 : idx; \ | ||
271 | }) | ||
272 | |||
255 | #endif /* _LINUX_CPUIDLE_H */ | 273 | #endif /* _LINUX_CPUIDLE_H */ |