diff options
Diffstat (limited to 'drivers/of/selftest.c')
-rw-r--r-- | drivers/of/selftest.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index ae4450070503..fe70b86bcffb 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/of.h> | 11 | #include <linux/of.h> |
12 | #include <linux/of_irq.h> | 12 | #include <linux/of_irq.h> |
13 | #include <linux/of_platform.h> | ||
13 | #include <linux/list.h> | 14 | #include <linux/list.h> |
14 | #include <linux/mutex.h> | 15 | #include <linux/mutex.h> |
15 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
@@ -427,6 +428,36 @@ static void __init of_selftest_match_node(void) | |||
427 | } | 428 | } |
428 | } | 429 | } |
429 | 430 | ||
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 | |||
430 | static int __init of_selftest(void) | 461 | static int __init of_selftest(void) |
431 | { | 462 | { |
432 | struct device_node *np; | 463 | struct device_node *np; |
@@ -445,6 +476,7 @@ static int __init of_selftest(void) | |||
445 | of_selftest_parse_interrupts(); | 476 | of_selftest_parse_interrupts(); |
446 | of_selftest_parse_interrupts_extended(); | 477 | of_selftest_parse_interrupts_extended(); |
447 | of_selftest_match_node(); | 478 | of_selftest_match_node(); |
479 | of_selftest_platform_populate(); | ||
448 | pr_info("end of selftest - %i passed, %i failed\n", | 480 | pr_info("end of selftest - %i passed, %i failed\n", |
449 | selftest_results.passed, selftest_results.failed); | 481 | selftest_results.passed, selftest_results.failed); |
450 | return 0; | 482 | return 0; |