aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/unittest.c
diff options
context:
space:
mode:
authorFrank Rowand <frank.rowand@sony.com>2018-10-04 23:41:03 -0400
committerFrank Rowand <frank.rowand@sony.com>2018-11-09 01:12:31 -0500
commit160b1d4e4127f0ef5d9ac281b6fa6ef1fb78c45f (patch)
treebe20d4b09e04c66e5dd19e127a7ae39c9ed1376f /drivers/of/unittest.c
parent5babefb7f7ab1f23861336d511cc666fa45ede82 (diff)
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: Alan Tull <atull@kernel.org> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r--drivers/of/unittest.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index d625a91a7f60..fe01c5869b0f 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -2192,7 +2192,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop);
2192OVERLAY_INFO_EXTERN(overlay_bad_phandle); 2192OVERLAY_INFO_EXTERN(overlay_bad_phandle);
2193OVERLAY_INFO_EXTERN(overlay_bad_symbol); 2193OVERLAY_INFO_EXTERN(overlay_bad_symbol);
2194 2194
2195/* order of entries is hard-coded into users of overlays[] */ 2195/* entries found by name */
2196static struct overlay_info overlays[] = { 2196static struct overlay_info overlays[] = {
2197 OVERLAY_INFO(overlay_base, -9999), 2197 OVERLAY_INFO(overlay_base, -9999),
2198 OVERLAY_INFO(overlay, 0), 2198 OVERLAY_INFO(overlay, 0),
@@ -2215,7 +2215,8 @@ static struct overlay_info overlays[] = {
2215 OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL), 2215 OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL),
2216 OVERLAY_INFO(overlay_bad_phandle, -EINVAL), 2216 OVERLAY_INFO(overlay_bad_phandle, -EINVAL),
2217 OVERLAY_INFO(overlay_bad_symbol, -EINVAL), 2217 OVERLAY_INFO(overlay_bad_symbol, -EINVAL),
2218 {} 2218 /* end marker */
2219 {.dtb_begin = NULL, .dtb_end = NULL, .expected_result = 0, .name = NULL}
2219}; 2220};
2220 2221
2221static struct device_node *overlay_base_root; 2222static struct device_node *overlay_base_root;
@@ -2245,6 +2246,19 @@ void __init unittest_unflatten_overlay_base(void)
2245 u32 data_size; 2246 u32 data_size;
2246 void *new_fdt; 2247 void *new_fdt;
2247 u32 size; 2248 u32 size;
2249 int found = 0;
2250 const char *overlay_name = "overlay_base";
2251
2252 for (info = overlays; info && info->name; info++) {
2253 if (!strcmp(overlay_name, info->name)) {
2254 found = 1;
2255 break;
2256 }
2257 }
2258 if (!found) {
2259 pr_err("no overlay data for %s\n", overlay_name);
2260 return;
2261 }
2248 2262
2249 info = &overlays[0]; 2263 info = &overlays[0];
2250 2264
@@ -2292,11 +2306,10 @@ static int __init overlay_data_apply(const char *overlay_name, int *overlay_id)
2292{ 2306{
2293 struct overlay_info *info; 2307 struct overlay_info *info;
2294 int found = 0; 2308 int found = 0;
2295 int k;
2296 int ret; 2309 int ret;
2297 u32 size; 2310 u32 size;
2298 2311
2299 for (k = 0, info = overlays; info && info->name; info++, k++) { 2312 for (info = overlays; info && info->name; info++) {
2300 if (!strcmp(overlay_name, info->name)) { 2313 if (!strcmp(overlay_name, info->name)) {
2301 found = 1; 2314 found = 1;
2302 break; 2315 break;