* [PATCH] ktime: provide typesafe ktime_to_ns()
@ 2018-07-11 18:16 Eric Dumazet
2018-07-12 19:37 ` [tip:timers/core] ktime: Provide " tip-bot for Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2018-07-11 18:16 UTC (permalink / raw)
To: Thomas Gleixner
Cc: lkml, Eric Dumazet, Willem de Bruijn, Eric Dumazet, John Stultz,
Peter Zijlstra, Linus Torvalds
Using ktime_to_ns() is nice to help backports to stable kernels.
Having a typesafe function instead of a macro avoid stupid typos
and waste of time tracking these typos.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Willem de Bruijn <willemb@google.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
---
include/linux/ktime.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 5b9fddbaac4166b11121f75a3f3b4db7af1aac4c..b2bb44f87f5a3edb6ee6f179c83fcde42a363fe5 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -93,8 +93,11 @@ static inline ktime_t timeval_to_ktime(struct timeval tv)
/* Map the ktime_t to timeval conversion to ns_to_timeval function */
#define ktime_to_timeval(kt) ns_to_timeval((kt))
-/* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
-#define ktime_to_ns(kt) (kt)
+/* Convert ktime_t to nanoseconds */
+static inline s64 ktime_to_ns(const ktime_t kt)
+{
+ return kt;
+}
/**
* ktime_compare - Compares two ktime_t variables for less, greater or equal
--
2.18.0.203.gfac676dfb9-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:timers/core] ktime: Provide typesafe ktime_to_ns()
2018-07-11 18:16 [PATCH] ktime: provide typesafe ktime_to_ns() Eric Dumazet
@ 2018-07-12 19:37 ` tip-bot for Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Eric Dumazet @ 2018-07-12 19:37 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, linux-kernel, peterz, john.stultz, edumazet, willemb,
eric.dumazet, hpa, torvalds, mingo
Commit-ID: a8802d97e73346bc81609df9dfba7d3306f40d87
Gitweb: https://git.kernel.org/tip/a8802d97e73346bc81609df9dfba7d3306f40d87
Author: Eric Dumazet <edumazet@google.com>
AuthorDate: Wed, 11 Jul 2018 11:16:41 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 12 Jul 2018 21:35:28 +0200
ktime: Provide typesafe ktime_to_ns()
Using ktime_to_ns() is nice to help backports to stable kernels.
Having a typesafe function instead of a macro avoid stupid typos
and waste of time tracking these typos.
Reported-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lkml.kernel.org/r/20180711181641.10369-1-edumazet@google.com
---
include/linux/ktime.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 5b9fddbaac41..b2bb44f87f5a 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -93,8 +93,11 @@ static inline ktime_t timeval_to_ktime(struct timeval tv)
/* Map the ktime_t to timeval conversion to ns_to_timeval function */
#define ktime_to_timeval(kt) ns_to_timeval((kt))
-/* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
-#define ktime_to_ns(kt) (kt)
+/* Convert ktime_t to nanoseconds */
+static inline s64 ktime_to_ns(const ktime_t kt)
+{
+ return kt;
+}
/**
* ktime_compare - Compares two ktime_t variables for less, greater or equal
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-12 19:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-11 18:16 [PATCH] ktime: provide typesafe ktime_to_ns() Eric Dumazet
2018-07-12 19:37 ` [tip:timers/core] ktime: Provide " tip-bot for Eric Dumazet
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).