i2c(npcx): Replace cprints by cputs/cprintf

These print-outs are usually very deep in the call stack (rare
error cases that do not happen often), and therefore are the
longest branches on most tasks. Replacing cprints by
cputs/cprintf helps with that.

BRANCH=none
BUG=b:75234824
TEST=make BOARD=soraka SECTION=RW analyzestack | grep Task shrinks
     significantly (more than 100 bytes on some tasks)

Change-Id: I7c5bb750f4aa624cd06736e0bb6b24d307fc0196
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/966041
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Nicolas Boichat
2018-03-16 13:34:22 +08:00
committed by chrome-bot
parent e04111356a
commit c776583aeb
2 changed files with 13 additions and 12 deletions

View File

@@ -155,7 +155,7 @@ static int i2c_wait_stop_completed(int controller, int timeout)
return EC_ERROR_TIMEOUT;
}
void i2c_abort_data(int controller)
static void i2c_abort_data(int controller)
{
/* Clear NEGACK, STASTR and BER bits */
SET_BIT(NPCX_SMBST(controller), NPCX_SMBST_BER);
@@ -165,7 +165,7 @@ void i2c_abort_data(int controller)
/* Wait till STOP condition is generated */
if (i2c_wait_stop_completed(controller, I2C_MAX_TIMEOUT)
!= EC_SUCCESS) {
cprints(CC_I2C, "Abort i2c %02x fail!", controller);
cprintf(CC_I2C, "Abort i2c %02x fail!\n", controller);
/* Clear BB (BUS BUSY) bit */
SET_BIT(NPCX_SMBCST(controller), NPCX_SMBCST_BB);
return;
@@ -175,7 +175,7 @@ void i2c_abort_data(int controller)
SET_BIT(NPCX_SMBCST(controller), NPCX_SMBCST_BB);
}
int i2c_reset(int controller)
static int i2c_reset(int controller)
{
uint16_t timeout = I2C_MAX_TIMEOUT;
/* Disable the SMB module */
@@ -190,7 +190,7 @@ int i2c_reset(int controller)
}
if (timeout == 0) {
cprints(CC_I2C, "Reset i2c %02x fail!", controller);
cprintf(CC_I2C, "Reset i2c %02x fail!\n", controller);
return 0;
}
@@ -199,7 +199,7 @@ int i2c_reset(int controller)
return 1;
}
void i2c_recovery(int controller, volatile struct i2c_status *p_status)
static void i2c_recovery(int controller, volatile struct i2c_status *p_status)
{
CPRINTS("i2c %d recovery! error code is %d, current state is %d",
controller, p_status->err_code, p_status->oper_state);
@@ -258,7 +258,7 @@ enum smb_error i2c_master_transaction(int controller)
/* Need to read the other bytes from next transaction */
p_status->oper_state = SMB_READ_OPER;
} else
cprints(CC_I2C, "Unexpected i2c state machine! %d",
cprintf(CC_I2C, "Unexpected i2c state machine! %d\n",
p_status->oper_state);
/* Generate a START condition */
@@ -298,8 +298,9 @@ enum smb_error i2c_master_transaction(int controller)
/* Wait till STOP condition is generated for normal transaction */
if (p_status->err_code == SMB_OK && i2c_wait_stop_completed(controller,
I2C_MIN_TIMEOUT) != EC_SUCCESS) {
cprints(CC_I2C, "STOP fail! scl %02x is held by slave device!",
controller);
cprintf(CC_I2C,
"STOP fail! scl %02x is held by slave device!\n",
controller);
p_status->err_code = SMB_TIMEOUT_ERROR;
}

View File

@@ -431,7 +431,7 @@ int i2c_unwedge(int port)
* If we get here, a slave is holding the clock
* low and there is nothing we can do.
*/
CPRINTS("I2C unwedge failed, SCL is being held low");
CPUTS("I2C unwedge failed, SCL is being held low");
ret = EC_ERROR_UNKNOWN;
goto unwedge_done;
}
@@ -444,7 +444,7 @@ int i2c_unwedge(int port)
if (i2c_raw_get_sda(port))
goto unwedge_done;
CPRINTS("I2C unwedge called with SDA held low");
CPUTS("I2C unwedge called with SDA held low");
/* Keep trying to unwedge the SDA line until we run out of attempts. */
for (i = 0; i < UNWEDGE_SDA_ATTEMPTS; i++) {
@@ -479,11 +479,11 @@ int i2c_unwedge(int port)
}
if (!i2c_raw_get_sda(port)) {
CPRINTS("I2C unwedge failed, SDA still low");
CPUTS("I2C unwedge failed, SDA still low");
ret = EC_ERROR_UNKNOWN;
}
if (!i2c_raw_get_scl(port)) {
CPRINTS("I2C unwedge failed, SCL still low");
CPUTS("I2C unwedge failed, SCL still low");
ret = EC_ERROR_UNKNOWN;
}