@@ -404,7 +404,6 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
404404 struct pinctrl_map * * map ,
405405 unsigned int * num_maps )
406406{
407- struct device_node * child ;
408407 int ret ;
409408
410409 * map = NULL ;
@@ -414,12 +413,10 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
414413 if (ret < 0 )
415414 return ret ;
416415
417- for_each_child_of_node (np , child ) {
416+ for_each_child_of_node_scoped (np , child ) {
418417 ret = rzn1_dt_node_to_map_one (pctldev , child , map , num_maps );
419- if (ret < 0 ) {
420- of_node_put (child );
418+ if (ret < 0 )
421419 return ret ;
422- }
423420 }
424421
425422 return 0 ;
@@ -760,7 +757,6 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
760757{
761758 struct rzn1_pmx_func * func ;
762759 struct rzn1_pin_group * grp ;
763- struct device_node * child ;
764760 unsigned int i = 0 ;
765761 int ret ;
766762
@@ -793,15 +789,13 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
793789 ipctl -> ngroups ++ ;
794790 }
795791
796- for_each_child_of_node (np , child ) {
792+ for_each_child_of_node_scoped (np , child ) {
797793 func -> groups [i ] = child -> name ;
798794 grp = & ipctl -> groups [ipctl -> ngroups ];
799795 grp -> func = func -> name ;
800796 ret = rzn1_pinctrl_parse_groups (child , grp , ipctl );
801- if (ret < 0 ) {
802- of_node_put (child );
797+ if (ret < 0 )
803798 return ret ;
804- }
805799 i ++ ;
806800 ipctl -> ngroups ++ ;
807801 }
@@ -816,7 +810,6 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
816810 struct rzn1_pinctrl * ipctl )
817811{
818812 struct device_node * np = pdev -> dev .of_node ;
819- struct device_node * child ;
820813 unsigned int maxgroups = 0 ;
821814 unsigned int i = 0 ;
822815 int nfuncs = 0 ;
@@ -834,7 +827,7 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
834827 return - ENOMEM ;
835828
836829 ipctl -> ngroups = 0 ;
837- for_each_child_of_node (np , child )
830+ for_each_child_of_node_scoped (np , child )
838831 maxgroups += rzn1_pinctrl_count_function_groups (child );
839832
840833 ipctl -> groups = devm_kmalloc_array (& pdev -> dev ,
@@ -844,12 +837,10 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
844837 if (!ipctl -> groups )
845838 return - ENOMEM ;
846839
847- for_each_child_of_node (np , child ) {
840+ for_each_child_of_node_scoped (np , child ) {
848841 ret = rzn1_pinctrl_parse_functions (child , ipctl , i ++ );
849- if (ret < 0 ) {
850- of_node_put (child );
842+ if (ret < 0 )
851843 return ret ;
852- }
853844 }
854845
855846 return 0 ;
0 commit comments