@@ -519,7 +519,6 @@ static int ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinct
519519 bank -> irqtype = 0 ;
520520 bank -> irqinten = 0 ;
521521 bank -> chip .label = bank -> name ;
522- bank -> chip .of_gpio_n_cells = 2 ;
523522 bank -> chip .parent = & pdev -> dev ;
524523 bank -> chip .request = ma35_gpio_core_to_request ;
525524 bank -> chip .direction_input = ma35_gpio_core_direction_in ;
@@ -976,9 +975,10 @@ static const struct pinconf_ops ma35_pinconf_ops = {
976975 .is_generic = true,
977976};
978977
979- static int ma35_pinctrl_parse_groups (struct device_node * np , struct group_desc * grp ,
978+ static int ma35_pinctrl_parse_groups (struct fwnode_handle * fwnode , struct group_desc * grp ,
980979 struct ma35_pinctrl * npctl , u32 index )
981980{
981+ struct device_node * np = to_of_node (fwnode );
982982 struct ma35_pin_setting * pin ;
983983 unsigned long * configs ;
984984 unsigned int nconfigs ;
@@ -990,7 +990,7 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
990990 if (ret )
991991 return ret ;
992992
993- count = of_property_count_elems_of_size ( np , "nuvoton,pins" , sizeof ( u32 ) );
993+ count = fwnode_property_count_u32 ( fwnode , "nuvoton,pins" );
994994 if (!count || count % 3 )
995995 return - EINVAL ;
996996
@@ -1000,7 +1000,7 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
10001000
10011001 grp -> grp .name = np -> name ;
10021002
1003- ret = of_property_read_u32_array ( np , "nuvoton,pins" , elems , count );
1003+ ret = fwnode_property_read_u32_array ( fwnode , "nuvoton,pins" , elems , count );
10041004 if (ret )
10051005 return - EINVAL ;
10061006 grp -> grp .npins = count / 3 ;
@@ -1027,10 +1027,11 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
10271027 return 0 ;
10281028}
10291029
1030- static int ma35_pinctrl_parse_functions (struct device_node * np , struct ma35_pinctrl * npctl ,
1030+ static int ma35_pinctrl_parse_functions (struct fwnode_handle * fwnode , struct ma35_pinctrl * npctl ,
10311031 u32 index )
10321032{
1033- struct device_node * child ;
1033+ struct device_node * np = to_of_node (fwnode );
1034+ struct fwnode_handle * child ;
10341035 struct pinfunction * func ;
10351036 struct group_desc * grp ;
10361037 static u32 grp_index ;
@@ -1050,12 +1051,14 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
10501051 if (!groups )
10511052 return - ENOMEM ;
10521053
1053- for_each_child_of_node (np , child ) {
1054- groups [i ] = child -> name ;
1054+ fwnode_for_each_child_node (fwnode , child ) {
1055+ struct device_node * node = to_of_node (child );
1056+
1057+ groups [i ] = node -> name ;
10551058 grp = & npctl -> groups [grp_index ++ ];
10561059 ret = ma35_pinctrl_parse_groups (child , grp , npctl , i ++ );
10571060 if (ret ) {
1058- of_node_put (child );
1061+ fwnode_handle_put (child );
10591062 return ret ;
10601063 }
10611064 }
@@ -1066,13 +1069,12 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
10661069
10671070static int ma35_pinctrl_probe_dt (struct platform_device * pdev , struct ma35_pinctrl * npctl )
10681071{
1072+ struct device * dev = & pdev -> dev ;
10691073 struct fwnode_handle * child ;
10701074 u32 idx = 0 ;
10711075 int ret ;
10721076
1073- device_for_each_child_node (& pdev -> dev , child ) {
1074- if (fwnode_property_present (child , "gpio-controller" ))
1075- continue ;
1077+ for_each_gpiochip_node (dev , child ) {
10761078 npctl -> nfunctions ++ ;
10771079 npctl -> ngroups += of_get_child_count (to_of_node (child ));
10781080 }
@@ -1090,11 +1092,8 @@ static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinct
10901092 if (!npctl -> groups )
10911093 return - ENOMEM ;
10921094
1093- device_for_each_child_node (& pdev -> dev , child ) {
1094- if (fwnode_property_present (child , "gpio-controller" ))
1095- continue ;
1096-
1097- ret = ma35_pinctrl_parse_functions (to_of_node (child ), npctl , idx ++ );
1095+ for_each_gpiochip_node (dev , child ) {
1096+ ret = ma35_pinctrl_parse_functions (child , npctl , idx ++ );
10981097 if (ret ) {
10991098 fwnode_handle_put (child );
11001099 dev_err (& pdev -> dev , "failed to parse function\n" );
@@ -1139,7 +1138,7 @@ int ma35_pinctrl_probe(struct platform_device *pdev, const struct ma35_pinctrl_s
11391138 npctl -> info = info ;
11401139 npctl -> dev = & pdev -> dev ;
11411140
1142- npctl -> regmap = syscon_regmap_lookup_by_phandle (pdev -> dev . of_node , "nuvoton,sys" );
1141+ npctl -> regmap = syscon_regmap_lookup_by_phandle (dev_of_node ( dev ) , "nuvoton,sys" );
11431142 if (IS_ERR (npctl -> regmap ))
11441143 return dev_err_probe (& pdev -> dev , PTR_ERR (npctl -> regmap ),
11451144 "No syscfg phandle specified\n" );
0 commit comments