mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] of: implement of_get_machine_vendor()
Date: Mon, 15 Dec 2025 09:24:38 +0100	[thread overview]
Message-ID: <20251215082442.1977789-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20251215082442.1977789-1-a.fatoum@pengutronix.de>

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@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




  reply	other threads:[~2025-12-15  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15  8:24 [PATCH 1/3] startup: implement get_autoboot_state() helper Ahmad Fatoum
2025-12-15  8:24 ` Ahmad Fatoum [this message]
2025-12-15  8:24 ` [PATCH 3/3] lib: smbios: add support for populating SMBIOS table Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251215082442.1977789-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox