diff options
author | Ting Shen <phoenixshen@google.com> | 2021-02-05 15:49:23 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-05 09:31:10 +0000 |
commit | 06fa2ba85860edf3e811fb002584a38690d79831 (patch) | |
tree | 4f1cc1e2b064f0372638a858e785649a4738e1e7 /common/i2c_bitbang.c | |
parent | 78c6af23aced2bd462056bd90b6885a3bb8318df (diff) | |
download | chrome-ec-06fa2ba85860edf3e811fb002584a38690d79831.tar.gz |
i2c_bitbang: save stack space by removing printf
According to stack analyzer, cprintf takes 232 byte stack size.
Replace cprintf by cputs on critical paths to save space.
After this change, the CHARGER task on juniper takes 200 bytes less
(1048 -> 848).
BUG=b:179451031
TEST=cherry-pick this CL to kukui branch, run `make analyzestack`
BRANCH=kukui
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: Ie23820fd4836877d912d6af583e13d43d990f9ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2677842
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Commit-Queue: Eric Yilun Lin <yllin@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'common/i2c_bitbang.c')
-rw-r--r-- | common/i2c_bitbang.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/common/i2c_bitbang.c b/common/i2c_bitbang.c index 1a2b0414f1..86d76a8b47 100644 --- a/common/i2c_bitbang.c +++ b/common/i2c_bitbang.c @@ -10,7 +10,7 @@ #include "timer.h" #include "util.h" -#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args) +#define CPUTS(str) cputs(CC_I2C, str) static int started; @@ -40,8 +40,7 @@ static void i2c_bitbang_unwedge(const struct i2c_port_t *i2c_port) * If we get here, a peripheral is holding the * clock low and there is nothing we can do. */ - CPRINTS("I2C%d unwedge failed, " - "SCL is held low", i2c_port->port); + CPUTS("I2C unwedge failed, SCL is held low\n"); return; } i2c_delay(); @@ -53,7 +52,7 @@ static void i2c_bitbang_unwedge(const struct i2c_port_t *i2c_port) if (gpio_get_level(i2c_port->sda)) return; - CPRINTS("I2C%d unwedge called with SDA held low", i2c_port->port); + CPUTS("I2C unwedge called with SDA held low\n"); /* Keep trying to unwedge the SDA line until we run out of attempts. */ for (i = 0; i < UNWEDGE_SDA_ATTEMPTS; i++) { @@ -89,9 +88,9 @@ static void i2c_bitbang_unwedge(const struct i2c_port_t *i2c_port) } if (!gpio_get_level(i2c_port->sda)) - CPRINTS("I2C%d unwedge failed, SDA still low", i2c_port->port); + CPUTS("I2C unwedge failed, SDA still low\n"); if (!gpio_get_level(i2c_port->scl)) - CPRINTS("I2C%d unwedge failed, SCL still low", i2c_port->port); + CPUTS("I2C unwedge failed, SCL still low\n"); } static void i2c_stop_cond(const struct i2c_port_t *i2c_port) @@ -150,7 +149,7 @@ static int clock_stretching(const struct i2c_port_t *i2c_port) * the transfer process. */ i2c_stop_cond(i2c_port); - CPRINTS("clock low timeout"); + CPUTS("clock low timeout\n"); return EC_ERROR_TIMEOUT; } @@ -170,7 +169,7 @@ static int i2c_start_cond(const struct i2c_port_t *i2c_port) i2c_delay(); if (gpio_get_level(i2c_port->sda) == 0) { - CPRINTS("%s: arbitration lost", __func__); + CPUTS("start_cond: arbitration lost\n"); started = 0; return EC_ERROR_UNKNOWN; } @@ -204,7 +203,7 @@ static int i2c_write_bit(const struct i2c_port_t *i2c_port, int bit) i2c_delay(); if (bit && gpio_get_level(i2c_port->sda) == 0) { - CPRINTS("%s: arbitration lost", __func__); + CPUTS("write_bit: arbitration lost\n"); started = 0; return EC_ERROR_UNKNOWN; } @@ -289,7 +288,7 @@ static int i2c_bitbang_xfer(const struct i2c_port_t *i2c_port, int i = 0; if (i2c_port->kbps != 100) - CPRINTS("warning: bitbang driver only supports 100kbps"); + CPUTS("warning: bitbang driver only supports 100kbps\n"); if (out_size) { if (flags & I2C_XFER_START) { |