aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/time.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-11-01 14:11:03 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-11-05 01:06:21 -0500
commit978d7eb31d44de34a7f71e04ed4158f3f854688d (patch)
treeaed6b90715df7b2f44a69ac948a0af70a4427143 /arch/powerpc/kernel/time.c
parentf1167fb318f0ff0bcb9cbb57bb6d16ad450f0cfb (diff)
powerpc: Avoid giving out RTC dates below EPOCH
Doing so causes xtime to be negative which crashes the timekeeping code in funny ways when doing suspend/resume Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/time.c')
-rw-r--r--arch/powerpc/kernel/time.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 92dc844299b6..a136a11c490d 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -777,7 +777,7 @@ int update_persistent_clock(struct timespec now)
777 return ppc_md.set_rtc_time(&tm); 777 return ppc_md.set_rtc_time(&tm);
778} 778}
779 779
780void read_persistent_clock(struct timespec *ts) 780static void __read_persistent_clock(struct timespec *ts)
781{ 781{
782 struct rtc_time tm; 782 struct rtc_time tm;
783 static int first = 1; 783 static int first = 1;
@@ -800,10 +800,23 @@ void read_persistent_clock(struct timespec *ts)
800 return; 800 return;
801 } 801 }
802 ppc_md.get_rtc_time(&tm); 802 ppc_md.get_rtc_time(&tm);
803
803 ts->tv_sec = mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, 804 ts->tv_sec = mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
804 tm.tm_hour, tm.tm_min, tm.tm_sec); 805 tm.tm_hour, tm.tm_min, tm.tm_sec);
805} 806}
806 807
808void read_persistent_clock(struct timespec *ts)
809{
810 __read_persistent_clock(ts);
811
812 /* Sanitize it in case real time clock is set below EPOCH */
813 if (ts->tv_sec < 0) {
814 ts->tv_sec = 0;
815 ts->tv_nsec = 0;
816 }
817
818}
819
807/* clocksource code */ 820/* clocksource code */
808static cycle_t rtc_read(struct clocksource *cs) 821static cycle_t rtc_read(struct clocksource *cs)
809{ 822{