Commit b7a46e7b authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Rob Herring

of: unittest: Merge of_unittest_apply{,_revert}_overlay_check()

of_unittest_apply_overlay_check() and the first part of
of_unittest_apply_revert_overlay_check() are identical.
Reduce code duplication by replacing them by two wrappers around a
common helper.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/4bafe338655beab6b244047e737c0c2aa60b613d.1690533838.git.geert+renesas@glider.beSigned-off-by: default avatarRob Herring <robh@kernel.org>
parent 35df904d
...@@ -2134,8 +2134,7 @@ static int __init of_unittest_apply_overlay(int overlay_nr, int *ovcs_id) ...@@ -2134,8 +2134,7 @@ static int __init of_unittest_apply_overlay(int overlay_nr, int *ovcs_id)
return 0; return 0;
} }
/* apply an overlay while checking before and after states */ static int __init __of_unittest_apply_overlay_check(int overlay_nr,
static int __init of_unittest_apply_overlay_check(int overlay_nr,
int unittest_nr, int before, int after, int unittest_nr, int before, int after,
enum overlay_type ovtype) enum overlay_type ovtype)
{ {
...@@ -2167,6 +2166,19 @@ static int __init of_unittest_apply_overlay_check(int overlay_nr, ...@@ -2167,6 +2166,19 @@ static int __init of_unittest_apply_overlay_check(int overlay_nr,
return -EINVAL; return -EINVAL;
} }
return ovcs_id;
}
/* apply an overlay while checking before and after states */
static int __init of_unittest_apply_overlay_check(int overlay_nr,
int unittest_nr, int before, int after,
enum overlay_type ovtype)
{
int ovcs_id = __of_unittest_apply_overlay_check(overlay_nr,
unittest_nr, before, after, ovtype);
if (ovcs_id < 0)
return ovcs_id;
return 0; return 0;
} }
...@@ -2177,31 +2189,10 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr, ...@@ -2177,31 +2189,10 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr,
{ {
int ret, ovcs_id, save_ovcs_id; int ret, ovcs_id, save_ovcs_id;
/* unittest device must be in before state */ ovcs_id = __of_unittest_apply_overlay_check(overlay_nr, unittest_nr,
if (of_unittest_device_exists(unittest_nr, ovtype) != before) { before, after, ovtype);
unittest(0, "%s with device @\"%s\" %s\n", if (ovcs_id < 0)
overlay_name_from_nr(overlay_nr), return ovcs_id;
unittest_path(unittest_nr, ovtype),
!before ? "enabled" : "disabled");
return -EINVAL;
}
/* apply the overlay */
ovcs_id = 0;
ret = of_unittest_apply_overlay(overlay_nr, &ovcs_id);
if (ret != 0) {
/* of_unittest_apply_overlay already called unittest() */
return ret;
}
/* unittest device must be in after state */
if (of_unittest_device_exists(unittest_nr, ovtype) != after) {
unittest(0, "%s with device @\"%s\" %s\n",
overlay_name_from_nr(overlay_nr),
unittest_path(unittest_nr, ovtype),
!after ? "enabled" : "disabled");
return -EINVAL;
}
/* remove the overlay */ /* remove the overlay */
save_ovcs_id = ovcs_id; save_ovcs_id = ovcs_id;
......
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