* [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()
@ 2013-05-14 7:45 Gu Zheng
2013-05-14 15:57 ` John Stultz
0 siblings, 1 reply; 4+ messages in thread
From: Gu Zheng @ 2013-05-14 7:45 UTC (permalink / raw)
To: john.stultz, Andrew Morton; +Cc: linux-kernel, JBottomley, linux-scsi
>From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
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.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
include/linux/time.h | 1 +
kernel/time.c | 11 +++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/include/linux/time.h b/include/linux/time.h
index 22d81b3..1aec534 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -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
diff --git a/kernel/time.c b/kernel/time.c
index d3617db..715377d 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -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);
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()
2013-05-14 7:45 [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds() Gu Zheng
@ 2013-05-14 15:57 ` John Stultz
2013-05-15 3:32 ` Gu Zheng
0 siblings, 1 reply; 4+ messages in thread
From: John Stultz @ 2013-05-14 15:57 UTC (permalink / raw)
To: Gu Zheng; +Cc: Andrew Morton, linux-kernel, JBottomley, linux-scsi
On 05/14/2013 12:45 AM, Gu Zheng wrote:
> From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()
2013-05-14 15:57 ` John Stultz
@ 2013-05-15 3:32 ` Gu Zheng
2013-05-15 11:18 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Gu Zheng @ 2013-05-15 3:32 UTC (permalink / raw)
To: John Stultz; +Cc: Andrew Morton, linux-kernel, JBottomley, linux-scsi
On 05/14/2013 11:57 PM, John Stultz wrote:
> On 05/14/2013 12:45 AM, Gu Zheng wrote:
>> From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> 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
>
> thanks
> -john
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()
2013-05-15 3:32 ` Gu Zheng
@ 2013-05-15 11:18 ` James Bottomley
0 siblings, 0 replies; 4+ messages in thread
From: James Bottomley @ 2013-05-15 11:18 UTC (permalink / raw)
To: Gu Zheng; +Cc: John Stultz, Andrew Morton, linux-kernel, linux-scsi
On Wed, 2013-05-15 at 11:32 +0800, Gu Zheng wrote:
> On 05/14/2013 11:57 PM, John Stultz wrote:
>
> > On 05/14/2013 12:45 AM, Gu Zheng wrote:
> >> From 18072c1c3506a7e37ee485307a2c343efe5af4d0 Mon Sep 17 00:00:00 2001
> >> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
> >> 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.
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-15 11:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-14 7:45 [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds() Gu Zheng
2013-05-14 15:57 ` John Stultz
2013-05-15 3:32 ` Gu Zheng
2013-05-15 11:18 ` James Bottomley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox