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

From: Viresh Kumar
Date: Fri Apr 04 2014 - 02:42:22 EST


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@xxxxxxxxxx>
---
kernel/hrtimer.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

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.
*/
--
1.7.12.rc2.18.g61b472e

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/