diff mbox

[OPW,kernel] timekeeping: Added a function to return tv_sec portion of ktime_get_ts64()

Message ID 20141014131249.GA16762@heena-HP-Compaq-8200-Elite-MT-PC
State New, archived
Headers show

Commit Message

Heena Sirwani Oct. 14, 2014, 1:12 p.m. UTC
The following patch adds a function to return tv_sec portion of
ktime_get_ts64() function in order to have a function that returns
seconds as 64-bit integers instead of 32-bit integers to address the
y2038 problem.

Signed-off-by: Heena Sirwani <heenasirwani@gmail.com>
---
 include/linux/timekeeping.h | 1 +
 kernel/time/timekeeping.c   | 7 +++++++
 2 files changed, 8 insertions(+)

Comments

Arnd Bergmann Oct. 14, 2014, 1:18 p.m. UTC | #1
On Tuesday 14 October 2014 18:42:49 Heena Sirwani wrote:
> +time64_t ktime_get_ts64_tvsec(struct timespec64 *ts)
> +{
> +       ktime_get_ts64(ts);
> +       return ts->tv_sec;
> +}
> +EXPORT_SYMBOL_GPL(ktime_get_ts64_tvsec);
> 

This doesn't really need to take an argument, you can simply
declare a local variable to hold the temporary timespec64.

	Arnd
diff mbox

Patch

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 1caa6b0..517be39 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -28,6 +28,7 @@  struct timespec __current_kernel_time(void);
 struct timespec get_monotonic_coarse(void);
 extern void getrawmonotonic(struct timespec *ts);
 extern void ktime_get_ts64(struct timespec64 *ts);
+extern time64_t ktime_get_ts64_tvsec(struct timespec64 *ts);
 
 extern int __getnstimeofday64(struct timespec64 *tv);
 extern void getnstimeofday64(struct timespec64 *tv);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index ec1791f..1e1d23c7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -648,6 +648,13 @@  void ktime_get_ts64(struct timespec64 *ts)
 }
 EXPORT_SYMBOL_GPL(ktime_get_ts64);
 
+time64_t ktime_get_ts64_tvsec(struct timespec64 *ts)
+{
+	ktime_get_ts64(ts);
+	return ts->tv_sec;
+}
+EXPORT_SYMBOL_GPL(ktime_get_ts64_tvsec);
+
 #ifdef CONFIG_NTP_PPS
 
 /**