cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32, 64}
authorSudeep Holla <Sudeep.Holla@arm.com>
Tue, 19 Jul 2016 17:52:56 +0000 (18:52 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 Jul 2016 21:29:38 +0000 (23:29 +0200)
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>
drivers/cpuidle/cpuidle-arm.c
include/linux/cpuidle.h

index e342565e8715e95af6c76a80ca393d8fcfada66a..4ba3d3fe142f3ae4dc7039c98b7eeaa4b3aac78d 100644 (file)
 static int arm_enter_idle_state(struct cpuidle_device *dev,
                                struct cpuidle_driver *drv, int idx)
 {
-       int ret;
-
-       if (!idx) {
-               cpu_do_idle();
-               return idx;
-       }
-
-       ret = cpu_pm_enter();
-       if (!ret) {
-               /*
-                * Pass idle state index to cpu_suspend which in turn will
-                * call the CPU ops suspend protocol with idle index as a
-                * parameter.
-                */
-               ret = arm_cpuidle_suspend(idx);
-
-               cpu_pm_exit();
-       }
-
-       return ret ? -1 : idx;
+       /*
+        * Pass idle state index to arm_cpuidle_suspend which in turn
+        * will call the CPU ops suspend protocol with idle index as a
+        * parameter.
+        */
+       return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx);
 }
 
 static struct cpuidle_driver arm_idle_driver = {
index 07b83d32f66c857aeabe1eae476db0c1a9e5fbda..bb31373c3478bdb0ed97dcf8856d1b81ccdc76e3 100644 (file)
@@ -252,4 +252,22 @@ static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
 #define CPUIDLE_DRIVER_STATE_START     0
 #endif
 
+#define CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx)       \
+({                                                             \
+       int __ret;                                              \
+                                                               \
+       if (!idx) {                                             \
+               cpu_do_idle();                                  \
+               return idx;                                     \
+       }                                                       \
+                                                               \
+       __ret = cpu_pm_enter();                                 \
+       if (!__ret) {                                           \
+               __ret = low_level_idle_enter(idx);              \
+               cpu_pm_exit();                                  \
+       }                                                       \
+                                                               \
+       __ret ? -1 : idx;                                       \
+})
+
 #endif /* _LINUX_CPUIDLE_H */