[PATCH] common: clarify global.of.kernel.add_machine_compatible
Ahmad Fatoum
a.fatoum at pengutronix.de
Sun Apr 13 23:22:57 PDT 2025
While the name hints at the compatible being added has something to do
with the kernel, the magicvar help text doesn't.
Point that out and make the functionality dependent on CONFIG_OFTREE.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/misc.c | 7 +++++--
include/barebox-info.h | 5 +++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/common/misc.c b/common/misc.c
index 0c883b76c1c2..375fbbb199c7 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -148,7 +148,6 @@ BAREBOX_MAGICVAR(global.model, "Product name of this hardware");
static char *hostname;
static char *serial_number;
-static char *of_machine_compatible;
/* Note that HOST_NAME_MAX is 64 on Linux */
#define BAREBOX_HOST_NAME_MAX 64
@@ -260,6 +259,9 @@ const char *barebox_get_serial_number(void)
BAREBOX_MAGICVAR(global.serial_number, "Board serial number");
+#ifdef CONFIG_OFTREE
+static char *of_machine_compatible;
+
void barebox_set_of_machine_compatible(const char *__compatible)
{
free(of_machine_compatible);
@@ -282,7 +284,8 @@ static int of_kernel_init(void)
}
device_initcall(of_kernel_init);
-BAREBOX_MAGICVAR(global.of.kernel.add_machine_compatible, "Additional machine/board compatible");
+BAREBOX_MAGICVAR(global.of.kernel.add_machine_compatible, "Extra machine/board compatible to prepend to kernel DT compatible");
+#endif
static void __noreturn do_panic(bool stacktrace, const char *fmt, va_list ap)
{
diff --git a/include/barebox-info.h b/include/barebox-info.h
index 446cd0dbaf93..ab46c69e9eb5 100644
--- a/include/barebox-info.h
+++ b/include/barebox-info.h
@@ -25,7 +25,12 @@ bool barebox_hostname_is_valid(const char *s);
const char *barebox_get_serial_number(void);
void barebox_set_serial_number(const char *);
+#ifdef CONFIG_OFTREE
void barebox_set_of_machine_compatible(const char *);
const char *barebox_get_of_machine_compatible(void);
+#else
+static inline void barebox_set_of_machine_compatible(const char *) {return NULL; }
+static inline const char *barebox_get_of_machine_compatible(void) { return NULL; }
+#endif
#endif
--
2.39.5
More information about the barebox
mailing list