Commit 160b1d4e authored by Frank Rowand's avatar Frank Rowand

of: unittest: find overlays[] entry by name instead of index

One accessor of overlays[] was using a hard coded index value to
find the correct array entry instead of searching for the entry
containing the correct name.
Tested-by: default avatarAlan Tull <atull@kernel.org>
Signed-off-by: default avatarFrank Rowand <frank.rowand@sony.com>
parent 5babefb7
...@@ -2192,7 +2192,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop); ...@@ -2192,7 +2192,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop);
OVERLAY_INFO_EXTERN(overlay_bad_phandle); OVERLAY_INFO_EXTERN(overlay_bad_phandle);
OVERLAY_INFO_EXTERN(overlay_bad_symbol); OVERLAY_INFO_EXTERN(overlay_bad_symbol);
/* order of entries is hard-coded into users of overlays[] */ /* entries found by name */
static struct overlay_info overlays[] = { static struct overlay_info overlays[] = {
OVERLAY_INFO(overlay_base, -9999), OVERLAY_INFO(overlay_base, -9999),
OVERLAY_INFO(overlay, 0), OVERLAY_INFO(overlay, 0),
...@@ -2215,7 +2215,8 @@ static struct overlay_info overlays[] = { ...@@ -2215,7 +2215,8 @@ static struct overlay_info overlays[] = {
OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL), OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL),
OVERLAY_INFO(overlay_bad_phandle, -EINVAL), OVERLAY_INFO(overlay_bad_phandle, -EINVAL),
OVERLAY_INFO(overlay_bad_symbol, -EINVAL), OVERLAY_INFO(overlay_bad_symbol, -EINVAL),
{} /* end marker */
{.dtb_begin = NULL, .dtb_end = NULL, .expected_result = 0, .name = NULL}
}; };
static struct device_node *overlay_base_root; static struct device_node *overlay_base_root;
...@@ -2245,6 +2246,19 @@ void __init unittest_unflatten_overlay_base(void) ...@@ -2245,6 +2246,19 @@ void __init unittest_unflatten_overlay_base(void)
u32 data_size; u32 data_size;
void *new_fdt; void *new_fdt;
u32 size; u32 size;
int found = 0;
const char *overlay_name = "overlay_base";
for (info = overlays; info && info->name; info++) {
if (!strcmp(overlay_name, info->name)) {
found = 1;
break;
}
}
if (!found) {
pr_err("no overlay data for %s\n", overlay_name);
return;
}
info = &overlays[0]; info = &overlays[0];
...@@ -2292,11 +2306,10 @@ static int __init overlay_data_apply(const char *overlay_name, int *overlay_id) ...@@ -2292,11 +2306,10 @@ static int __init overlay_data_apply(const char *overlay_name, int *overlay_id)
{ {
struct overlay_info *info; struct overlay_info *info;
int found = 0; int found = 0;
int k;
int ret; int ret;
u32 size; u32 size;
for (k = 0, info = overlays; info && info->name; info++, k++) { for (info = overlays; info && info->name; info++) {
if (!strcmp(overlay_name, info->name)) { if (!strcmp(overlay_name, info->name)) {
found = 1; found = 1;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment