public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] iio: adc: Improve include relevance for some ADCs.
@ 2026-01-19 21:20 Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 01/11] iio: adc: ltc2471: Improve include relevance Jonathan Cameron
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:20 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

So this is a continuation of experimenting with IWYU to ensure that we
follow what I consider best practice in driver by including all
headers that are used (subject to some slightly fuzzy rules for some
of them standard kernel headers).

I was focusing on cases where kernel.h was included and moving from that
to the more specific headers. That partly explains why there were so
many headers to add. However, it is also clear that many standard
headers (mutex.h for example) were missing from these drivers.

There are a few notes and questions in the individual patch descriptions,
typically where I have either decided to ignore a recommendation or
conversely have broken things down more finely than IWYU was doing with
my config files.

All comments welcome.  Whilst I don't consider this particular high
priority (much of it was done in a train where I couldn't access my
email)m I would like to provide more examples in tree of what I consider
to the right way to do things!

Thanks,

Jonathan

Jonathan Cameron (11):
  iio: adc: ltc2471: Improve include relevance
  iio: adc: ltc2309: Improve include relevance
  iio: adc: max1027: Reorder headers into alphabetical order
  iio: adc: max1027: Improve include relevance
  iio: adc: max11100: Improve include relevance
  iio: adc: max11410: Improve relevance of includes
  iio: adc: ad4130: Improve include relevance
  iio: adc: ad7124: Improve include relevance
  iio: adc: ad7124: Replace device.h with more specific includes
  iio: adc: ad7192: Put headers in alphabetical order
  iio: adc: ad7192: Improve include relevance

 drivers/iio/adc/ad4130.c   | 22 ++++++++++++++++++----
 drivers/iio/adc/ad7124.c   | 17 +++++++++++++----
 drivers/iio/adc/ad7192.c   | 32 +++++++++++++++++++-------------
 drivers/iio/adc/ltc2309.c  |  9 ++++++++-
 drivers/iio/adc/ltc2471.c  |  8 ++++++--
 drivers/iio/adc/max1027.c  | 18 ++++++++++++++++--
 drivers/iio/adc/max11100.c | 11 ++++++++---
 drivers/iio/adc/max11410.c | 22 ++++++++++++++++++++--
 8 files changed, 108 insertions(+), 31 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 01/11] iio: adc: ltc2471: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-20  7:51   ` Andy Shevchenko
  2026-01-19 21:21 ` [PATCH 02/11] iio: adc: ltc2309: " Jonathan Cameron
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Based on output of iwyu drop unused iio/sysfs.h and replace kernel.h with
more appropriate includes. Add some other includes that were relying on
being indirectly included from other headers.

Justification for added includes:
  #include <asm/byteorder.h>          // for be16_to_cpu
  #include <linux/bits.h>             // for BIT
  #include <linux/dev_printk.h>       // for dev_err
  #include <linux/mod_devicetable.h>  // for i2c_device_id
  #include <linux/types.h>            // for __be16

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
---
 drivers/iio/adc/ltc2471.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ltc2471.c b/drivers/iio/adc/ltc2471.c
index a579107fd5c9..d0ba1b3a6ca1 100644
--- a/drivers/iio/adc/ltc2471.c
+++ b/drivers/iio/adc/ltc2471.c
@@ -7,12 +7,16 @@
  * Author: Mike Looijmans <mike.looijmans@topic.nl>
  */
 
+#include <linux/bits.h>
+#include <linux/dev_printk.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
-#include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/types.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
+
+#include <asm/byteorder.h>
 
 enum ltc2471_chips {
 	ltc2471,
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 02/11] iio: adc: ltc2309: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 01/11] iio: adc: ltc2471: Improve include relevance Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-20  7:52   ` Andy Shevchenko
  2026-01-19 21:21 ` [PATCH 03/11] iio: adc: max1027: Reorder headers into alphabetical order Jonathan Cameron
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Based on output of iwyu, drop kernel.h in favor of more specific includes
+ add some others that are only indirectly included from other headers.

Justification for additions:
  #include <asm/byteorder.h>         // for be16_to_cpu
  #include <linux/array_size.h>      // for ARRAY_SIZE
  #include <linux/bits.h>            // for BIT, GENMASK
  #include <linux/dev_printk.h>      // for dev_err, dev_err_probe
  #include <linux/err.h>             // for ERR_PTR, EINVAL, ENODEV, ENOMEM
  #include <linux/mod_devicetable.h> // for i2c_device_id, of_device_id
  #include <linux/types.h>           // for __be16, u8

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Liam Beguin <liambeguin@gmail.com>
---
 drivers/iio/adc/ltc2309.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 5f0d947d0615..2838e0a9858c 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -7,13 +7,20 @@
  *
  * Copyright (c) 2023, Liam Beguin <liambeguin@gmail.com>
  */
+#include <linux/array_size.h>
+#include <linux/bits.h>
 #include <linux/bitfield.h>
+#include <linux/dev_printk.h>
+#include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
-#include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/regulator/consumer.h>
+#include <linux/types.h>
+
+#include <asm/byteorder.h>
 
 #define LTC2309_ADC_RESOLUTION	12
 #define LTC2309_INTERNAL_REF_MV 4096
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 03/11] iio: adc: max1027: Reorder headers into alphabetical order
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 01/11] iio: adc: ltc2471: Improve include relevance Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 02/11] iio: adc: ltc2309: " Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-20  7:53   ` Andy Shevchenko
  2026-01-19 21:21 ` [PATCH 04/11] iio: adc: max1027: Improve include relevance Jonathan Cameron
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Only delay.h was out of place. Move that before adding missing headers
highlighted by iwyu.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/max1027.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
index 7e736e77d8bb..913665b52cea 100644
--- a/drivers/iio/adc/max1027.c
+++ b/drivers/iio/adc/max1027.c
@@ -12,11 +12,11 @@
   * Partial support for max1027 and similar chips.
   */
 
+#include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
-#include <linux/delay.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 04/11] iio: adc: max1027: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (2 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 03/11] iio: adc: max1027: Reorder headers into alphabetical order Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-20  7:56   ` Andy Shevchenko
  2026-01-21  9:37   ` Nuno Sá
  2026-01-19 21:21 ` [PATCH 05/11] iio: adc: max11100: " Jonathan Cameron
                   ` (8 subsequent siblings)
  12 siblings, 2 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Drop kernel.h in favor of more specific headers and add includes that were
previously relying on other headers including them.

Whether to include device.h or the relevant sub headers is non obvious.
In this case, there is an access to struct device for
spi->dev.driver->name which is used to name the irq.

The justification from iwyu for the additional includes is:
  #include <asm/byteorder.h>           // for be16_to_cpu
  #include <linux/array_size.h>        // for ARRAY_SIZE
  #include <linux/bitops.h>            // for BIT, GENMASK, fls, hweight32
  #include <linux/cleanup.h>           // for guard
  #include <linux/compiler.h>          // for __aligned
  #include <linux/completion.h>        // for complete, init_completion
  #include <linux/device.h>            // for dev_err, dev_name, devm_kmal. ..
  #include <linux/errno.h>             // for ENOMEM, EINVAL, EBUSY, ETIME...
  #include <linux/interrupt.h>         // for devm_request_irq, irqreturn
  #include <linux/jiffies.h>           // for msecs_to_jiffies
  #include <linux/minmax.h>            // for __cmp_op_max
  #include <linux/mutex.h>             // for class_mutex_constructor, cla...
  #include <linux/stddef.h>            // for NULL, false
  #include <linux/types.h>             // for u8, bool, __be16

stddef.h not directly included as few drivers do this.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/max1027.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
index 913665b52cea..22d90efc9ab6 100644
--- a/drivers/iio/adc/max1027.c
+++ b/drivers/iio/adc/max1027.c
@@ -12,11 +12,23 @@
   * Partial support for max1027 and similar chips.
   */
 
+#include <linux/array_size.h>
+#include <linux/bitops.h>
+#include <linux/cleanup.h>
+#include <linux/compiler.h>
+#include <linux/completion.h>
 #include <linux/delay.h>
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/printk.h>
 #include <linux/spi/spi.h>
+#include <linux/types.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
@@ -24,6 +36,8 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
+#include <asm/byteorder.h>
+
 #define MAX1027_CONV_REG  BIT(7)
 #define MAX1027_SETUP_REG BIT(6)
 #define MAX1027_AVG_REG   BIT(5)
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 05/11] iio: adc: max11100: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (3 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 04/11] iio: adc: max1027: Improve include relevance Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 06/11] iio: adc: max11410: Improve relevance of includes Jonathan Cameron
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Using the iwyu tool to help, drop kernel.h in favor of more specific
headers.
Also drop a delay.h and iio/driver.h as neither was used.
Add other headers that were relying on indirect includes.

Justification for additions:
  #include <linux/array_size.h>      // for ARRAY_SIZE
  #include <linux/bits.h>            // for BIT
  #include <linux/compiler.h>        // for __aligned
  #include <linux/dev_printk.h>      // for dev_err
  #include <linux/device/devres.h>   // for devm_add_action_or_reset
  #include <linux/err.h>             // for EINVAL, IS_ERR, PTR_ERR, ENOMEM
  #include <linux/minmax.h>          // for __cmp_op_max
  #include <linux/types.h>           // for u8

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/max11100.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c
index 520e37f75aac..f5adf7dba700 100644
--- a/drivers/iio/adc/max11100.c
+++ b/drivers/iio/adc/max11100.c
@@ -6,16 +6,21 @@
  * Copyright (C) 2016-17 Renesas Electronics Corporation
  * Copyright (C) 2016-17 Jacopo Mondi
  */
-#include <linux/delay.h>
-#include <linux/kernel.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/compiler.h>
+#include <linux/dev_printk.h>
+#include <linux/device/devres.h>
+#include <linux/err.h>
+#include <linux/minmax.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+#include <linux/types.h>
 #include <linux/unaligned.h>
 
 #include <linux/iio/iio.h>
-#include <linux/iio/driver.h>
 
 /*
  * LSB is the ADC single digital step
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 06/11] iio: adc: max11410: Improve relevance of includes
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (4 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 05/11] iio: adc: max11100: " Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 07/11] iio: adc: ad4130: Improve include relevance Jonathan Cameron
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Drop kernel.h in favor of more specific headers and add other headers that
were previously only indirectly included. Also add a forwards definition
of struct regulator as it is only used as an opaque pointer type in this
file.

Justification for new headers from iwyu:
  #include <linux/array_size.h>        // for ARRAY_SIZE
  #include <linux/bitops.h>            // for BIT, GENMASK, __clear_bit
  #include <linux/cleanup.h>           // for guard
  #include <linux/compiler.h>          // for __aligned
  #include <linux/completion.h>        // for complete, init_completion
  #include <linux/iio/iio.h>           // for iio_chan_spec, iio_chan_info...
  #include <linux/iopoll.h>            // for read_poll_timeout
  #include <linux/jiffies.h>           // for msecs_to_jiffies
  #include <linux/kstrtox.h>           // for kstrtobool
  #include <linux/log2.h>              // for order_base_2
  #include <linux/math.h>              // for DIV_ROUND_CLOSEST
  #include <linux/minmax.h>            // for clamp_val, __cmp_op_max
  #include <linux/mod_devicetable.h>   // for of_device_id, spi_device_id
  #include <linux/mutex.h>             // for class_mutex_constructor, mut...
  #include <linux/property.h>          // for fwnode_property_read_u32
  #include <linux/stddef.h>            // for NULL, true
  #include <linux/sysfs.h>             // for sysfs_emit, attribute_group
  #include <linux/types.h>             // for u32, u8, bool, ssize_t, alig...
  struct regulator;

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Ibrahim Tilki <Ibrahim.Tilki@analog.com>
---
 drivers/iio/adc/max11410.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/max11410.c b/drivers/iio/adc/max11410.c
index 511b2f14dfaf..c8a9718c4e4b 100644
--- a/drivers/iio/adc/max11410.c
+++ b/drivers/iio/adc/max11410.c
@@ -4,20 +4,36 @@
  *
  * Copyright 2022 Analog Devices Inc.
  */
+#include <linux/array_size.h>
+#include <linux/bitops.h>
 #include <linux/bitfield.h>
+#include <linux/cleanup.h>
+#include <linux/compiler.h>
+#include <linux/completion.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
+#include <linux/iopoll.h>
+#include <linux/jiffies.h>
+#include <linux/kstrtox.h>
+#include <linux/log2.h>
+#include <linux/math.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
-
+#include <linux/stddef.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
 #include <linux/unaligned.h>
 
 #include <linux/iio/buffer.h>
+#include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
@@ -130,6 +146,8 @@ struct max11410_channel_config {
 	bool buffered_vrefn;
 };
 
+struct regulator;
+
 struct max11410_state {
 	struct spi_device *spi_dev;
 	struct iio_trigger *trig;
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 07/11] iio: adc: ad4130: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (5 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 06/11] iio: adc: max11410: Improve relevance of includes Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 08/11] iio: adc: ad7124: " Jonathan Cameron
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Replace asm/div64.h with linux/math64.h and drop kernel.h in
favor of more specific includes.  Also add some others that should
be directly included to follow approximate include what you use.

Justification for new headers from iwyu with a couple of comments where
this deviates from recommendations.

  #include <linux/array_size.h>      // for ARRAY_SIZE
  #include <linux/bitmap.h>          // for for_each_set_bit
  #include <linux/build_bug.h>       // for static_assert
  #include <linux/compiler.h>        // for __aligned
  #include <linux/completion.h>      // for complete, init_completion, rei...
  #include <linux/container_of.h>    // for container_of

  #include <linux/init.h>            // for THIS_MODULE
Ignored this one as seems reasonable to assume module.h will always include
whereever that is!

  #include <linux/jiffies.h>         // for msecs_to_jiffies
  #include <linux/math.h>            // for rounddown
  #include <linux/math64.h>          // for div_u64, div_u64_rem, DIV64_U6...
  #include <linux/minmax.h>          // for __cmp_op_max
  #include <linux/mod_devicetable.h> // for of_device_id
  #include <linux/mutex.h>           // for class_mutex_constructor, class...
  #include <linux/of.h>              // for of_property_read_string, devic...
  #include <linux/stddef.h>          // for false, true, NULL
  #include <linux/string.h>          // for memcpy, memset
  #include <linux/stringify.h>       // for __stringify
  #include <linux/sysfs.h>           // for sysfs_emit
  #include <linux/types.h>           // for u32, bool, u64, u8, ssize_t

  struct fwnode_handle;
Ignored this last recomendation because I think property.h can reasonably
be expected to always include whereever this is.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Cosmin Tanislav <cosmin.tanislav@analog.com>
---
 drivers/iio/adc/ad4130.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ad4130.c b/drivers/iio/adc/ad4130.c
index 5567ae5dee88..745efefb7f35 100644
--- a/drivers/iio/adc/ad4130.c
+++ b/drivers/iio/adc/ad4130.c
@@ -4,8 +4,14 @@
  * Author: Cosmin Tanislav <cosmin.tanislav@analog.com>
  */
 
+#include <linux/array_size.h>
+#include <linux/bitmap.h>
 #include <linux/bitfield.h>
 #include <linux/bitops.h>
+#include <linux/build_bug.h>
+#include <linux/compiler.h>
+#include <linux/completion.h>
+#include <linux/container_of.h>
 #include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
@@ -15,16 +21,24 @@
 #include <linux/gpio/driver.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/kernel.h>
+#include <linux/jiffies.h>
+#include <linux/math.h>
+#include <linux/math64.h>
+#include <linux/minmax.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
-#include <linux/units.h>
-
-#include <asm/div64.h>
+#include <linux/stddef.h>
+#include <linux/stringify.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
 #include <linux/unaligned.h>
+#include <linux/units.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 08/11] iio: adc: ad7124: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (6 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 07/11] iio: adc: ad4130: Improve include relevance Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 09/11] iio: adc: ad7124: Replace device.h with more specific includes Jonathan Cameron
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Drop unused linux/kfifo.h and linux/iio/sysfs.h.
Replace kernel.h with more specific headers and add other missing
headers that should be directly included to follow approximate include
what you use principles.

Justification for new headers from iwyu:
  #include <linux/array_size.h>          // for ARRAY_SIZE
  #include <linux/container_of.h>        // for container_of
  #include <linux/kstrtox.h>             // for kstrtobool
  #include <linux/limits.h>              // for U32_MAX
  #include <linux/math.h>                // for DIV_ROUND_CLOSEST, abs
  #include <linux/mutex.h>               // for class_mutex_constructor
  #include <linux/slab.h>                // for __free_kfree
  #include <linux/stddef.h>              // for true, NULL, false, struct_...
  #include <linux/types.h>               // for bool, u32, u8, size_t, ssi...

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: David Lechner <dlechner@baylibre.com>
---
 drivers/iio/adc/ad7124.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index 5c1a8f886bcc..5d3be891fa7e 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -5,30 +5,36 @@
  * Copyright 2018 Analog Devices Inc.
  * Copyright 2025 BayLibre, SAS
  */
+#include <linux/array_size.h>
 #include <linux/bitfield.h>
 #include <linux/bitops.h>
 #include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
+#include <linux/container_of.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/kfifo.h>
+#include <linux/kstrtox.h>
+#include <linux/limits.h>
+#include <linux/math.h>
 #include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/sprintf.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
 #include <linux/units.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/adc/ad_sigma_delta.h>
-#include <linux/iio/sysfs.h>
 
 /* AD7124 registers */
 #define AD7124_COMMS			0x00
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 09/11] iio: adc: ad7124: Replace device.h with more specific includes
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (7 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 08/11] iio: adc: ad7124: " Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 10/11] iio: adc: ad7192: Put headers in alphabetical order Jonathan Cameron
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Separate patch to make this change more obvious.
This driver makes no direct use of anything in device.h but
uses both include/linux/device/devres.h and include/linux/dev_printk.h
as well as needing a forwards def for struct device.
So replace device.h with those headers and the struct device forwards
definition.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: David Lechner <dlechner@baylibre.com>
---
I'm still tweaking my iwyu config, so currently it doesn't suggest this
one automatically. I'm interested to hear opinions on whether it is a
good way to go or not!
---
 drivers/iio/adc/ad7124.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index 5d3be891fa7e..84da872fab6f 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -14,7 +14,8 @@
 #include <linux/container_of.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
-#include <linux/device.h>
+#include <linux/dev_printk.h>
+#include <linux/device/devres.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/kstrtox.h>
@@ -36,6 +37,8 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/adc/ad_sigma_delta.h>
 
+struct device;
+
 /* AD7124 registers */
 #define AD7124_COMMS			0x00
 #define AD7124_STATUS			0x00
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 10/11] iio: adc: ad7192: Put headers in alphabetical order
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (8 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 09/11] iio: adc: ad7124: Replace device.h with more specific includes Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-19 21:21 ` [PATCH 11/11] iio: adc: ad7192: Improve include relevance Jonathan Cameron
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Precusor to cleaning them up that makes it easier to see what
is being done.  Leave the iio/ ones alone as many of those will be
dropped.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alisa-Dariana Roman <alisadariana@gmail.com>
---
 drivers/iio/adc/ad7192.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
index 530e1d307860..6b48581d7606 100644
--- a/drivers/iio/adc/ad7192.c
+++ b/drivers/iio/adc/ad7192.c
@@ -5,23 +5,23 @@
  * Copyright 2011-2015 Analog Devices Inc.
  */
 
-#include <linux/interrupt.h>
 #include <linux/bitfield.h>
 #include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
+#include <linux/delay.h>
 #include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/spi/spi.h>
-#include <linux/regulator/consumer.h>
 #include <linux/err.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
+#include <linux/module.h>
 #include <linux/property.h>
+#include <linux/regulator/consumer.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+#include <linux/sysfs.h>
 #include <linux/units.h>
 
 #include <linux/iio/iio.h>
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 11/11] iio: adc: ad7192: Improve include relevance
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (9 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 10/11] iio: adc: ad7192: Put headers in alphabetical order Jonathan Cameron
@ 2026-01-19 21:21 ` Jonathan Cameron
  2026-01-20  7:58 ` [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Andy Shevchenko
  2026-01-21  9:41 ` Nuno Sá
  12 siblings, 0 replies; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-19 21:21 UTC (permalink / raw)
  To: linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Drop unused:
  #include <linux/iio/buffer.h>  // lines 29-29
  #include <linux/iio/trigger.h>  // lines 30-30
  #include <linux/iio/trigger_consumer.h>  // lines 31-31
  #include <linux/iio/triggered_buffer.h>  // lines 32-32
  #include <linux/sched.h>  // lines 20-20
  #include <linux/slab.h>  // lines 15-15

Replace kernel.h with more specific headers and add missing headers.

Justification from iwyu for added headers:
  #include <linux/array_size.h>          // for ARRAY_SIZE
  #include <linux/bitmap.h>              // for for_each_set_bit
  #include <linux/bits.h>                // for BIT, GENMASK
  #include <linux/compiler.h>            // for inline
  #include <linux/container_of.h>        // for container_of
  #include <linux/kstrtox.h>             // for kstrtobool
  #include <linux/limits.h>              // for U32_MAX
  #include <linux/math.h>                // for DIV_ROUND_CLOSEST, DIV_ROU...
  #include <linux/math64.h>              // for do_div
  #include <linux/minmax.h>              // for in_range
  #include <linux/mutex.h>               // for class_mutex_constructor
  #include <linux/stddef.h>              // for true, NULL, false
  #include <linux/types.h>               // for bool, u32, u8, ssize_t

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alisa-Dariana Roman <alisadariana@gmail.com>
---
 drivers/iio/adc/ad7192.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
index 6b48581d7606..24e1fa796829 100644
--- a/drivers/iio/adc/ad7192.c
+++ b/drivers/iio/adc/ad7192.c
@@ -5,31 +5,37 @@
  * Copyright 2011-2015 Analog Devices Inc.
  */
 
+#include <linux/array_size.h>
 #include <linux/bitfield.h>
+#include <linux/bitmap.h>
+#include <linux/bits.h>
 #include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
+#include <linux/compiler.h>
+#include <linux/container_of.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
+#include <linux/kstrtox.h>
+#include <linux/limits.h>
+#include <linux/math.h>
+#include <linux/math64.h>
+#include <linux/minmax.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
 #include <linux/units.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/trigger.h>
-#include <linux/iio/trigger_consumer.h>
-#include <linux/iio/triggered_buffer.h>
 #include <linux/iio/adc/ad_sigma_delta.h>
 
 /* Registers */
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 01/11] iio: adc: ltc2471: Improve include relevance
  2026-01-19 21:21 ` [PATCH 01/11] iio: adc: ltc2471: Improve include relevance Jonathan Cameron
@ 2026-01-20  7:51   ` Andy Shevchenko
  0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-01-20  7:51 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Mon, Jan 19, 2026 at 09:21:00PM +0000, Jonathan Cameron wrote:

> Based on output of iwyu drop unused iio/sysfs.h and replace kernel.h with
> more appropriate includes. Add some other includes that were relying on
> being indirectly included from other headers.
> 
> Justification for added includes:
>   #include <asm/byteorder.h>          // for be16_to_cpu
>   #include <linux/bits.h>             // for BIT
>   #include <linux/dev_printk.h>       // for dev_err
>   #include <linux/mod_devicetable.h>  // for i2c_device_id
>   #include <linux/types.h>            // for __be16

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
with below comments to be considered.

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> Cc: Mike Looijmans <mike.looijmans@topic.nl>

Move Cc below '---'

> ---
>  drivers/iio/adc/ltc2471.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

> +#include <linux/bits.h>
> +#include <linux/dev_printk.h>
>  #include <linux/err.h>
>  #include <linux/i2c.h>
> -#include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/types.h>

+ blank line here, otherwise it might be recognised as unordered piece.

>  #include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 02/11] iio: adc: ltc2309: Improve include relevance
  2026-01-19 21:21 ` [PATCH 02/11] iio: adc: ltc2309: " Jonathan Cameron
@ 2026-01-20  7:52   ` Andy Shevchenko
  0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-01-20  7:52 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Mon, Jan 19, 2026 at 09:21:01PM +0000, Jonathan Cameron wrote:

> 
> Based on output of iwyu, drop kernel.h in favor of more specific includes
> + add some others that are only indirectly included from other headers.
> 
> Justification for additions:
>   #include <asm/byteorder.h>         // for be16_to_cpu
>   #include <linux/array_size.h>      // for ARRAY_SIZE
>   #include <linux/bits.h>            // for BIT, GENMASK
>   #include <linux/dev_printk.h>      // for dev_err, dev_err_probe
>   #include <linux/err.h>             // for ERR_PTR, EINVAL, ENODEV, ENOMEM
>   #include <linux/mod_devicetable.h> // for i2c_device_id, of_device_id
>   #include <linux/types.h>           // for __be16, u8

Similar comments and one Q here. Should we establish IIO header grouping in all
(touched) drivers? If so, move it outside of linux/*.

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Liam Beguin <liambeguin@gmail.com>
> ---

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 03/11] iio: adc: max1027: Reorder headers into alphabetical order
  2026-01-19 21:21 ` [PATCH 03/11] iio: adc: max1027: Reorder headers into alphabetical order Jonathan Cameron
@ 2026-01-20  7:53   ` Andy Shevchenko
  0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-01-20  7:53 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Mon, Jan 19, 2026 at 09:21:02PM +0000, Jonathan Cameron wrote:

> Only delay.h was out of place. Move that before adding missing headers
> highlighted by iwyu.

Hmm... What's the justification for kernel.h? might_*()?

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> ---

Cc to be located here...

>  drivers/iio/adc/max1027.c | 2 +-

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] iio: adc: max1027: Improve include relevance
  2026-01-19 21:21 ` [PATCH 04/11] iio: adc: max1027: Improve include relevance Jonathan Cameron
@ 2026-01-20  7:56   ` Andy Shevchenko
  2026-01-20 22:10     ` Jonathan Cameron
  2026-01-21  9:37   ` Nuno Sá
  1 sibling, 1 reply; 21+ messages in thread
From: Andy Shevchenko @ 2026-01-20  7:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Mon, Jan 19, 2026 at 09:21:03PM +0000, Jonathan Cameron wrote:

> Drop kernel.h in favor of more specific headers and add includes that were
> previously relying on other headers including them.
> 
> Whether to include device.h or the relevant sub headers is non obvious.
> In this case, there is an access to struct device for
> spi->dev.driver->name which is used to name the irq.
> 
> The justification from iwyu for the additional includes is:
>   #include <asm/byteorder.h>           // for be16_to_cpu
>   #include <linux/array_size.h>        // for ARRAY_SIZE
>   #include <linux/bitops.h>            // for BIT, GENMASK, fls, hweight32
>   #include <linux/cleanup.h>           // for guard
>   #include <linux/compiler.h>          // for __aligned
>   #include <linux/completion.h>        // for complete, init_completion

>   #include <linux/device.h>            // for dev_err, dev_name, devm_kmal. ..

Not good, we also should treat device.h as "include everything" and try to
avoid that, above comment hints like

dev_printk.h
device/devres.h

>   #include <linux/errno.h>             // for ENOMEM, EINVAL, EBUSY, ETIME...
>   #include <linux/interrupt.h>         // for devm_request_irq, irqreturn
>   #include <linux/jiffies.h>           // for msecs_to_jiffies
>   #include <linux/minmax.h>            // for __cmp_op_max
>   #include <linux/mutex.h>             // for class_mutex_constructor, cla...
>   #include <linux/stddef.h>            // for NULL, false
>   #include <linux/types.h>             // for u8, bool, __be16

> stddef.h not directly included as few drivers do this.

Yes, we assume that types guarantees stddef.h to be provided.

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> ---

Cc here...

>  drivers/iio/adc/max1027.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)

...

> +#include <linux/array_size.h>
> +#include <linux/bitops.h>
> +#include <linux/cleanup.h>

> +#include <linux/compiler.h>

Same as stddef. types.h will bring this.

> +#include <linux/completion.h>
>  #include <linux/delay.h>
> -#include <linux/kernel.h>

> +#include <linux/device.h>

See above.

> +#include <linux/errno.h>
> +#include <linux/interrupt.h>
> +#include <linux/jiffies.h>
> +#include <linux/minmax.h>
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/mutex.h>
> +#include <linux/printk.h>
>  #include <linux/spi/spi.h>
> +#include <linux/types.h>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/11] iio: adc: Improve include relevance for some ADCs.
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (10 preceding siblings ...)
  2026-01-19 21:21 ` [PATCH 11/11] iio: adc: ad7192: Improve include relevance Jonathan Cameron
@ 2026-01-20  7:58 ` Andy Shevchenko
  2026-01-21  9:41 ` Nuno Sá
  12 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-01-20  7:58 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Mon, Jan 19, 2026 at 09:20:59PM +0000, Jonathan Cameron wrote:

> So this is a continuation of experimenting with IWYU to ensure that we
> follow what I consider best practice in driver by including all
> headers that are used (subject to some slightly fuzzy rules for some
> of them standard kernel headers).
> 
> I was focusing on cases where kernel.h was included and moving from that
> to the more specific headers. That partly explains why there were so
> many headers to add. However, it is also clear that many standard
> headers (mutex.h for example) were missing from these drivers.
> 
> There are a few notes and questions in the individual patch descriptions,
> typically where I have either decided to ignore a recommendation or
> conversely have broken things down more finely than IWYU was doing with
> my config files.
> 
> All comments welcome.  Whilst I don't consider this particular high
> priority (much of it was done in a train where I couldn't access my
> email)m I would like to provide more examples in tree of what I consider

"m"? Bump on the rail that makes your finger slip over keyboard? :-)

> to the right way to do things!

I commented 4 patches, but seems the set of issues I found is repetitive,
So, please address those in all patches and I will look into v2.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] iio: adc: max1027: Improve include relevance
  2026-01-20  7:56   ` Andy Shevchenko
@ 2026-01-20 22:10     ` Jonathan Cameron
  2026-01-20 22:52       ` Andy Shevchenko
  0 siblings, 1 reply; 21+ messages in thread
From: Jonathan Cameron @ 2026-01-20 22:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Tue, 20 Jan 2026 09:56:59 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, Jan 19, 2026 at 09:21:03PM +0000, Jonathan Cameron wrote:
> 
> > Drop kernel.h in favor of more specific headers and add includes that were
> > previously relying on other headers including them.
> > 
> > Whether to include device.h or the relevant sub headers is non obvious.
> > In this case, there is an access to struct device for
> > spi->dev.driver->name which is used to name the irq.
> > 
> > The justification from iwyu for the additional includes is:
> >   #include <asm/byteorder.h>           // for be16_to_cpu
> >   #include <linux/array_size.h>        // for ARRAY_SIZE
> >   #include <linux/bitops.h>            // for BIT, GENMASK, fls, hweight32
> >   #include <linux/cleanup.h>           // for guard
> >   #include <linux/compiler.h>          // for __aligned
> >   #include <linux/completion.h>        // for complete, init_completion  
> 
> >   #include <linux/device.h>            // for dev_err, dev_name, devm_kmal. ..  
> 
> Not good, we also should treat device.h as "include everything" and try to
> avoid that, above comment hints like
> 
> dev_printk.h
> device/devres.h

It's there for
spi->dev.driver->name used for some reason as the irq name.

I considered fixing that but felt it was out of scope for this series.
I'll add a comment as iwyu forgot to mention use of struct device ;)

Thanks,

Jonathan


> 
> >   #include <linux/errno.h>             // for ENOMEM, EINVAL, EBUSY, ETIME...

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] iio: adc: max1027: Improve include relevance
  2026-01-20 22:10     ` Jonathan Cameron
@ 2026-01-20 22:52       ` Andy Shevchenko
  0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-01-20 22:52 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Andy Shevchenko, David Lechner, Nuno Sá,
	Mike Looijmans, Liam Beguin, Miquel Raynal, Ibrahim Tilki,
	Cosmin Tanislav, Alisa-Dariana Roman, Jonathan Cameron

On Tue, Jan 20, 2026 at 10:10:40PM +0000, Jonathan Cameron wrote:
> On Tue, 20 Jan 2026 09:56:59 +0200
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > On Mon, Jan 19, 2026 at 09:21:03PM +0000, Jonathan Cameron wrote:

...

> > >   #include <linux/device.h>            // for dev_err, dev_name, devm_kmal. ..  
> > 
> > Not good, we also should treat device.h as "include everything" and try to
> > avoid that, above comment hints like
> > 
> > dev_printk.h
> > device/devres.h
> 
> It's there for
> spi->dev.driver->name used for some reason as the irq name.

Ah, I see...

> I considered fixing that but felt it was out of scope for this series.

Sure thing!

> I'll add a comment as iwyu forgot to mention use of struct device ;)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] iio: adc: max1027: Improve include relevance
  2026-01-19 21:21 ` [PATCH 04/11] iio: adc: max1027: Improve include relevance Jonathan Cameron
  2026-01-20  7:56   ` Andy Shevchenko
@ 2026-01-21  9:37   ` Nuno Sá
  1 sibling, 0 replies; 21+ messages in thread
From: Nuno Sá @ 2026-01-21  9:37 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

On Mon, 2026-01-19 at 21:21 +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Drop kernel.h in favor of more specific headers and add includes that were
> previously relying on other headers including them.
> 
> Whether to include device.h or the relevant sub headers is non obvious.
> In this case, there is an access to struct device for
> spi->dev.driver->name which is used to name the irq.
> 
> The justification from iwyu for the additional includes is:
>   #include <asm/byteorder.h>           // for be16_to_cpu
>   #include <linux/array_size.h>        // for ARRAY_SIZE
>   #include <linux/bitops.h>            // for BIT, GENMASK, fls, hweight32
>   #include <linux/cleanup.h>           // for guard
>   #include <linux/compiler.h>          // for __aligned
>   #include <linux/completion.h>        // for complete, init_completion
>   #include <linux/device.h>            // for dev_err, dev_name, devm_kmal. ..
>   #include <linux/errno.h>             // for ENOMEM, EINVAL, EBUSY, ETIME...
>   #include <linux/interrupt.h>         // for devm_request_irq, irqreturn
>   #include <linux/jiffies.h>           // for msecs_to_jiffies
>   #include <linux/minmax.h>            // for __cmp_op_max
>   #include <linux/mutex.h>             // for class_mutex_constructor, cla...
>   #include <linux/stddef.h>            // for NULL, false
>   #include <linux/types.h>             // for u8, bool, __be16
> 
> stddef.h not directly included as few drivers do this.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/iio/adc/max1027.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
> index 913665b52cea..22d90efc9ab6 100644
> --- a/drivers/iio/adc/max1027.c
> +++ b/drivers/iio/adc/max1027.c
> @@ -12,11 +12,23 @@
>    * Partial support for max1027 and similar chips.
>    */
>  
> +#include <linux/array_size.h>
> +#include <linux/bitops.h>
> +#include <linux/cleanup.h>
> +#include <linux/compiler.h>
> +#include <linux/completion.h>
>  #include <linux/delay.h>
> -#include <linux/kernel.h>
> +#include <linux/device.h>
> +#include <linux/errno.h>
> +#include <linux/interrupt.h>
> +#include <linux/jiffies.h>
> +#include <linux/minmax.h>
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/mutex.h>
> +#include <linux/printk.h>

To be consistent, the above should also be in the commit message.

- Nuno Sá

>  #include <linux/spi/spi.h>
> +#include <linux/types.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/buffer.h>
> @@ -24,6 +36,8 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  
> +#include <asm/byteorder.h>
> +
>  #define MAX1027_CONV_REG  BIT(7)
>  #define MAX1027_SETUP_REG BIT(6)
>  #define MAX1027_AVG_REG   BIT(5)

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/11] iio: adc: Improve include relevance for some ADCs.
  2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
                   ` (11 preceding siblings ...)
  2026-01-20  7:58 ` [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Andy Shevchenko
@ 2026-01-21  9:41 ` Nuno Sá
  12 siblings, 0 replies; 21+ messages in thread
From: Nuno Sá @ 2026-01-21  9:41 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, Andy Shevchenko
  Cc: David Lechner, Nuno Sá, Mike Looijmans, Liam Beguin,
	Miquel Raynal, Ibrahim Tilki, Cosmin Tanislav,
	Alisa-Dariana Roman, Jonathan Cameron

On Mon, 2026-01-19 at 21:20 +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> So this is a continuation of experimenting with IWYU to ensure that we
> follow what I consider best practice in driver by including all
> headers that are used (subject to some slightly fuzzy rules for some
> of them standard kernel headers).
> 
> I was focusing on cases where kernel.h was included and moving from that
> to the more specific headers. That partly explains why there were so
> many headers to add. However, it is also clear that many standard
> headers (mutex.h for example) were missing from these drivers.
> 
> There are a few notes and questions in the individual patch descriptions,
> typically where I have either decided to ignore a recommendation or
> conversely have broken things down more finely than IWYU was doing with
> my config files.
> 
> All comments welcome.  Whilst I don't consider this particular high
> priority (much of it was done in a train where I couldn't access my
> email)m I would like to provide more examples in tree of what I consider
> to the right way to do things!
> 
> Thanks,
> 
> Jonathan
> 
> Jonathan Cameron (11):
>   iio: adc: ltc2471: Improve include relevance
>   iio: adc: ltc2309: Improve include relevance
>   iio: adc: max1027: Reorder headers into alphabetical order
>   iio: adc: max1027: Improve include relevance
>   iio: adc: max11100: Improve include relevance
>   iio: adc: max11410: Improve relevance of includes
>   iio: adc: ad4130: Improve include relevance
>   iio: adc: ad7124: Improve include relevance
>   iio: adc: ad7124: Replace device.h with more specific includes
>   iio: adc: ad7192: Put headers in alphabetical order
>   iio: adc: ad7192: Improve include relevance
> 
>  drivers/iio/adc/ad4130.c   | 22 ++++++++++++++++++----
>  drivers/iio/adc/ad7124.c   | 17 +++++++++++++----
>  drivers/iio/adc/ad7192.c   | 32 +++++++++++++++++++-------------
>  drivers/iio/adc/ltc2309.c  |  9 ++++++++-
>  drivers/iio/adc/ltc2471.c  |  8 ++++++--
>  drivers/iio/adc/max1027.c  | 18 ++++++++++++++++--
>  drivers/iio/adc/max11100.c | 11 ++++++++---
>  drivers/iio/adc/max11410.c | 22 ++++++++++++++++++++--
>  8 files changed, 108 insertions(+), 31 deletions(-)

Just one minor comment. LGTM

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2026-01-21  9:40 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 21:20 [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Jonathan Cameron
2026-01-19 21:21 ` [PATCH 01/11] iio: adc: ltc2471: Improve include relevance Jonathan Cameron
2026-01-20  7:51   ` Andy Shevchenko
2026-01-19 21:21 ` [PATCH 02/11] iio: adc: ltc2309: " Jonathan Cameron
2026-01-20  7:52   ` Andy Shevchenko
2026-01-19 21:21 ` [PATCH 03/11] iio: adc: max1027: Reorder headers into alphabetical order Jonathan Cameron
2026-01-20  7:53   ` Andy Shevchenko
2026-01-19 21:21 ` [PATCH 04/11] iio: adc: max1027: Improve include relevance Jonathan Cameron
2026-01-20  7:56   ` Andy Shevchenko
2026-01-20 22:10     ` Jonathan Cameron
2026-01-20 22:52       ` Andy Shevchenko
2026-01-21  9:37   ` Nuno Sá
2026-01-19 21:21 ` [PATCH 05/11] iio: adc: max11100: " Jonathan Cameron
2026-01-19 21:21 ` [PATCH 06/11] iio: adc: max11410: Improve relevance of includes Jonathan Cameron
2026-01-19 21:21 ` [PATCH 07/11] iio: adc: ad4130: Improve include relevance Jonathan Cameron
2026-01-19 21:21 ` [PATCH 08/11] iio: adc: ad7124: " Jonathan Cameron
2026-01-19 21:21 ` [PATCH 09/11] iio: adc: ad7124: Replace device.h with more specific includes Jonathan Cameron
2026-01-19 21:21 ` [PATCH 10/11] iio: adc: ad7192: Put headers in alphabetical order Jonathan Cameron
2026-01-19 21:21 ` [PATCH 11/11] iio: adc: ad7192: Improve include relevance Jonathan Cameron
2026-01-20  7:58 ` [PATCH 00/11] iio: adc: Improve include relevance for some ADCs Andy Shevchenko
2026-01-21  9:41 ` Nuno Sá

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox