[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACRpkdbWWWhQ5V5tc0FkQSx80ZXZ+ki-mn9Cc_Vm-jOwVu0R3A@mail.gmail.com>
Date: Fri, 5 Jul 2019 23:55:51 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Chris Packham <chris.packham@...iedtelesis.co.nz>
Cc: Bartosz Golaszewski <bgolaszewski@...libre.com>,
Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] gpiolib: Preserve desc->flags when setting state
Hi Chris,
thanks for your patch!
On Thu, Jul 4, 2019 at 6:21 AM Chris Packham
<chris.packham@...iedtelesis.co.nz> wrote:
> desc->flags may already have values set by of_gpiochip_add() so make
> sure that this isn't undone when setting the initial direction.
>
> Fixes: 3edfb7bd76bd1cba ("gpiolib: Show correct direction from the beginning")
> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
> ---
>
> Notes:
> Changes in v2:
> - add braces to avoid ambiguious else warning
This is almost the solution!
> - 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;
> + if (chip->get_direction && gpiochip_line_is_valid(chip, i)) {
> + if (!chip->get_direction(chip, i))
> + set_bit(FLAG_IS_OUT, &desc->flags);
You need to clear_bit() in the reverse case. We just learned we can't
assume anything about the flags here, like just assign them.
> + } else {
> + if (!chip->direction_input)
> + set_bit(FLAG_IS_OUT, &desc->flags);
Same here.
Yours,
Linus Walleij
Powered by blists - more mailing lists