[PATCH 2/3] of: implement of_get_machine_vendor()

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Dec 15 00:24:38 PST 2025


While of_get_machine_compatible() returns what's after the comma in the
first top-level compatible string, of_get_machine_vendor() will return
what's before the comma. This will be used to report OEM name via
SMBIOS.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/of/base.c | 23 +++++++++++++++++++++++
 include/of.h      |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0a7704ca1045..71c95ad19863 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -3720,6 +3720,29 @@ const char *of_get_machine_compatible(void)
 }
 EXPORT_SYMBOL(of_get_machine_compatible);
 
+/**
+ * of_get_machine_vendor - get first vendor prefix string from the root node.
+ *
+ * Returns the string or NULL.
+ */
+char *of_get_machine_vendor(void)
+{
+	const char *name = NULL;
+	char *p;
+
+	if (!root_node)
+		return NULL;
+
+
+	of_property_read_string(root_node, "compatible", &name);
+
+	p = strdup(name);
+	if (p)
+		*strchrnul(p, ',') = '\0';
+	return p;
+}
+EXPORT_SYMBOL(of_get_machine_vendor);
+
 static int of_init_early_vars(void)
 {
 	struct device_node *bootsource;
diff --git a/include/of.h b/include/of.h
index d1efab13c780..04263e394237 100644
--- a/include/of.h
+++ b/include/of.h
@@ -217,6 +217,7 @@ extern void of_delete_node(struct device_node *node);
 
 extern int of_alias_from_compatible(const struct device_node *node, char *alias, int len);
 extern const char *of_get_machine_compatible(void);
+extern char *of_get_machine_vendor(void);
 extern int of_machine_is_compatible(const char *compat);
 extern int of_device_is_compatible(const struct device_node *device,
 		const char *compat);
-- 
2.47.3




More information about the barebox mailing list