[PATCH 4/8] pbl: eeprom: return error from eeprom_read()
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Feb 2 07:55:01 PST 2024
Hello Sascha,
On 02.02.24 16:31, Sascha Hauer wrote:
> Reading from an I2C EEPROM can clearly produce errors, so return
> an error code instead of void.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
> 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;
as there is likely nothing useful that can be done this early,
I'd prefer you leave the error message be.
Cheers,
Ahmad
> +
> + return 0;
> }
>
> #endif
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list