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>
This commit is contained in:
parent
b07f92a220
commit
259145feff
|
@ -893,19 +893,32 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev,
|
||||||
unsigned long *configs;
|
unsigned long *configs;
|
||||||
unsigned int nconfigs = 0;
|
unsigned int nconfigs = 0;
|
||||||
bool has_config = 0;
|
bool has_config = 0;
|
||||||
unsigned reserve = 0;
|
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
const char *group, *gpio_name;
|
const char *group, *gpio_name;
|
||||||
struct device_node *np_config;
|
struct device_node *np_config;
|
||||||
|
|
||||||
ret = of_property_read_string(np, "ste,function", &function);
|
ret = of_property_read_string(np, "ste,function", &function);
|
||||||
if (ret >= 0)
|
if (ret >= 0) {
|
||||||
reserve = 1;
|
ret = of_property_count_strings(np, "ste,pins");
|
||||||
|
if (ret < 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
|
||||||
|
num_maps, ret);
|
||||||
|
if (ret < 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
of_property_for_each_string(np, "ste,pins", prop, group) {
|
||||||
|
ret = abx500_dt_add_map_mux(map, reserved_maps,
|
||||||
|
num_maps, group, function);
|
||||||
|
if (ret < 0)
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = pinconf_generic_parse_dt_config(np, &configs, &nconfigs);
|
ret = pinconf_generic_parse_dt_config(np, &configs, &nconfigs);
|
||||||
if (nconfigs)
|
if (nconfigs)
|
||||||
has_config = 1;
|
has_config = 1;
|
||||||
|
|
||||||
np_config = of_parse_phandle(np, "ste,config", 0);
|
np_config = of_parse_phandle(np, "ste,config", 0);
|
||||||
if (np_config) {
|
if (np_config) {
|
||||||
ret = pinconf_generic_parse_dt_config(np_config, &configs,
|
ret = pinconf_generic_parse_dt_config(np_config, &configs,
|
||||||
|
@ -914,29 +927,18 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev,
|
||||||
goto exit;
|
goto exit;
|
||||||
has_config |= nconfigs;
|
has_config |= nconfigs;
|
||||||
}
|
}
|
||||||
|
if (has_config) {
|
||||||
|
ret = of_property_count_strings(np, "ste,pins");
|
||||||
|
if (ret < 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
ret = of_property_count_strings(np, "ste,pins");
|
ret = pinctrl_utils_reserve_map(pctldev, map,
|
||||||
if (ret < 0)
|
reserved_maps,
|
||||||
goto exit;
|
num_maps, ret);
|
||||||
|
if (ret < 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
if (has_config)
|
of_property_for_each_string(np, "ste,pins", prop, group) {
|
||||||
reserve++;
|
|
||||||
|
|
||||||
reserve *= ret;
|
|
||||||
|
|
||||||
ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
|
|
||||||
num_maps, reserve);
|
|
||||||
if (ret < 0)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
of_property_for_each_string(np, "ste,pins", prop, group) {
|
|
||||||
if (function) {
|
|
||||||
ret = abx500_dt_add_map_mux(map, reserved_maps,
|
|
||||||
num_maps, group, function);
|
|
||||||
if (ret < 0)
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
if (has_config) {
|
|
||||||
gpio_name = abx500_find_pin_name(pctldev, group);
|
gpio_name = abx500_find_pin_name(pctldev, group);
|
||||||
|
|
||||||
ret = abx500_dt_add_map_configs(map, reserved_maps,
|
ret = abx500_dt_add_map_configs(map, reserved_maps,
|
||||||
|
@ -944,8 +946,8 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue