diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2024-03-01 14:04:44 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-03-04 10:49:23 +0100 |
commit | 9f2b74f1eb58f0a382d3d84d24cadd7b446b72de (patch) | |
tree | c2626fcb899f06e4dd32bb2d27cad25c59426e1c | |
parent | 143f2ae76809d2c57fc1fd65c563af542d247938 (diff) | |
download | barebox-9f2b74f1eb58.tar.gz barebox-9f2b74f1eb58.tar.xz |
blspec: don't parse whole device tree to compare compatibles
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>
Link: https://lore.barebox.org/20240301130445.171385-4-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/blspec.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/common/blspec.c b/common/blspec.c index b70332a54c..23a24c63db 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; |