From patchwork Fri Jun 21 15:05:20 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: 167395 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp858845ilk; Fri, 21 Jun 2019 08:05:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2qtYG0y0bNel+o1f891UQy00tbbzPoXzoxqKL9JqX+Uu4PdoPx8E5UHtdNOkDk0nLRK2z X-Received: by 2002:a63:fa4e:: with SMTP id g14mr18924041pgk.237.1561129554734; Fri, 21 Jun 2019 08:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561129554; cv=none; d=google.com; s=arc-20160816; b=JILMOspGMp3cSdcBtTyiKdQJFbIraXg25AWhX+gPvZ6cYPd7kCPGixFOslbxCtLuGK RZbsBDi3oMu4dBnbiVXobKydAm/P8aEb3/lV8XPHmnTAxjdnORZhvjJJfNeXqKvLC5ZA yHUyrUeWh2UOrtX/dtSvs/8gyUfarYoXiuSXyFpH5WMSp8xMo6bHKjsj31XfMSAwJ5OT X6MurggVG8w7u8q5OZHODhSdzmnbqIV37ZoYMr9qF+sAahFnHzWte3UGo8xStvVrchTG ZSI+agOw4GFFkD1as7Z2A9u5IcZ9RPy1RQyfoILisfAPiHb7uwKnFASXmgWIJtQ/iPM8 q7ww== 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=IR+m6MJP1VSpE1GIf5m/GTbhO+09Zr2eGp7rJzk4oR8=; b=jTtd6F98Xia1EaFiBBTqn3uC+QFTITNqydHAQVS8z95rKMrsNvHXy5WnQRqFJVyT8Y VDm2g57wnrZaRt0IA1RxYTaqxgSdLaVro6wHrlHQeBEsbHR6SETfh0OORoVPlrd+Z+XI 3tpthGYS7myHzYVnaMjJkVLbIToA/CUXQ3GBoAtAb1O1AWT8PvueF6WKjcbGhUQbWx2x Hgkf1qY5i1TDvkLUQxh+0OcIqHYEZ8iGwwylIO6C+xlrLooxNyMP3N8Er94b/02HB8NV LDkArg4qqGEcjFlCdklVHuK1ksEHWunYVaZ+gaFeMVRyJ7qaO7vxx4IK2M40zz1mYBd9 B6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=xsjryigW; 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 r129si2660276pgr.307.2019.06.21.08.05.54; Fri, 21 Jun 2019 08:05:54 -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=xsjryigW; 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 S1726434AbfFUPFw (ORCPT + 30 others); Fri, 21 Jun 2019 11:05:52 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:40599 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbfFUPFw (ORCPT ); Fri, 21 Jun 2019 11:05:52 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 651ff04c; Fri, 21 Jun 2019 14:32:25 +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=wgxcqaEpc5Cj5n/ndmwgTvDT9 vE=; b=xsjryigWlVcK7sXgiP7ABxtgCzBywMndAJEObIT0im2mXSZoVUElKWONH Relzk/vH/vyxoq8a43Fn6zMCXaq4X5tpMGh+/uJAKo+k3Ec1aRMOtvZaHGMaxQ2b mXTR+rtwjWjjQlXN7MCmfxY1IHAJgpujOXtSTZjMSeXznVjZXwFNPcBpeYElL6s2 VJSAxUmJfJvwn10BGF3Tv6W9NdhM/lrYcaHeZ+t4Q37IZtmlMTCoWDdntiohZtZw JFStW3qhNpmUSCP9PFk12DjiVXdYhfm+LSXsfkjhYwd9dKYlNMKA4fcjOoqZFftE rKUR3ylQS8MUtfRfvoUQQs9eXfodg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 83a3c10e (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Fri, 21 Jun 2019 14:32:25 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Arnd Bergmann , Thomas Gleixner Subject: [PATCH v3 3/4] timekeeping: add missing _ns functions for coarse accessors Date: Fri, 21 Jun 2019 17:05:20 +0200 Message-Id: <20190621150521.17687-3-Jason@zx2c4.com> In-Reply-To: <20190621150521.17687-1-Jason@zx2c4.com> References: <20190621150521.17687-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 diff --git a/Documentation/core-api/timekeeping.rst b/Documentation/core-api/timekeeping.rst index 47b41e948459..0d4019fcaa87 100644 --- a/Documentation/core-api/timekeeping.rst +++ b/Documentation/core-api/timekeeping.rst @@ -99,16 +99,20 @@ Coarse and fast 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_boot_coarse_ns( void ) + u64 ktime_get_real_coarse_ns( void ) + u64 ktime_get_tai_coarse_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 c5d360779fab..3df8e63c704b 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_real_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_real()); +} + +static inline u64 ktime_get_boot_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_boottime()); +} + +static inline u64 ktime_get_tai_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_clocktai()); +} + /** * ktime_mono_to_real - Convert monotonic time to clock realtime */