From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH v2 4/8] pbl: eeprom: return error from eeprom_read()
Date: Mon, 5 Feb 2024 08:45:49 +0100 [thread overview]
Message-ID: <20240205074553.2005284-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240205074553.2005284-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 | 11 +++++++++--
1 file 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
--
2.39.2
next prev parent reply other threads:[~2024-02-05 7:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-05 7:45 [PATCH v2 0/8] ARM: i.MX93: TQMA93xx: Add LGA variant Sascha Hauer
2024-02-05 7:45 ` [PATCH v2 1/8] i2c: lpi2c: determine clk rate during probe Sascha Hauer
2024-02-05 7:45 ` [PATCH v2 2/8] i2c: lpi2c: use udelay for timeout loops Sascha Hauer
2024-02-05 7:45 ` [PATCH v2 3/8] i2c: lpi2c: add PBL support Sascha Hauer
2024-02-05 7:45 ` Sascha Hauer [this message]
2024-02-05 7:45 ` [PATCH v2 5/8] common: add TQ EEPROM support Sascha Hauer
2024-02-05 8:11 ` Marco Felsch
2024-02-05 8:18 ` Sascha Hauer
2024-02-05 7:45 ` [PATCH v2 6/8] ARM: i.MX9: add i2c base address defines Sascha Hauer
2024-02-05 7:45 ` [PATCH v2 7/8] ARM: i.MX9: rename TQ i.MX93 board to TQMA93XX Sascha Hauer
2024-02-05 7:45 ` [PATCH v2 8/8] ARM: i.MX: tqma93xx: Add LGA board variant Sascha Hauer
2024-02-08 7:19 ` [PATCH v2 0/8] ARM: i.MX93: TQMA93xx: Add LGA 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=20240205074553.2005284-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