From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
linux-iio@vger.kernel.org, "Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Matti Vaittinen" <mazziesaccount@gmail.com>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Tanzir Hasan" <tanzhasanwork@gmail.com>
Subject: Re: [PATCH] iio: accel: kionix-kx022a: Apply approximate iwyu principles to includes
Date: Mon, 30 Jun 2025 15:06:16 +0100 [thread overview]
Message-ID: <20250630150616.000053b1@huawei.com> (raw)
In-Reply-To: <aGJp-NYffceeX8bi@smile.fi.intel.com>
On Mon, 30 Jun 2025 13:42:00 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Sun, Jun 29, 2025 at 07:43:36PM +0100, Jonathan Cameron wrote:
> > On Sun, 29 Jun 2025 19:36:49 +0100
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > >
> > > Motivated by the W=1 warning about export.h that was introduced this cycle
> > > this is an attempt to apply an approximation of the principles of including
> > > whatever is used in the file directly.
> > >
> > > Helped by the include-what-you-use tool.
> > >
> > > Reasoning:
> > > - Drop linux/moduleparam.h as completely unused.
> > > - linux/array_size.h for ARRAY_SIZE()
> > > - linux/bitmap.h for for_each_set_bit
> > > - linux/errno.h for error codes.
> > > - linux/export.h for EXPORT_SYMBOL*()
> > > - linux/math64.h for do_div - alternative would be asm/div64.h
> > > - linux/minmax.h for min()
> > > - linux/sysfs.h for sysfs_emit()
> > > - linux/time64.h for USEC_PER_MSEC
> > > - linux/iio/buffer.h for iio_push_to_buffers_with_timestamp()
> > > - asm/byteorder.h for le16_to_cpu()
> > >
> > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > ---
> > >
> > > I picked this one fairly randomly as an example but longer term I'd like
> > > to look through at least all new drivers with this in mind + all the ones
> > > that are currently messing up my W=1 build logs.
> > >
> > > Note I've been very descriptive in this patch to allow people to suggest
> > > better alternatives for some of the ones that aren't entirely obvious.
> > >
> > Helpfully I had a script lying around from 2021:
> > https://lore.kernel.org/all/20211003153306.391766-1-jic23@kernel.org/
> >
> > Just for reference I used iwyu with:
> >
> > make LLVM=1 LOCALVERSION= W=1 -j12 C=1 CHECK=include-what-you-use CHECKFLAGS="-Xiwyu --no_default_mappings -Xiwyu --mapping_file=iio.imp"
> >
> > where iio.imp is from a few years ago and contains:
> > { include: ["\"linux/sizes.h\"", "private", <linux/sizes.h>, "public"] },
> > { include: ["\"linux/slab.h\"", "private", <linux/slab.h>, "public"] },
> > { include: ["\"linux/spinlock.h\"", "private", <linux/spinlock.h>, "public"] },
> > { include: ["\"linux/spinlock_types.h\"", "private", <linux/spinlock.h>, "public"] },
> > { include: ["\"linux/spi/spi.h\"", "private", <linux/spi/spi.h>, "public"] },
> > { include: ["\"linux/stat.h\"", "private", <linux/stat.h>, "public"] },
> > { include: ["\"linux/stdarg.h\"", "private", <linux/stdarg.h>, "public"] },
> > { include: ["\"linux/stddef.h\"", "private", <linux/stddef.h>, "public"] },
> > { include: ["\"linux/string.h\"", "private", <linux/string.h>, "public"] },
> > { include: ["\"linux/stringify.h\"", "private", <linux/stringify.h>, "public"] },
> > { include: ["\"linux/sysfs.h\"", "private", <linux/sysfs.h>, "public"] },
> > { include: ["\"linux/types.h\"", "private", <linux/types.h>, "public"] },
> > { include: ["\"linux/uuid.h\"", "private", <linux/uuid.h>, "public"] },
> > { include: ["\"linux/sched.h\"", "private", <linux/sched.h>, "public"] },
> > { include: ["\"linux/wait.h\"", "private", <linux/wait.h>, "public"] },
> > { include: ["\"linux/workqueue.h\"", "private", <linux/workqueue.h>, "public"] },
> > { include: ["\"asm-generic/int-ll64.h\"", "private", <linux/types.h>, "public"] },
> > { include: ["\"linux/device.h\"", "private", <linux/device.h>, "public"] },
> > { include: ["\"linux/dev_printk.h\"", "private", <linux/device.h>, "public"] },
> > { include: ["\"linux/device/bus.h\"", "private", <linux/device.h>, "public"] },
> > { include: ["\"linux/device/driver.h\"", "private", <linux/device.h>, "public"] },
> > { include: ["\"linux/bits.h\"", "private", <linux/bits.h>, "public"] },
> > { include: ["\"vdso/bits.h\"", "private", <linux/bits.h>, "public"] },
> > { include: ["\"vdso/limits.h\"", "private", <linux/limits.h>, "public"] },
> > { include: ["\"linux/limits.h\"", "private", <linux/limits.h>, "public"] },
> > { include: ["\"vdso/ktime.h\"", "private", <linux/ktime.h>, "public"] },
> > { include: ["\"linux/ktime.h\"", "private", <linux/ktime.h>, "public"] },
> > { include: ["\"vdso/time64.h\"", "private", <linux/time64.h>, "public"] },
> > { include: ["\"linux/time.h\"", "private", <linux/time.h>, "public"] },
> > { include: ["\"linux/timer.h\"", "private", <linux/timer.h>, "public"] }
> > ]
> >
> > Clear this needs a few upates, like mutex_types.h -> mutex.h and
> > probably devres.h->device.h
>
> Right, we got a lot of new *_types.h headers.
> This is a database (kind of) I was talking about in previous reply.
> Can we actually start it as .iwyu or so in the kernel source tree?
Nick and Tanzir talked about using iwyu at Plumbers 2023 and probably have
a much better starting point that this (even more) ancient version.
I missed the talk completely at the time, but came across it more recently.
+CC them both
Jonathan
next prev parent reply other threads:[~2025-06-30 14:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-29 18:36 [PATCH] iio: accel: kionix-kx022a: Apply approximate iwyu principles to includes Jonathan Cameron
2025-06-29 18:43 ` Jonathan Cameron
2025-06-30 10:42 ` Andy Shevchenko
2025-06-30 14:06 ` Jonathan Cameron [this message]
2025-07-12 16:52 ` Tanzir Hasan
2025-06-30 10:40 ` Andy Shevchenko
2025-07-06 17:13 ` Jonathan Cameron
2025-07-10 6:53 ` Matti Vaittinen
2025-07-07 19:53 ` Andy Shevchenko
2025-07-09 13:32 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250630150616.000053b1@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nuno.sa@analog.com \
--cc=tanzhasanwork@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox