diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2014-09-30 05:22:07 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-09-30 05:23:28 -0400 |
commit | 259145feff723cd65fcf53156bdd7a11816b1e31 (patch) | |
tree | 0a682bbfd9666bf8594976d60bfe2b9170cab4f4 /drivers/pinctrl | |
parent | b07f92a220fa4df01e7feb1791245882249ba200 (diff) |
pinctrl: abx500: refactor DT parser to take two paths
We refactor the DT parser to look for either a config or a
function and then look for further nodes and reserve maps,
not the two things mixed up like prior to this patch.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/nomadik/pinctrl-abx500.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index be95f5e68c01..af0d417fe3fb 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c | |||
@@ -893,19 +893,32 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, | |||
893 | unsigned long *configs; | 893 | unsigned long *configs; |
894 | unsigned int nconfigs = 0; | 894 | unsigned int nconfigs = 0; |
895 | bool has_config = 0; | 895 | bool has_config = 0; |
896 | unsigned reserve = 0; | ||
897 | struct property *prop; | 896 | struct property *prop; |
898 | const char *group, *gpio_name; | 897 | const char *group, *gpio_name; |
899 | struct device_node *np_config; | 898 | struct device_node *np_config; |
900 | 899 | ||
901 | ret = of_property_read_string(np, "ste,function", &function); | 900 | ret = of_property_read_string(np, "ste,function", &function); |
902 | if (ret >= 0) | 901 | if (ret >= 0) { |
903 | reserve = 1; | 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 | } | ||
904 | 918 | ||
905 | ret = pinconf_generic_parse_dt_config(np, &configs, &nconfigs); | 919 | ret = pinconf_generic_parse_dt_config(np, &configs, &nconfigs); |
906 | if (nconfigs) | 920 | if (nconfigs) |
907 | has_config = 1; | 921 | has_config = 1; |
908 | |||
909 | np_config = of_parse_phandle(np, "ste,config", 0); | 922 | np_config = of_parse_phandle(np, "ste,config", 0); |
910 | if (np_config) { | 923 | if (np_config) { |
911 | ret = pinconf_generic_parse_dt_config(np_config, &configs, | 924 | ret = pinconf_generic_parse_dt_config(np_config, &configs, |
@@ -914,29 +927,18 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, | |||
914 | goto exit; | 927 | goto exit; |
915 | has_config |= nconfigs; | 928 | has_config |= nconfigs; |
916 | } | 929 | } |
930 | if (has_config) { | ||
931 | ret = of_property_count_strings(np, "ste,pins"); | ||
932 | if (ret < 0) | ||
933 | goto exit; | ||
917 | 934 | ||
918 | ret = of_property_count_strings(np, "ste,pins"); | 935 | ret = pinctrl_utils_reserve_map(pctldev, map, |
919 | if (ret < 0) | 936 | reserved_maps, |
920 | goto exit; | 937 | num_maps, ret); |
921 | 938 | if (ret < 0) | |
922 | if (has_config) | 939 | goto exit; |
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; | ||
931 | 940 | ||
932 | of_property_for_each_string(np, "ste,pins", prop, group) { | 941 | 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) { | ||
940 | gpio_name = abx500_find_pin_name(pctldev, group); | 942 | gpio_name = abx500_find_pin_name(pctldev, group); |
941 | 943 | ||
942 | ret = abx500_dt_add_map_configs(map, reserved_maps, | 944 | ret = abx500_dt_add_map_configs(map, reserved_maps, |
@@ -944,8 +946,8 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, | |||
944 | if (ret < 0) | 946 | if (ret < 0) |
945 | goto exit; | 947 | goto exit; |
946 | } | 948 | } |
947 | |||
948 | } | 949 | } |
950 | |||
949 | exit: | 951 | exit: |
950 | return ret; | 952 | return ret; |
951 | } | 953 | } |