linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid()
@ 2021-04-06 18:00 Marek Vasut
  2021-04-07  9:25 ` [Linux-stm32] " Fabien Dessenne
  2021-04-08  7:29 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Vasut @ 2021-04-06 18:00 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Marek Vasut, Fabien Dessenne, Alexandre Torgue, Linus Walleij,
	linux-stm32

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
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index da72e3e5c08d..ad9eb5ed8e81 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -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) {
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Linux-stm32] [PATCH] pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid()
  2021-04-06 18:00 [PATCH] pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid() Marek Vasut
@ 2021-04-07  9:25 ` Fabien Dessenne
  2021-04-08  7:29 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Fabien Dessenne @ 2021-04-07  9:25 UTC (permalink / raw)
  To: Marek Vasut, linux-arm-kernel
  Cc: Linus Walleij, Alexandre Torgue, Fabien Dessenne, linux-stm32

Hi Marek,

Thank you for the patch!


On 06/04/2021 8:00 pm, Marek Vasut wrote:
> 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>

Acked-by: Fabien Dessenne <fabien.dessenne@foss.st.com>

> 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
> ---
>   drivers/pinctrl/stm32/pinctrl-stm32.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> index da72e3e5c08d..ad9eb5ed8e81 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
> @@ -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) {
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid()
  2021-04-06 18:00 [PATCH] pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid() Marek Vasut
  2021-04-07  9:25 ` [Linux-stm32] " Fabien Dessenne
@ 2021-04-08  7:29 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2021-04-08  7:29 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Linux ARM, Fabien Dessenne, Alexandre Torgue, linux-stm32

On Tue, Apr 6, 2021 at 8:00 PM Marek Vasut <marex@denx.de> wrote:

> 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

Patch applied.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-08  7:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 18:00 [PATCH] pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid() Marek Vasut
2021-04-07  9:25 ` [Linux-stm32] " Fabien Dessenne
2021-04-08  7:29 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).