From patchwork Tue Jul 18 17:25:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 9849225 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 7430D60392 for ; Tue, 18 Jul 2017 17:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58753285BD for ; Tue, 18 Jul 2017 17:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D499285CB; Tue, 18 Jul 2017 17:26:07 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 0BBE2285BD for ; Tue, 18 Jul 2017 17:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751835AbdGRRZ4 (ORCPT ); Tue, 18 Jul 2017 13:25:56 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:33606 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751791AbdGRRZy (ORCPT ); Tue, 18 Jul 2017 13:25:54 -0400 Received: by mail-pf0-f177.google.com with SMTP id s70so5446937pfs.0 for ; Tue, 18 Jul 2017 10:25:54 -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=RdK2+nuYus0HMgD4Jh56x18xNKP0lnlpNH7Xjh8k3RQ=; b=Z/cUewIkDHaPNf34BGfPkew3h35Vo+Zv00Zj/gsRbex2Q8HgcjK/Z0LRfo8BhDRqAi wB7pFPcRZHuKDM06Nw2Eco5ODSyGIpJHrefE5/OdiHtOTb//ntCj22oaGwrvkxM89QEh wzAvYdl6d5KuNYY699CvscDCXanOLBsUoArPFSAyD7cQEre5nzgMZZx5nikhnd3FMi2n +AsIUd2Awj5NVy1cXt/rEH+ONP3d+XFU21Jl8ibpHxGzZ2eL9/IU7R0mVL1Z23pY9Vf7 6bconBqW3jCTdDu65O86WQ0yH9QqowYbOygCinFccJ0fsNyuQswxZKNY0eo7s3BvsLyw LwpQ== 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=RdK2+nuYus0HMgD4Jh56x18xNKP0lnlpNH7Xjh8k3RQ=; b=BWaYlRcVAvqmjNTkTo6VYafWXLbyRzbTe4xd0vyJAJ5cPlAoFabJnNAUvQxbaOvF1O uJBuqW3nrt5LO5yfuTzHPNbTx2lrk5yX6NLj0fl6HFvfYV84yl5FdpSxXqiC/+tlJ3QF H74TJRDw2m7ukyk81ChYYYP21BKzLLq8IX8V9kalMbbMwn2hUKgn+YhsJBEBbhkMopLL dN0H9s4WFD62g73WfsVpWVQnT+K7gT6l/HyeHUSNb7qi8kG8M72zB/tJhHnleiosMuIt cQ+bPg8dhWHbNA/yQ/cwam4CMA/L+F5Ujt7GV4o8lHA9wmRgztbBfxhD4V8YVBsRVvya QAJQ== X-Gm-Message-State: AIVw11300lghWo/CSc84Xc41YujxqDLU1e4hEZkF5+CkE8g1Q9Cq8Q8S TNH+V+PG8CSx8/Ux X-Received: by 10.84.136.129 with SMTP id 1mr2954780pll.39.1500398754355; Tue, 18 Jul 2017 10:25:54 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id o6sm5816796pgs.43.2017.07.18.10.25.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 10:25:53 -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 Subject: [PATCH 2/4] rtc-lib: Print wall time at die and reboot Date: Tue, 18 Jul 2017 10:25:43 -0700 Message-Id: <20170718172545.114568-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 --- drivers/rtc/rtc-lib.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 676d6a83e843..c28fdfbb99d4 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c @@ -12,6 +12,8 @@ */ #include +#include +#include #include 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 /*