@@ -456,6 +456,9 @@ static void __init of_unittest_parse_phandle_with_args(void)
456
456
457
457
unittest (passed , "index %i - data error on node %pOF rc=%i\n" ,
458
458
i , args .np , rc );
459
+
460
+ if (rc == 0 )
461
+ of_node_put (args .np );
459
462
}
460
463
461
464
/* Check for missing list property */
@@ -545,8 +548,9 @@ static void __init of_unittest_parse_phandle_with_args(void)
545
548
546
549
static void __init of_unittest_parse_phandle_with_args_map (void )
547
550
{
548
- struct device_node * np , * p0 , * p1 , * p2 , * p3 ;
551
+ struct device_node * np , * p [ 6 ] = {} ;
549
552
struct of_phandle_args args ;
553
+ unsigned int prefs [6 ];
550
554
int i , rc ;
551
555
552
556
np = of_find_node_by_path ("/testcase-data/phandle-tests/consumer-b" );
@@ -555,34 +559,24 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
555
559
return ;
556
560
}
557
561
558
- p0 = of_find_node_by_path ("/testcase-data/phandle-tests/provider0" );
559
- if (!p0 ) {
560
- pr_err ("missing testcase data\n" );
561
- return ;
562
- }
563
-
564
- p1 = of_find_node_by_path ("/testcase-data/phandle-tests/provider1" );
565
- if (!p1 ) {
566
- pr_err ("missing testcase data\n" );
567
- return ;
568
- }
569
-
570
- p2 = of_find_node_by_path ("/testcase-data/phandle-tests/provider2" );
571
- if (!p2 ) {
572
- pr_err ("missing testcase data\n" );
573
- return ;
574
- }
575
-
576
- p3 = of_find_node_by_path ("/testcase-data/phandle-tests/provider3" );
577
- if (!p3 ) {
578
- pr_err ("missing testcase data\n" );
579
- return ;
562
+ p [0 ] = of_find_node_by_path ("/testcase-data/phandle-tests/provider0" );
563
+ p [1 ] = of_find_node_by_path ("/testcase-data/phandle-tests/provider1" );
564
+ p [2 ] = of_find_node_by_path ("/testcase-data/phandle-tests/provider2" );
565
+ p [3 ] = of_find_node_by_path ("/testcase-data/phandle-tests/provider3" );
566
+ p [4 ] = of_find_node_by_path ("/testcase-data/phandle-tests/provider4" );
567
+ p [5 ] = of_find_node_by_path ("/testcase-data/phandle-tests/provider5" );
568
+ for (i = 0 ; i < ARRAY_SIZE (p ); ++ i ) {
569
+ if (!p [i ]) {
570
+ pr_err ("missing testcase data\n" );
571
+ return ;
572
+ }
573
+ prefs [i ] = kref_read (& p [i ]-> kobj .kref );
580
574
}
581
575
582
576
rc = of_count_phandle_with_args (np , "phandle-list" , "#phandle-cells" );
583
- unittest (rc == 7 , "of_count_phandle_with_args() returned %i, expected 7\n" , rc );
577
+ unittest (rc == 8 , "of_count_phandle_with_args() returned %i, expected 7\n" , rc );
584
578
585
- for (i = 0 ; i < 8 ; i ++ ) {
579
+ for (i = 0 ; i < 9 ; i ++ ) {
586
580
bool passed = true;
587
581
588
582
memset (& args , 0 , sizeof (args ));
@@ -593,13 +587,13 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
593
587
switch (i ) {
594
588
case 0 :
595
589
passed &= !rc ;
596
- passed &= (args .np == p1 );
590
+ passed &= (args .np == p [ 1 ] );
597
591
passed &= (args .args_count == 1 );
598
592
passed &= (args .args [0 ] == 1 );
599
593
break ;
600
594
case 1 :
601
595
passed &= !rc ;
602
- passed &= (args .np == p3 );
596
+ passed &= (args .np == p [ 3 ] );
603
597
passed &= (args .args_count == 3 );
604
598
passed &= (args .args [0 ] == 2 );
605
599
passed &= (args .args [1 ] == 5 );
@@ -610,28 +604,36 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
610
604
break ;
611
605
case 3 :
612
606
passed &= !rc ;
613
- passed &= (args .np == p0 );
607
+ passed &= (args .np == p [ 0 ] );
614
608
passed &= (args .args_count == 0 );
615
609
break ;
616
610
case 4 :
617
611
passed &= !rc ;
618
- passed &= (args .np == p1 );
612
+ passed &= (args .np == p [ 1 ] );
619
613
passed &= (args .args_count == 1 );
620
614
passed &= (args .args [0 ] == 3 );
621
615
break ;
622
616
case 5 :
623
617
passed &= !rc ;
624
- passed &= (args .np == p0 );
618
+ passed &= (args .np == p [ 0 ] );
625
619
passed &= (args .args_count == 0 );
626
620
break ;
627
621
case 6 :
628
622
passed &= !rc ;
629
- passed &= (args .np == p2 );
623
+ passed &= (args .np == p [ 2 ] );
630
624
passed &= (args .args_count == 2 );
631
625
passed &= (args .args [0 ] == 15 );
632
626
passed &= (args .args [1 ] == 0x20 );
633
627
break ;
634
628
case 7 :
629
+ passed &= !rc ;
630
+ passed &= (args .np == p [3 ]);
631
+ passed &= (args .args_count == 3 );
632
+ passed &= (args .args [0 ] == 2 );
633
+ passed &= (args .args [1 ] == 5 );
634
+ passed &= (args .args [2 ] == 3 );
635
+ break ;
636
+ case 8 :
635
637
passed &= (rc == - ENOENT );
636
638
break ;
637
639
default :
@@ -640,6 +642,9 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
640
642
641
643
unittest (passed , "index %i - data error on node %s rc=%i\n" ,
642
644
i , args .np -> full_name , rc );
645
+
646
+ if (rc == 0 )
647
+ of_node_put (args .np );
643
648
}
644
649
645
650
/* Check for missing list property */
@@ -686,6 +691,13 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
686
691
"OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found 1" );
687
692
688
693
unittest (rc == - EINVAL , "expected:%i got:%i\n" , - EINVAL , rc );
694
+
695
+ for (i = 0 ; i < ARRAY_SIZE (p ); ++ i ) {
696
+ unittest (prefs [i ] == kref_read (& p [i ]-> kobj .kref ),
697
+ "provider%d: expected:%d got:%d\n" ,
698
+ i , prefs [i ], kref_read (& p [i ]-> kobj .kref ));
699
+ of_node_put (p [i ]);
700
+ }
689
701
}
690
702
691
703
static void __init of_unittest_property_string (void )
0 commit comments