LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, Stephen Boyd <sboyd@kernel.org>,
John Stultz <john.stultz@linaro.org>,
y2038@lists.linaro.org, Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 5/5] timekeeping: Add more coarse clocktai/boottime interfaces
Date: Fri, 27 Apr 2018 15:40:16 +0200 [thread overview]
Message-ID: <20180427134016.2525989-6-arnd@arndb.de> (raw)
In-Reply-To: <20180427134016.2525989-1-arnd@arndb.de>
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 <arnd@arndb.de>
---
include/linux/timekeeping.h | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
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
*/
--
2.9.0
next prev parent reply other threads:[~2018-04-27 13:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-27 13:40 [PATCH 0/5] timekeeping: API cleanup and extensions Arnd Bergmann
2018-04-27 13:40 ` [PATCH 1/5] timekeeping: Remove timespec64 hack Arnd Bergmann
2018-04-27 20:16 ` Arnd Bergmann
2018-05-19 12:00 ` [tip:timers/2038] " tip-bot for Arnd Bergmann
2018-04-27 13:40 ` [PATCH 2/5] timekeeping: Clean up ktime_get_real_ts64 Arnd Bergmann
2018-05-19 12:01 ` [tip:timers/2038] " tip-bot for Arnd Bergmann
2018-04-27 13:40 ` [PATCH 3/5] timekeeping: Standardize on ktime_get_*() naming Arnd Bergmann
2018-05-19 12:01 ` [tip:timers/2038] " tip-bot for Arnd Bergmann
2018-04-27 13:40 ` [PATCH 4/5] timekeeping: Add ktime_get_coarse_with_offset Arnd Bergmann
2018-05-19 12:02 ` [tip:timers/2038] " tip-bot for Arnd Bergmann
2018-04-27 13:40 ` Arnd Bergmann [this message]
2018-05-19 12:02 ` [tip:timers/2038] timekeeping: Add more coarse clocktai/boottime interfaces tip-bot for Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180427134016.2525989-6-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=y2038@lists.linaro.org \
--subject='Re: [PATCH 5/5] timekeeping: Add more coarse clocktai/boottime interfaces' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).