aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2019-11-13 11:18:09 +0100
committerGeert Uytterhoeven <geert+renesas@glider.be>2019-12-09 09:43:02 +0100
commit1d0f9e1e1e46939ae52804917647982b43754996 (patch)
tree53e673f338e43cb9dd45ea8709caf2f8f9883537 /drivers/pinctrl
parentLinux 5.5-rc1 (diff)
downloadlinux-dev-1d0f9e1e1e46939ae52804917647982b43754996.tar.xz
linux-dev-1d0f9e1e1e46939ae52804917647982b43754996.zip
pinctrl: sh-pfc: Make legacy function GPIO handling less fragile
If there are no function GPIOs, sh_pfc_register_gpiochip() returns early with a success indicator. This is fragile, as new code may be added after the #ifdef block, which won't be executed in case of early return. Invert the logic, so the code always continues until the end of the function on success. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Link: https://lore.kernel.org/r/20191113101809.28600-1-geert+renesas@glider.be
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/sh-pfc/gpio.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c
index 5a55b8da7919..8213e118aa40 100644
--- a/drivers/pinctrl/sh-pfc/gpio.c
+++ b/drivers/pinctrl/sh-pfc/gpio.c
@@ -386,12 +386,11 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
}
/* Register the function GPIOs chip. */
- if (pfc->info->nr_func_gpios == 0)
- return 0;
-
- chip = sh_pfc_add_gpiochip(pfc, gpio_function_setup, NULL);
- if (IS_ERR(chip))
- return PTR_ERR(chip);
+ if (pfc->info->nr_func_gpios) {
+ chip = sh_pfc_add_gpiochip(pfc, gpio_function_setup, NULL);
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+ }
#endif /* CONFIG_PINCTRL_SH_FUNC_GPIO */
return 0;