All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Damien Hedde" <damien.hedde@greensocs.com>,
	"Luc Michel" <luc.michel@greensocs.com>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PATCH 3/4] clock: Remove clock_get_ns()
Date: Tue,  8 Dec 2020 18:15:53 +0000	[thread overview]
Message-ID: <20201208181554.435-4-peter.maydell@linaro.org> (raw)
In-Reply-To: <20201208181554.435-1-peter.maydell@linaro.org>

Remove the now-unused clock_get_ns() API and the CLOCK_PERIOD_TO_NS()
macro that only it was using.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 docs/devel/clocks.rst | 17 +++++++++++++----
 include/hw/clock.h    |  6 ------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst
index aebeedbb95e..9a93d1361b4 100644
--- a/docs/devel/clocks.rst
+++ b/docs/devel/clocks.rst
@@ -238,8 +238,17 @@ object during device instance init. For example:
 Fetching clock frequency/period
 -------------------------------
 
-To get the current state of a clock, use the functions ``clock_get()``,
-``clock_get_ns()`` or ``clock_get_hz()``.
+To get the current state of a clock, use the functions ``clock_get()``
+or ``clock_get_hz()``.
+
+``clock_get()`` returns the period of the clock in its fully precise
+internal representation, as an unsigned 64-bit integer in units of
+2^-32 nanoseconds. (For many purposes ``clock_ticks_to_ns()`` will
+be more convenient; see the section below on expiry deadlines.)
+
+``clock_get_hz()`` returns the frequency of the clock, rounded to the
+next lowest integer. This implies some inaccuracy due to the rounding,
+so be cautious about using it in calculations.
 
 It is also possible to register a callback on clock frequency changes.
 Here is an example:
@@ -254,8 +263,8 @@ Here is an example:
          */
 
         /* do something with the new period */
-        fprintf(stdout, "device new period is %" PRIu64 "ns\n",
-                        clock_get_ns(dev->my_clk_input));
+        fprintf(stdout, "device new period is %" PRIu64 "* 2^-32 ns\n",
+                        clock_get(dev->my_clk_input));
     }
 
 Calculating expiry deadlines
diff --git a/include/hw/clock.h b/include/hw/clock.h
index a9425d9fb14..9c0b1eb4c3f 100644
--- a/include/hw/clock.h
+++ b/include/hw/clock.h
@@ -39,7 +39,6 @@ typedef void ClockCallback(void *opaque);
  * macro helpers to convert to hertz / nanosecond
  */
 #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)
 
@@ -214,11 +213,6 @@ static inline unsigned clock_get_hz(Clock *clk)
     return CLOCK_PERIOD_TO_HZ(clock_get(clk));
 }
 
-static inline unsigned clock_get_ns(Clock *clk)
-{
-    return CLOCK_PERIOD_TO_NS(clock_get(clk));
-}
-
 /**
  * clock_ticks_to_ns:
  * @clk: the clock to query
-- 
2.20.1



  parent reply	other threads:[~2020-12-08 18:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 18:15 [PATCH 0/4] clock: Get rid of clock_get_ns() Peter Maydell
2020-12-08 18:15 ` [PATCH 1/4] clock: Introduce clock_ticks_to_ns() Peter Maydell
2020-12-08 23:39   ` Richard Henderson
2020-12-09  8:49     ` Luc Michel
2020-12-09 14:11       ` Richard Henderson
2020-12-09 14:26         ` Peter Maydell
2020-12-09 15:05           ` Richard Henderson
2020-12-10 20:47     ` Peter Maydell
2020-12-11  1:36       ` Richard Henderson
2020-12-08 18:15 ` [PATCH 2/4] target/mips: Don't use clock_get_ns() in clock period calculation Peter Maydell
2020-12-08 23:41   ` Richard Henderson
2020-12-09  8:50   ` Luc Michel
2020-12-08 18:15 ` Peter Maydell [this message]
2020-12-08 23:43   ` [PATCH 3/4] clock: Remove clock_get_ns() Richard Henderson
2020-12-09  8:50   ` Luc Michel
2020-12-08 18:15 ` [PATCH 4/4] clock: Define and use new clock_display_freq() Peter Maydell
2020-12-08 23:50   ` Richard Henderson
2020-12-09  8:50   ` Luc Michel
2020-12-11 13:50 ` [PATCH 0/4] clock: Get rid of clock_get_ns() Philippe Mathieu-Daudé
2020-12-11 14:01   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201208181554.435-4-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=damien.hedde@greensocs.com \
    --cc=f4bug@amsat.org \
    --cc=luc.michel@greensocs.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.