mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/8] pbl: eeprom: return error from eeprom_read()
Date: Fri, 2 Feb 2024 16:55:01 +0100	[thread overview]
Message-ID: <a0a28cdb-bba0-411d-b102-a67ba57e31d4@pengutronix.de> (raw)
In-Reply-To: <20240202153113.245488-5-s.hauer@pengutronix.de>

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




  reply	other threads:[~2024-02-02 15:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 15:31 [PATCH 0/8] ARM: i.MX93: TQMA93xx: Add LGA variant Sascha Hauer
2024-02-02 15:31 ` [PATCH 1/8] i2c: lpi2c: determine clk rate during probe Sascha Hauer
2024-02-02 15:31 ` [PATCH 2/8] i2c: lpi2c: use udelay for timeout loops Sascha Hauer
2024-02-02 15:31 ` [PATCH 3/8] i2c: lpi2c: add PBL support Sascha Hauer
2024-02-02 15:31 ` [PATCH 4/8] pbl: eeprom: return error from eeprom_read() Sascha Hauer
2024-02-02 15:55   ` Ahmad Fatoum [this message]
2024-02-02 15:31 ` [PATCH 5/8] common: add TQ EEPROM support Sascha Hauer
2024-02-02 15:56   ` Ahmad Fatoum
2024-02-02 15:31 ` [PATCH 6/8] ARM: i.MX9: add i2c base address defines Sascha Hauer
2024-02-02 15:31 ` [PATCH 7/8] ARM: i.MX9: rename TQ i.MX93 board to TQMA93XX Sascha Hauer
2024-02-02 15:31 ` [PATCH 8/8] ARM: i.MX: tqma93xx: Add LGA board variant Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0a28cdb-bba0-411d-b102-a67ba57e31d4@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox