diff options
author | Pantelis Antoniou <pantelis.antoniou@konsulko.com> | 2014-12-19 07:34:34 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2015-01-23 08:10:07 -0500 |
commit | 6b1271de3723a7957c7cc6a7f36ea114f557e730 (patch) | |
tree | 7a3ebbd46b197ca193d47182d87bc1831e5c7ed5 /drivers/of | |
parent | 15204ab1ebc5aba608cd19c83c37b98438b938b0 (diff) |
of/unittest: Overlays with sub-devices tests
Introduce selftests for overlays using sub-devices present
in children nodes.
Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/unittest-data/tests-overlay.dtsi | 55 | ||||
-rw-r--r-- | drivers/of/unittest.c | 39 |
2 files changed, 94 insertions, 0 deletions
diff --git a/drivers/of/unittest-data/tests-overlay.dtsi b/drivers/of/unittest-data/tests-overlay.dtsi index 75976da22b2e..a2b687d5f324 100644 --- a/drivers/of/unittest-data/tests-overlay.dtsi +++ b/drivers/of/unittest-data/tests-overlay.dtsi | |||
@@ -176,5 +176,60 @@ | |||
176 | }; | 176 | }; |
177 | }; | 177 | }; |
178 | 178 | ||
179 | overlay10 { | ||
180 | fragment@0 { | ||
181 | target-path = "/testcase-data/overlay-node/test-bus"; | ||
182 | __overlay__ { | ||
183 | |||
184 | /* suppress DTC warning */ | ||
185 | #address-cells = <1>; | ||
186 | #size-cells = <0>; | ||
187 | |||
188 | test-selftest10 { | ||
189 | compatible = "selftest"; | ||
190 | status = "okay"; | ||
191 | reg = <10>; | ||
192 | |||
193 | #address-cells = <1>; | ||
194 | #size-cells = <0>; | ||
195 | |||
196 | test-selftest101 { | ||
197 | compatible = "selftest"; | ||
198 | status = "okay"; | ||
199 | reg = <1>; | ||
200 | }; | ||
201 | |||
202 | }; | ||
203 | }; | ||
204 | }; | ||
205 | }; | ||
206 | |||
207 | overlay11 { | ||
208 | fragment@0 { | ||
209 | target-path = "/testcase-data/overlay-node/test-bus"; | ||
210 | __overlay__ { | ||
211 | |||
212 | /* suppress DTC warning */ | ||
213 | #address-cells = <1>; | ||
214 | #size-cells = <0>; | ||
215 | |||
216 | test-selftest11 { | ||
217 | compatible = "selftest"; | ||
218 | status = "okay"; | ||
219 | reg = <11>; | ||
220 | |||
221 | #address-cells = <1>; | ||
222 | #size-cells = <0>; | ||
223 | |||
224 | test-selftest111 { | ||
225 | compatible = "selftest"; | ||
226 | status = "okay"; | ||
227 | reg = <1>; | ||
228 | }; | ||
229 | |||
230 | }; | ||
231 | }; | ||
232 | }; | ||
233 | }; | ||
179 | }; | 234 | }; |
180 | }; | 235 | }; |
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 844838e11ef1..41a4a138f53b 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -978,6 +978,9 @@ static int selftest_probe(struct platform_device *pdev) | |||
978 | } | 978 | } |
979 | 979 | ||
980 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 980 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); |
981 | |||
982 | of_platform_populate(np, NULL, NULL, &pdev->dev); | ||
983 | |||
981 | return 0; | 984 | return 0; |
982 | } | 985 | } |
983 | 986 | ||
@@ -1385,6 +1388,39 @@ static void of_selftest_overlay_8(void) | |||
1385 | selftest(1, "overlay test %d passed\n", 8); | 1388 | selftest(1, "overlay test %d passed\n", 8); |
1386 | } | 1389 | } |
1387 | 1390 | ||
1391 | /* test insertion of a bus with parent devices */ | ||
1392 | static void of_selftest_overlay_10(void) | ||
1393 | { | ||
1394 | int ret; | ||
1395 | char *child_path; | ||
1396 | |||
1397 | /* device should disable */ | ||
1398 | ret = of_selftest_apply_overlay_check(10, 10, 0, 1); | ||
1399 | if (selftest(ret == 0, "overlay test %d failed; overlay application\n", 10)) | ||
1400 | return; | ||
1401 | |||
1402 | child_path = kasprintf(GFP_KERNEL, "%s/test-selftest101", | ||
1403 | selftest_path(10)); | ||
1404 | if (selftest(child_path, "overlay test %d failed; kasprintf\n", 10)) | ||
1405 | return; | ||
1406 | |||
1407 | ret = of_path_platform_device_exists(child_path); | ||
1408 | kfree(child_path); | ||
1409 | if (selftest(ret, "overlay test %d failed; no child device\n", 10)) | ||
1410 | return; | ||
1411 | } | ||
1412 | |||
1413 | /* test insertion of a bus with parent devices (and revert) */ | ||
1414 | static void of_selftest_overlay_11(void) | ||
1415 | { | ||
1416 | int ret; | ||
1417 | |||
1418 | /* device should disable */ | ||
1419 | ret = of_selftest_apply_revert_overlay_check(11, 11, 0, 1); | ||
1420 | if (selftest(ret == 0, "overlay test %d failed; overlay application\n", 11)) | ||
1421 | return; | ||
1422 | } | ||
1423 | |||
1388 | static void __init of_selftest_overlay(void) | 1424 | static void __init of_selftest_overlay(void) |
1389 | { | 1425 | { |
1390 | struct device_node *bus_np = NULL; | 1426 | struct device_node *bus_np = NULL; |
@@ -1433,6 +1469,9 @@ static void __init of_selftest_overlay(void) | |||
1433 | of_selftest_overlay_6(); | 1469 | of_selftest_overlay_6(); |
1434 | of_selftest_overlay_8(); | 1470 | of_selftest_overlay_8(); |
1435 | 1471 | ||
1472 | of_selftest_overlay_10(); | ||
1473 | of_selftest_overlay_11(); | ||
1474 | |||
1436 | out: | 1475 | out: |
1437 | of_node_put(bus_np); | 1476 | of_node_put(bus_np); |
1438 | } | 1477 | } |