diff mbox

[1/5] target-s390x: add a tod2time function

Message ID 1431985349-11226-2-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno May 18, 2015, 9:42 p.m. UTC
Add a tod2time function similar to the time2tod one, instead of open
coding the conversion.

Cc: Alexander Graf <agraf@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-s390x/cpu.h         | 5 +++++
 target-s390x/misc_helper.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 8135dda..28aa39d 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -970,6 +970,11 @@  static inline uint64_t time2tod(uint64_t ns) {
     return (ns << 9) / 125;
 }
 
+/* Converts s390's clock format to ns */
+static inline uint64_t tod2time(uint64_t t) {
+    return (t * 125) >> 9;
+}
+
 static inline void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
                                   uint64_t param64)
 {
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index e1007fa..230bafd 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -294,7 +294,7 @@  void HELPER(sckc)(CPUS390XState *env, uint64_t time)
     /* difference between now and then */
     time -= clock_value(env);
     /* nanoseconds */
-    time = (time * 125) >> 9;
+    time = tod2time(time);
 
     timer_mod(env->tod_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time);
 }
@@ -314,7 +314,7 @@  void HELPER(spt)(CPUS390XState *env, uint64_t time)
     }
 
     /* nanoseconds */
-    time = (time * 125) >> 9;
+    time = tod2time(time);
 
     timer_mod(env->cpu_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time);
 }