[PATCH] gpio: sifive: use the correct register to read output values
Niklas Cassel
Niklas.Cassel at wdc.com
Tue Feb 8 02:13:44 PST 2022
On Sat, Feb 05, 2022 at 05:39:35PM +0100, Linus Walleij wrote:
> On Fri, Feb 4, 2022 at 2:02 PM Niklas Cassel <Niklas.Cassel at wdc.com> wrote:
>
> > From: Niklas Cassel <niklas.cassel at wdc.com>
>
> Hi Niklas, long time no C!
I C what you did there ;)
I've been working mostly on spdk and fio, unfortunately,
both projects are written in C :)
Learning Rust is still on the todo list...
>
> > Setting the output of a GPIO to 1 using gpiod_set_value(), followed by
> > reading the same GPIO using gpiod_get_value(), will currently yield an
> > incorrect result.
> >
> > This is because the SiFive GPIO device stores the output values in reg_set,
> > not reg_dat.
> >
> > Supply the flag BGPIOF_READ_OUTPUT_REG_SET to bgpio_init() so that the
> > generic driver reads the correct register.
> >
> > Signed-off-by: Niklas Cassel <niklas.cassel at wdc.com>
>
> Looks like a straight-forward fix so:
> Reviewed-by: Linus Walleij <linus.walleij at linaro.org>
Thanks for the review!
Indeed, I can't understand how no one has caught this bug before.
I guess most drivers simply use gpiod_set_value() to control a pin,
e.g. chip select, but rarely care about the existing value of the pin,
so gpiod_get_value() being broken does not really matter to most drivers.
Kind regards,
Niklas
More information about the linux-riscv
mailing list