diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-05 08:45:49 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-08 08:17:00 +0100 |
commit | 2b273ff6e36dacfd2a0ca0d91b5750afb1330cd8 (patch) | |
tree | 8dfa47f11364c453ae95bce830f9fd46286c2260 | |
parent | 8f05c6dbc2879c48b2fb6ba0eca0c5fb66f57f08 (diff) | |
download | barebox-2b273ff6e36d.tar.gz barebox-2b273ff6e36d.tar.xz |
pbl: eeprom: return error from eeprom_read()
Reading from an I2C EEPROM can clearly produce errors, so return
an error code instead of void.
Link: https://lore.barebox.org/20240205074553.2005284-5-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | include/pbl/eeprom.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/pbl/eeprom.h b/include/pbl/eeprom.h index df868b1a37..4d9ef22fc8 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,15 @@ 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 != 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 |