pinctrl: fix error path in pinconf_map_to_setting()
The code was using the union member setting->data.configs.group_or_pin to store a potential error code, but since that member is unsigned the < 0 comparison was not true, letting errors pass through, ending up as mapped to pin "-22". Fix this up and print the error. Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
@@ -282,21 +282,28 @@ int pinconf_map_to_setting(struct pinctrl_map const *map,
|
|||||||
struct pinctrl_setting *setting)
|
struct pinctrl_setting *setting)
|
||||||
{
|
{
|
||||||
struct pinctrl_dev *pctldev = setting->pctldev;
|
struct pinctrl_dev *pctldev = setting->pctldev;
|
||||||
|
int pin;
|
||||||
|
|
||||||
switch (setting->type) {
|
switch (setting->type) {
|
||||||
case PIN_MAP_TYPE_CONFIGS_PIN:
|
case PIN_MAP_TYPE_CONFIGS_PIN:
|
||||||
setting->data.configs.group_or_pin =
|
pin = pin_get_from_name(pctldev,
|
||||||
pin_get_from_name(pctldev,
|
map->data.configs.group_or_pin);
|
||||||
map->data.configs.group_or_pin);
|
if (pin < 0) {
|
||||||
if (setting->data.configs.group_or_pin < 0)
|
dev_err(pctldev->dev, "could not map pin config for \"%s\"",
|
||||||
return setting->data.configs.group_or_pin;
|
map->data.configs.group_or_pin);
|
||||||
|
return pin;
|
||||||
|
}
|
||||||
|
setting->data.configs.group_or_pin = pin;
|
||||||
break;
|
break;
|
||||||
case PIN_MAP_TYPE_CONFIGS_GROUP:
|
case PIN_MAP_TYPE_CONFIGS_GROUP:
|
||||||
setting->data.configs.group_or_pin =
|
pin = pinctrl_get_group_selector(pctldev,
|
||||||
pinctrl_get_group_selector(pctldev,
|
map->data.configs.group_or_pin);
|
||||||
map->data.configs.group_or_pin);
|
if (pin < 0) {
|
||||||
if (setting->data.configs.group_or_pin < 0)
|
dev_err(pctldev->dev, "could not map group config for \"%s\"",
|
||||||
return setting->data.configs.group_or_pin;
|
map->data.configs.group_or_pin);
|
||||||
|
return pin;
|
||||||
|
}
|
||||||
|
setting->data.configs.group_or_pin = pin;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Reference in New Issue
Block a user