]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/base/power/trace.c
Merge tag 'dlm-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm
[karo-tx-linux.git] / drivers / base / power / trace.c
index a6975795e7f3c7cb9b815a15355ecb466ac3aa65..1cda505d6a852bb9b9e698a9c2788e5def59f30e 100644 (file)
@@ -10,8 +10,9 @@
 #include <linux/pm-trace.h>
 #include <linux/export.h>
 #include <linux/rtc.h>
+#include <linux/suspend.h>
 
-#include <asm/rtc.h>
+#include <linux/mc146818rtc.h>
 
 #include "power.h"
 
@@ -74,6 +75,9 @@
 
 #define DEVSEED (7919)
 
+bool pm_trace_rtc_abused __read_mostly;
+EXPORT_SYMBOL_GPL(pm_trace_rtc_abused);
+
 static unsigned int dev_hash_value;
 
 static int set_magic_time(unsigned int user, unsigned int file, unsigned int device)
@@ -103,7 +107,8 @@ static int set_magic_time(unsigned int user, unsigned int file, unsigned int dev
        n /= 24;
        time.tm_min = (n % 20) * 3;
        n /= 20;
-       set_rtc_time(&time);
+       mc146818_set_time(&time);
+       pm_trace_rtc_abused = true;
        return n ? -1 : 0;
 }
 
@@ -112,7 +117,7 @@ static unsigned int read_magic_time(void)
        struct rtc_time time;
        unsigned int val;
 
-       get_rtc_time(&time);
+       mc146818_get_time(&time);
        pr_info("RTC time: %2d:%02d:%02d, date: %02d/%02d/%02d\n",
                time.tm_hour, time.tm_min, time.tm_sec,
                time.tm_mon + 1, time.tm_mday, time.tm_year % 100);
@@ -239,9 +244,31 @@ int show_trace_dev_match(char *buf, size_t size)
        return ret;
 }
 
+static int
+pm_trace_notify(struct notifier_block *nb, unsigned long mode, void *_unused)
+{
+       switch (mode) {
+       case PM_POST_HIBERNATION:
+       case PM_POST_SUSPEND:
+               if (pm_trace_rtc_abused) {
+                       pm_trace_rtc_abused = false;
+                       pr_warn("Possible incorrect RTC due to pm_trace, please use 'ntpdate' or 'rdate' to reset it.\n");
+               }
+               break;
+       default:
+               break;
+       }
+       return 0;
+}
+
+static struct notifier_block pm_trace_nb = {
+       .notifier_call = pm_trace_notify,
+};
+
 static int early_resume_init(void)
 {
        hash_value_early_read = read_magic_time();
+       register_pm_notifier(&pm_trace_nb);
        return 0;
 }