From patchwork Fri Jun 21 20:32:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 167418 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1192805ilk; Fri, 21 Jun 2019 13:35:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxajYkz/4iR9f77bVG5YGHBo2Tru1RqIx9jouXSrPbcL0la2kFPyzo03MSV9Pl/Co7C0krB X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr51483199plo.88.1561149324116; Fri, 21 Jun 2019 13:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561149324; cv=none; d=google.com; s=arc-20160816; b=LVBkH0i0ZcwU2WrEIfsy3bh0sS5oPqYx7rGBDcYSOIh6uANyZ74QNbQt99/NvSTDuV TiVEaEUWoGVgGnxjQiw3vCoU9B9t5roxz9FIukVUyt77cKdnG6yqxqdHPCnFdgZVQ58V Yrq7UFw9npAlVFDzPK9HOkJW4NUMfrPoHgmhOZqONbDUbyZUp9z0d1WYQgzIUUCUJyj9 vjk4JxloQiGiaX431HH/UquqpzUU+j04r5oi7lXhuMQrpgKP4FW+ls4SrOUjN6WzMIhH HJ54V29/cyZWG3/IYP9PI8AACHGihdaHuRq0xbiEjFZF5SrFug+wektvVDB63oqXzg7V Z1nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0AD/HVM3l/KW69wyxqSObKfdIkdLrJ9ESG/V2LC/zxw=; b=y5KMr/DArLhCGdnNX+4xMRL30s6FDlThzanwT1DyN+G0l1E0nqE3yBRLvkacPPy+N9 9I3PRAT/c9XykjypL2cU7E439MtJ0OH4W2nYcZ26POGxJULH7RjVf/Ajb32TKHteI8oo U+qhaY0WdTFB1H5uSnRFI+uQ/HX+Lw7ZQ8+kb6MmaT4aSuR4u+f4/PwkNkNoIXDolrS4 FuOaLzFNxAz3RwuJSUyk8Xcf3j1mmEzpnfIQOuplm0JAIgHlBnKGWt5LF0XVHGfAqhaP 1oB5Pe/IwH2Z9IIkG92GtbYpYqXAvaEHsLM12de5RFAdpu/DVsyri02kIwqvphOK6CDe XCWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=g+3UFVo+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si3215464pgp.232.2019.06.21.13.35.23; Fri, 21 Jun 2019 13:35:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=g+3UFVo+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726257AbfFUUd0 (ORCPT + 30 others); Fri, 21 Jun 2019 16:33:26 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:35689 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbfFUUd0 (ORCPT ); Fri, 21 Jun 2019 16:33:26 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 00c64e1f; Fri, 21 Jun 2019 19:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=Rd7DgGQGCDmIY2IlsuleKmiw/ SU=; b=g+3UFVo+53+frply9pyTAWFq36oo8WGeNYF7aOjJu4hdqRJ8/pgX83zDo drR+42ekWaViposXGO4mQ1CbEqXNt1sXDEGy4E0gba4E51oNsMXENwrY681WCbV9 edSPiuyNgBJIVpYuw5n3N4KegqACsg9fuo7q0dWLANQnUSa4XbSJQcIiPKNize/A /HG49y6kC1MDAA6E3JiKyi+BjD1xcqRC3nILr13KRrwrLR5uuih5EMzlWGbUeBbU 4j5Fnhxs/SIp33q19WtdA0l71s+SttqO0frZh/+f2RHHUWLKwVRof18yPeitDo40 ejnNTKsX+j64Zx6TgVEguP3aXy1QA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 8d461b48 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Fri, 21 Jun 2019 19:59:56 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Arnd Bergmann , Thomas Gleixner Subject: [PATCH v5 3/3] timekeeping: add missing _ns functions for coarse accessors Date: Fri, 21 Jun 2019 22:32:49 +0200 Message-Id: <20190621203249.3909-3-Jason@zx2c4.com> In-Reply-To: <20190621203249.3909-1-Jason@zx2c4.com> References: <20190621203249.3909-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This further unifies the accessors for the fast and coarse functions, so that the same types of functions are available for each. There was also a bit of confusion with the documentation, which prior advertised a function that has never existed. Finally, the vanilla ktime_get_coarse() was omitted from the API originally, so this fills this oversight. Signed-off-by: Jason A. Donenfeld Cc: Arnd Bergmann Cc: Thomas Gleixner --- Documentation/core-api/timekeeping.rst | 10 +++++++--- include/linux/timekeeping.h | 27 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) -- 2.21.0 Reviewed-by: Arnd Bergmann diff --git a/Documentation/core-api/timekeeping.rst b/Documentation/core-api/timekeeping.rst index 4d92b1ac8024..15fc58e85ef9 100644 --- a/Documentation/core-api/timekeeping.rst +++ b/Documentation/core-api/timekeeping.rst @@ -99,16 +99,20 @@ Coarse and fast_ns access Some additional variants exist for more specialized cases: -.. c:function:: ktime_t ktime_get_coarse_boottime( void ) +.. c:function:: ktime_t ktime_get_coarse( void ) + ktime_t ktime_get_coarse_boottime( void ) ktime_t ktime_get_coarse_real( void ) ktime_t ktime_get_coarse_clocktai( void ) - ktime_t ktime_get_coarse_raw( void ) + +.. c:function:: u64 ktime_get_coarse_ns( void ) + u64 ktime_get_coarse_boot_ns( void ) + u64 ktime_get_coarse_real_ns( void ) + u64 ktime_get_coarse_clocktai_ns( void ) .. c:function:: void ktime_get_coarse_ts64( struct timespec64 * ) void ktime_get_coarse_boottime_ts64( struct timespec64 * ) void ktime_get_coarse_real_ts64( struct timespec64 * ) void ktime_get_coarse_clocktai_ts64( struct timespec64 * ) - void ktime_get_coarse_raw_ts64( struct timespec64 * ) These are quicker than the non-coarse versions, but less accurate, corresponding to CLOCK_MONONOTNIC_COARSE and CLOCK_REALTIME_COARSE diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index fd6123722ea8..1435d928fcbf 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -113,6 +113,33 @@ static inline ktime_t ktime_get_coarse_clocktai(void) return ktime_get_coarse_with_offset(TK_OFFS_TAI); } +static inline ktime_t ktime_get_coarse(void) +{ + struct timespec64 ts; + ktime_get_coarse_ts64(&ts); + return timespec64_to_ktime(ts); +} + +static inline u64 ktime_get_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse()); +} + +static inline u64 ktime_get_coarse_real_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_real()); +} + +static inline u64 ktime_get_coarse_boot_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_boottime()); +} + +static inline u64 ktime_get_coarse_clocktai_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_clocktai()); +} + /** * ktime_mono_to_real - Convert monotonic time to clock realtime */