diff mbox series

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

Message ID 20210305201225.3753841-3-sean.anderson@seco.com
State Superseded
Delegated to: Tom Rini
Headers show
Series sysinfo: Add gpio sysinfo driver | expand

Commit Message

Sean Anderson March 5, 2021, 8:12 p.m. UTC
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@seco.com>
---

Changes in v2:
- Set BOARD_HWVERSION to SYSINFO_ID_REVISION, as they represent the same
  content.
- Use enums instead of defines for sysinfo ids

 drivers/sysinfo/gazerbeam.h |  8 +++++---
 drivers/sysinfo/sandbox.h   |  2 +-
 include/sysinfo.h           | 13 +++++++++++++
 3 files changed, 19 insertions(+), 4 deletions(-)

Comments

Simon Glass March 12, 2021, 4:45 a.m. UTC | #1
On Fri, 5 Mar 2021 at 13:12, Sean Anderson <sean.anderson@seco.com> wrote:
>
> 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@seco.com>
> ---
>
> Changes in v2:
> - Set BOARD_HWVERSION to SYSINFO_ID_REVISION, as they represent the same
>   content.
> - Use enums instead of defines for sysinfo ids
>
>  drivers/sysinfo/gazerbeam.h |  8 +++++---
>  drivers/sysinfo/sandbox.h   |  2 +-
>  include/sysinfo.h           | 13 +++++++++++++
>  3 files changed, 19 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/sysinfo/gazerbeam.h b/drivers/sysinfo/gazerbeam.h
index 171729d203..21514dd122 100644
--- a/drivers/sysinfo/gazerbeam.h
+++ b/drivers/sysinfo/gazerbeam.h
@@ -5,10 +5,12 @@ 
  *
  */
 
+#include <sysinfo.h>
+
 enum {
-	BOARD_MULTICHANNEL,
-	BOARD_VARIANT,
-	BOARD_HWVERSION,
+	BOARD_HWVERSION = SYSINFO_ID_REVISION,
+	BOARD_MULTICHANNEL = SYSINFO_ID_END + 1,
+	BOARD_VARIANT
 };
 
 enum {
diff --git a/drivers/sysinfo/sandbox.h b/drivers/sysinfo/sandbox.h
index 2cff494f56..9a67fd2389 100644
--- a/drivers/sysinfo/sandbox.h
+++ b/drivers/sysinfo/sandbox.h
@@ -5,7 +5,7 @@ 
  */
 
 enum {
-	BOOL_CALLED_DETECT,
+	BOOL_CALLED_DETECT = SYSINFO_ID_END + 1,
 	INT_TEST1,
 	INT_TEST2,
 	STR_VACATIONSPOT,
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