aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2014-05-13 11:07:54 -0400
committerRob Herring <robh@kernel.org>2014-05-13 15:11:11 -0400
commitfb2caa50fbacd21719a90dd66b617ce3cb4fd6d7 (patch)
tree4a4766604759d418b75c8567cf8f0fdeaa85b59d /drivers/of
parent7d1cdc89c54d2cb8157cf1f36fc65e8583d26484 (diff)
of/selftest: add testcase for nodes with same name and address
Add a test case for nodes which have the same name and same non-translatable unit address. Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Grant Likely <grant.likely@linaro.org> Reviewed-by: Frank Rowand <frank.rowand@sonymobile.com>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/selftest.c20
-rw-r--r--drivers/of/testcase-data/testcases.dtsi1
-rw-r--r--drivers/of/testcase-data/tests-platform.dtsi35
3 files changed, 55 insertions, 1 deletions
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index c1d7d38009f1..2588faaaa305 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -431,8 +431,12 @@ static void __init of_selftest_match_node(void)
431static void __init of_selftest_platform_populate(void) 431static void __init of_selftest_platform_populate(void)
432{ 432{
433 int irq; 433 int irq;
434 struct device_node *np; 434 struct device_node *np, *child;
435 struct platform_device *pdev; 435 struct platform_device *pdev;
436 struct of_device_id match[] = {
437 { .compatible = "test-device", },
438 {}
439 };
436 440
437 np = of_find_node_by_path("/testcase-data"); 441 np = of_find_node_by_path("/testcase-data");
438 of_platform_populate(np, of_default_bus_match_table, NULL, NULL); 442 of_platform_populate(np, of_default_bus_match_table, NULL, NULL);
@@ -452,6 +456,20 @@ static void __init of_selftest_platform_populate(void)
452 irq = platform_get_irq(pdev, 0); 456 irq = platform_get_irq(pdev, 0);
453 selftest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq); 457 selftest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq);
454 458
459 np = of_find_node_by_path("/testcase-data/platform-tests");
460 if (!np) {
461 pr_err("No testcase data in device tree\n");
462 return;
463 }
464
465 for_each_child_of_node(np, child) {
466 struct device_node *grandchild;
467 of_platform_populate(child, match, NULL, NULL);
468 for_each_child_of_node(child, grandchild)
469 selftest(of_find_device_by_node(grandchild),
470 "Could not create device for node '%s'\n",
471 grandchild->name);
472 }
455} 473}
456 474
457static int __init of_selftest(void) 475static int __init of_selftest(void)
diff --git a/drivers/of/testcase-data/testcases.dtsi b/drivers/of/testcase-data/testcases.dtsi
index 3a5b75a8e4d7..6d8d980ac858 100644
--- a/drivers/of/testcase-data/testcases.dtsi
+++ b/drivers/of/testcase-data/testcases.dtsi
@@ -1,3 +1,4 @@
1#include "tests-phandle.dtsi" 1#include "tests-phandle.dtsi"
2#include "tests-interrupts.dtsi" 2#include "tests-interrupts.dtsi"
3#include "tests-match.dtsi" 3#include "tests-match.dtsi"
4#include "tests-platform.dtsi"
diff --git a/drivers/of/testcase-data/tests-platform.dtsi b/drivers/of/testcase-data/tests-platform.dtsi
new file mode 100644
index 000000000000..eb20eeb2b062
--- /dev/null
+++ b/drivers/of/testcase-data/tests-platform.dtsi
@@ -0,0 +1,35 @@
1
2/ {
3 testcase-data {
4 platform-tests {
5 #address-cells = <1>;
6 #size-cells = <0>;
7
8 test-device@0 {
9 compatible = "test-device";
10 reg = <0x0>;
11
12 #address-cells = <1>;
13 #size-cells = <0>;
14
15 dev@100 {
16 compatible = "test-sub-device";
17 reg = <0x100>;
18 };
19 };
20
21 test-device@1 {
22 compatible = "test-device";
23 reg = <0x1>;
24
25 #address-cells = <1>;
26 #size-cells = <0>;
27
28 dev@100 {
29 compatible = "test-sub-device";
30 reg = <0x100>;
31 };
32 };
33 };
34 };
35};