summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-05-31 09:12:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-02 08:37:23 +0200
commit156c6c0c62b5238d828a33a4cea1000e10aa0d30 (patch)
treeae572a9743b243673076376cae21430f1ab1ce2c /drivers
parente63077f60ec743cd5535db2f5d49bbf0e9b95335 (diff)
downloadbarebox-156c6c0c62b5238d828a33a4cea1000e10aa0d30.tar.gz
barebox-156c6c0c62b5238d828a33a4cea1000e10aa0d30.tar.xz
of: warn about of_add_memory_bank errors
Now that errors from of_probe are propagated to the respective initcalls registering the device tree, propagate of_add_memory_bank errors as well. This ensures that clashes of device-tree added regions with previous ones don't go unnoticed. This can e.g. be the case if a device tree happens to have both /memory@X { }; and /memory { }; nodes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531071239.30653-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/base.c24
-rw-r--r--drivers/of/mem_generic.c5
2 files changed, 21 insertions, 8 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index b99201a50f..17f58dba23 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2248,6 +2248,7 @@ int of_add_memory(struct device_node *node, bool dump)
return -ENXIO;
while (!of_address_to_resource(node, n, &res)) {
+ int err;
n++;
if (!resource_size(&res))
continue;
@@ -2255,12 +2256,15 @@ int of_add_memory(struct device_node *node, bool dump)
if (!of_device_is_available(node))
continue;
- of_add_memory_bank(node, dump, mem_bank_num,
+ err = of_add_memory_bank(node, dump, mem_bank_num,
res.start, resource_size(&res));
+ if (err)
+ ret = err;
+
mem_bank_num++;
}
- return 0;
+ return ret;
}
static struct device_node *of_chosen;
@@ -2283,18 +2287,25 @@ const struct of_device_id of_default_bus_match_table[] = {
}
};
-static void of_probe_memory(void)
+static int of_probe_memory(void)
{
struct device_node *memory = root_node;
+ int ret = 0;
/* Parse all available node with "memory" device_type */
while (1) {
+ int err;
+
memory = of_find_node_by_type(memory, "memory");
if (!memory)
break;
- of_add_memory(memory, false);
+ err = of_add_memory(memory, false);
+ if (err)
+ ret = err;
}
+
+ return ret;
}
static void of_platform_device_create_root(struct device_node *np)
@@ -2315,6 +2326,7 @@ static void of_platform_device_create_root(struct device_node *np)
int of_probe(void)
{
struct device_node *firmware;
+ int ret;
if(!root_node)
return -ENODEV;
@@ -2325,7 +2337,7 @@ int of_probe(void)
if (of_model)
barebox_set_model(of_model);
- of_probe_memory();
+ ret = of_probe_memory();
firmware = of_find_node_by_path("/firmware");
if (firmware)
@@ -2336,7 +2348,7 @@ int of_probe(void)
of_clk_init(root_node, NULL);
of_platform_populate(root_node, of_default_bus_match_table, NULL);
- return 0;
+ return ret;
}
/**
diff --git a/drivers/of/mem_generic.c b/drivers/of/mem_generic.c
index 9094243c04..55d93bcb06 100644
--- a/drivers/of/mem_generic.c
+++ b/drivers/of/mem_generic.c
@@ -2,14 +2,15 @@
#include <of.h>
#include <memory.h>
-void of_add_memory_bank(struct device_node *node, bool dump, int r,
+int of_add_memory_bank(struct device_node *node, bool dump, int r,
u64 base, u64 size)
{
static char str[6];
sprintf(str, "ram%d", r);
- barebox_add_memory_bank(str, base, size);
if (dump)
pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+
+ return barebox_add_memory_bank(str, base, size);
}