[PATCH] tty: serial: cpm_uart: Fix behaviour for non existing GPIOs
Linus Walleij
linus.walleij at linaro.org
Wed Jun 10 21:18:06 AEST 2020
Hi Christophe!
On Sat, Jun 6, 2020 at 9:30 AM Christophe Leroy
<christophe.leroy at csgroup.eu> wrote:
> gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS);
>
> - if (gpiod) {
> + if (!IS_ERR_OR_NULL(gpiod)) {
> if (i == GPIO_RTS || i == GPIO_DTR)
> ret = gpiod_direction_output(gpiod, 0);
> else
This code, and the way descriptors are used in the driver leads
me to believe that the right solution is to use the optional
call with a hard error check:
gpiod = devm_gpiod_get_index_optional(...);
if (IS_ERR(gpiod))
return PTR_ERR(gpiod);
if (gpiod) {
... followed by the old code ...
This makes sure that the array member is left NULL if there is no
GPIO on this line, and all other errors, such as -EPROBE_DEFER
which currently absolutely does not work, will lead to us properly
exiting with an error.
Yours,
Linus Walleij
More information about the Linuxppc-dev
mailing list