[U-Boot] [PATCH PATCH v4 14/15] include: board: provide empty stubs when the BOARD option is not selected

Jean-Jacques Hiblot jjhiblot at ti.com
Mon Aug 5 09:44:09 UTC 2019


Useful to avoid #ifdef throughout the code that uses the board driver API.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---

Changes in v4: New

 include/board.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/include/board.h b/include/board.h
index 0f4f1aadeb..96e8ca77bd 100644
--- a/include/board.h
+++ b/include/board.h
@@ -31,6 +31,7 @@
  * to read the serial number.
  */
 
+#if CONFIG_IS_ENABLED(BOARD)
 struct board_ops {
 	/**
 	 * detect() - Run the hardware info detection procedure for this
@@ -172,3 +173,39 @@ int board_get(struct udevice **devp);
  */
 const char *board_get_fit_loadable(struct udevice *dev, int index,
 				   const char *type);
+
+#else
+
+static inline int board_detect(struct udevice *dev)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get_bool(struct udevice *dev, int id, bool *val)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get_int(struct udevice *dev, int id, int *val)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get_str(struct udevice *dev, int id, size_t size,
+				char *val)
+{
+	return -ENOSYS;
+}
+
+static inline int board_get(struct udevice **devp)
+{
+	return -ENOSYS;
+}
+
+static inline const char *board_get_fit_loadable(struct udevice *dev,
+						 int index, const char *type)
+{
+	return NULL;
+}
+
+#endif
-- 
2.17.1



More information about the U-Boot mailing list