Re: [PATCH v2 4/5] gpiolib: don't overwrite the entire flags field in gpiod_free_commit()

From: Bartosz Golaszewski

Date: Tue Nov 10 2026 - 03:54:39 EST


On Mon, Nov 09, 2026 at 11:53:03PM +0200, Andy Shevchenko wrote:
> On Mon, Nov 09, 2026 at 11:27:08AM +0100, Bartosz Golaszewski wrote:
> > Use gpiod_update_flags() to clear all request-related flags in one go
> > instead of risking racing with concurrent users and overwriting any
> > changes they could have done between READ_ONCE() and WRITE_ONCE().
>
> ...
>
> > #include <linux/acpi.h>
> > #include <linux/array_size.h>
> > #include <linux/bitmap.h>
> > +#include <linux/bitops.h>
> > #include <linux/cleanup.h>
> > #include <linux/compat.h>
> > #include <linux/debugfs.h>
>
> No need, bitmap API implies all bitops.
>

I honestly have no idea what the policy is on "proxy" headers. In some
cases people advise against them, in others they say to include them.

Is this documented anywhere?

> > + set_mask_bits(&desc->flags,
> > + BIT(GPIOD_FLAG_ACTIVE_LOW) |
> > + BIT(GPIOD_FLAG_REQUESTED) |
> > + BIT(GPIOD_FLAG_OPEN_DRAIN) |
> > + BIT(GPIOD_FLAG_OPEN_SOURCE) |
> > + BIT(GPIOD_FLAG_PULL_UP) |
> > + BIT(GPIOD_FLAG_PULL_DOWN) |
> > + BIT(GPIOD_FLAG_BIAS_DISABLE) |
> > + BIT(GPIOD_FLAG_EDGE_RISING) |
> > + BIT(GPIOD_FLAG_EDGE_FALLING) |
> > + BIT(GPIOD_FLAG_EVENT_CLOCK_REALTIME) |
> > + BIT(GPIOD_FLAG_EVENT_CLOCK_HTE) |
> > + BIT(GPIOD_FLAG_IS_HOGGED), 0);
>
> Indentation is broken (and it has spaces, which makes me totally confused what
> the point of those spaces in the first place?).
>

Yep, and sashiko has some nits too. I'll need a v3.

Bart