[PATCH 3/6] sysinfo: tq_eeprom: new driver

Simon Glass sjg at chromium.org
Fri May 8 19:58:57 CEST 2026


Hi Nora,

On 2026-05-08T08:48:28, Feilke, Alexander
<Alexander.Feilke at ew.tq-group.com> wrote:
> sysinfo: tq_eeprom: new driver
>
> Introduce a sysinfo driver that can be instantiated from the device,
> which will provide information from the EEPROM found on all TQ-Systems
> SoMs.
>
> Signed-off-by: Nora Schiffer <nora.schiffer at ew.tq-group.com>
> Signed-off-by: Max Merchel <Max.Merchel at ew.tq-group.com>
> Signed-off-by: Alexander Feilke <alexander.feilke at ew.tq-group.com>
>
> drivers/sysinfo/Kconfig     |   8 ++
>  drivers/sysinfo/Makefile    |   1 +
>  drivers/sysinfo/tq_eeprom.c | 223 ++++++++++++++++++++++++++++++++++++++++++++
>  include/sysinfo/tq_eeprom.h |  24 +++++
>  4 files changed, 256 insertions(+)

> diff --git a/drivers/sysinfo/tq_eeprom.c b/drivers/sysinfo/tq_eeprom.c
> @@ -0,0 +1,223 @@
> +#include <display_options.h>
> +#include <dm.h>
> +#include <i2c_eeprom.h>
> +#include <log.h>
> +#include <net.h>
> +#include <dm/device_compat.h>
> +#include <linux/ctype.h>
> +#include <linux/sizes.h>
> +#include <sysinfo/tq_eeprom.h>

Can you drop display_options.h and linux/sizes.h ?

> diff --git a/drivers/sysinfo/tq_eeprom.c b/drivers/sysinfo/tq_eeprom.c
> @@ -0,0 +1,223 @@
> +static int tq_eeprom_serial_len_old(const struct tq_eeprom_data *data)
> +{
> +     int i;
> +
> +     for (i = 0; i < sizeof(data->serial); i++) {
> +             if (!isdigit(data->serial[i]))
> +                     break;
> +     }
> +
> +     return i;
> +}
> +
> +static int tq_eeprom_serial_len_new(const struct tq_eeprom_data *data)
> +{
> +     int i;
> +
> +     for (i = 0; i < sizeof(data->serial); i++) {
> +             if (!(isdigit(data->serial[i]) || isupper(data->serial[i])))
> +                     break;
> +     }
> +
> +     return i;
> +}

Please fold these into a single helper taking a 'bool allow_upper' (or similar).

> diff --git a/drivers/sysinfo/tq_eeprom.c b/drivers/sysinfo/tq_eeprom.c
> @@ -0,0 +1,223 @@
> +static int tq_eeprom_dump(const struct sysinfo_tq_eeprom_priv *priv)
> +{
> +     printf("TQ EEPROM:\n");
> +     printf("  ID:  %s\n", priv->id[0] ? priv->id : '<invalid>');
> +     printf("  SN:  %s\n", priv->serial[0] ? priv->serial : '<invalid>');
> +     printf("  MAC: ");
> +     if (is_valid_ethaddr(priv->mac))
> +             printf('%pM\n', priv->mac);
> +     else
> +             printf('<invalid>\n');
> +
> +     return 0;
> +}

Always returns 0 and the caller ignores it, so please make this void.

> diff --git a/drivers/sysinfo/tq_eeprom.c b/drivers/sysinfo/tq_eeprom.c
> @@ -0,0 +1,223 @@
> +     for (i = 0; i < sizeof(data->id); i++) {
> +             if (!(isprint(data->id[i]) && isascii(data->id[i])))
> +                     break;
> +     }

isprint() already implies the ASCII printable range - you can drop the
isascii() check.

Regards,
Simon


More information about the U-Boot mailing list