[PATCH 1/13] hrtimer: add abstraction functions for accessing the "expires" member

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Arjan van de Ven
Date: Monday, September 1, 2008 - 4:05 pm

From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] hrtimer: add abstraction functions for accessing the "expires" member

In order to be able to turn hrtimers into range based, we need to provide
accessor functions for getting to the "expires" ktime_t member of the
struct hrtimer.

This patch adds a set of accessors for this purpose:
* hrtimer_set_expires
* hrtimer_set_expires_tv64
* hrtimer_add_expires
* hrtimer_add_expires_ns
* hrtimer_get_expires
* hrtimer_get_expires_tv64
* hrtimer_get_expires_ns
* hrtimer_expires_remaining
* hrtimer_start_expires

No users of these new accessors are added yet; these follow in later patches.
Hopefully this patch can even go into 2.6.27-rc so that the conversions will
not have a bottleneck in -next

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 include/linux/hrtimer.h |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index becd17d..9900e99 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -217,6 +217,45 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
 	return timer->base->cpu_base->hres_active;
 }
 
+static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
+{
+	timer->expires = time;
+}
+static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
+{
+	timer->expires.tv64 = tv64;
+}
+
+static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
+{
+	timer->expires = ktime_add_safe(timer->expires, time);
+}
+
+static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
+{
+	timer->expires = ktime_add_ns(timer->expires, ns);
+}
+
+static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
+{
+	return timer->expires;
+}
+
+static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
+{
+	return timer->expires.tv64;
+}
+
+static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
+{
+	return ktime_to_ns(timer->expires);
+}
+
+static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
+{
+    return ktime_sub(timer->expires, timer->base->get_time());
+}
+
 /*
  * The resolution of the clocks. The resolution value is returned in
  * the clock_getres() system call to give application programmers an
@@ -287,6 +326,12 @@ extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
 extern int hrtimer_cancel(struct hrtimer *timer);
 extern int hrtimer_try_to_cancel(struct hrtimer *timer);
 
+static inline int hrtimer_start_expires(struct hrtimer *timer,
+						enum hrtimer_mode mode)
+{
+	return hrtimer_start(timer, hrtimer_get_expires(timer), mode);
+}
+
 static inline int hrtimer_restart(struct hrtimer *timer)
 {
 	return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
-- 
1.5.5.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/13] Turn hrtimers into a range capable timer, Arjan van de Ven, (Mon Sep 1, 4:03 pm)
[PATCH 1/13] hrtimer: add abstraction functions for access ..., Arjan van de Ven, (Mon Sep 1, 4:05 pm)
[PATCH 2/13] hrtimer: convert kvm to the new hrtimer apis, Arjan van de Ven, (Mon Sep 1, 4:05 pm)
[PATCH 8/13] hrtimer: convert s390 to the new hrtimer apis, Arjan van de Ven, (Mon Sep 1, 4:10 pm)
[PATCH 9/13] hrtimer: convert sound/ to the new hrtimer apis, Arjan van de Ven, (Mon Sep 1, 4:11 pm)
[PATCH 11/13] hrtimer: turn hrtimers into range timers, Arjan van de Ven, (Mon Sep 1, 4:13 pm)
Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers, Arjan van de Ven, (Tue Sep 2, 6:05 am)
Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers, Arjan van de Ven, (Tue Sep 2, 6:06 am)
Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers, Arjan van de Ven, (Tue Sep 2, 9:02 am)
Re: [PATCH 0/13] Turn hrtimers into a range capable timer, Arjan van de Ven, (Sat Sep 6, 9:30 am)
Re: [PATCH 0/13] Turn hrtimers into a range capable timer, Rusty Russell, (Thu Sep 11, 8:39 pm)
Re: [PATCH 0/13] Turn hrtimers into a range capable timer, Arjan van de Ven, (Thu Sep 11, 10:42 pm)
Re: [PATCH 0/13] Turn hrtimers into a range capable timer, Thomas Gleixner, (Fri Sep 12, 1:24 pm)