[PATCH u-boot, v2019.04-aspeed-openbmc 04/12] misc: i2c_eeprom: verify that the chip is functional at probe()

Tan Siewert tan.siewert at hetzner.com
Fri Jan 17 20:44:23 AEDT 2025


From: Baruch Siach <baruch at tkos.co.il>

Read a single byte from EEPROM to verify that it is actually there.

This is equivalent to Linux kernel commit 00f0ea70d2b8 ("eeprom: at24:
check if the chip is functional in probe()").

Cc: Bartosz Golaszewski <bgolaszewski at baylibre.com>
Signed-off-by: Baruch Siach <baruch at tkos.co.il>

hs: fixed style check prefer kernel type 'u8' over 'uint8_t'
(cherry picked from commit 5ae84860b0428b37063a6d7b03cae26a4e772da7)
Signed-off-by: Tan Siewert <tan.siewert at hetzner.com>
---
 drivers/misc/i2c_eeprom.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index f25d0540075..8f2349ad5a7 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -84,6 +84,14 @@ static int i2c_eeprom_std_ofdata_to_platdata(struct udevice *dev)
 
 static int i2c_eeprom_std_probe(struct udevice *dev)
 {
+	u8 test_byte;
+	int ret;
+
+	/* Verify that the chip is functional */
+	ret = i2c_eeprom_read(dev, 0, &test_byte, 1);
+	if (ret)
+		return -ENODEV;
+
 	return 0;
 }
 
-- 
2.47.0



More information about the openbmc mailing list