Skip to content

Commit fb2caa5

Browse files
committed
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 <[email protected]> Reviewed-by: Grant Likely <[email protected]> Reviewed-by: Frank Rowand <[email protected]>
1 parent 7d1cdc8 commit fb2caa5

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

drivers/of/selftest.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,12 @@ static void __init of_selftest_match_node(void)
431431
static void __init of_selftest_platform_populate(void)
432432
{
433433
int irq;
434-
struct device_node *np;
434+
struct device_node *np, *child;
435435
struct platform_device *pdev;
436+
struct of_device_id match[] = {
437+
{ .compatible = "test-device", },
438+
{}
439+
};
436440

437441
np = of_find_node_by_path("/testcase-data");
438442
of_platform_populate(np, of_default_bus_match_table, NULL, NULL);
@@ -452,6 +456,20 @@ static void __init of_selftest_platform_populate(void)
452456
irq = platform_get_irq(pdev, 0);
453457
selftest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq);
454458

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+
}
455473
}
456474

457475
static int __init of_selftest(void)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#include "tests-phandle.dtsi"
22
#include "tests-interrupts.dtsi"
33
#include "tests-match.dtsi"
4+
#include "tests-platform.dtsi"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
};

0 commit comments

Comments
 (0)