@@ -893,19 +893,32 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev,
893893 unsigned long * configs ;
894894 unsigned int nconfigs = 0 ;
895895 bool has_config = 0 ;
896- unsigned reserve = 0 ;
897896 struct property * prop ;
898897 const char * group , * gpio_name ;
899898 struct device_node * np_config ;
900899
901900 ret = of_property_read_string (np , "ste,function" , & function );
902- if (ret >= 0 )
903- reserve = 1 ;
901+ if (ret >= 0 ) {
902+ ret = of_property_count_strings (np , "ste,pins" );
903+ if (ret < 0 )
904+ goto exit ;
905+
906+ ret = pinctrl_utils_reserve_map (pctldev , map , reserved_maps ,
907+ num_maps , ret );
908+ if (ret < 0 )
909+ goto exit ;
910+
911+ of_property_for_each_string (np , "ste,pins" , prop , group ) {
912+ ret = abx500_dt_add_map_mux (map , reserved_maps ,
913+ num_maps , group , function );
914+ if (ret < 0 )
915+ goto exit ;
916+ }
917+ }
904918
905919 ret = pinconf_generic_parse_dt_config (np , & configs , & nconfigs );
906920 if (nconfigs )
907921 has_config = 1 ;
908-
909922 np_config = of_parse_phandle (np , "ste,config" , 0 );
910923 if (np_config ) {
911924 ret = pinconf_generic_parse_dt_config (np_config , & configs ,
@@ -914,38 +927,27 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev,
914927 goto exit ;
915928 has_config |= nconfigs ;
916929 }
930+ if (has_config ) {
931+ ret = of_property_count_strings (np , "ste,pins" );
932+ if (ret < 0 )
933+ goto exit ;
917934
918- ret = of_property_count_strings (np , "ste,pins" );
919- if (ret < 0 )
920- goto exit ;
921-
922- if (has_config )
923- reserve ++ ;
924-
925- reserve *= ret ;
926-
927- ret = pinctrl_utils_reserve_map (pctldev , map , reserved_maps ,
928- num_maps , reserve );
929- if (ret < 0 )
930- goto exit ;
935+ ret = pinctrl_utils_reserve_map (pctldev , map ,
936+ reserved_maps ,
937+ num_maps , ret );
938+ if (ret < 0 )
939+ goto exit ;
931940
932- of_property_for_each_string (np , "ste,pins" , prop , group ) {
933- if (function ) {
934- ret = abx500_dt_add_map_mux (map , reserved_maps ,
935- num_maps , group , function );
936- if (ret < 0 )
937- goto exit ;
938- }
939- if (has_config ) {
941+ of_property_for_each_string (np , "ste,pins" , prop , group ) {
940942 gpio_name = abx500_find_pin_name (pctldev , group );
941943
942944 ret = abx500_dt_add_map_configs (map , reserved_maps ,
943945 num_maps , gpio_name , configs , 1 );
944946 if (ret < 0 )
945947 goto exit ;
946948 }
947-
948949 }
950+
949951exit :
950952 return ret ;
951953}
0 commit comments