Re: [PATCH 4/8] pbl: eeprom: return error from eeprom_read()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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;

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 |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux