Re: [PATCH 3/5] gpiolib: provide gpiod_update_flags()

From: Linus Walleij

Date: Thu Nov 05 2026 - 08:29:21 EST


On Wed, Nov 4, 2026 at 4:37 PM Bartosz Golaszewski
<bartosz.golaszewski@xxxxxxxxxxxxxxxx> wrote:

> We have several places in GPIO core where we copy the desc->flags field,
> change several bits in the copy and write back the whole word with
> WRITE_ONCE(). Concurrent updates of flags that modify other bits are
> lost.
>
> Add gpiod_update_flags() - it replaces a masked set of bits with
> try_cmpxchg() loop. All bits are updated in one atomic step so no other
> thread can observe it half-done. Unmasked bits are not rewritten with
> stale values.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>

Sashiko has a good suggestion for this patch :)

With that addressed:
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Yours,
Linus Walleij