diff options
author | Keith Short <keithshort@chromium.org> | 2020-06-25 10:12:33 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-26 02:31:22 +0000 |
commit | f63835743dfc7d01a0c2a3c1cde8480a6237bac7 (patch) | |
tree | 08ce76e0ed5ddd8acc473bbb4a1a180e107476f4 | |
parent | 44923f73697eb73f8ec4084e9ec4b8e3e952dce1 (diff) | |
download | chrome-ec-f63835743dfc7d01a0c2a3c1cde8480a6237bac7.tar.gz |
tcpmv1: string reduction
De-duplicate some output strings to reduce flash sizes.
BUG=none
BRANCH=none
TEST=make buildall -j
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: Ide613f2641cdf7190603c37ab774121a4bd639ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2267680
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 9d95b5b480..12af26a69e 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -16,6 +16,7 @@ #include "gpio.h" #include "hooks.h" #include "host_command.h" +#include "printf.h" #include "registers.h" #include "system.h" #include "task.h" @@ -56,6 +57,11 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) +static int tcpc_prints(const char *string, int port) +{ + return CPRINTS("TCPC p%d %s", port, string); +} + BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT <= EC_USB_PD_MAX_PORTS); /* @@ -85,6 +91,7 @@ static uint8_t pd_comm_enabled[CONFIG_USB_PD_PORT_MAX_COUNT]; #else /* CONFIG_COMMON_RUNTIME */ #define CPRINTF(format, args...) #define CPRINTS(format, args...) +#define tcpc_prints(string, port) static const int debug_level; #endif @@ -454,7 +461,7 @@ static void handle_device_access(int port) pd[port].low_power_time = get_time().val + PD_LPM_DEBOUNCE_US; if (pd[port].flags & PD_FLAGS_LPM_ENGAGED) { - CPRINTS("TCPC p%d Exit Low Power Mode", port); + tcpc_prints("Exit Low Power Mode", port); pd[port].flags &= ~(PD_FLAGS_LPM_ENGAGED | PD_FLAGS_LPM_REQUESTED); /* @@ -491,9 +498,9 @@ static int reset_device_and_notify(int port) pd[port].flags &= ~PD_FLAGS_LPM_TRANSITION; if (rv == EC_SUCCESS) - CPRINTS("TCPC p%d init ready", port); + tcpc_prints("init ready", port); else - CPRINTS("TCPC p%d init failed!", port); + tcpc_prints("init failed!", port); /* * Before getting the other tasks that are waiting, clear the reset @@ -604,9 +611,9 @@ static int reset_device_and_notify(int port) const int rv = tcpm_init(port); if (rv == EC_SUCCESS) - CPRINTS("TCPC p%d init ready", port); + tcpc_prints("init ready", port); else - CPRINTS("TCPC p%d init failed!", port); + tcpc_prints("init failed!", port); return rv; } @@ -3868,7 +3875,7 @@ void pd_task(void *u) #ifndef CONFIG_USB_PD_TCPC int rstatus; #endif - CPRINTS("TCPC p%d suspended!", port); + tcpc_prints("suspended!", port); pd[port].req_suspend_state = 0; #ifdef CONFIG_USB_PD_TCPC pd_rx_disable_monitoring(port); @@ -3881,7 +3888,7 @@ void pd_task(void *u) #endif rstatus = tcpm_release(port); if (rstatus != 0 && rstatus != EC_ERROR_UNIMPLEMENTED) - CPRINTS("TCPC p%d release failed!", port); + tcpc_prints("release failed!", port); #endif /* Drain any outstanding software message queues. */ tcpm_clear_pending_messages(port); @@ -3900,12 +3907,12 @@ void pd_task(void *u) } #ifdef CONFIG_USB_PD_TCPC pd_hw_init(port, PD_ROLE_DEFAULT(port)); - CPRINTS("TCPC p%d resumed!", port); + tcpc_prints("resumed!", port); #else if (rstatus != EC_ERROR_UNIMPLEMENTED && pd_restart_tcpc(port) != 0) { /* stay in PD_STATE_SUSPENDED */ - CPRINTS("TCPC p%d restart failed!", port); + tcpc_prints("restart failed!", port); break; } /* Set the CC termination and state back to default */ @@ -3914,7 +3921,7 @@ void pd_task(void *u) TYPEC_CC_RP : TYPEC_CC_RD); set_state(port, PD_DEFAULT_STATE(port)); - CPRINTS("TCPC p%d resumed!", port); + tcpc_prints("resumed!", port); #endif break; } @@ -4793,7 +4800,7 @@ void pd_task(void *u) pd[port].flags |= PD_FLAGS_LPM_TRANSITION; tcpm_enter_low_power_mode(port); pd[port].flags &= ~PD_FLAGS_LPM_TRANSITION; - CPRINTS("TCPC p%d Enter Low Power Mode", port); + tcpc_prints("Enter Low Power Mode", port); timeout = -1; } else if (timeout < 0 || timeout > time_left) { timeout = time_left; @@ -4965,7 +4972,7 @@ void pd_set_suspend(int port, int suspend) msleep(1); } while (--tries != 0); if (!tries) - CPRINTS("TCPC p%d set_suspend failed!", port); + tcpc_prints("set_suspend failed!", port); } else { pd_control_resume(port); } |