mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback
@ 2019-07-08 13:26 Ahmad Fatoum
  2019-07-08 13:26 ` [PATCH 2/2] pinctrl: stm32: fix error path when gpio chip is not found Ahmad Fatoum
  2019-07-09 10:17 ` [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2019-07-08 13:26 UTC (permalink / raw)
  To: barebox

There's already a debug output whenever a pin is configured, extend this
by printing a "header" with the node name and how many pins configurations
will follow.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pinctrl/pinctrl-stm32.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-stm32.c b/drivers/pinctrl/pinctrl-stm32.c
index 8e392eac5099..af96974d0d01 100644
--- a/drivers/pinctrl/pinctrl-stm32.c
+++ b/drivers/pinctrl/pinctrl-stm32.c
@@ -138,6 +138,9 @@ static int stm32_pinctrl_set_state(struct pinctrl_device *pdev, struct device_no
 		else if (of_get_property(pins, "output-high", NULL))
 			dir = PIN_OUTPUT_HIGH;
 
+		dev_dbg(pdev->dev, "%s: multiplexing %d pins\n",
+			pins->full_name, num_pins);
+
 		for (i = 0; i < num_pins; i++) {
 			struct stm32_gpio_bank *bank = NULL;
 			u32 pinfunc, mode, alt;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] pinctrl: stm32: fix error path when gpio chip is not found
  2019-07-08 13:26 [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback Ahmad Fatoum
@ 2019-07-08 13:26 ` Ahmad Fatoum
  2019-07-09 10:17 ` [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2019-07-08 13:26 UTC (permalink / raw)
  To: barebox

Current error path has two issues:

- PTR_ERR is applied to a NULL pointer, so even error conditions return
  zero, which is a valid successful return.
- The return value is stored into an unsigned integer which is checked
  to be less than zero, so the error is never handled.

Fix both issues.

Fixes: f4f933a64 ("pinctrl: add driver for STM32 GPIO and pin multiplexer")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pinctrl/pinctrl-stm32.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-stm32.c b/drivers/pinctrl/pinctrl-stm32.c
index af96974d0d01..7f04cea50b75 100644
--- a/drivers/pinctrl/pinctrl-stm32.c
+++ b/drivers/pinctrl/pinctrl-stm32.c
@@ -51,7 +51,7 @@ static inline int stm32_gpio_pin(int gpio, struct stm32_gpio_bank **bank)
 
 		chip = gpio_get_chip(gpio);
 		if (!chip)
-			return PTR_ERR(chip);
+			return -EINVAL;
 
 		*bank = to_stm32_gpio_bank(chip);
 	}
@@ -144,7 +144,8 @@ static int stm32_pinctrl_set_state(struct pinctrl_device *pdev, struct device_no
 		for (i = 0; i < num_pins; i++) {
 			struct stm32_gpio_bank *bank = NULL;
 			u32 pinfunc, mode, alt;
-			unsigned offset, func;
+			unsigned func;
+			int offset;
 
 			ret = of_property_read_u32_index(pins, "pinmux",
 					i, &pinfunc);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback
  2019-07-08 13:26 [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback Ahmad Fatoum
  2019-07-08 13:26 ` [PATCH 2/2] pinctrl: stm32: fix error path when gpio chip is not found Ahmad Fatoum
@ 2019-07-09 10:17 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2019-07-09 10:17 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jul 08, 2019 at 03:26:46PM +0200, Ahmad Fatoum wrote:
> There's already a debug output whenever a pin is configured, extend this
> by printing a "header" with the node name and how many pins configurations
> will follow.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/pinctrl/pinctrl-stm32.c | 3 +++
>  1 file changed, 3 insertions(+)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2019-07-09 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 13:26 [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback Ahmad Fatoum
2019-07-08 13:26 ` [PATCH 2/2] pinctrl: stm32: fix error path when gpio chip is not found Ahmad Fatoum
2019-07-09 10:17 ` [PATCH 1/2] pinctrl: stm32: add debug output in set_state callback Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox