diff mbox

[Xen-devel,27/34] xen/arm: time: move ticks_to_ns and ns_to_ticks in asm/time.h

Message ID 1395766541-23979-28-git-send-email-julien.grall@linaro.org
State Deferred, archived
Headers show

Commit Message

Julien Grall March 25, 2014, 4:55 p.m. UTC
Both ticks_to_ns and ns_to_ticks are wrapper to a division. Move it into
asm/time.h to let the compiler inlines them.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@citrix.com>
Cc: Tim Deegan <tim@xen.org>
---
 xen/arch/arm/time.c        |   10 ----------
 xen/arch/arm/vtimer.c      |    3 ---
 xen/include/asm-arm/time.h |   13 +++++++++++++
 3 files changed, 13 insertions(+), 13 deletions(-)

Comments

Ian Campbell March 27, 2014, 5:11 p.m. UTC | #1
On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote:
> Both ticks_to_ns and ns_to_ticks are wrapper to a division. Move it into
> asm/time.h to let the compiler inlines them.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
diff mbox

Patch

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 8dd4bea..7f4f2b4 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -57,16 +57,6 @@  const struct dt_irq *timer_dt_irq(enum timer_ppi ppi)
     return &timer_irq[ppi];
 }
 
-/*static inline*/ s_time_t ticks_to_ns(uint64_t ticks)
-{
-    return muldiv64(ticks, SECONDS(1), 1000 * cpu_khz);
-}
-
-/*static inline*/ uint64_t ns_to_ticks(s_time_t ns)
-{
-    return muldiv64(ns, 1000 * cpu_khz, SECONDS(1));
-}
-
 /* TODO: On a real system the firmware would have set the frequency in
    the CNTFRQ register.  Also we'd need to use devicetree to find
    the RTC.  When we've seen some real systems, we can delete this.
diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
index 3d6a721..83f4c0f 100644
--- a/xen/arch/arm/vtimer.c
+++ b/xen/arch/arm/vtimer.c
@@ -26,9 +26,6 @@ 
 #include <asm/gic.h>
 #include <asm/regs.h>
 
-extern s_time_t ticks_to_ns(uint64_t ticks);
-extern uint64_t ns_to_ticks(s_time_t ns);
-
 static void phys_timer_expired(void *data)
 {
     struct vtimer *t = data;
diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h
index d10c737..31dab85 100644
--- a/xen/include/asm-arm/time.h
+++ b/xen/include/asm-arm/time.h
@@ -5,6 +5,8 @@ 
     DT_MATCH_COMPATIBLE("arm,armv7-timer"), \
     DT_MATCH_COMPATIBLE("arm,armv8-timer")
 
+#include <xen/lib.h>
+
 typedef unsigned long cycles_t;
 
 static inline cycles_t get_cycles (void)
@@ -34,6 +36,17 @@  extern void __cpuinit init_timer_interrupt(void);
 /* Counter value at boot time */
 extern uint64_t boot_count;
 
+/* Helpers to convert ticks <=> ns */
+static inline s_time_t ticks_to_ns(uint64_t ticks)
+{
+    return muldiv64(ticks, SECONDS(1), 1000 * cpu_khz);
+}
+
+static inline uint64_t ns_to_ticks(s_time_t ns)
+{
+    return muldiv64(ns, 1000 * cpu_khz, SECONDS(1));
+}
+
 #endif /* __ARM_TIME_H__ */
 /*
  * Local variables: