diff mbox

[V2,23/36] hrtimer: create for_each_active_base()

Message ID 170b73764b62e2af7cfcdd2fdea1dd203ab5173a.1396592516.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar April 4, 2014, 6:36 a.m. UTC
There are many places where we need to iterate over all the currently active
clock bases for a particular cpu_base. Create for_each_active_base() to simplify
code at those places.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/hrtimer.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 379d21a..ceadfa5 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -113,6 +113,19 @@  static inline bool base_on_this_cpu(struct hrtimer_clock_base *base)
 }
 
 /*
+ * for_each_active_base: iterate over all active clock bases
+ * @_index: 'int' variable for internal purpose
+ * @_base: holds pointer to a active clock base
+ * @_cpu_base: cpu base to iterate on
+ * @_active_bases: 'unsigned int' variable for internal purpose
+ */
+#define for_each_active_base(_index, _base, _cpu_base, _active_bases)	\
+	for ((_active_bases) = (_cpu_base)->active_bases;		\
+		(_index) = ffs(_active_bases),				\
+		(_base) = (_cpu_base)->clock_base + (_index) - 1, (_index); \
+		(_active_bases) &= ~(1 << ((_index) - 1)))
+
+/*
  * Get the coarse grained time at the softirq based on xtime and
  * wall_to_monotonic.
  */