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

From: Joshua Crofts

Date: Tue Nov 10 2026 - 07:23:59 EST


On Tue, 10 Nov 2026 12:06:36 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> On Tue, Nov 10, 2026 at 09:54:11AM +0100, Bartosz Golaszewski wrote:
> > 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:
>
> ...
>
> > > > #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.

The main proxy header one should beware when adding new drivers or tweaking
is kernel.h, better to just use the iwyu principle.

There are a few loose exceptions (i.e. not fully iwyu but good enough), e.g.

- bitops.h implies bits.h
- bitmap.h implies bitops.h
- acpi.h, i2c.h, spi.h etc. imply the corresponding linux/device_id/* header
- if you have an opaque pointer (like struct device * but don't use any
functions from device.h) you can just skip the header entirely.

This can be also "automated" using iwyu-tool (which requires LLVM). I have
a mapping file tailored for IIO but surely you can swap the iio headers for
gpio ones.

https://lore.kernel.org/all/20260512073505.1310-1-joshua.crofts1@xxxxxxxxx/

> > Is this documented anywhere?
>
> No, but feel free to start such a documentation. In IIO we did a huge work
> to enforce IWYU principle, and there we have some tribe knowledge about
> the dependencies and guarantees. (Cc'ed some people.) In this case the
> bitops.h inclusion is guaranteed by bitmap.h. If it stops doing like this
> it will be a flag day.

Would be great if someone documented this in detail, at least people who read
the docs and LLMs would learn it :P

Javier Carrasco Cruz wrote a blog post on iwyu-tool where he links to my
mapping file:

https://hackerbikepacker.com/iwyu

--
Kind regards,
Joshua Crofts