10
10
#include <linux/module.h>
11
11
#include <linux/of.h>
12
12
#include <linux/of_irq.h>
13
+ #include <linux/of_platform.h>
13
14
#include <linux/list.h>
14
15
#include <linux/mutex.h>
15
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
461
static int __init of_selftest (void )
431
462
{
432
463
struct device_node * np ;
@@ -445,6 +476,7 @@ static int __init of_selftest(void)
445
476
of_selftest_parse_interrupts ();
446
477
of_selftest_parse_interrupts_extended ();
447
478
of_selftest_match_node ();
479
+ of_selftest_platform_populate ();
448
480
pr_info ("end of selftest - %i passed, %i failed\n" ,
449
481
selftest_results .passed , selftest_results .failed );
450
482
return 0 ;
0 commit comments