Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/4bafe338655beab6b244047e737c0c2aa60b613d.1690533838.git.geert+renesas@glider.be
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Geert Uytterhoeven and committed by
Rob Herring
b7a46e7b 35df904d

+18 -27
+18 -27
drivers/of/unittest.c
··· 2134 2134 return 0; 2135 2135 } 2136 2136 2137 - /* apply an overlay while checking before and after states */ 2138 - static int __init of_unittest_apply_overlay_check(int overlay_nr, 2137 + static int __init __of_unittest_apply_overlay_check(int overlay_nr, 2139 2138 int unittest_nr, int before, int after, 2140 2139 enum overlay_type ovtype) 2141 2140 { ··· 2166 2167 return -EINVAL; 2167 2168 } 2168 2169 2170 + return ovcs_id; 2171 + } 2172 + 2173 + /* apply an overlay while checking before and after states */ 2174 + static int __init of_unittest_apply_overlay_check(int overlay_nr, 2175 + int unittest_nr, int before, int after, 2176 + enum overlay_type ovtype) 2177 + { 2178 + int ovcs_id = __of_unittest_apply_overlay_check(overlay_nr, 2179 + unittest_nr, before, after, ovtype); 2180 + if (ovcs_id < 0) 2181 + return ovcs_id; 2182 + 2169 2183 return 0; 2170 2184 } 2171 2185 ··· 2189 2177 { 2190 2178 int ret, ovcs_id, save_ovcs_id; 2191 2179 2192 - /* unittest device must be in before state */ 2193 - if (of_unittest_device_exists(unittest_nr, ovtype) != before) { 2194 - unittest(0, "%s with device @\"%s\" %s\n", 2195 - overlay_name_from_nr(overlay_nr), 2196 - unittest_path(unittest_nr, ovtype), 2197 - !before ? "enabled" : "disabled"); 2198 - return -EINVAL; 2199 - } 2200 - 2201 - /* apply the overlay */ 2202 - ovcs_id = 0; 2203 - ret = of_unittest_apply_overlay(overlay_nr, &ovcs_id); 2204 - if (ret != 0) { 2205 - /* of_unittest_apply_overlay already called unittest() */ 2206 - return ret; 2207 - } 2208 - 2209 - /* unittest device must be in after state */ 2210 - if (of_unittest_device_exists(unittest_nr, ovtype) != after) { 2211 - unittest(0, "%s with device @\"%s\" %s\n", 2212 - overlay_name_from_nr(overlay_nr), 2213 - unittest_path(unittest_nr, ovtype), 2214 - !after ? "enabled" : "disabled"); 2215 - return -EINVAL; 2216 - } 2180 + ovcs_id = __of_unittest_apply_overlay_check(overlay_nr, unittest_nr, 2181 + before, after, ovtype); 2182 + if (ovcs_id < 0) 2183 + return ovcs_id; 2217 2184 2218 2185 /* remove the overlay */ 2219 2186 save_ovcs_id = ovcs_id;