* [PATCH] eeprom: at24: verify that chip is accessible during probe
@ 2026-02-18 12:42 Marco Felsch
2026-02-23 9:15 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Marco Felsch @ 2026-02-18 12:42 UTC (permalink / raw)
To: barebox
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eeprom: at24: verify that chip is accessible during probe
2026-02-18 12:42 [PATCH] eeprom: at24: verify that chip is accessible during probe Marco Felsch
@ 2026-02-23 9:15 ` Sascha Hauer
2026-02-23 9:56 ` Marco Felsch
0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2026-02-23 9:15 UTC (permalink / raw)
To: Marco Felsch; +Cc: barebox
On Wed, Feb 18, 2026 at 01:42:48PM +0100, Marco Felsch wrote:
> 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;
a return of -ENODEV from driver probe doesn't print an error. Is that
what we want here?
Sascha
> + goto err_devfs_create;
> + }
> +
> at24->nvmem = nvmem_register(&at24->nvmem_config);
> err = PTR_ERR_OR_ZERO(at24->nvmem);
> if (err)
> --
> 2.47.3
>
>
>
--
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eeprom: at24: verify that chip is accessible during probe
2026-02-23 9:15 ` Sascha Hauer
@ 2026-02-23 9:56 ` Marco Felsch
2026-02-23 11:16 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Marco Felsch @ 2026-02-23 9:56 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 26-02-23, Sascha Hauer wrote:
> On Wed, Feb 18, 2026 at 01:42:48PM +0100, Marco Felsch wrote:
> > 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;
>
> a return of -ENODEV from driver probe doesn't print an error. Is that
> what we want here?
That's a good point, quickly checked the Linux implementation which
doesn't print an error too. However, you're right and we should print a
dev_err() or so here. Is this something you may add while applying or
shall I send a new v2?
Regards,
Marco
>
> Sascha
>
> > + goto err_devfs_create;
> > + }
> > +
> > at24->nvmem = nvmem_register(&at24->nvmem_config);
> > err = PTR_ERR_OR_ZERO(at24->nvmem);
> > if (err)
> > --
> > 2.47.3
> >
> >
> >
>
> --
> 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 |
>
--
#gernperDu
#CallMeByMyFirstName
Pengutronix e.K. | |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eeprom: at24: verify that chip is accessible during probe
2026-02-23 9:56 ` Marco Felsch
@ 2026-02-23 11:16 ` Sascha Hauer
2026-02-23 11:22 ` Marco Felsch
0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2026-02-23 11:16 UTC (permalink / raw)
To: Marco Felsch; +Cc: barebox
On Mon, Feb 23, 2026 at 10:56:24AM +0100, Marco Felsch wrote:
> On 26-02-23, Sascha Hauer wrote:
> > On Wed, Feb 18, 2026 at 01:42:48PM +0100, Marco Felsch wrote:
> > > 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;
> >
> > a return of -ENODEV from driver probe doesn't print an error. Is that
> > what we want here?
>
> That's a good point, quickly checked the Linux implementation which
> doesn't print an error too. However, you're right and we should print a
> dev_err() or so here. Is this something you may add while applying or
> shall I send a new v2?
I can fix it up, but I wanted to push the thinking about the correct
error code to you ;)
How about returning the return value of at24_read()?
Sascha
--
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eeprom: at24: verify that chip is accessible during probe
2026-02-23 11:16 ` Sascha Hauer
@ 2026-02-23 11:22 ` Marco Felsch
0 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2026-02-23 11:22 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 26-02-23, Sascha Hauer wrote:
> On Mon, Feb 23, 2026 at 10:56:24AM +0100, Marco Felsch wrote:
> > On 26-02-23, Sascha Hauer wrote:
> > > On Wed, Feb 18, 2026 at 01:42:48PM +0100, Marco Felsch wrote:
> > > > 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;
> > >
> > > a return of -ENODEV from driver probe doesn't print an error. Is that
> > > what we want here?
> >
> > That's a good point, quickly checked the Linux implementation which
> > doesn't print an error too. However, you're right and we should print a
> > dev_err() or so here. Is this something you may add while applying or
> > shall I send a new v2?
>
> I can fix it up, but I wanted to push the thinking about the correct
> error code to you ;)
>
> How about returning the return value of at24_read()?
Ah now I got you :) Yeah we could do that to not cast the error provided
by at24_read().
I will send a new v2.
Regards,
Marco
>
> Sascha
>
> --
> 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 |
>
--
#gernperDu
#CallMeByMyFirstName
Pengutronix e.K. | |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-23 11:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-18 12:42 [PATCH] eeprom: at24: verify that chip is accessible during probe Marco Felsch
2026-02-23 9:15 ` Sascha Hauer
2026-02-23 9:56 ` Marco Felsch
2026-02-23 11:16 ` Sascha Hauer
2026-02-23 11:22 ` Marco Felsch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox