diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 38 | ||||
-rw-r--r-- | drivers/of/fdt.c | 150 | ||||
-rw-r--r-- | drivers/of/platform.c | 4 | ||||
-rw-r--r-- | drivers/of/property.c | 17 | ||||
-rw-r--r-- | drivers/of/unittest.c | 175 |
5 files changed, 223 insertions, 161 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 61de453b885c..8a24d37153b4 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -651,6 +651,28 @@ bool of_device_is_available(const struct device_node *device) EXPORT_SYMBOL(of_device_is_available); /** + * __of_device_is_fail - check if a device has status "fail" or "fail-..." + * + * @device: Node to check status for, with locks already held + * + * Return: True if the status property is set to "fail" or "fail-..." (for any + * error code suffix), false otherwise + */ +static bool __of_device_is_fail(const struct device_node *device) +{ + const char *status; + + if (!device) + return false; + + status = __of_get_property(device, "status", NULL); + if (status == NULL) + return false; + + return !strcmp(status, "fail") || !strncmp(status, "fail-", 5); +} + +/** * of_device_is_big_endian - check if a device has BE registers * * @device: Node to check for endianness @@ -796,6 +818,9 @@ EXPORT_SYMBOL(of_get_next_available_child); * of_get_next_cpu_node - Iterate on cpu nodes * @prev: previous child of the /cpus node, or NULL to get first * + * Unusable CPUs (those with the status property set to "fail" or "fail-...") + * will be skipped. + * * Return: A cpu node pointer with refcount incremented, use of_node_put() * on it when done. Returns NULL when prev is the last child. Decrements * the refcount of prev. @@ -817,6 +842,8 @@ struct device_node *of_get_next_cpu_node(struct device_node *prev) of_node_put(node); } for (; next; next = next->sibling) { + if (__of_device_is_fail(next)) + continue; if (!(of_node_name_eq(next, "cpu") || __of_node_is_type(next, "cpu"))) continue; @@ -1349,9 +1376,14 @@ int of_phandle_iterator_next(struct of_phandle_iterator *it) * property data length */ if (it->cur + count > it->list_end) { - pr_err("%pOF: %s = %d found %d\n", - it->parent, it->cells_name, - count, it->cell_count); + if (it->cells_name) + pr_err("%pOF: %s = %d found %td\n", + it->parent, it->cells_name, + count, it->list_end - it->cur); + else + pr_err("%pOF: phandle %s needs %d, found %td\n", + it->parent, of_node_full_name(it->node), + count, it->list_end - it->cur); goto err; } } diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bdca35284ceb..ad85ff6474ff 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -26,6 +26,7 @@ #include <linux/serial_core.h> #include <linux/sysfs.h> #include <linux/random.h> +#include <linux/kmemleak.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #include <asm/page.h> @@ -482,9 +483,11 @@ static int __init early_init_dt_reserve_memory_arch(phys_addr_t base, if (nomap) { /* * If the memory is already reserved (by another region), we - * should not allow it to be marked nomap. + * should not allow it to be marked nomap, but don't worry + * if the region isn't memory as it won't be mapped. */ - if (memblock_is_region_reserved(base, size)) + if (memblock_overlaps_region(&memblock.memory, base, size) && + memblock_is_region_reserved(base, size)) return -EBUSY; return memblock_mark_nomap(base, size); @@ -522,9 +525,12 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, size = dt_mem_next_cell(dt_root_size_cells, &prop); if (size && - early_init_dt_reserve_memory_arch(base, size, nomap) == 0) + early_init_dt_reserve_memory_arch(base, size, nomap) == 0) { pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n", uname, &base, (unsigned long)(size / SZ_1M)); + if (!nomap) + kmemleak_alloc_phys(base, size, 0, 0); + } else pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n", uname, &base, (unsigned long)(size / SZ_1M)); @@ -965,18 +971,22 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) elfcorehdr_addr, elfcorehdr_size); } -static phys_addr_t cap_mem_addr; -static phys_addr_t cap_mem_size; +static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND; /** * early_init_dt_check_for_usable_mem_range - Decode usable memory range * location from flat tree - * @node: reference to node containing usable memory range location ('chosen') */ -static void __init early_init_dt_check_for_usable_mem_range(unsigned long node) +void __init early_init_dt_check_for_usable_mem_range(void) { const __be32 *prop; int len; + phys_addr_t cap_mem_addr; + phys_addr_t cap_mem_size; + unsigned long node = chosen_node_offset; + + if ((long)node < 0) + return; pr_debug("Looking for usable-memory-range property... "); @@ -989,6 +999,8 @@ static void __init early_init_dt_check_for_usable_mem_range(unsigned long node) pr_debug("cap_mem_start=%pa cap_mem_size=%pa\n", &cap_mem_addr, &cap_mem_size); + + memblock_cap_memory_range(cap_mem_addr, cap_mem_size); } #ifdef CONFIG_SERIAL_EARLYCON @@ -1042,13 +1054,14 @@ int __init early_init_dt_scan_chosen_stdout(void) /* * early_init_dt_scan_root - fetch the top level address and size cells */ -int __init early_init_dt_scan_root(unsigned long node, const char *uname, - int depth, void *data) +int __init early_init_dt_scan_root(void) { const __be32 *prop; + const void *fdt = initial_boot_params; + int node = fdt_path_offset(fdt, "/"); - if (depth != 0) - return 0; + if (node < 0) + return -ENODEV; dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; @@ -1063,8 +1076,7 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname, dt_root_addr_cells = be32_to_cpup(prop); pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells); - /* break now */ - return 1; + return 0; } u64 __init dt_mem_next_cell(int s, const __be32 **cellp) @@ -1078,73 +1090,78 @@ u64 __init dt_mem_next_cell(int s, const __be32 **cellp) /* * early_init_dt_scan_memory - Look for and parse memory nodes */ -int __init early_init_dt_scan_memory(unsigned long node, const char *uname, - int depth, void *data) +int __init early_init_dt_scan_memory(void) { - const char *type = of_get_flat_dt_prop(node, "device_type", NULL); - const __be32 *reg, *endp; - int l; - bool hotpluggable; + int node; + const void *fdt = initial_boot_params; - /* We are scanning "memory" nodes only */ - if (type == NULL || strcmp(type, "memory") != 0) - return 0; + fdt_for_each_subnode(node, fdt, 0) { + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); + const __be32 *reg, *endp; + int l; + bool hotpluggable; - reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); - if (reg == NULL) - reg = of_get_flat_dt_prop(node, "reg", &l); - if (reg == NULL) - return 0; + /* We are scanning "memory" nodes only */ + if (type == NULL || strcmp(type, "memory") != 0) + continue; - endp = reg + (l / sizeof(__be32)); - hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL); + reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); + if (reg == NULL) + reg = of_get_flat_dt_prop(node, "reg", &l); + if (reg == NULL) + continue; - pr_debug("memory scan node %s, reg size %d,\n", uname, l); + endp = reg + (l / sizeof(__be32)); + hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL); - while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { - u64 base, size; + pr_debug("memory scan node %s, reg size %d,\n", + fdt_get_name(fdt, node, NULL), l); - base = dt_mem_next_cell(dt_root_addr_cells, ®); - size = dt_mem_next_cell(dt_root_size_cells, ®); + while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { + u64 base, size; - if (size == 0) - continue; - pr_debug(" - %llx, %llx\n", base, size); + base = dt_mem_next_cell(dt_root_addr_cells, ®); + size = dt_mem_next_cell(dt_root_size_cells, ®); - early_init_dt_add_memory_arch(base, size); + if (size == 0) + continue; + pr_debug(" - %llx, %llx\n", base, size); - if (!hotpluggable) - continue; + early_init_dt_add_memory_arch(base, size); - if (memblock_mark_hotplug(base, size)) - pr_warn("failed to mark hotplug range 0x%llx - 0x%llx\n", - base, base + size); - } + if (!hotpluggable) + continue; + if (memblock_mark_hotplug(base, size)) + pr_warn("failed to mark hotplug range 0x%llx - 0x%llx\n", + base, base + size); + } + } return 0; } -int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, - int depth, void *data) +int __init early_init_dt_scan_chosen(char *cmdline) { - int l; + int l, node; const char *p; const void *rng_seed; + const void *fdt = initial_boot_params; - pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); + node = fdt_path_offset(fdt, "/chosen"); + if (node < 0) + node = fdt_path_offset(fdt, "/chosen@0"); + if (node < 0) + return -ENOENT; - if (depth != 1 || !data || - (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) - return 0; + chosen_node_offset = node; early_init_dt_check_for_initrd(node); early_init_dt_check_for_elfcorehdr(node); - early_init_dt_check_for_usable_mem_range(node); /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); if (p != NULL && l > 0) - strlcpy(data, p, min(l, COMMAND_LINE_SIZE)); + strlcpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); /* * CONFIG_CMDLINE is meant to be a default in case nothing else @@ -1153,18 +1170,18 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, */ #ifdef CONFIG_CMDLINE #if defined(CONFIG_CMDLINE_EXTEND) - strlcat(data, " ", COMMAND_LINE_SIZE); - strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + strlcat(cmdline, " ", COMMAND_LINE_SIZE); + strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); #elif defined(CONFIG_CMDLINE_FORCE) - strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); #else /* No arguments from boot loader, use kernel's cmdl*/ - if (!((char *)data)[0]) - strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + if (!((char *)cmdline)[0]) + strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); #endif #endif /* CONFIG_CMDLINE */ - pr_debug("Command line is: %s\n", (char *)data); + pr_debug("Command line is: %s\n", (char *)cmdline); rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); if (rng_seed && l > 0) { @@ -1178,8 +1195,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, fdt_totalsize(initial_boot_params)); } - /* break now */ - return 1; + return 0; } #ifndef MIN_MEMBLOCK_ADDR @@ -1261,21 +1277,21 @@ bool __init early_init_dt_verify(void *params) void __init early_init_dt_scan_nodes(void) { - int rc = 0; + int rc; /* Initialize {size,address}-cells info */ - of_scan_flat_dt(early_init_dt_scan_root, NULL); + early_init_dt_scan_root(); /* Retrieve various information from the /chosen node */ - rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); - if (!rc) + rc = early_init_dt_scan_chosen(boot_command_line); + if (rc) pr_warn("No chosen node found, continuing without\n"); /* Setup memory, calling early_init_dt_add_memory_arch */ - of_scan_flat_dt(early_init_dt_scan_memory, NULL); + early_init_dt_scan_memory(); /* Handle linux,usable-memory-range property */ - memblock_cap_memory_range(cap_mem_addr, cap_mem_size); + early_init_dt_check_for_usable_mem_range(); } bool __init early_init_dt_scan(void *params) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b3faf89744aa..793350028906 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -540,6 +540,10 @@ static int __init of_platform_default_populate_init(void) of_node_put(node); } + node = of_get_compatible_child(of_chosen, "simple-framebuffer"); + of_platform_device_create(node, NULL, NULL); + of_node_put(node); + /* Populate everything else. */ of_platform_default_populate(NULL, NULL, NULL); diff --git a/drivers/of/property.c b/drivers/of/property.c index a3483484a5a2..8e90071de6ed 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1075,6 +1075,17 @@ static struct device_node *of_get_compat_node(struct device_node *np) return np; } +static struct device_node *of_get_compat_node_parent(struct device_node *np) +{ + struct device_node *parent, *node; + + parent = of_get_parent(np); + node = of_get_compat_node(parent); + of_node_put(parent); + + return node; +} + /** * of_link_to_phandle - Add fwnode link to supplier from supplier phandle * @con_np: consumer device tree node @@ -1249,7 +1260,9 @@ static struct device_node *parse_##fname(struct device_node *np, \ * @parse_prop.index: For properties holding a list of phandles, this is the * index into the list * @optional: Describes whether a supplier is mandatory or not - * @node_not_dev: The consumer node containing the property is never a device. + * @node_not_dev: The consumer node containing the property is never converted + * to a struct device. Instead, parse ancestor nodes for the + * compatible property to find a node corresponding to a device. * * Returns: * parse_prop() return values are @@ -1424,7 +1437,7 @@ static int of_link_property(struct device_node *con_np, const char *prop_name) struct device_node *con_dev_np; con_dev_np = s->node_not_dev - ? of_get_compat_node(con_np) + ? of_get_compat_node_parent(con_np) : of_node_get(con_np); matched = true; i++; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 481ba8682ebf..70992103c07d 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -911,11 +911,18 @@ static void __init of_unittest_dma_ranges_one(const char *path, if (!rc) { phys_addr_t paddr; dma_addr_t dma_addr; - struct device dev_bogus; + struct device *dev_bogus; - dev_bogus.dma_range_map = map; - paddr = dma_to_phys(&dev_bogus, expect_dma_addr); - dma_addr = phys_to_dma(&dev_bogus, expect_paddr); + dev_bogus = kzalloc(sizeof(struct device), GFP_KERNEL); + if (!dev_bogus) { + unittest(0, "kzalloc() failed\n"); + kfree(map); + return; + } + + dev_bogus->dma_range_map = map; + paddr = dma_to_phys(dev_bogus, expect_dma_addr); + dma_addr = phys_to_dma(dev_bogus, expect_paddr); unittest(paddr == expect_paddr, "of_dma_get_range: wrong phys addr %pap (expecting %llx) on node %pOF\n", @@ -925,6 +932,7 @@ static void __init of_unittest_dma_ranges_one(const char *path, &dma_addr, expect_dma_addr, np); kfree(map); + kfree(dev_bogus); } of_node_put(np); #endif @@ -934,8 +942,9 @@ static void __init of_unittest_parse_dma_ranges(void) { of_unittest_dma_ranges_one("/testcase-data/address-tests/device@70000000", 0x0, 0x20000000); - of_unittest_dma_ranges_one("/testcase-data/address-tests/bus@80000000/device@1000", - 0x100000000, 0x20000000); + if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT)) + of_unittest_dma_ranges_one("/testcase-data/address-tests/bus@80000000/device@1000", + 0x100000000, 0x20000000); of_unittest_dma_ranges_one("/testcase-data/address-tests/pci@90000000", 0x80000000, 0x20000000); } @@ -1492,7 +1501,7 @@ static int __init unittest_data_add(void) } #ifdef CONFIG_OF_OVERLAY -static int __init overlay_data_apply(const char *overlay_name, int *overlay_id); +static int __init overlay_data_apply(const char *overlay_name, int *ovcs_id); static int unittest_probe(struct platform_device *pdev) { @@ -1657,7 +1666,7 @@ static void __init of_unittest_overlay_gpio(void) * The overlays are applied by overlay_data_apply() * instead of of_unittest_apply_overlay() so that they * will not be tracked. Thus they will not be removed - * by of_unittest_destroy_tracked_overlays(). + * by of_unittest_remove_tracked_overlays(). * * - apply overlay_gpio_01 * - apply overlay_gpio_02a @@ -1905,86 +1914,70 @@ static const char *overlay_name_from_nr(int nr) static const char *bus_path = "/testcase-data/overlay-node/test-bus"; -/* FIXME: it is NOT guaranteed that overlay ids are assigned in sequence */ - -#define MAX_UNITTEST_OVERLAYS 256 -static unsigned long overlay_id_bits[BITS_TO_LONGS(MAX_UNITTEST_OVERLAYS)]; -static int overlay_first_id = -1; +#define MAX_TRACK_OVCS_IDS 256 -static long of_unittest_overlay_tracked(int id) -{ - if (WARN_ON(id >= MAX_UNITTEST_OVERLAYS)) - return 0; - return overlay_id_bits[BIT_WORD(id)] & BIT_MASK(id); -} +static int track_ovcs_id[MAX_TRACK_OVCS_IDS]; +static int track_ovcs_id_overlay_nr[MAX_TRACK_OVCS_IDS]; +static int track_ovcs_id_cnt; -static void of_unittest_track_overlay(int id) +static void of_unittest_track_overlay(int ovcs_id, int overlay_nr) { - if (overlay_first_id < 0) - overlay_first_id = id; - id -= overlay_first_id; - - if (WARN_ON(id >= MAX_UNITTEST_OVERLAYS)) + if (WARN_ON(track_ovcs_id_cnt >= MAX_TRACK_OVCS_IDS)) return; - overlay_id_bits[BIT_WORD(id)] |= BIT_MASK(id); + + track_ovcs_id[track_ovcs_id_cnt] = ovcs_id; + track_ovcs_id_overlay_nr[track_ovcs_id_cnt] = overlay_nr; + track_ovcs_id_cnt++; } -static void of_unittest_untrack_overlay(int id) +static void of_unittest_untrack_overlay(int ovcs_id) { - if (overlay_first_id < 0) + if (WARN_ON(track_ovcs_id_cnt < 1)) return; - id -= overlay_first_id; - if (WARN_ON(id >= MAX_UNITTEST_OVERLAYS)) - return; - overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id); -} -static void of_unittest_destroy_tracked_overlays(void) -{ - int id, ret, defers, ovcs_id; + track_ovcs_id_cnt--; - if (overlay_first_id < 0) - return; + /* If out of synch then test is broken. Do not try to recover. */ + WARN_ON(track_ovcs_id[track_ovcs_id_cnt] != ovcs_id); +} - /* try until no defers */ - do { - defers = 0; - /* remove in reverse order */ - for (id = MAX_UNITTEST_OVERLAYS - 1; id >= 0; id--) { - if (!of_unittest_overlay_tracked(id)) - continue; +static void of_unittest_remove_tracked_overlays(void) +{ + int ret, ovcs_id, overlay_nr, save_ovcs_id; + const char *overlay_name; - ovcs_id = id + overlay_first_id; - ret = of_overlay_remove(&ovcs_id); - if (ret == -ENODEV) { - pr_warn("%s: no overlay to destroy for #%d\n", - __func__, id + overlay_first_id); - continue; - } - if (ret != 0) { - defers++; - pr_warn("%s: overlay destroy failed for #%d\n", - __func__, id + overlay_first_id); - continue; - } + while (track_ovcs_id_cnt > 0) { - of_unittest_untrack_overlay(id); + ovcs_id = track_ovcs_id[track_ovcs_id_cnt - 1]; + overlay_nr = track_ovcs_id_overlay_nr[track_ovcs_id_cnt - 1]; + save_ovcs_id = ovcs_id; + ret = of_overlay_remove(&ovcs_id); + if (ret == -ENODEV) { + overlay_name = overlay_name_from_nr(overlay_nr); + pr_warn("%s: of_overlay_remove() for overlay \"%s\" failed, ret = %d\n", + __func__, overlay_name, ret); } - } while (defers > 0); + of_unittest_untrack_overlay(save_ovcs_id); + } + } -static int __init of_unittest_apply_overlay(int overlay_nr, int *overlay_id) +static int __init of_unittest_apply_overlay(int overlay_nr, int *ovcs_id) { + /* + * The overlay will be tracked, thus it will be removed + * by of_unittest_remove_tracked_overlays(). + */ + const char *overlay_name; overlay_name = overlay_name_from_nr(overlay_nr); - if (!overlay_data_apply(overlay_name, overlay_id)) { - unittest(0, "could not apply overlay \"%s\"\n", - overlay_name); + if (!overlay_data_apply(overlay_name, ovcs_id)) { + unittest(0, "could not apply overlay \"%s\"\n", overlay_name); return -EFAULT; } - of_unittest_track_overlay(*overlay_id); + of_unittest_track_overlay(*ovcs_id, overlay_nr); return 0; } @@ -2029,7 +2022,7 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr, int unittest_nr, int before, int after, enum overlay_type ovtype) { - int ret, ovcs_id, save_id; + int ret, ovcs_id, save_ovcs_id; /* unittest device must be in before state */ if (of_unittest_device_exists(unittest_nr, ovtype) != before) { @@ -2057,7 +2050,7 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr, return -EINVAL; } - save_id = ovcs_id; + save_ovcs_id = ovcs_id; ret = of_overlay_remove(&ovcs_id); if (ret != 0) { unittest(0, "%s failed to be destroyed @\"%s\"\n", @@ -2065,7 +2058,7 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr, unittest_path(unittest_nr, ovtype)); return ret; } - of_unittest_untrack_overlay(save_id); + of_unittest_untrack_overlay(save_ovcs_id); /* unittest device must be again in before state */ if (of_unittest_device_exists(unittest_nr, PDEV_OVERLAY) != before) { @@ -2192,7 +2185,7 @@ static void __init of_unittest_overlay_5(void) /* test overlay application in sequence */ static void __init of_unittest_overlay_6(void) { - int i, ov_id[2], ovcs_id; + int i, save_ovcs_id[2], ovcs_id; int overlay_nr = 6, unittest_nr = 6; int before = 0, after = 1; const char *overlay_name; @@ -2225,8 +2218,8 @@ static void __init of_unittest_overlay_6(void) unittest(0, "could not apply overlay \"%s\"\n", overlay_name); return; } - ov_id[0] = ovcs_id; - of_unittest_track_overlay(ov_id[0]); + save_ovcs_id[0] = ovcs_id; + of_unittest_track_overlay(ovcs_id, overlay_nr + 0); EXPECT_END(KERN_INFO, "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status"); @@ -2242,8 +2235,8 @@ static void __init of_unittest_overlay_6(void) unittest(0, "could not apply overlay \"%s\"\n", overlay_name); return; } - ov_id[1] = ovcs_id; - of_unittest_track_overlay(ov_id[1]); + save_ovcs_id[1] = ovcs_id; + of_unittest_track_overlay(ovcs_id, overlay_nr + 1); EXPECT_END(KERN_INFO, "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status"); @@ -2263,7 +2256,7 @@ static void __init of_unittest_overlay_6(void) } for (i = 1; i >= 0; i--) { - ovcs_id = ov_id[i]; + ovcs_id = save_ovcs_id[i]; if (of_overlay_remove(&ovcs_id)) { unittest(0, "%s failed destroy @\"%s\"\n", overlay_name_from_nr(overlay_nr + i), @@ -2271,7 +2264,7 @@ static void __init of_unittest_overlay_6(void) PDEV_OVERLAY)); return; } - of_unittest_untrack_overlay(ov_id[i]); + of_unittest_untrack_overlay(save_ovcs_id[i]); } for (i = 0; i < 2; i++) { @@ -2294,7 +2287,7 @@ static void __init of_unittest_overlay_6(void) /* test overlay application in sequence */ static void __init of_unittest_overlay_8(void) { - int i, ov_id[2], ovcs_id; + int i, save_ovcs_id[2], ovcs_id; int overlay_nr = 8, unittest_nr = 8; const char *overlay_name; int ret; @@ -2316,8 +2309,8 @@ static void __init of_unittest_overlay_8(void) if (!ret) return; - ov_id[0] = ovcs_id; - of_unittest_track_overlay(ov_id[0]); + save_ovcs_id[0] = ovcs_id; + of_unittest_track_overlay(ovcs_id, overlay_nr + 0); overlay_name = overlay_name_from_nr(overlay_nr + 1); @@ -2335,11 +2328,11 @@ static void __init of_unittest_overlay_8(void) return; } - ov_id[1] = ovcs_id; - of_unittest_track_overlay(ov_id[1]); + save_ovcs_id[1] = ovcs_id; + of_unittest_track_overlay(ovcs_id, overlay_nr + 1); /* now try to remove first overlay (it should fail) */ - ovcs_id = ov_id[0]; + ovcs_id = save_ovcs_id[0]; EXPECT_BEGIN(KERN_INFO, "OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8"); @@ -2356,6 +2349,10 @@ static void __init of_unittest_overlay_8(void) "OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8"); if (!ret) { + /* + * Should never get here. If we do, expect a lot of + * subsequent tracking and overlay removal related errors. + */ unittest(0, "%s was destroyed @\"%s\"\n", overlay_name_from_nr(overlay_nr + 0), unittest_path(unittest_nr, @@ -2365,7 +2362,7 @@ static void __init of_unittest_overlay_8(void) /* removing them in order should work */ for (i = 1; i >= 0; i--) { - ovcs_id = ov_id[i]; + ovcs_id = save_ovcs_id[i]; if (of_overlay_remove(&ovcs_id)) { unittest(0, "%s not destroyed @\"%s\"\n", overlay_name_from_nr(overlay_nr + i), @@ -2373,7 +2370,7 @@ static void __init of_unittest_overlay_8(void) PDEV_OVERLAY)); return; } - of_unittest_untrack_overlay(ov_id[i]); + of_unittest_untrack_overlay(save_ovcs_id[i]); } unittest(1, "overlay test %d passed\n", 8); @@ -2805,7 +2802,7 @@ static void __init of_unittest_overlay(void) of_unittest_overlay_gpio(); - of_unittest_destroy_tracked_overlays(); + of_unittest_remove_tracked_overlays(); out: of_node_put(bus_np); @@ -2837,7 +2834,7 @@ struct overlay_info { uint8_t *dtb_begin; uint8_t *dtb_end; int expected_result; - int overlay_id; + int ovcs_id; char *name; }; @@ -2991,7 +2988,7 @@ void __init unittest_unflatten_overlay_base(void) * * Return 0 on unexpected error. */ -static int __init overlay_data_apply(const char *overlay_name, int *overlay_id) +static int __init overlay_data_apply(const char *overlay_name, int *ovcs_id) { struct overlay_info *info; int found = 0; @@ -3013,9 +3010,9 @@ static int __init overlay_data_apply(const char *overlay_name, int *overlay_id) if (!size) pr_err("no overlay data for %s\n", overlay_name); - ret = of_overlay_fdt_apply(info->dtb_begin, size, &info->overlay_id); - if (overlay_id) - *overlay_id = info->overlay_id; + ret = of_overlay_fdt_apply(info->dtb_begin, size, &info->ovcs_id); + if (ovcs_id) + *ovcs_id = info->ovcs_id; if (ret < 0) goto out; |