Skip to contentSkip to conversation

pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid()

PATCH In review Marek Vasut 3 participants 3 messages Apr 6, 2021 – Apr 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: stm32: Print invalid AF warning inside stm32_pctrl_is_function_valid()

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.

Cc Fabien Dessenne <[email protected]>
Cc Alexandre Torgue <[email protected]>
Cc Linus Walleij <[email protected]>

To: [email protected]

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


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 1/1
#1 lore raw

Hi Marek,

Thank you for the patch!

Quoted 7 lines · Marek Vasut

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.

Quoted 47 lines

Cc: Fabien Dessenne <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: [email protected]
To: [email protected]

---
  drivers/pinctrl/stm32/pinctrl-stm32.c | 13 ++++---------
  1 file changed, 4 insertions(+), 9 deletions(-)
drivers/pinctrl/stm32/pinctrl-stm32.c +3 -5
index da72e3e5c08d..ad9eb5ed8e81 100644
@@ -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;
 

drivers/pinctrl/stm32/pinctrl-stm32.c static int stm32_pmx_set_mux(struct pinctrl_dev *pctldev, · line 826

Quoted 10 lines
drivers/pinctrl/stm32/pinctrl-stm32.c +1 -4
  	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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
In reply to Marek Vasut
Quoted 6 lines · Marek Vasut

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.

Quoted 6 lines
Cc Fabien Dessenne <[email protected]>
Cc Alexandre Torgue <[email protected]>
Cc Linus Walleij <[email protected]>

To: [email protected]

Patch applied.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel