diff options
author | Simon Glass <sjg@chromium.org> | 2018-03-08 11:00:39 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-09 07:17:51 -0800 |
commit | 526cc1e4edacf23450380c5e3469576ade196acc (patch) | |
tree | 44076aa2f286c9db92275765ad5d58572f50a59a /chip/npcx | |
parent | 49f76d0c863146cce707e724fa79de629b912a65 (diff) | |
download | chrome-ec-526cc1e4edacf23450380c5e3469576ade196acc.tar.gz |
i2c: npcx: Check that unwedging succeeds
If the I2C port is completely broken then there is no point in trying to
continue with the transaction. This can happen if the pull-ups on the bus
are not working because they are in a power domain which is not currently
enabled.
Check the return value from i2c_unwedge() and return if it doesn't work.
Tidy up a few comments at the same time.
BUG=b:72129419
BRANCH=none
TEST=manually remove the check AP being off in sb_tsi_get_val() and see
that it quickly fails now, rather than hanging the EC for a while trying
the transaction.
Change-Id: I66ab52943459726537dfc74355f8aeaa5817dba5
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/956017
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@google.com>
Diffstat (limited to 'chip/npcx')
-rw-r--r-- | chip/npcx/i2c.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/chip/npcx/i2c.c b/chip/npcx/i2c.c index bccdb3c084..16c85d4439 100644 --- a/chip/npcx/i2c.c +++ b/chip/npcx/i2c.c @@ -652,11 +652,14 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, p_status->oper_state != SMB_WRITE_SUSPEND && (i2c_bus_busy(ctrl) || (i2c_get_line_levels(port) != I2C_LINE_IDLE))) { + int ret; - /* Attempt to unwedge the i2c port. */ - i2c_unwedge(port); + /* Attempt to unwedge the i2c port */ + ret = i2c_unwedge(port); + if (ret) + return ret; p_status->err_code = SMB_BUS_BUSY; - /* recovery i2c controller */ + /* recover i2c controller */ i2c_recovery(ctrl, p_status); /* Select port again for recovery */ i2c_select_port(port); |