summaryrefslogtreecommitdiff
path: root/power/common.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-05-19 15:03:27 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-21 20:32:17 +0000
commitffac23c0ea1bd4ff4568f5bd709a98f912b833a7 (patch)
tree362dd0ba205731aa07be97dd35b44b237799b23b /power/common.c
parent478361de694b1fb45abf3c38dafbbf7fd1aa5f71 (diff)
downloadchrome-ec-ffac23c0ea1bd4ff4568f5bd709a98f912b833a7.tar.gz
Add cprints() and ccprints()
Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'power/common.c')
-rw-r--r--power/common.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/power/common.c b/power/common.c
index 1a4a906a88..1dffd64163 100644
--- a/power/common.c
+++ b/power/common.c
@@ -19,7 +19,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/*
* Default timeout in us; if we've been waiting this long for an input
@@ -69,7 +69,7 @@ static void power_update_signals(void)
}
if ((in_signals & in_debug) != (inew & in_debug))
- CPRINTF("[%T power in 0x%04x]\n", inew);
+ CPRINTS("power in 0x%04x", inew);
in_signals = inew;
}
@@ -84,7 +84,7 @@ int power_has_signals(uint32_t want)
if ((in_signals & want) == want)
return 1;
- CPRINTF("[%T power lost input; wanted 0x%04x, got 0x%04x]\n",
+ CPRINTS("power lost input; wanted 0x%04x, got 0x%04x",
want, in_signals & want);
return 0;
@@ -99,8 +99,8 @@ int power_wait_signals(uint32_t want)
while ((in_signals & in_want) != in_want) {
if (task_wait_event(DEFAULT_TIMEOUT) == TASK_EVENT_TIMER) {
power_update_signals();
- CPRINTF("[%T power timeout on input; "
- "wanted 0x%04x, got 0x%04x]\n",
+ CPRINTS("power timeout on input; "
+ "wanted 0x%04x, got 0x%04x",
in_want, in_signals & in_want);
return EC_ERROR_TIMEOUT;
}
@@ -150,7 +150,7 @@ static enum power_state power_common_state(enum power_state state)
* Time's up. Hibernate until wake pin
* asserted.
*/
- CPRINTF("[%T hibernating]\n");
+ CPRINTS("hibernating");
system_hibernate(0, 0);
} else {
uint64_t wait = target_time - time_now;
@@ -262,7 +262,7 @@ void chipset_task(void)
enum power_state new_state;
while (1) {
- CPRINTF("[%T power state %d = %s, in 0x%04x]\n",
+ CPRINTS("power state %d = %s, in 0x%04x",
state, state_names[state], in_signals);
/* Always let the specific chipset handle the state first */
@@ -317,9 +317,9 @@ DECLARE_HOOK(HOOK_LID_CHANGE, power_lid_change, HOOK_PRIO_DEFAULT);
static void power_ac_change(void)
{
if (extpower_is_present()) {
- CPRINTF("[%T AC on]\n");
+ CPRINTS("AC on");
} else {
- CPRINTF("[%T AC off]\n");
+ CPRINTS("AC off");
if (state == POWER_G3) {
last_shutdown_time = get_time().val;
@@ -350,7 +350,7 @@ static int command_powerinfo(int argc, char **argv)
* Print power state in same format as state machine. This is
* used by FAFT tests, so must match exactly.
*/
- ccprintf("[%T power state %d = %s, in 0x%04x]\n",
+ ccprints("power state %d = %s, in 0x%04x",
state, state_names[state], in_signals);
return EC_SUCCESS;