@@ -12,6 +12,8 @@
*/
#include <linux/export.h>
+#include <linux/kdebug.h>
+#include <linux/reboot.h>
#include <linux/rtc.h>
static const unsigned char rtc_days_in_month[] = {
@@ -108,6 +110,62 @@ void rtc_show_time(const char *prefix_msg)
tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
}
EXPORT_SYMBOL(rtc_show_time);
+
+static int rtc_show_time_die_notify(struct notifier_block *self,
+ unsigned long event, void *data)
+{
+ if (event != DIE_OOPS)
+ return NOTIFY_DONE;
+ rtc_show_time("Oops");
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block rtc_show_time_die_nb = {
+ .notifier_call = rtc_show_time_die_notify,
+ .priority = 0,
+};
+
+static int rtc_show_time_reboot_notify(struct notifier_block *self,
+ unsigned long event, void *data)
+{
+ const char *txt;
+
+ switch (event) {
+ case SYS_RESTART:
+ txt = "Restart";
+ break;
+ case SYS_HALT:
+ txt = "Halt";
+ break;
+ case SYS_POWER_OFF:
+ txt = "Power-Off";
+ break;
+ default:
+ return NOTIFY_DONE;
+ }
+ rtc_show_time(txt);
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block rtc_show_time_reboot_nb = {
+ .notifier_call = rtc_show_time_reboot_notify,
+ .priority = 0,
+};
+
+static __init int init_rtc_show_time(void)
+{
+ int ret;
+
+ ret = register_die_notifier(&rtc_show_time_die_nb);
+ if (ret)
+ pr_warn("Failed to register rtc_show_time die notifier\n");
+ ret = register_reboot_notifier(&rtc_show_time_reboot_nb);
+ if (ret)
+ pr_warn("Failed to register rtc_show_time reboot notifier\n");
+
+ return ret;
+}
+device_initcall(init_rtc_show_time);
#endif
/*
Permits power state and battery life diagnosis. Feature activated by CONFIG_RTC_SHOW_TIME. Signed-off-by: Mark Salyzyn <salyzyn@android.com> --- drivers/rtc/rtc-lib.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)