diff mbox series

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

Message ID 20201020182008.2240590-4-f4bug@amsat.org
State New
Headers show
Series hw/clock: Inline and remove CLOCK_PERIOD_TO_HZ/CLOCK_PERIOD_TO_NS macro | expand

Commit Message

Philippe Mathieu-Daudé Oct. 20, 2020, 6:20 p.m. UTC
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 mbox series

Patch

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)