Skip to contentSkip to conversation

Kernel/time: Introduce a new timestamp function local_time_seconds()

PATCH In review Gu Zheng 3 participants 4 messages May 14, 2013 – May 15, 2013

Subsystems (2)
lore
Share & tools
lore

Gu Zheng

author
#0 lore raw

PATCH 1/2 Kernel/time: Introduce a new timestamp function local_time_seconds()

Quoted 1 line

From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001

From: Gu Zheng <[email protected]>
Date: Mon, 13 May 2013 15:45:24 +0900
Subject: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()

Introduce a new timestamp function local_time_seconds() to hide the conversion of system time in UTC to local time seconds.

---
 include/linux/time.h |    1 +
 kernel/time.c        |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
include/linux/time.h +1 -0
index 22d81b3..1aec534 100644
@@ -271,4 +271,5 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
 	a->tv_nsec = ns;
 }
 
+extern u32 local_time_seconds(void);
 #endif
kernel/time.c +11 -0
index d3617db..715377d 100644
@@ -712,3 +712,14 @@ struct timespec timespec_add_safe(const struct timespec lhs,
 
 	return res;
 }
+
+/*
+ * Convert system time in UTC to local time seconds.
+ */
+u32 local_time_seconds(void)
+{
+	struct timeval utc;
+	do_gettimeofday(&utc);
+	return (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
+}
+EXPORT_SYMBOL(local_time_seconds);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Gu Zheng

From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
From: Gu Zheng <[email protected]>
Date: Mon, 13 May 2013 15:45:24 +0900
Subject: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()

Introduce a new timestamp function local_time_seconds() to hide the conversion of system time in UTC to local time seconds.

So, why is this useful/needed?

thanks
-john

author
#2 lore raw
Quoted 9 lines · John Stultz
Quoted 6 lines · Gu Zheng

From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
From: Gu Zheng <[email protected]>
Date: Mon, 13 May 2013 15:45:24 +0900
Subject: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()

Introduce a new timestamp function local_time_seconds() to hide the conversion of system time in UTC to local time seconds.

So, why is this useful/needed?

Hi John,
There are some subsystems use local time seconds as a timestamp, such as scsi(refer to:http://www.spinics.net/lists/linux-scsi/msg66089.html),
and so do many out-of-kernel-tree code I think.

Best regards,
Gu

Quoted 5 lines

thanks
-john

maintainer
#3 lore raw
Quoted 10 lines · Gu Zheng
Quoted 8 lines · John Stultz
Quoted 6 lines · Gu Zheng

From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
From: Gu Zheng <[email protected]>
Date: Mon, 13 May 2013 15:45:24 +0900
Subject: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()

Introduce a new timestamp function local_time_seconds() to hide the conversion of system time in UTC to local time seconds.

Quoted 7 lines
Quoted 1 line

So, why is this useful/needed?

Hi John,
There are some subsystems use local time seconds as a timestamp,
such as scsi(refer to:http://www.spinics.net/lists/linux-scsi/msg66089.html), and so do many out-of-kernel-tree code I think.

I don't think the 3ware drivers, which are the only ones that do this actually care. I think jiffies to seconds would suit the event timestamps equally well, so I don't really see a need to make this a formal kernel export given that it's only a single driver family in the entirety of the kernel.

James