public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
To: john.stultz@linaro.org, Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	JBottomley@parallels.com, linux-scsi@vger.kernel.org
Subject: [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds()
Date: Tue, 14 May 2013 15:45:43 +0800	[thread overview]
Message-ID: <5191EBA7.9010303@cn.fujitsu.com> (raw)

>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


             reply	other threads:[~2013-05-14  7:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14  7:45 Gu Zheng [this message]
2013-05-14 15:57 ` [PATCH 1/2] Kernel/time: Introduce a new timestamp function local_time_seconds() John Stultz
2013-05-15  3:32   ` Gu Zheng
2013-05-15 11:18     ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5191EBA7.9010303@cn.fujitsu.com \
    --to=guz.fnst@cn.fujitsu.com \
    --cc=JBottomley@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox