Commit 1d0f9e1e authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

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: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20191113101809.28600-1-geert+renesas@glider.be
parent e42617b8
...@@ -386,12 +386,11 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc) ...@@ -386,12 +386,11 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
} }
/* Register the function GPIOs chip. */ /* Register the function GPIOs chip. */
if (pfc->info->nr_func_gpios == 0) if (pfc->info->nr_func_gpios) {
return 0;
chip = sh_pfc_add_gpiochip(pfc, gpio_function_setup, NULL); chip = sh_pfc_add_gpiochip(pfc, gpio_function_setup, NULL);
if (IS_ERR(chip)) if (IS_ERR(chip))
return PTR_ERR(chip); return PTR_ERR(chip);
}
#endif /* CONFIG_PINCTRL_SH_FUNC_GPIO */ #endif /* CONFIG_PINCTRL_SH_FUNC_GPIO */
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment