Yu-Ping Wu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59539 )
Change subject: drivers/analogix/anx7625: Fix return code handling ......................................................................
drivers/analogix/anx7625: Fix return code handling
On some platforms (rockchip, mediatek), platform_i2c_transfer() might return a positive error code, and so are i2c_readb() and i2c_writeb(). Currently the analogix driver incorrectly assumes the error code is always negative. Therefore, fix the return code handling in functions anx7625_reg_*(), and return -1 from them.
BUG=b:207055969 TEST=emerge-asurada coreboot BRANCH=none
Change-Id: I955b9aae11e20d75fac414d15714330e364dad2f Signed-off-by: Yu-Ping Wu yupingso@chromium.org --- M src/drivers/analogix/anx7625/anx7625.c 1 file changed, 22 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/59539/1
diff --git a/src/drivers/analogix/anx7625/anx7625.c b/src/drivers/analogix/anx7625/anx7625.c index 11e9ed1..5fbcf20 100644 --- a/src/drivers/analogix/anx7625/anx7625.c +++ b/src/drivers/analogix/anx7625/anx7625.c @@ -54,9 +54,12 @@ }
ret = i2c_writeb(bus, saddr, offset, 0x00); - if (ret < 0) - ANXERROR("Failed to access %#x:%#x\n", saddr, offset); - return ret; + if (ret) { + ANXERROR("Failed to access %#x:%#x, ret=%#x\n", saddr, offset, + ret); + return -1; + } + return 0; }
static int anx7625_reg_read(uint8_t bus, uint8_t saddr, uint8_t offset, @@ -66,9 +69,10 @@
i2c_access_workaround(bus, saddr); ret = i2c_readb(bus, saddr, offset, val); - if (ret < 0) { - ANXERROR("Failed to read i2c reg=%#x:%#x\n", saddr, offset); - return ret; + if (ret) { + ANXERROR("Failed to read i2c reg=%#x:%#x, ret=%#x\n", saddr, + offset, ret); + return -1; } return *val; } @@ -80,10 +84,12 @@
i2c_access_workaround(bus, saddr); ret = i2c_read_bytes(bus, saddr, reg_addr, buf, len); - if (ret < 0) - ANXERROR("Failed to read i2c block=%#x:%#x[len=%#x]\n", saddr, - reg_addr, len); - return ret; + if (ret) { + ANXERROR("Failed to read i2c block=%#x:%#x[len=%#x], ret=%#x\n", + saddr, reg_addr, len, ret); + return -1; + } + return 0; }
static int anx7625_reg_write(uint8_t bus, uint8_t saddr, uint8_t reg_addr, @@ -93,10 +99,13 @@
i2c_access_workaround(bus, saddr); ret = i2c_writeb(bus, saddr, reg_addr, reg_val); - if (ret < 0) - ANXERROR("Failed to write i2c id=%#x:%#x\n", saddr, reg_addr); + if (ret) { + ANXERROR("Failed to write i2c id=%#x:%#x, ret=%#x\n", saddr, + reg_addr, ret); + return -1; + }
- return ret; + return 0; }
static int anx7625_write_or(uint8_t bus, uint8_t saddr, uint8_t offset,