diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-16 10:54:37 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-16 10:54:37 +0200 |
commit | 0ae461c2ee6baed1a94b88c0ecfc4a9d0f4e5201 (patch) | |
tree | 7c6e35c227d10607d6f15e91b69fb2e96f6c1a8c /drivers | |
parent | 226938796e525f42e002769f21dc66d16ac26f9b (diff) | |
parent | 73a9619b85497d19b74e6a023aa9ce0e88a1143d (diff) | |
download | barebox-0ae461c2ee6baed1a94b88c0ecfc4a9d0f4e5201.tar.gz barebox-0ae461c2ee6baed1a94b88c0ecfc4a9d0f4e5201.tar.xz |
Merge branch 'for-next/overlapping-memory-banks'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 40 | ||||
-rw-r--r-- | drivers/of/mem_generic.c | 5 |
2 files changed, 30 insertions, 15 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 0e8750efec..193bae7fa0 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1699,32 +1699,34 @@ int of_set_root_node(struct device_node *node) return 0; } -void barebox_register_of(struct device_node *root) +int barebox_register_of(struct device_node *root) { if (root_node) - return; + return -EBUSY; of_set_root_node(root); of_fix_tree(root); if (IS_ENABLED(CONFIG_OFDEVICE)) - of_probe(); + return of_probe(); + + return 0; } -void barebox_register_fdt(const void *dtb) +int barebox_register_fdt(const void *dtb) { struct device_node *root; if (root_node) - return; + return -EBUSY; root = of_unflatten_dtb(dtb); if (IS_ERR(root)) { pr_err("Cannot unflatten dtb: %pe\n", root); - return; + return PTR_ERR(root); } - barebox_register_of(root); + return barebox_register_of(root); } /** @@ -2254,6 +2256,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; @@ -2261,12 +2264,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; @@ -2289,18 +2295,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) @@ -2321,6 +2334,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; @@ -2331,7 +2345,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) @@ -2342,7 +2356,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); } |