From patchwork Sun Jan 3 20:50:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 356157 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp14472841jai; Sun, 3 Jan 2021 13:08:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJybt3tEw1xUg/MF3yQX0wbukpdl5zBqWZjP/4zJxqi7VdLUzl0vxaJoeqg3Bao+ja+Ns5GI X-Received: by 2002:a25:e443:: with SMTP id b64mr95717847ybh.89.1609708104239; Sun, 03 Jan 2021 13:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609708104; cv=none; d=google.com; s=arc-20160816; b=kCpmLCLZqIkpj88fF5UNgwR/K2d7/BLajiu6dEAkR+pIj6xvU+z9z2HIfNH4EiP3NG dU2+uEmHJ7R6Mv1moi2ZJpnXPPyoTy5fwt4oAZGxNgrg5TlH6dYizc4cxjEXv1XMDdHC Le/B1QhCk6GRAm+sjvDt7N22F3KpV7cEVd0Niw/WpWe/1m4Ol+bkCYT70xn1KD/bjIqY Wxqip/7NrW53qkk0kWptyuxGWUFeYUl9nQkNSqFPGXuUfz4kKeKliBZeyoP/Ok/zBEm1 L7vo6YvhCQZ6OFaoSrgMYGI1ZoWMRAgfkfFK5ihzfJy+S8Vep6GstfygnbCev2ilOe9T DY3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=DdsNLET2BpxdZf8VQjwnKxo9S8h71JuQHMRBO6qs7tI=; b=us0gY6qV6L87eFzVWZGGXZkuDn9MS5RUvwzT3IRWsRvyn0N7lxfwZ3xRGj+Il3nA/u 8f92oFWvGtchBAwvqandm7YOQxBxNZCxAiENpzdwTw+gkDTqOag/m6f2ckCUPmm4IUp1 S4d9ZVNDHxxWLVZL7fhy5Ru7TgNwBX6HjhlUnP4p061zNGbYMMgtE7umKiZ6l/VCPf5V Y4n9rJ7Khm92k9jRnK5LyPFK4VvTHdOSbl1cO99x/pq1gXvjQvPpzLiEnL0IMdmRd3V7 BskE74PwKpXpJEd7zsCV8ZTLLf0pnHATvbVFmcejxwLeit1CZKBH5R8fnPbZ4cnf9qqx RHbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rBSEI6xm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p13si53821156ybl.262.2021.01.03.13.08.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jan 2021 13:08:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rBSEI6xm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Received: from localhost ([::1]:57426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwAbv-0006QF-LG for patch@linaro.org; Sun, 03 Jan 2021 16:08:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwAMC-000449-I7 for qemu-devel@nongnu.org; Sun, 03 Jan 2021 15:52:08 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:42578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwAMA-0006By-Ty for qemu-devel@nongnu.org; Sun, 03 Jan 2021 15:52:08 -0500 Received: by mail-wr1-x429.google.com with SMTP id m5so29428791wrx.9 for ; Sun, 03 Jan 2021 12:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DdsNLET2BpxdZf8VQjwnKxo9S8h71JuQHMRBO6qs7tI=; b=rBSEI6xmzmEpa53fx2l9KF0RZUTeHaXoiSr1fzEnbG+9ZgJe3fOihKUjOjqA9OdJ5j +lAvPncHXgRryST94UdsBHD5f+10TgjJlP0mU+KPwQg8J3w8M+f19sym51AHhU+yla3A ZIad6XT26v5k+dtoqBth2UKRhjBCupZkhikCaTRbD6BV8caBiy9nXDWtQVTrAWqMahr3 WH6YKZV/Puum4R5yo31Ezv7XShU+Lc/HCjMmonhok9SFIef91KzmQ5wF4Sqa1UJEDsf0 BPYi4XxzUa4EpohXLrUhDRBdHnEgZCF3wZkH73Od0xrqKziLUsjrU7Q7E5aqu4oMQv7N ZE4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DdsNLET2BpxdZf8VQjwnKxo9S8h71JuQHMRBO6qs7tI=; b=dfXisdwxDvXC/18Kgltqg4HBN6rXfimtliYqGGNDere9kPBG5FKV1eDYa1d9qdrN+c 6yd8XHiSXYWQP4u2nCnJ6zsmXPfRMN3LDfbm2IB1QwmuTEw9fFWJcHe0yyjyVdh41GEQ M3+NAOJj2Kpv+aca+45HONNHUKFfbNj38XzwW3/nUnmmjxhfad9TVBV5fPdBQbKb+Bpj kOZrCc34+mGIO0S5EZNL3ICSvwZL2o/g0fM08RLJn2zRX9HKL9/ytFeKdT6TD/JmKNAU Pk7nsnQhucg1mD3Sorxmd7MNeR3xKl66o4gM7WnFwiw6xbYhbDNVP2GbjxF834/NuOdp NEdA== X-Gm-Message-State: AOAM531cn9ocLGu7ii6BNwb3hwujKf74UtfkRagTamZ6GpHlI51NojLk O6bTa6S3ryzd0dwxpftbicCm86H3bEE= X-Received: by 2002:a5d:528a:: with SMTP id c10mr69994916wrv.117.1609707125359; Sun, 03 Jan 2021 12:52:05 -0800 (PST) Received: from localhost.localdomain (194.red-83-57-172.dynamicip.rima-tde.net. [83.57.172.194]) by smtp.gmail.com with ESMTPSA id r1sm90035030wrl.95.2021.01.03.12.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jan 2021 12:52:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 21/35] clock: Remove clock_get_ns() Date: Sun, 3 Jan 2021 21:50:07 +0100 Message-Id: <20210103205021.2837760-22-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210103205021.2837760-1-f4bug@amsat.org> References: <20210103205021.2837760-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Luc Michel , Huacai Chen , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 Tested-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20201215150929.30311-4-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- docs/devel/clocks.rst | 17 +++++++++++++---- include/hw/clock.h | 6 ------ 2 files changed, 13 insertions(+), 10 deletions(-) -- 2.26.2 diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst index c2e70e64db1..2d317ff32f2 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 b5fff6ded83..852c636961e 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -40,7 +40,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) @@ -215,11 +214,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