@@ -268,28 +268,23 @@ static int s32_dt_node_to_map(struct pinctrl_dev *pctldev,
268
268
unsigned int * num_maps )
269
269
{
270
270
unsigned int reserved_maps ;
271
- struct device_node * np ;
272
- int ret = 0 ;
271
+ int ret ;
273
272
274
273
reserved_maps = 0 ;
275
274
* map = NULL ;
276
275
* num_maps = 0 ;
277
276
278
- for_each_available_child_of_node (np_config , np ) {
277
+ for_each_available_child_of_node_scoped (np_config , np ) {
279
278
ret = s32_dt_group_node_to_map (pctldev , np , map ,
280
279
& reserved_maps , num_maps ,
281
280
np_config -> name );
282
281
if (ret < 0 ) {
283
- of_node_put ( np );
284
- break ;
282
+ pinctrl_utils_free_map ( pctldev , * map , * num_maps );
283
+ return ret ;
285
284
}
286
285
}
287
286
288
- if (ret )
289
- pinctrl_utils_free_map (pctldev , * map , * num_maps );
290
-
291
- return ret ;
292
-
287
+ return 0 ;
293
288
}
294
289
295
290
static const struct pinctrl_ops s32_pctrl_ops = {
@@ -786,7 +781,6 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
786
781
struct s32_pinctrl_soc_info * info ,
787
782
u32 index )
788
783
{
789
- struct device_node * child ;
790
784
struct pinfunction * func ;
791
785
struct s32_pin_group * grp ;
792
786
const char * * groups ;
@@ -810,14 +804,12 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
810
804
if (!groups )
811
805
return - ENOMEM ;
812
806
813
- for_each_child_of_node (np , child ) {
807
+ for_each_child_of_node_scoped (np , child ) {
814
808
groups [i ] = child -> name ;
815
809
grp = & info -> groups [info -> grp_index ++ ];
816
810
ret = s32_pinctrl_parse_groups (child , grp , info );
817
- if (ret ) {
818
- of_node_put (child );
811
+ if (ret )
819
812
return ret ;
820
- }
821
813
i ++ ;
822
814
}
823
815
@@ -831,7 +823,6 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
831
823
{
832
824
struct s32_pinctrl_soc_info * info = ipctl -> info ;
833
825
struct device_node * np = pdev -> dev .of_node ;
834
- struct device_node * child ;
835
826
struct resource * res ;
836
827
struct regmap * map ;
837
828
void __iomem * base ;
@@ -889,7 +880,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
889
880
return - ENOMEM ;
890
881
891
882
info -> ngroups = 0 ;
892
- for_each_child_of_node (np , child )
883
+ for_each_child_of_node_scoped (np , child )
893
884
info -> ngroups += of_get_child_count (child );
894
885
895
886
info -> groups = devm_kcalloc (& pdev -> dev , info -> ngroups ,
@@ -898,12 +889,10 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
898
889
return - ENOMEM ;
899
890
900
891
i = 0 ;
901
- for_each_child_of_node (np , child ) {
892
+ for_each_child_of_node_scoped (np , child ) {
902
893
ret = s32_pinctrl_parse_functions (child , info , i ++ );
903
- if (ret ) {
904
- of_node_put (child );
894
+ if (ret )
905
895
return ret ;
906
- }
907
896
}
908
897
909
898
return 0 ;
0 commit comments