diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-07-08 15:26:47 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-07-09 12:17:16 +0200 |
commit | bd7014fc490e8ca56dc9d418b07f5b9dbc65283d (patch) | |
tree | f28c997a01b09ee1d8163626bb1f74cbc1b5fd78 | |
parent | 3cad56f3e166b7b070c8e8bade5c29a04d74ef75 (diff) | |
download | barebox-bd7014fc490e8ca56dc9d418b07f5b9dbc65283d.tar.gz barebox-bd7014fc490e8ca56dc9d418b07f5b9dbc65283d.tar.xz |
pinctrl: stm32: fix error path when gpio chip is not found
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/pinctrl/pinctrl-stm32.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/pinctrl/pinctrl-stm32.c b/drivers/pinctrl/pinctrl-stm32.c index af96974d0d..7f04cea50b 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); |