From patchwork Thu Jun 20 14:11:59 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: 167343 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2124756ilk; Thu, 20 Jun 2019 07:12:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlvOhA4Wv9sDZpw16pQloxZJjxxkvf0SKvKq98uGmgMF7fRqrBC9vBCK5TKmvjKzROoXRT X-Received: by 2002:a17:90a:216f:: with SMTP id a102mr3401739pje.29.1561039956044; Thu, 20 Jun 2019 07:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561039956; cv=none; d=google.com; s=arc-20160816; b=KEC9f3OArYY3L/ZKzv8E+YUpjcm0kjNq/ZdWVTsfoFIbVcyZ9kK4FbAROJfqdotWqY hKONOvc3ef6qurFj5vFPvTcWdJgSewHhXSA7NhGScZDT/kj9m9otqivvWC63XDPdEJMj cdNMa2Pye26yaXxP514344d4inbQOZMCD/XFt9mtbIIJlpbZqFsfDZ5188oPKpgu6r0s ClO6J6GQL176PylMXjfZ7hoWL6a3oC1zY2i1eViwzTNnEbc7G6Gn4Ttb60lOYWcP0TAu K1UTGSod0k4wPLe/aWpg1j1Qo184ucUoE8oBqDOIxqrNiXEp5WM666Q13PKVwDQPD1WV JOcA== 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=JDegmG5uFKjJ8c8yxdYHWZtZl88yh+8bzXvRnfmlCro=; b=QCUFOc0OwBL9LTzlYAF7Yaf0FQCnD/ESbRToQC60wDo0tAznPPucy6gaWBCUHU7EvW 8ZdoeepzLHy4RMkmsJqw3u8klTcRZapMdRutROJ0z//U4m71bk7NVvc5aEL7SZyIdd2F hX+dHZ7YnNHnYwBPAfCRfr5gtimaqHdQFgo3eSU46IPHxhHXSjEsKVApJBRd3ysEp/Kw Pn5SaL4qPUG9dZO//COkFI9hxW/JpYH8jEORyDe73kuPIxJWcUNxulV3SyXIxJ4GC/l3 2m836SzOezKRiEt1SBtbn+QdnR0XafSJ1e2tGftXBu6i0HcTNwiLUDS4ACvXAYTUhjcV CSuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=hbhNRQit; 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 t24si5754638pgv.242.2019.06.20.07.12.35; Thu, 20 Jun 2019 07:12:36 -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=hbhNRQit; 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 S1732172AbfFTOMe (ORCPT + 30 others); Thu, 20 Jun 2019 10:12:34 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:46513 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfFTOMb (ORCPT ); Thu, 20 Jun 2019 10:12:31 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id c9fd27a9; Thu, 20 Jun 2019 13:39:13 +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=0Fdw7HaeEiZuqMq3Bs3OcHBPs N0=; b=hbhNRQitEi35VPDhVdSARikBsNjSpCOZKRHHkg/49LlfcVyv8LE14FOzU ChmQ8BRHTOOyigdk/yC8uOBmd0EhyF9a+duR4yMv+c6mA59r1FaZWw1iDJ+9/+Fl KZthbGFb6PC32d4B/AG0ZW4jDN7cEwLNTQ9gL8G/YGFDtavPRsM6JEoUdtSVDL0Q hmKsb/s2VmllMwc3D1t1SCE5YMlHSy2uJCGw5uFJIOViXWGB/Z7KfyiPccJ/mAHh yaHHbZh6JYEyb0QtvjHLPW/V/cUczO8kQzh9Yt0fTea+qYJJc0gO3G7KeX1X/D8c 185/RebJKwBYvfdeXsnyrpkOW+WYQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2e56fd00 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Thu, 20 Jun 2019 13:39:13 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Arnd Bergmann , Thomas Gleixner Subject: [PATCH 3/3] timekeeping: add missing _ns functions for coarse accessors Date: Thu, 20 Jun 2019 16:11:59 +0200 Message-Id: <20190620141159.15965-3-Jason@zx2c4.com> In-Reply-To: <20190620141159.15965-1-Jason@zx2c4.com> References: <20190620141159.15965-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 ad32085174f8..d5e88f0e06a4 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 */