Merge lp:~ycheng-twn/powerd/powerd-better_log into lp:powerd

Proposed by Yuan-Chen Cheng
Status: Superseded
Proposed branch: lp:~ycheng-twn/powerd/powerd-better_log
Merge into: lp:powerd
Diff against target: 215 lines (+37/-4)
11 files modified
debian/changelog (+6/-0)
libsuspend/autosleep.c (+2/-0)
libsuspend/common.h (+1/-0)
libsuspend/earlysuspend.c (+2/-0)
libsuspend/legacy.c (+2/-0)
libsuspend/libsuspend.c (+8/-0)
libsuspend/libsuspend.h (+1/-0)
libsuspend/mocksuspend.c (+3/-0)
src/backlight.c (+6/-1)
src/power-request.c (+5/-3)
src/powerd.cpp (+1/-0)
To merge this branch: bzr merge lp:~ycheng-twn/powerd/powerd-better_log
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+230983@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-18.

Description of the change

Better log for 1. show suspend module used, 2. use libsuspend function name as call it to make debug easier.

Tested on devices and works fine.

To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good, thanks.

Just creating a new bzr branch because you don't need to change debian/changelog, that is done by our CI engine.

review: Approve

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-07-07 21:23:43 +0000
3+++ debian/changelog 2014-08-15 14:06:56 +0000
4@@ -1,3 +1,9 @@
5+powerd (0.16+14.10.20140707-0ubuntu1ppa1) utopic; urgency=medium
6+
7+ * better log for debug.
8+
9+ -- Yuan-Chen Cheng <yc.cheng@canonical.com> Mon, 11 Aug 2014 19:31:18 +0800
10+
11 powerd (0.16+14.10.20140707-0ubuntu1) utopic; urgency=medium
12
13 [ Alfonso Sanchez-Beato (email Canonical) ]
14
15=== modified file 'libsuspend/autosleep.c'
16--- libsuspend/autosleep.c 2013-05-23 14:45:14 +0000
17+++ libsuspend/autosleep.c 2014-08-15 14:06:56 +0000
18@@ -21,6 +21,7 @@
19 #include "common.h"
20 #include "sysfs.h"
21
22+static const char autosleep_name[] = "autosleep";
23 static const char autosleep_path[] = "/sys/power/autosleep";
24 static const char wakelock_path[] = "/sys/power/wake_lock";
25 static const char wakeunlock_path[] = "/sys/power/wake_unlock";
26@@ -52,6 +53,7 @@
27 }
28
29 static const struct suspend_handler autosleep_handler = {
30+ .name = autosleep_name,
31 .enter = autosleep_enter,
32 .exit = autosleep_exit,
33 .acquire_wake_lock = autosleep_acquire_wake_lock,
34
35=== modified file 'libsuspend/common.h'
36--- libsuspend/common.h 2013-05-23 14:45:14 +0000
37+++ libsuspend/common.h 2014-08-15 14:06:56 +0000
38@@ -22,6 +22,7 @@
39 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
40
41 struct suspend_handler {
42+ const char *name;
43 int (*prepare)(void);
44 int (*enter)(void);
45 int (*exit)(void);
46
47=== modified file 'libsuspend/earlysuspend.c'
48--- libsuspend/earlysuspend.c 2014-01-06 16:12:54 +0000
49+++ libsuspend/earlysuspend.c 2014-08-15 14:06:56 +0000
50@@ -46,6 +46,7 @@
51 static pthread_cond_t fb_state_cond = PTHREAD_COND_INITIALIZER;
52 static int wait_for_fb = 0;
53
54+static const char earlysuspend_name[] = "earlysuspend";
55 static const char state_path[] = "/sys/power/state";
56 static const char wakelock_path[] = "/sys/power/wake_lock";
57 static const char wakeunlock_path[] = "/sys/power/wake_unlock";
58@@ -147,6 +148,7 @@
59 }
60
61 static const struct suspend_handler earlysuspend_handler = {
62+ .name = earlysuspend_name,
63 .enter = earlysuspend_enter,
64 .exit = earlysuspend_exit,
65 .acquire_wake_lock = earlysuspend_acquire_wake_lock,
66
67=== modified file 'libsuspend/legacy.c'
68--- libsuspend/legacy.c 2013-05-15 14:14:35 +0000
69+++ libsuspend/legacy.c 2014-08-15 14:06:56 +0000
70@@ -21,6 +21,7 @@
71 #include "common.h"
72 #include "sysfs.h"
73
74+static const char legacy_name[] = "legacy";
75 static const char state_path[] = "/sys/power/state";
76 static const char wakelock_path[] = "/sys/power/wake_lock";
77 static const char wakeup_count_path[] = "/sys/power/wakeup_count";
78@@ -67,6 +68,7 @@
79 }
80
81 static const struct suspend_handler legacy_handler = {
82+ .name = legacy_name,
83 .prepare = legacy_prepare,
84 .enter = legacy_enter,
85 };
86
87=== modified file 'libsuspend/libsuspend.c'
88--- libsuspend/libsuspend.c 2013-05-23 14:45:14 +0000
89+++ libsuspend/libsuspend.c 2014-08-15 14:06:56 +0000
90@@ -44,6 +44,14 @@
91 handler = mocksuspend_detect();
92 }
93
94+const char *libsuspend_getname(void)
95+{
96+ if (!handler)
97+ return "not-initialized yet";
98+
99+ return handler->name;
100+}
101+
102 int libsuspend_prepare_suspend(void)
103 {
104 if (!handler)
105
106=== modified file 'libsuspend/libsuspend.h'
107--- libsuspend/libsuspend.h 2013-05-23 14:45:14 +0000
108+++ libsuspend/libsuspend.h 2014-08-15 14:06:56 +0000
109@@ -24,6 +24,7 @@
110 #endif
111
112 void libsuspend_init(int force_mock);
113+const char *libsuspend_getname(void);
114 int libsuspend_prepare_suspend(void);
115 int libsuspend_enter_suspend(void);
116 int libsuspend_exit_suspend(void);
117
118=== modified file 'libsuspend/mocksuspend.c'
119--- libsuspend/mocksuspend.c 2013-05-23 14:45:14 +0000
120+++ libsuspend/mocksuspend.c 2014-08-15 14:06:56 +0000
121@@ -19,6 +19,8 @@
122 #include <stdio.h>
123 #include "common.h"
124
125+static const char mocksuspend_name[] = "mocksuspend";
126+
127 static int mocksuspend_prepare(void)
128 {
129 printf("mocksuspend prepare\n");
130@@ -50,6 +52,7 @@
131 }
132
133 static const struct suspend_handler mocksuspend_handler = {
134+ .name = mocksuspend_name,
135 .prepare = mocksuspend_prepare,
136 .enter = mocksuspend_enter,
137 .exit = mocksuspend_exit,
138
139=== modified file 'src/backlight.c'
140--- src/backlight.c 2014-05-13 22:05:20 +0000
141+++ src/backlight.c 2014-08-15 14:06:56 +0000
142@@ -90,8 +90,13 @@
143 (scaled_brightness << 8) | scaled_brightness);
144
145 ret = light_dev->set_light(light_dev, &state);
146- if (!ret)
147+ if (!ret) {
148+ powerd_debug("light_dev: set_light to brightness %i succ", brightness);
149 current_brightness = brightness;
150+ } else {
151+ powerd_debug("light_dev: set_light to brightness %i failed", brightness);
152+ }
153+
154 return ret;
155 }
156
157
158=== modified file 'src/power-request.c'
159--- src/power-request.c 2014-05-13 22:05:20 +0000
160+++ src/power-request.c 2014-08-15 14:06:56 +0000
161@@ -120,7 +120,7 @@
162 int ret;
163
164 if (g_atomic_int_add(&suspend_block_count, 1) == 0) {
165- powerd_debug("Blocking suspend");
166+ powerd_debug("libsuspend: acquire_wake_lock: %s", power_request_wakelock_name);
167 ret = libsuspend_acquire_wake_lock(power_request_wakelock_name);
168 if (ret)
169 powerd_warn("Could not acquire wake lock");
170@@ -142,7 +142,7 @@
171 retry = !g_atomic_int_compare_and_exchange(&suspend_block_count,
172 old_count, old_count - 1);
173 if (!retry && old_count == 1) {
174- powerd_debug("Unblocking suspend");
175+ powerd_debug("libsuspend: release_wake_lock: %s", power_request_wakelock_name);
176 ret = libsuspend_release_wake_lock(power_request_wakelock_name);
177 if (ret)
178 powerd_warn("Could not release wake lock");
179@@ -361,6 +361,7 @@
180
181 static int enter_suspend(void)
182 {
183+ powerd_debug("libsuspend: enter_suspend.");
184 int ret = libsuspend_enter_suspend();
185 if (!ret)
186 suspend_active = TRUE;
187@@ -369,6 +370,7 @@
188
189 static int exit_suspend(void)
190 {
191+ powerd_debug("libsuspend: exit_suspend.");
192 int ret = libsuspend_exit_suspend();
193 if (!ret) {
194 suspend_active = FALSE;
195@@ -431,7 +433,7 @@
196
197 /* Must call libsuspend_prepare_suspend() _before_ emitting signal */
198 if (pending_system_state == POWERD_SYS_STATE_SUSPEND) {
199- powerd_debug("preparing for suspend");
200+ powerd_debug("libsuspend: prepare_suspend.");
201 ret = libsuspend_prepare_suspend();
202 if (ret)
203 powerd_warn("Failed to prepare for suspend: %d", ret);
204
205=== modified file 'src/powerd.cpp'
206--- src/powerd.cpp 2014-07-02 16:24:51 +0000
207+++ src/powerd.cpp 2014-08-15 14:06:56 +0000
208@@ -568,6 +568,7 @@
209 device_config_init();
210
211 libsuspend_init(0);
212+ powerd_info("libsuspend: detect module: %s.", libsuspend_getname());
213 powerd_stats_init();
214 powerd_client_init();
215 power_request_init();

Subscribers

People subscribed via source and target branches