From patchwork Wed Jul 19 19:45:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 9853157 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 1D09A602BD for ; Wed, 19 Jul 2017 19:45:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B883286E2 for ; Wed, 19 Jul 2017 19:45:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F692286C8; Wed, 19 Jul 2017 19:45:54 +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=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 80748286F2 for ; Wed, 19 Jul 2017 19:45:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934161AbdGSTpv (ORCPT ); Wed, 19 Jul 2017 15:45:51 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33925 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934158AbdGSTpt (ORCPT ); Wed, 19 Jul 2017 15:45:49 -0400 Received: by mail-pf0-f179.google.com with SMTP id q85so3761693pfq.1 for ; Wed, 19 Jul 2017 12:45:48 -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=nAtc3Sktya8OSWDQDyAqj9+CKsCno8F152/gi77hfdM=; b=gHIC4NTwGUvZIWEeGLmGYUkqshXHWVRdNzNNGAK/gbZVKX4HgLMV8LC3rumJfppoV1 TZkFa2Jq4pWv56fKud0r1SyZtEFfwU+ptbgEXmNUV/NIiEOmik+M/nCjLg4sSVsb3+ZS DzUJYDG8zBkEBicIPahSGDHIHLwNCYbkYLkX5+SXIVBhTFNQLZq52GAsV5nCPBtjpQXP sGXRwswct4iN5tckvrhBt2UkskCj2eGpbZub6hk6YdgtGvFrtV+Gvv2KszgGWxWSbDbA yPo27v/uCQcUr8ifx/A/RIQURbthwVLfXj6odprzakz/stI+Xa1TPE3z2PRzNwDHc0Hv S/CQ== 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=nAtc3Sktya8OSWDQDyAqj9+CKsCno8F152/gi77hfdM=; b=OOIsXo730dGey9wsbBFcd76iTuX7FcDF9OegvxoUhLqRCjbnMwPdgNLKYKY1MbylZb UFgnR7oyAr6MbKZaByxscTZ0uw3mV3Oct5JQX0Cno45R9OnRCvqD2UZPlCx7p0n2wm3g PfgiMz3fEKSSMA97Xcqt7Al/xaagBms/gt7DixnQmCckoH44aqD2r92Vav7mhj7lVcew km8d6Cr+pePAodx0nHaJRzBevr5XWDt3+RJiSITr4HaDHLbjERYntcw3xTPJzMDh/dSa ydQg4GwKrLdBiMGXE9+TxWodN970LNNiOt9tYqQQzyQo9dvfU31+xRhwmffjHxz0QMwf ZlGA== X-Gm-Message-State: AIVw110SzqVl2YodR81ZNsouPt9Y6JrEWCfcisunxQpBgTnCM8eX39Fw PDvuqOMHFX3XqbwP X-Received: by 10.99.38.69 with SMTP id m66mr1288651pgm.72.1500493548555; Wed, 19 Jul 2017 12:45:48 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id o10sm1037710pgc.81.2017.07.19.12.45.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jul 2017 12:45:48 -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 v2 2/4] time: Print wall time at die and reboot Date: Wed, 19 Jul 2017 12:45:37 -0700 Message-Id: <20170719194541.29031-1-salyzyn@android.com> X-Mailer: git-send-email 2.14.0.rc0.284.gd933b75aa4-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 19a8a0cc94f0..6c7b8ae6be0c 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) @@ -27,3 +29,60 @@ void rtc_show_time(const char *prefix_msg) #endif } 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);