From patchwork Fri Apr 27 13:40:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134621 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp739105lji; Fri, 27 Apr 2018 06:41:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpJtI7UwidHhnPMHM7jpRNSnCe2hwLne9SUQRVBkxUFQ09GuHgVlVmQsJo6dbMamkGYbi/W X-Received: by 2002:a17:902:b209:: with SMTP id t9-v6mr2379209plr.105.1524836488783; Fri, 27 Apr 2018 06:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524836488; cv=none; d=google.com; s=arc-20160816; b=y8E+PIj+Ba1HmDGY+hzDKd1AX9VEQ4tbeCrZtz+NwzY8N6d1jFtRiTd7IJysewLIUk CTv7iAt/Jux2bATUtBzSsXj9LV9x7jEkP2CxXL+5XFllZ7m0enHrqOdAnFUKR9sPegGD ZQ0apv3QCTRbJbJau00l/Apjzw1kGBcZohJZ0tDpBfP9o4gkPcdPsRpI733I37QIrnMG yFAUJfiLr6pu/tOzmjF1hM/IDA3yHVGrcukvTH6FKJJ1Ga2l8e91/VHgJ9qJ8qg5h+De M7QoLARMrR7bCgwIxm4ufrDkoHjq98QhLN6uYIqBhQtt64uFwyPBu7IYr568AoagL+fF cYgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mk5YpSsyBDAkRzi8iew3T0+V7LxKJNs3Xs6uJZMH14k=; b=MapTPJzSKefOrYzaU+Uch2HuCKQ5vKLP2mZuOvD7DKTMTr8QLTid1iEYlXj8Xrhpcr uOQeISsWI8VtZ2pFioWBFGLp4fHPc2a/CEaB+SeGPjYQEWfOoaNyc05YCp8SELm2cR/U PKQmdyJ0vemTwY6Tibh9nDWqCeWaX2qAWrRNI/LM6trWBZewKwCrk46Hr5saLpFlbxcQ KgG2VLhTkZLOJZZfVP2+Xq08cm/nBmfL+KjUPdacCOwUxbLHi3QMmsteam2qClz8ysoq APrNpeRXD0w08hHGfRC01C92/lqY5CU7Hy/w9cHm+jKQDpUDKsvbtrOfv4zqvFegSkzo QL+g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j28si1326852pfe.337.2018.04.27.06.41.28; Fri, 27 Apr 2018 06:41:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932830AbeD0NlZ (ORCPT + 29 others); Fri, 27 Apr 2018 09:41:25 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:50563 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932666AbeD0Nkb (ORCPT ); Fri, 27 Apr 2018 09:40:31 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0MTcE0-1elh2L3sZc-00QWsT; Fri, 27 Apr 2018 15:40:22 +0200 From: Arnd Bergmann To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Stephen Boyd , John Stultz , y2038@lists.linaro.org, Arnd Bergmann Subject: [PATCH 5/5] timekeeping: Add more coarse clocktai/boottime interfaces Date: Fri, 27 Apr 2018 15:40:16 +0200 Message-Id: <20180427134016.2525989-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180427134016.2525989-1-arnd@arndb.de> References: <20180427134016.2525989-1-arnd@arndb.de> X-Provags-ID: V03:K1:uonBy91dvbuMWIj/ldRXQtdvkjZzO/hIlRcXmhW1mUizriMiMPA GFsdZ7d4EMf/2MWspTb99iulTlDts7EAqBQYgEbo7VrDShmyr+jNOJYEuJuJh3AwbRKmOs9 1h46DT+S4NaDauOmh/WnSZclNm43XaM+JD7dpImAIx+vmS4ZBYocfrUhcPTAPBWdGgx5Lm+ mkLppwOtklC6aLNHGK6Mg== X-UI-Out-Filterresults: notjunk:1; V01:K0:EF0DKsAPUBM=:thJXz+QNOYMTDmMuZx3Ge/ NCqH1OMDohWDyJdJvD/gXnn7ELSV6Yg8puy1IchZERkuzsfaWY1mQYCQoZOtiy1LhOmxLcry4 0B9Cgc+IwBpqocePQ1JKtRp3V0id58jBRuSTeK0iR6B7ZHzLDyyfJAJSrbskJwE4boe+/qmEl 5nXeRqS2GBtNXxY9+rieDCunF4Lkz1H9DMD+kqvPIy3A4SOfsaT6g8J/GbxaJ87EA61JUlTpA hg+HWPzW4oa7C2dCy7+d16Dr00ezcvTdTn3hjVD/hBc4n71j9KU3t8bhehgb0JKusdbuPLIzl WOCr5MJTMFNC3CRloou5Ac8MtFy1VDbHpbFKlGf0zzrL8tPsraGXZCHnxPPSse3WdH35gKLzK cauuGqQolCk5hK1axoOv1FumRQ8OYjUDMR7Vip2pm38bFCRlGgNCx8UlsrkpRdT5M+PPMHmBZ gCg+AntKA//2qcZW0qO8E0HpVmWehhetIFxkQIdlnoR2Bn3TyIrEY+MWv4kShrGs/gbWvx2Bv qWMsQPWm1Z93e1yuf2PeE0sXBVn8iO7qpzYobe1hdLcU9TBCT/4kpOAiFBvpiSF2YL3/4D/ew uhvd2146gjNg1FnyICxRVv56GPjUMcooNSaQkfQ8fP4YaKkykTDCCUa7lOSAOIjGRNdmfWc1N G94Pxc4J8DQpROd6LGTcA1QBU4TPicYCjAseeZaQIzcHyYwWJm1oL2KUGFnylciFw4vI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The set of APIs we provide has a few holes for coarse times, e.g. we provide ktime_get_coarse_boottime() and ktime_get_boottime_ts64(), but not the combination of the two. This adds four new functions: ktime_get_coarse_boottime_ts64() ktime_get_boottime_seconds() ktime_get_coarse_clocktai_ts64() ktime_get_clocktai_seconds() to fill in some of the missing pieces. I have missed only the ktime_get_boottime_seconds() accessor in a few occasions in the past, but it seems better to just provide all four together, as there is very little cost to having them. Signed-off-by: Arnd Bergmann --- include/linux/timekeeping.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 42f71f4b658a..86bc2026efce 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -137,18 +137,40 @@ extern u64 ktime_get_boot_fast_ns(void); extern u64 ktime_get_real_fast_ns(void); /* - * timespec64 interfaces utilizing the ktime based ones + * timespec64/time64_t interfaces utilizing the ktime based ones + * for API completeness, these could be implemented more efficiently + * if needed. */ static inline void ktime_get_boottime_ts64(struct timespec64 *ts) { *ts = ktime_to_timespec64(ktime_get_boottime()); } +static inline void ktime_get_coarse_boottime_ts64(struct timespec64 *ts) +{ + *ts = ktime_to_timespec64(ktime_get_coarse_boottime()); +} + +static inline time64_t ktime_get_boottime_seconds(void) +{ + return ktime_divns(ktime_get_coarse_boottime(), NSEC_PER_SEC); +} + static inline void ktime_get_clocktai_ts64(struct timespec64 *ts) { *ts = ktime_to_timespec64(ktime_get_clocktai()); } +static inline void ktime_get_coarse_clocktai_ts64(struct timespec64 *ts) +{ + *ts = ktime_to_timespec64(ktime_get_coarse_clocktai()); +} + +static inline time64_t ktime_get_clocktai_seconds(void) +{ + return ktime_divns(ktime_get_coarse_clocktai(), NSEC_PER_SEC); +} + /* * RTC specific */