[PATCH] hrtimer: add hrtimer_start_now()

From: Olliver Schinagl
Date: Thu Jan 22 2015 - 02:38:56 EST


From: Olliver Schinagl <oliver@xxxxxxxxxxx>

When using a hrtimer for repeating periodic ticks, hrtimer_forward_now()
is often used. Quite possibly the timer loop is thus probably fully
controlled by hrtimer_forward_now() and we don't really care when the
timer is started. With hrtimer_start() we need to define exactly when a
event has to start. By introducing hrtimer_start_now() we do the same as
what hrtimer_forward_now() does, start as soon as possible and get into
the timer loop.

Signed-off-by: Olliver Schinagl <oliver@xxxxxxxxxxx>
---
include/linux/hrtimer.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index a036d05..080a5f5 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -353,6 +353,12 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
/* Basic timer operations: */
extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
const enum hrtimer_mode mode);
+
+static inline int hrtimer_start_now(struct hrtimer *timer,
+ const enum hrtimer_mode mode)
+{
+ return hrtimer_start(timer, timer->base->get_time(), mode);
+}
extern int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
unsigned long range_ns, const enum hrtimer_mode mode);
extern int
--
2.1.4

--
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/