[PATCH 2/5] sysinfo: Provide some global/default IDs

Sean Anderson sean.anderson at seco.com
Mon Mar 1 21:46:00 CET 2021


This adds an ID for a board revision. Existing IDs have been moved above
SYSINFO_ID_END to allow for future expansion.

Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---

 drivers/sysinfo/gazerbeam.h | 10 +++++-----
 drivers/sysinfo/sandbox.h   | 10 ++++------
 include/sysinfo.h           | 13 +++++++++++++
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/sysinfo/gazerbeam.h b/drivers/sysinfo/gazerbeam.h
index 171729d203..d8e3c48955 100644
--- a/drivers/sysinfo/gazerbeam.h
+++ b/drivers/sysinfo/gazerbeam.h
@@ -5,11 +5,11 @@
  *
  */
 
-enum {
-	BOARD_MULTICHANNEL,
-	BOARD_VARIANT,
-	BOARD_HWVERSION,
-};
+#include <sysinfo.h>
+
+#define BOARD_MULTICHANNEL	(SYSINFO_ID_END + 1)
+#define	BOARD_VARIANT		(SYSINFO_ID_END + 2)
+#define BOARD_HWVERSION		(SYSINFO_ID_END + 3)
 
 enum {
 	VAR_CON,
diff --git a/drivers/sysinfo/sandbox.h b/drivers/sysinfo/sandbox.h
index 2cff494f56..dc7c15e738 100644
--- a/drivers/sysinfo/sandbox.h
+++ b/drivers/sysinfo/sandbox.h
@@ -4,9 +4,7 @@
  * Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
  */
 
-enum {
-	BOOL_CALLED_DETECT,
-	INT_TEST1,
-	INT_TEST2,
-	STR_VACATIONSPOT,
-};
+#define BOOL_CALLED_DETECT	(SYSINFO_ID_END + 1)
+#define INT_TEST1		(SYSINFO_ID_END + 2)
+#define INT_TEST2		(SYSINFO_ID_END + 3)
+#define STR_VACATIONSPOT	(SYSINFO_ID_END + 4)
diff --git a/include/sysinfo.h b/include/sysinfo.h
index c045d316b0..9386bdf49a 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -32,6 +32,19 @@
  */
 
 #if CONFIG_IS_ENABLED(SYSINFO)
+/**
+ * enum sysinfo_id - IDs which may be passed to sysinfo accessors
+ */
+enum sysinfo_id {
+	/** @SYSINFO_ID_REVISION: Use this ID to access the board revision. */
+	SYSINFO_ID_REVISION,
+	/**
+	 * @SYSINFO_ID_END: The last global sysinfo id. If you need to return
+	 * custom information, use SYSINFO_ID_END+1 as the base offset.
+	 */
+	SYSINFO_ID_END = 127,
+};
+
 struct sysinfo_ops {
 	/**
 	 * detect() - Run the hardware info detection procedure for this
-- 
2.25.1



More information about the U-Boot mailing list