qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] hw/clock: Inline and remove CLOCK_PERIOD_TO_HZ()


From: Philippe Mathieu-Daudé
Subject: [PATCH 3/4] hw/clock: Inline and remove CLOCK_PERIOD_TO_HZ()
Date: Tue, 20 Oct 2020 20:20:07 +0200

This macro is only used once. Inline and remove it.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/clock.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/hw/clock.h b/include/hw/clock.h
index cbc5e6ced1e..b58038f1e7d 100644
--- a/include/hw/clock.h
+++ b/include/hw/clock.h
@@ -40,7 +40,6 @@ typedef void ClockCallback(void *opaque);
 #define CLOCK_PERIOD_FROM_NS(ns) ((ns) * (CLOCK_PERIOD_1SEC / 1000000000llu))
 #define CLOCK_PERIOD_TO_NS(per) ((per) / (CLOCK_PERIOD_1SEC / 1000000000llu))
 #define CLOCK_PERIOD_FROM_HZ(hz) (((hz) != 0) ? CLOCK_PERIOD_1SEC / (hz) : 0u)
-#define CLOCK_PERIOD_TO_HZ(per) (((per) != 0) ? CLOCK_PERIOD_1SEC / (per) : 0u)
 
 /**
  * Clock:
@@ -203,9 +202,12 @@ static inline uint64_t clock_get(const Clock *clk)
     return clk->period;
 }
 
-static inline unsigned clock_get_hz(Clock *clk)
+static inline uint64_t clock_get_hz(Clock *clk)
 {
-    return CLOCK_PERIOD_TO_HZ(clock_get(clk));
+    if (!clk->period) {
+        return 0u;
+    }
+    return CLOCK_PERIOD_1SEC / clk->period;
 }
 
 static inline unsigned clock_get_ns(Clock *clk)
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]