From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 4/8] pbl: eeprom: return error from eeprom_read()
Date: Fri, 2 Feb 2024 16:31:09 +0100 [thread overview]
Message-ID: <20240202153113.245488-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240202153113.245488-1-s.hauer@pengutronix.de>
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;
+
+ return 0;
}
#endif
--
2.39.2
next prev parent reply other threads:[~2024-02-02 15:31 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 ` Sascha Hauer [this message]
2024-02-02 15:55 ` [PATCH 4/8] pbl: eeprom: return error from eeprom_read() Ahmad Fatoum
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=20240202153113.245488-5-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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