From 12017041d62e735ffe840a2e4e2cef4353de322a Mon Sep 17 00:00:00 2001 From: Ling Jin Date: Wed, 13 Mar 2019 16:33:46 -0500 Subject: [PATCH] qpnp-power-on: Print system timestamp on Power key event Print system timestamp on Power key press and release events. This would make debugging easy Ported from: https://gerrit.mot.com/#/c/1320467/ Change-Id: I2c810e4b59c2d3bd8a705d407a339d9efe6fad3d Reviewed-on: https://gerrit.mot.com/1320467 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Ryan Lattrel Reviewed-by: Ling Jin Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1456668 Reviewed-on: https://gerrit.mot.com/1771193 Reviewed-by: Huosheng Liao --- drivers/input/misc/qpnp-power-on.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/input/misc/qpnp-power-on.c b/drivers/input/misc/qpnp-power-on.c index 64123c678fb2..1a990b2a145a 100644 --- a/drivers/input/misc/qpnp-power-on.c +++ b/drivers/input/misc/qpnp-power-on.c @@ -26,6 +26,7 @@ #include #include #include +#include #define PMIC_VER_8941 0x01 #define PMIC_VERSION_REG 0x0105 @@ -986,6 +987,10 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type) uint pon_rt_sts; u64 elapsed_us; int rc; + struct timespec64 now; + struct timeval timestamp; + struct tm tm; + char buff[255]; cfg = qpnp_get_cfg(pon, pon_type); if (!cfg) @@ -1014,6 +1019,19 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type) pon_rt_bit = is_pon_gen3(pon) ? QPNP_PON_GEN3_KPDPWR_N_SET : QPNP_PON_KPDPWR_N_SET; + + /* get the time stamp in readable format to print*/ + ktime_get_real_ts64(&now); + timestamp.tv_sec = now.tv_sec; + timestamp.tv_usec = now.tv_nsec/1000; + time64_to_tm((time64_t)(timestamp.tv_sec), 0, &tm); + snprintf(buff, sizeof(buff), + "%u-%02d-%02d %02d:%02d:%02d UTC", + (int) tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + + pr_info("Report pwrkey %s event at: %s\n", pon_rt_bit & + pon_rt_sts ? "press" : "release", buff); break; case PON_RESIN: pon_rt_bit = is_pon_gen3(pon)