timekeeping: Ignore the bogus sleep time if pm_trace is enabled
[sfrench/cifs-2.6.git] / drivers / rtc / rtc-cmos.c
index dd3d59806ffa02ef955660390533881d9f6cee62..b27a18968a1adf6001bd8b6a4d079f39acafcdda 100644 (file)
@@ -191,6 +191,13 @@ static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
 
 static int cmos_read_time(struct device *dev, struct rtc_time *t)
 {
+       /*
+        * If pm_trace abused the RTC for storage, set the timespec to 0,
+        * which tells the caller that this RTC value is unusable.
+        */
+       if (!pm_trace_rtc_valid())
+               return -EIO;
+
        /* REVISIT:  if the clock has a "century" register, use
         * that instead of the heuristic in mc146818_get_time().
         * That'll make Y3K compatility (year > 2070) easy!