Re: gpio desc flags being lost

From: Linus Walleij
Date: Fri Jul 05 2019 - 17:53:41 EST


On Wed, Jul 3, 2019 at 11:30 PM Chris Packham
<Chris.Packham@xxxxxxxxxxxxxxxxxxx> wrote:

> The problem is caused by commit 3edfb7bd76bd1cba ("gpiolib: Show correct
> direction from the beginning"). I'll see if I can whip up a patch to fix it.

Oh. I think:

if (chip->get_direction && gpiochip_line_is_valid(chip, i))
desc->flags = !chip->get_direction(chip, i) ?
(1 << FLAG_IS_OUT) : 0;
else
desc->flags = !chip->direction_input ?
(1 << FLAG_IS_OUT) : 0;


Needs to have desc->flags |= ... &= ~

if (!chip->get_direction(chip, i))
desc->flags |= (1 << FLAG_IS_OUT);
else
desc->flags &= ~(1 << FLAG_IS_OUT);

And the same for direction_input()

Yours,
Linus Walleij