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 3/4] blspec: don't parse whole device tree to compare compatibles
Date: Fri,  1 Mar 2024 14:04:44 +0100	[thread overview]
Message-ID: <20240301130445.171385-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240301130445.171385-1-a.fatoum@pengutronix.de>

Now that we have an fdt_machine_is_compatible that can operate on
flattened device trees, use it to speed up the process of finding
compatible bootloader spec entries.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/blspec.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index b70332a54c28..23a24c63db15 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -427,7 +427,9 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	const char *devicetree;
 	const char *abspath;
 	int ret;
-	struct device_node *root = NULL, *barebox_root;
+	struct device_node *barebox_root;
+	size_t size;
+	void *fdt;
 	const char *compat;
 	char *filename;
 
@@ -455,25 +457,23 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 
 	filename = basprintf("%s/%s", abspath, devicetree);
 
-	root = of_read_file(filename);
-	if (IS_ERR(root)) {
+	fdt = read_file(filename, &size);
+	if (!fdt) {
 		ret = false;
-		root = NULL;
 		goto out;
 	}
 
-	if (of_device_is_compatible(root, compat)) {
+	if (fdt_machine_is_compatible(fdt, size, compat)) {
 		ret = true;
 		goto out;
 	}
 
-	pr_info("ignoring entry with incompatible devicetree \"%s\"\n",
-			(char *)of_get_property(root, "compatible", NULL));
+	pr_info("ignoring entry with incompatible devicetree: %s\n", devicetree);
 
 	ret = false;
 
 out:
-	of_delete_node(root);
+	free(fdt);
 	free(filename);
 
 	return ret;
-- 
2.39.2




  parent reply	other threads:[~2024-03-01 13:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 13:04 [PATCH 0/4] of: fdt: read blspec/FIT DT compat without unflattening Ahmad Fatoum
2024-03-01 13:04 ` [PATCH 1/4] of: fdt: factor out FDT header parsing Ahmad Fatoum
2024-03-01 13:04 ` [PATCH 2/4] of: fdt: implement fdt_machine_is_compatible Ahmad Fatoum
2024-03-04  9:37   ` Sascha Hauer
2024-03-04  9:49     ` Sascha Hauer
2024-03-04  9:50     ` Ahmad Fatoum
2024-03-01 13:04 ` Ahmad Fatoum [this message]
2024-03-01 13:04 ` [PATCH 4/4] FIT: support finding compatible configuration by FDT compatible Ahmad Fatoum
2024-03-04  9:49 ` [PATCH 0/4] of: fdt: read blspec/FIT DT compat without unflattening Sascha Hauer

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=20240301130445.171385-4-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