@@ -519,7 +519,6 @@ static int ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinct
519
519
bank -> irqtype = 0 ;
520
520
bank -> irqinten = 0 ;
521
521
bank -> chip .label = bank -> name ;
522
- bank -> chip .of_gpio_n_cells = 2 ;
523
522
bank -> chip .parent = & pdev -> dev ;
524
523
bank -> chip .request = ma35_gpio_core_to_request ;
525
524
bank -> chip .direction_input = ma35_gpio_core_direction_in ;
@@ -976,9 +975,10 @@ static const struct pinconf_ops ma35_pinconf_ops = {
976
975
.is_generic = true,
977
976
};
978
977
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 ,
980
979
struct ma35_pinctrl * npctl , u32 index )
981
980
{
981
+ struct device_node * np = to_of_node (fwnode );
982
982
struct ma35_pin_setting * pin ;
983
983
unsigned long * configs ;
984
984
unsigned int nconfigs ;
@@ -990,7 +990,7 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
990
990
if (ret )
991
991
return ret ;
992
992
993
- count = of_property_count_elems_of_size ( np , "nuvoton,pins" , sizeof ( u32 ) );
993
+ count = fwnode_property_count_u32 ( fwnode , "nuvoton,pins" );
994
994
if (!count || count % 3 )
995
995
return - EINVAL ;
996
996
@@ -1000,7 +1000,7 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
1000
1000
1001
1001
grp -> grp .name = np -> name ;
1002
1002
1003
- ret = of_property_read_u32_array ( np , "nuvoton,pins" , elems , count );
1003
+ ret = fwnode_property_read_u32_array ( fwnode , "nuvoton,pins" , elems , count );
1004
1004
if (ret )
1005
1005
return - EINVAL ;
1006
1006
grp -> grp .npins = count / 3 ;
@@ -1027,10 +1027,11 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
1027
1027
return 0 ;
1028
1028
}
1029
1029
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 ,
1031
1031
u32 index )
1032
1032
{
1033
- struct device_node * child ;
1033
+ struct device_node * np = to_of_node (fwnode );
1034
+ struct fwnode_handle * child ;
1034
1035
struct pinfunction * func ;
1035
1036
struct group_desc * grp ;
1036
1037
static u32 grp_index ;
@@ -1050,12 +1051,14 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
1050
1051
if (!groups )
1051
1052
return - ENOMEM ;
1052
1053
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 ;
1055
1058
grp = & npctl -> groups [grp_index ++ ];
1056
1059
ret = ma35_pinctrl_parse_groups (child , grp , npctl , i ++ );
1057
1060
if (ret ) {
1058
- of_node_put (child );
1061
+ fwnode_handle_put (child );
1059
1062
return ret ;
1060
1063
}
1061
1064
}
@@ -1066,13 +1069,12 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
1066
1069
1067
1070
static int ma35_pinctrl_probe_dt (struct platform_device * pdev , struct ma35_pinctrl * npctl )
1068
1071
{
1072
+ struct device * dev = & pdev -> dev ;
1069
1073
struct fwnode_handle * child ;
1070
1074
u32 idx = 0 ;
1071
1075
int ret ;
1072
1076
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 ) {
1076
1078
npctl -> nfunctions ++ ;
1077
1079
npctl -> ngroups += of_get_child_count (to_of_node (child ));
1078
1080
}
@@ -1090,11 +1092,8 @@ static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinct
1090
1092
if (!npctl -> groups )
1091
1093
return - ENOMEM ;
1092
1094
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 ++ );
1098
1097
if (ret ) {
1099
1098
fwnode_handle_put (child );
1100
1099
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
1139
1138
npctl -> info = info ;
1140
1139
npctl -> dev = & pdev -> dev ;
1141
1140
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" );
1143
1142
if (IS_ERR (npctl -> regmap ))
1144
1143
return dev_err_probe (& pdev -> dev , PTR_ERR (npctl -> regmap ),
1145
1144
"No syscfg phandle specified\n" );
0 commit comments