Skip to content

Commit 82c0f58

Browse files
robherringglikely
authored andcommitted
of: selftest: add deferred probe interrupt test
Signed-off-by: Rob Herring <[email protected]> [grant.likely: fixed failure when root node specifies the interrupt parent] Signed-off-by: Grant Likely <[email protected]>
1 parent ae107d0 commit 82c0f58

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

drivers/of/selftest.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/module.h>
1111
#include <linux/of.h>
1212
#include <linux/of_irq.h>
13+
#include <linux/of_platform.h>
1314
#include <linux/list.h>
1415
#include <linux/mutex.h>
1516
#include <linux/slab.h>
@@ -427,6 +428,36 @@ static void __init of_selftest_match_node(void)
427428
}
428429
}
429430

431+
static void __init of_selftest_platform_populate(void)
432+
{
433+
int irq;
434+
struct device_node *np;
435+
struct platform_device *pdev;
436+
437+
np = of_find_node_by_path("/testcase-data");
438+
of_platform_populate(np, of_default_bus_match_table, NULL, NULL);
439+
440+
/* Test that a missing irq domain returns -EPROBE_DEFER */
441+
np = of_find_node_by_path("/testcase-data/testcase-device1");
442+
pdev = of_find_device_by_node(np);
443+
if (!pdev)
444+
selftest(0, "device 1 creation failed\n");
445+
irq = platform_get_irq(pdev, 0);
446+
if (irq != -EPROBE_DEFER)
447+
selftest(0, "device deferred probe failed - %d\n", irq);
448+
449+
/* Test that a parsing failure does not return -EPROBE_DEFER */
450+
np = of_find_node_by_path("/testcase-data/testcase-device2");
451+
pdev = of_find_device_by_node(np);
452+
if (!pdev)
453+
selftest(0, "device 2 creation failed\n");
454+
irq = platform_get_irq(pdev, 0);
455+
if (irq >= 0 || irq == -EPROBE_DEFER)
456+
selftest(0, "device parsing error failed - %d\n", irq);
457+
458+
selftest(1, "passed");
459+
}
460+
430461
static int __init of_selftest(void)
431462
{
432463
struct device_node *np;
@@ -445,6 +476,7 @@ static int __init of_selftest(void)
445476
of_selftest_parse_interrupts();
446477
of_selftest_parse_interrupts_extended();
447478
of_selftest_match_node();
479+
of_selftest_platform_populate();
448480
pr_info("end of selftest - %i passed, %i failed\n",
449481
selftest_results.passed, selftest_results.failed);
450482
return 0;

drivers/of/testcase-data/tests-interrupts.dtsi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,18 @@
5454
<&test_intmap1 1 2>;
5555
};
5656
};
57+
58+
testcase-device1 {
59+
compatible = "testcase-device";
60+
interrupt-parent = <&test_intc0>;
61+
interrupts = <1>;
62+
};
63+
64+
testcase-device2 {
65+
compatible = "testcase-device";
66+
interrupt-parent = <&test_intc2>;
67+
interrupts = <1>; /* invalid specifier - too short */
68+
};
5769
};
70+
5871
};

0 commit comments

Comments
 (0)