[RAMEN9610-13834] ANDROID: power: wakeup_reason: Added log_wakeup_reason_name.
authorJeonghoon Jang <jnghn.jang@samsung.com>
Mon, 25 Mar 2019 08:14:51 +0000 (17:14 +0900)
committerhskang <hs1218.kang@samsung.com>
Tue, 26 Mar 2019 02:06:53 +0000 (11:06 +0900)
Change-Id: Ia58f79b5c31136d0d1715ffd8489895627b7e71c
Signed-off-by: Jeonghoon Jang <jnghn.jang@samsung.com>
include/linux/wakeup_reason.h
kernel/power/wakeup_reason.c

index d84d8c301546bb14724ad858b209cebde035cd8d..4502671248d4287a5eea0471bad33f5d6b47ce0d 100644 (file)
@@ -29,4 +29,6 @@ void log_suspend_abort_reason(const char *fmt, ...);
 static inline void log_suspend_abort_reason(const char *fmt, ...) { }
 #endif
 
+void log_wakeup_reason_name(const char *name);
+
 #endif /* _LINUX_WAKEUP_REASON_H */
index 252611fad2fee221c0cee0f3dc563bdd88a4fc3a..13f4ee63efdd3be69b90a29895eac79aaf1b8bcb 100644 (file)
@@ -36,6 +36,11 @@ static char abort_reason[MAX_SUSPEND_ABORT_LEN];
 static struct kobject *wakeup_reason;
 static DEFINE_SPINLOCK(resume_reason_lock);
 
+#define MAX_WAKEUP_SRCS 32
+static const char* wakeup_src_list[MAX_WAKEUP_SRCS];
+static int wakeup_src_cnt;
+static bool wakeup_src_by_name;
+
 static ktime_t last_monotime; /* monotonic time before last suspend */
 static ktime_t curr_monotime; /* monotonic time after last suspend */
 static ktime_t last_stime; /* monotonic boottime offset before last suspend */
@@ -60,6 +65,16 @@ static ssize_t last_resume_reason_show(struct kobject *kobj, struct kobj_attribu
                                                irq_list[irq_no]);
                }
        }
+
+       if (!suspend_abort && wakeup_src_by_name) {
+               int i;
+               for (i = 0; i < wakeup_src_cnt; i++) {
+                       /* XXX: 999 is dummy irq number for batterystats*/
+                       buf_offset += sprintf(buf + buf_offset, "999 %s\n",
+                                       wakeup_src_list[i]);
+               }
+       }
+
        spin_unlock(&resume_reason_lock);
        return buf_offset;
 }
@@ -130,6 +145,24 @@ void log_wakeup_reason(int irq)
        spin_unlock(&resume_reason_lock);
 }
 
+void log_wakeup_reason_name(const char *name)
+{
+       printk(KERN_INFO "Resume caused by wakeup source: %s\n", name);
+
+       spin_lock(&resume_reason_lock);
+       if (wakeup_src_cnt == MAX_WAKEUP_SRCS) {
+               spin_unlock(&resume_reason_lock);
+               printk(KERN_WARNING
+                       "Resume caused by more than %d wakeup sources\n",
+                       MAX_WAKEUP_REASON_IRQS);
+               return;
+       }
+
+       wakeup_src_list[wakeup_src_cnt++] = name;
+       wakeup_src_by_name = true;
+       spin_unlock(&resume_reason_lock);
+}
+
 int check_wakeup_reason(int irq)
 {
        int irq_no;
@@ -173,6 +206,8 @@ static int wakeup_reason_pm_event(struct notifier_block *notifier,
                spin_lock(&resume_reason_lock);
                irqcount = 0;
                suspend_abort = false;
+               wakeup_src_cnt = 0;
+               wakeup_src_by_name = false;
                spin_unlock(&resume_reason_lock);
                /* monotonic time since boot */
                last_monotime = ktime_get();