mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] eeprom: at24: verify that chip is accessible during probe
Date: Wed, 18 Feb 2026 13:42:48 +0100	[thread overview]
Message-ID: <20260218124307.2358552-1-m.felsch@pengutronix.de> (raw)

Perform a basic sanity check to verify that the EEPROM is actually
accessible by reading 1-byte. Linux does the same sanity check for all
non-ACPI platforms.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/eeprom/at24.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index 06a2a4b22697..a08d42fe3e14 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -373,6 +373,7 @@ static int at24_probe(struct device *dev)
 	unsigned i, num_addresses;
 	const char *devname;
 	const char *alias;
+	u8 test_byte;
 
 	if (dev->platform_data) {
 		chip = *(struct at24_platform_data *)dev->platform_data;
@@ -487,6 +488,12 @@ static int at24_probe(struct device *dev)
 	at24->nvmem_config.size = chip.byte_len;
 	at24->nvmem_config.id = devid;
 
+	/* Perform a one-byte test read to verify that the chip is functional */
+	if (at24_read(at24, &test_byte, 0, 1) != 1) {
+		err = -ENODEV;
+		goto err_devfs_create;
+	}
+
 	at24->nvmem = nvmem_register(&at24->nvmem_config);
 	err = PTR_ERR_OR_ZERO(at24->nvmem);
 	if (err)
-- 
2.47.3




                 reply	other threads:[~2026-02-18 12:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260218124307.2358552-1-m.felsch@pengutronix.de \
    --to=m.felsch@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