From 1959abd790df7ed6807f786f51224f84c0e0f823 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Fri, 13 Feb 2015 16:39:42 -0600 Subject: =?UTF-8?q?drivers/xpowers/axp209:=20Adapt=20to=20new=20I=C2=B2C?= =?UTF-8?q?=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally, axp209_(read|write) accessors relied on i2c_(read|write) to return the number of bytes transferred. This was changed in * cdb61a6 i2c: Replace the i2c API. to return an error code or 0 on success. This caused the AXP209 check to fail. Fix the accessors to account for this new behavior. Change-Id: Ib0f492bd52260d224d87f8e8f2d3c1244d1507df Signed-off-by: Alexandru Gagniuc Reviewed-on: http://review.coreboot.org/8432 Reviewed-by: Paul Menzel Reviewed-by: Kyösti Mälkki Tested-by: build bot (Jenkins) --- src/drivers/xpowers/axp209/axp209.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/drivers/xpowers') diff --git a/src/drivers/xpowers/axp209/axp209.c b/src/drivers/xpowers/axp209/axp209.c index ae2e3da40e..f36c506a2d 100644 --- a/src/drivers/xpowers/axp209/axp209.c +++ b/src/drivers/xpowers/axp209/axp209.c @@ -43,16 +43,22 @@ enum registers { * is no limitation on the AXP209 as to how many registers we may read or write * in one transaction. * These return the number of bytes read/written, or an error code. In this - * case, they return 1 on success, or an error code otherwise. + * case, they return 1 on success, or an error code otherwise. This is done to + * work with I²C drivers that return either 0 on success or the number of bytes + * actually transferred. */ static int axp209_read(u8 bus, u8 reg, u8 *val) { - return i2c_readb(bus, AXP209_I2C_ADDR, reg, val); + if (i2c_readb(bus, AXP209_I2C_ADDR, reg, val) < 0) + return CB_ERR; + return 1; } static int axp209_write(u8 bus, u8 reg, u8 val) { - return i2c_writeb(bus, AXP209_I2C_ADDR, reg, val); + if (i2c_writeb(bus, AXP209_I2C_ADDR, reg, val) < 0) + return CB_ERR; + return 1; } /** -- cgit v1.2.3