Thread (3 messages) 3 messages, 3 authors, 2020-06-10

Re: [PATCH] tty: serial: cpm_uart: Fix behaviour for non existing GPIOs

From: Linus Walleij <hidden>
Date: 2020-06-10 11:18:21
Also in: linux-serial, lkml

Hi Christophe!

On Sat, Jun 6, 2020 at 9:30 AM Christophe Leroy
[off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help