Reading from an I2C EEPROM can clearly produce errors, so return an error code instead of void. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- include/pbl/eeprom.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/pbl/eeprom.h b/include/pbl/eeprom.h index df868b1a37..7812402290 100644 --- a/include/pbl/eeprom.h +++ b/include/pbl/eeprom.h @@ -5,7 +5,7 @@ #include <common.h> #include <pbl/i2c.h> -static inline void eeprom_read(struct pbl_i2c *i2c, u16 client_addr, u32 addr, void *buf, u16 count) +static inline int eeprom_read(struct pbl_i2c *i2c, u16 client_addr, u32 addr, void *buf, u16 count) { u8 msgbuf[2]; struct i2c_msg msg[] = { @@ -27,8 +27,13 @@ static inline void eeprom_read(struct pbl_i2c *i2c, u16 client_addr, u32 addr, v msg[0].len = i; ret = pbl_i2c_xfer(i2c, msg, ARRAY_SIZE(msg)); + if (ret < 0) + return ret; + if (ret != ARRAY_SIZE(msg)) - pr_err("Failed to read from eeprom@%x: %d\n", client_addr, ret); + return -EIO; + + return 0; } #endif -- 2.39.2