include: board: provide empty stubs when the BOARD option is not selected
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Tue, 22 Oct 2019 14:39:20 +0000 (16:39 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 7 Jan 2020 16:13:24 +0000 (11:13 -0500)
Useful to avoid #ifdef throughout the code that uses the board driver API.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
include/board.h

index fd6a486702eac372c9221f4c6ff50c1cdc9ddbc5..678b652b0aa3fc547c01689f6f69cf6478a4504b 100644 (file)
@@ -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
@@ -174,3 +175,39 @@ int board_get(struct udevice **devp);
  */
 int board_get_fit_loadable(struct udevice *dev, int index,
                           const char *type, const char **strp);
+
+#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 int board_get_fit_loadable(struct udevice *dev, int index,
+                                        const char *type, const char **strp)
+{
+       return -ENOSYS;
+}
+
+#endif