linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 22/25] time/time:Introduce the timespec64_to_jiffies()/jiffies_to_timespec64() function
@ 2015-06-01 12:04 Baolin Wang
  0 siblings, 0 replies; only message in thread
From: Baolin Wang @ 2015-06-01 12:04 UTC (permalink / raw)
  To: tglx; +Cc: arnd, john.stultz, ahh, pjt, linux-kernel, baolin.wang, y2038

To make it is ready for 2038 issue when implementing the conversion
between cputime and timespec64, this patch introduces the
timespec64_to_jiffies() and jiffies_to_timespec64() functions.

And move the old functions timespec64_to_jiffies() and
jiffies_to_timespec64() to jiffies.h file, for it is convenient to
delete them later.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/linux/jiffies.h |   21 ++++++++++++++++++---
 kernel/time/time.c      |   12 ++++++------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index c367cbd..36c0461 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -290,9 +290,24 @@ static inline u64 jiffies_to_nsecs(const unsigned long j)
 
 extern unsigned long msecs_to_jiffies(const unsigned int m);
 extern unsigned long usecs_to_jiffies(const unsigned int u);
-extern unsigned long timespec_to_jiffies(const struct timespec *value);
-extern void jiffies_to_timespec(const unsigned long jiffies,
-				struct timespec *value);
+extern unsigned long __timespec_to_jiffies(unsigned long sec, long nsec);
+extern unsigned long timespec64_to_jiffies(const struct timespec64 *value);
+extern void jiffies_to_timespec64(const unsigned long jiffies,
+				  struct timespec64 *value);
+static inline unsigned long timespec_to_jiffies(const struct timespec *value)
+{
+	return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
+}
+
+static inline void jiffies_to_timespec(const unsigned long jiffies,
+				       struct timespec *value)
+{
+	struct timespec64 ts;
+
+	jiffies_to_timespec64(jiffies, &ts);
+	*value = timespec64_to_timespec(ts);
+}
+
 extern unsigned long timeval_to_jiffies(const struct timeval *value);
 extern void jiffies_to_timeval(const unsigned long jiffies,
 			       struct timeval *value);
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 33c539b..2ffb5e7 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -569,7 +569,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
  * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
  * value to a scaled second value.
  */
-static unsigned long
+unsigned long
 __timespec_to_jiffies(unsigned long sec, long nsec)
 {
 	nsec = nsec + TICK_NSEC - 1;
@@ -583,17 +583,17 @@ __timespec_to_jiffies(unsigned long sec, long nsec)
 		 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
 
 }
+EXPORT_SYMBOL(__timespec_to_jiffies);
 
 unsigned long
-timespec_to_jiffies(const struct timespec *value)
+timespec64_to_jiffies(const struct timespec64 *value)
 {
 	return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
 }
-
-EXPORT_SYMBOL(timespec_to_jiffies);
+EXPORT_SYMBOL(timespec64_to_jiffies);
 
 void
-jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
+jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value)
 {
 	/*
 	 * Convert jiffies to nanoseconds and separate with
@@ -604,7 +604,7 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
 				    NSEC_PER_SEC, &rem);
 	value->tv_nsec = rem;
 }
-EXPORT_SYMBOL(jiffies_to_timespec);
+EXPORT_SYMBOL(jiffies_to_timespec64);
 
 /*
  * We could use a similar algorithm to timespec_to_jiffies (with a
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-01 12:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 12:04 [PATCH v4 22/25] time/time:Introduce the timespec64_to_jiffies()/jiffies_to_timespec64() function Baolin Wang

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).