[PATCH 2/6] sysinfo: add sysinfo_get_and_detect() helper

Alexander Feilke Alexander.Feilke at ew.tq-group.com
Fri May 8 10:48:30 CEST 2026


From: Nora Schiffer <nora.schiffer at ew.tq-group.com>

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 | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/sysinfo.h b/include/sysinfo.h
index 54eb64a204a..026ea393730 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -446,3 +446,24 @@ static inline int sysinfo_get_fit_loadable(struct udevice *dev, int index,
 
 #endif
 #endif
+
+/**
+ * sysinfo_get_and_detect() - Return the sysinfo device for the sysinfo in
+ * question and runs its detect operation.
+ * @devp: Pointer to structure to receive the sysinfo device.
+ *
+ * Since there can only be at most one sysinfo instance, the API can supply a
+ * function that returns the unique device. This is especially useful for use
+ * in sysinfo files.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+static inline int sysinfo_get_and_detect(struct udevice **devp)
+{
+	int ret = sysinfo_get(devp);
+
+	if (!ret)
+		ret = sysinfo_detect(*devp);
+
+	return ret;
+}
-- 
2.34.1



More information about the U-Boot mailing list