OSDN Git Service

pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid()
authorMarek Vasut <marex@denx.de>
Tue, 6 Apr 2021 18:00:35 +0000 (20:00 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 8 Apr 2021 07:52:20 +0000 (09:52 +0200)
The "invalid function %d on pin %d .\n" message is triplicated in the
driver in different variants, just pull it into the function and have
it once in the driver. The bonus is that all variants of the message
now print the pin number and AF consistently, so it is easier to debug
such pinmux problems.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabien Dessenne <fabien.dessenne@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-stm32@st-md-mailman.stormreply.com
To: linux-arm-kernel@lists.infradead.org
Acked-by: Fabien Dessenne <fabien.dessenne@foss.st.com>
Link: https://lore.kernel.org/r/20210406180035.279249-1-marex@denx.de
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/stm32/pinctrl-stm32.c

index da72e3e..ad9eb5e 100644 (file)
@@ -531,6 +531,8 @@ static bool stm32_pctrl_is_function_valid(struct stm32_pinctrl *pctl,
                break;
        }
 
+       dev_err(pctl->dev, "invalid function %d on pin %d .\n", fnum, pin_num);
+
        return false;
 }
 
@@ -545,11 +547,8 @@ static int stm32_pctrl_dt_node_to_map_func(struct stm32_pinctrl *pctl,
        (*map)[*num_maps].type = PIN_MAP_TYPE_MUX_GROUP;
        (*map)[*num_maps].data.mux.group = grp->name;
 
-       if (!stm32_pctrl_is_function_valid(pctl, pin, fnum)) {
-               dev_err(pctl->dev, "invalid function %d on pin %d .\n",
-                               fnum, pin);
+       if (!stm32_pctrl_is_function_valid(pctl, pin, fnum))
                return -EINVAL;
-       }
 
        (*map)[*num_maps].data.mux.function = stm32_gpio_functions[fnum];
        (*num_maps)++;
@@ -620,7 +619,6 @@ static int stm32_pctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
                func = STM32_GET_PIN_FUNC(pinfunc);
 
                if (!stm32_pctrl_is_function_valid(pctl, pin, func)) {
-                       dev_err(pctl->dev, "invalid function.\n");
                        err = -EINVAL;
                        goto exit;
                }
@@ -821,11 +819,8 @@ static int stm32_pmx_set_mux(struct pinctrl_dev *pctldev,
        int pin;
 
        ret = stm32_pctrl_is_function_valid(pctl, g->pin, function);
-       if (!ret) {
-               dev_err(pctl->dev, "invalid function %d on group %d .\n",
-                               function, group);
+       if (!ret)
                return -EINVAL;
-       }
 
        range = pinctrl_find_gpio_range_from_pin(pctldev, g->pin);
        if (!range) {