From patchwork Tue Jul 18 21:21:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 9849561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80AEF602C8 for ; Tue, 18 Jul 2017 21:21:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7594028462 for ; Tue, 18 Jul 2017 21:21:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69EFD285FD; Tue, 18 Jul 2017 21:21:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDD5C28462 for ; Tue, 18 Jul 2017 21:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752102AbdGRVVc (ORCPT ); Tue, 18 Jul 2017 17:21:32 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:34160 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbdGRVVb (ORCPT ); Tue, 18 Jul 2017 17:21:31 -0400 Received: by mail-pf0-f178.google.com with SMTP id q85so17132768pfq.1 for ; Tue, 18 Jul 2017 14:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+DL46wWaGfQ+24tdYOjQIQPomRkrqNVm6V8j3RmDC4Y=; b=Td9H6xNTfhHr0j01fDZdRIP0lDGt+TIZYajnMtFhFcuQ7m3Z3aE9O83ZZ7H73tivg9 8ofTlKN15o2/uOCsA/T4TjioeA6+nkGHdDADPBEInWd9e5DhVTeVTrwowZQWBijrc2v6 7sDaAR9KEz8K+0sQiXkXjN+dttAFa7s6uSV9Ui7xiSrfbNq/7S3DLqcNntJrCKcodf2U iShJ6cBTrcLsxJbXXDGba1A1Nef8VmCKFPZEANkNhMiAGKuu6HhKYFxfXxTlxTpsCe6u 4SiW346d8ZPR0sybyymv+YGP8m5wVsYO4/tMzcgXx4rwf//ZooXTMvc83YuhOmxywSAG VY+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+DL46wWaGfQ+24tdYOjQIQPomRkrqNVm6V8j3RmDC4Y=; b=eCnv0BeLTmbZWuohaoNJ7CKhGgk7NlTHKTyXfO8Kp2er0qqsuxx65uYzrOlNZ7f77W aTCdgf9ijU0kg+Ehgc0XA3dCN2WPsxSFoyMeQSYdiiWjfc/htjZpPh6YVW9Mvtr+N+VZ Sn5XAlVmzcMCNmaajfAusf0HqoLUiDFdxABem+mCPkF6nRD8GAarkRrS1xTNPFbXD6aH iH8DraNkaSNkemrQrubndbigfCkXnZu4UVVbwmDdySByWLM83w1fmje+PejkXKnjhILO hpMy2q/Fge2rnWYpostogZkr4FBymnH/uOkX3o/KJ0JAwfOQODrW1eMxspKpNzW5RifL 3Smw== X-Gm-Message-State: AIVw110aSW5zU5mJMHJqHF3oHxJI8M+QPDZ4eOP7pDN9toXlp6Esuqpj L4n93dh+yE9I01gz X-Received: by 10.98.156.14 with SMTP id f14mr3628947pfe.77.1500412891082; Tue, 18 Jul 2017 14:21:31 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id t70sm5847142pfk.111.2017.07.18.14.21.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 14:21:30 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org, a.zummo@towertech.it, alexandre.belloni@free-electrons.com, linux-rtc@vger.kernel.org, Mark Salyzyn , Mark Salyzyn , Thierry Strudel Subject: [PATCH v2 2/4] time: Print wall time at die and reboot Date: Tue, 18 Jul 2017 14:21:08 -0700 Message-Id: <20170718212117.123296-1-salyzyn@android.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Permits power state and battery life diagnosis. Feature activated by CONFIG_RTC_SHOW_TIME. Signed-off-by: Mark Salyzyn v2: - react to implementation move to kernel timekeeping from rtc_lib - use late_initcall to ensure rtc_lib driver(s) are loaded --- kernel/time/rtc_show_time.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/kernel/time/rtc_show_time.c b/kernel/time/rtc_show_time.c index bbf4f92abf4f..d52e2a76cd00 100644 --- a/kernel/time/rtc_show_time.c +++ b/kernel/time/rtc_show_time.c @@ -6,6 +6,8 @@ * published by the Free Software Foundation. */ +#include +#include #include void rtc_show_time(const char *prefix_msg) @@ -21,3 +23,60 @@ 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; +} +/* rtc driver needs to be loaded before this is truly functional */ +late_initcall(init_rtc_show_time);