[PATCH v3 2/7] sysinfo: add sysinfo_get_and_detect() helper
Simon Glass
sjg at chromium.org
Mon Jun 1 23:12:59 CEST 2026
Hi Nora,
On 2026-05-27T09:51:17, Alexander Feilke
<Alexander.Feilke at ew.tq-group.com> wrote:
> sysinfo: add sysinfo_get_and_detect() helper
>
> sysinfo_detect() is commonly called after sysinfo_get(). Make the API a
> bit more convenient to use by introducing a helper.
>
> Signed-off-by: Nora Schiffer <nora.schiffer at ew.tq-group.com>
> Signed-off-by: Alexander Feilke <alexander.feilke at ew.tq-group.com>
>
> include/sysinfo.h | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> diff --git a/include/sysinfo.h b/include/sysinfo.h
> @@ -373,6 +373,26 @@ int sysinfo_get_data_by_index(struct udevice *dev, int id, int index,
> +/**
> + * sysinfo_get_and_detect() - Get the sysinfo device and run its detect
> + * operation.
> + * @devp: Pointer to structure to receive the sysinfo device.
> + *
> + * This is a convenience wrapper around sysinfo_get() followed by
> + * sysinfo_detect()
> + *
> + * Return: 0 if OK, -ve on error.
> + */
Please keep the kerneldoc brief on one line, as with sysinfo_get() and
the others in this file. Something like 'sysinfo_get_and_detect() -
Get the sysinfo device and detect it', with the rest in the body.
> diff --git a/include/sysinfo.h b/include/sysinfo.h
> @@ -373,6 +373,26 @@ int sysinfo_get_data_by_index(struct udevice *dev, int id, int index,
> +static inline int sysinfo_get_and_detect(struct udevice **devp)
> +{
> + int ret = sysinfo_get(devp);
> +
> + if (!ret)
> + ret = sysinfo_detect(*devp);
> +
> + return ret;
> +}
Please can you put the implementation in
drivers/sysinfo/sysinfo-uclass.c alongside sysinfo_get() and
sysinfo_detect()? It keeps the uclass API in one place and matches the
other wrappers.
> diff --git a/include/sysinfo.h b/include/sysinfo.h
> @@ -438,6 +458,11 @@ static inline int sysinfo_get(struct udevice **devp)
> +static inline int sysinfo_get_and_detect(struct udevice **devp)
> +{
> + return -ENOSYS;
> +}
Please add coverage for the new helper to test/dm/sysinfo.c - at
minimum a call that returns 0 and verifies BOOL_CALLED_DETECT then
reads back true.
Regards,
Simon
More information about the U-Boot
mailing list