Skip to contentSkip to conversation

IIO: More application of IWYU principles to includes.

PATCH In review Jonathan Cameron 3 participants 11 messages Jul 10, 2025

Subsystems (3)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover IIO: More application of IWYU principles to includes.

From: Jonathan Cameron <[email protected]>

I decided to look at a slightly larger set to continue trying to come up with consistent rules (for IIO anyway) on what we want to include direclty and what assumptions we can make about a header always including another.

As the series goes on reduce the amount of info on particular choices made just because the commit descriptions were getting very long.

A few open questions.
- linux/stddef.h - do we want to included this directly?
- linux/types.h - do we want to include this directly?
- linux/dev_printk.h - include even if device.h is needed for other reasons or rely on that as a grouping header if present and only use dev_printk where we don't need device.h.

I'll share a refreshed IWYU config once we come to firmer conclusions on the various choices. I haven't yet figured out now to not include anything at all for things like CONFIG*

Jonathan Cameron (7):
iio: pressure: bmp280: Apply iwyu principles to includes.
iio: pressure: zpa2326: Apply iwyu principles to includes
iio: pressure: mpl115: Apply iwyu principles to includes
iio: pressure: ms5611: Apply iwyu principles to includes
iio: pressure: hsc030pa: Apply IWYU principles to includes.
iio: pressure: mprls0025pa: Apply IWYU principles to includes.
iio: st_sensors: Apply IWYU principles to includes

 drivers/iio/accel/st_accel_buffer.c           |  6 ++++--
 drivers/iio/accel/st_accel_core.c             | 12 ++++++++---
 drivers/iio/accel/st_accel_i2c.c              |  5 ++++-
 drivers/iio/accel/st_accel_spi.c              |  3 ++-
 .../iio/common/st_sensors/st_sensors_buffer.c | 15 +++++++++-----
 .../iio/common/st_sensors/st_sensors_core.c   | 19 ++++++++++++++----
 .../iio/common/st_sensors/st_sensors_core.h   |  2 ++
 .../iio/common/st_sensors/st_sensors_i2c.c    |  8 ++++++--
 .../iio/common/st_sensors/st_sensors_spi.c    | 11 ++++++++--
 .../common/st_sensors/st_sensors_trigger.c    | 13 +++++++++---
 drivers/iio/gyro/st_gyro_buffer.c             |  6 ++++--
 drivers/iio/gyro/st_gyro_core.c               | 11 +++++++---
 drivers/iio/gyro/st_gyro_i2c.c                |  3 ++-
 drivers/iio/gyro/st_gyro_spi.c                |  3 ++-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c  |  5 ++++-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c   |  5 ++---
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c   |  5 ++---
 drivers/iio/magnetometer/st_magn_buffer.c     |  5 +++--
 drivers/iio/magnetometer/st_magn_core.c       | 11 +++++++---
 drivers/iio/magnetometer/st_magn_i2c.c        |  3 ++-
 drivers/iio/magnetometer/st_magn_spi.c        |  3 ++-
 drivers/iio/pressure/bmp280-core.c            | 17 ++++++++++++++--
 drivers/iio/pressure/bmp280-i2c.c             |  4 ++++
 drivers/iio/pressure/bmp280-regmap.c          |  6 ++++--
 drivers/iio/pressure/bmp280-spi.c             |  6 ++++++
 drivers/iio/pressure/hsc030pa.c               | 12 +++++------
 drivers/iio/pressure/hsc030pa.h               |  5 ++---
 drivers/iio/pressure/hsc030pa_i2c.c           |  4 ----
 drivers/iio/pressure/hsc030pa_spi.c           |  5 -----
 drivers/iio/pressure/mpl115.c                 | 13 +++++++++---
 drivers/iio/pressure/mpl115.h                 |  1 +
 drivers/iio/pressure/mpl115_i2c.c             |  8 +++++++-
 drivers/iio/pressure/mpl115_spi.c             |  5 +++++
 drivers/iio/pressure/mprls0025pa.c            |  9 +++++++--
 drivers/iio/pressure/mprls0025pa.h            |  9 ++-------
 drivers/iio/pressure/mprls0025pa_i2c.c        |  1 -
 drivers/iio/pressure/ms5611_core.c            | 15 +++++++++++---
 drivers/iio/pressure/ms5611_i2c.c             |  5 ++++-
 drivers/iio/pressure/ms5611_spi.c             |  9 +++++++--
 drivers/iio/pressure/st_pressure_buffer.c     |  6 ++++--
 drivers/iio/pressure/st_pressure_core.c       |  9 ++++++---
 drivers/iio/pressure/st_pressure_i2c.c        |  3 ++-
 drivers/iio/pressure/st_pressure_spi.c        |  3 ++-
 drivers/iio/pressure/zpa2326.c                | 20 +++++++++++++++----
 drivers/iio/pressure/zpa2326.h                |  3 +++
 drivers/iio/pressure/zpa2326_i2c.c            |  7 +++++--
 drivers/iio/pressure/zpa2326_spi.c            |  6 +++++-
 include/linux/iio/common/st_sensors_i2c.h     |  5 ++---
 include/linux/iio/common/st_sensors_spi.h     |  5 ++---
 49 files changed, 249 insertions(+), 106 deletions(-)
Signature · 1 line
2.50.0
author maintainer
#1 lore raw

PATCH 1/7 iio: pressure: bmp280: Apply iwyu principles to includes.

From: Jonathan Cameron <[email protected]>

The recent introduction of a warning on missing include of linux/export.h when W=1 motivated revisiting the includes in affected drivers. In general IWYU principles avoid complex include paths that make it hard to refactor headers.

- Move linux/unaligned.h entry to appropriate place.
- Drop comment on linux/irq.h as we don't generally keep a record in code of why includes are there.

Remove
- linux/device.h from bmp280-regmap.c as struct device forwards definition is enough.
- linux/module.h from bmp280-regmap.c as the module stuff is all in the other files.
Add all of:
- linux/array_size.h for ARRAY_SIZE()
- linux/device.h in the i2c and spi drivers
- linux/err.h for PTR_ERR() etc and also assume includes errno.h
- linux/export.h for EXPORT_SYMBOL*()
- linux/jiffies.h for msecs_to_jiffies
- linux/log2.h for ilog2()
- linux/math64.h for div64_s64
- linux/minmax.h for clamp_val()
- linux/mod_devicetable.h for spi_device_id etc
- linux/mutex.h for various mutex calls
- linux/pm.h for pm_ptr()
- linux/stddef.h for false / true
- linux/string.h for memcpy
- linux/string_choices.h for str_enable_disable
- linux/time.h for USEC_PER_MSEC
- linux/types.h for local bool definition.

---
I'm not sure on whether we should bother with stddef.h or types.h Looking for feedback on any others.

---
 drivers/iio/pressure/bmp280-core.c   | 17 +++++++++++++++--
 drivers/iio/pressure/bmp280-i2c.c    |  4 ++++
 drivers/iio/pressure/bmp280-regmap.c |  6 ++++--
 drivers/iio/pressure/bmp280-spi.c    |  6 ++++++
 4 files changed, 29 insertions(+), 4 deletions(-)
drivers/iio/pressure/bmp280-core.c +15 -2
index 74505c9ec1a0..e5d2de8cd5ef 100644
@@ -30,23 +30,36 @@
 
 #define pr_fmt(fmt) "bmp280: " fmt
 
+#include <linux/array_size.h>
 #include <linux/bitops.h>
 #include <linux/bitfield.h>
 #include <linux/cleanup.h>
 #include <linux/completion.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/err.h>
+#include <linux/export.h>
 #include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
-#include <linux/irq.h> /* For irq_get_irq_data() */
+#include <linux/irq.h>
+#include <linux/jiffies.h>
+#include <linux/log2.h>
+#include <linux/math64.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/nvmem-provider.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
+#include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/random.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/stddef.h>
+#include <linux/time64.h>
 #include <linux/types.h>
+#include <linux/unaligned.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
@@ -54,7 +67,7 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-#include <linux/unaligned.h>
+#include <asm/byteorder.h>
 
 #include "bmp280.h"
 
drivers/iio/pressure/bmp280-i2c.c +4 -0
index 8e459b6c97ff..6484341af710 100644
@@ -1,6 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-only
+#include <linux/device.h>
+#include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/pm.h>
 #include <linux/regmap.h>
 
 #include "bmp280.h"
drivers/iio/pressure/bmp280-regmap.c +4 -2
index b6a7b417c8cf..d34bf89afdda 100644
@@ -1,9 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/device.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/regmap.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
 
 #include "bmp280.h"
+struct device;
 
 static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg)
 {
drivers/iio/pressure/bmp280-spi.c +6 -0
index 3b90384f17d7..8ac68bfb8110 100644
@@ -5,10 +5,16 @@
  * Inspired by the older BMP085 driver drivers/misc/bmp085-spi.c
  */
 #include <linux/bits.h>
+#include <linux/device.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/pm.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/types.h>
 
 #include "bmp280.h"
 
Signature · 1 line
2.50.0
#2 lore raw

Re: [PATCH 1/7] iio: pressure: bmp280: Apply iwyu principles to includes.

Quoted 34 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

The recent introduction of a warning on missing include of linux/export.h when W=1 motivated revisiting the includes in affected drivers. In general IWYU principles avoid complex include paths that make it hard to refactor headers.

- Move linux/unaligned.h entry to appropriate place.
- Drop comment on linux/irq.h as we don't generally keep a record in code of why includes are there.

Remove
- linux/device.h from bmp280-regmap.c as struct device forwards definition is enough.
- linux/module.h from bmp280-regmap.c as the module stuff is all in the other files.
Add all of:
- linux/array_size.h for ARRAY_SIZE()
- linux/device.h in the i2c and spi drivers
- linux/err.h for PTR_ERR() etc and also assume includes errno.h
- linux/export.h for EXPORT_SYMBOL*()
- linux/jiffies.h for msecs_to_jiffies
- linux/log2.h for ilog2()
- linux/math64.h for div64_s64
- linux/minmax.h for clamp_val()
- linux/mod_devicetable.h for spi_device_id etc
- linux/mutex.h for various mutex calls
- linux/pm.h for pm_ptr()
- linux/stddef.h for false / true
- linux/string.h for memcpy
- linux/string_choices.h for str_enable_disable
- linux/time.h for USEC_PER_MSEC
- linux/types.h for local bool definition.

Quoted 4 lines

---
I'm not sure on whether we should bother with stddef.h or types.h Looking for feedback on any others.

types.h is superior.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw

PATCH 2/7 iio: pressure: zpa2326: Apply iwyu principles to includes

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Motivated by the new warning when W=1 if linux/exports.h is not included but the macros within it are used. Given the includes need improving go the whole way and apply include what you use principles to this driver.

Reasoning:
- First sort includes into alphabetical order, keeping the separate iio specific block and asm blocks as appropriate.
Drop:
- linux/kernel.h
Add:
- asm/byteorder.h for le16_to_cpup()
- linux/array_size.h for ARRAY_SIZE()
- linux/bitops.h for test_bit() (also BIT() etc in c files0
- linux/bits.h for BIT() in the header.
- linux/completion.h cof complete()
- linux/device.h for struct device
- linux/err.h for IS_ERR() and error codes.
- linux/export.h for EXPORT_SYMBOL*
- linux/jiffies.h for jiffies and HZ (in param.h)
- linux/pm.h for SET_RUNTIME_PM_OPS etc
Note that the way this driver handles CONFIG_PM is messy but not topic for this series.
- linux/stddef.h for true / false etc
- linux/sysfs.h for struct attribute_group

---
 drivers/iio/pressure/zpa2326.c     | 20 ++++++++++++++++----
 drivers/iio/pressure/zpa2326.h     |  3 +++
 drivers/iio/pressure/zpa2326_i2c.c |  7 +++++--
 drivers/iio/pressure/zpa2326_spi.c |  6 +++++-
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/iio/pressure/zpa2326.c +16 -4
index 6eef37c0952d..34743ee0be07 100644
@@ -51,20 +51,32 @@
  *   hardware samples averaging.
  */
 
-#include <linux/module.h>
-#include <linux/kernel.h>
+#include <linux/array_size.h>
+#include <linux/bitops.h>
+#include <linux/completion.h>
 #include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/export.h>
 #include <linux/interrupt.h>
-#include <linux/regulator/consumer.h>
+#include <linux/module.h>
+#include <linux/jiffies.h>
+#include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/stddef.h>
+#include <linux/sysfs.h>
+#include <linux/unaligned.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/unaligned.h>
+
+#include <asm/byteorder.h>
 #include "zpa2326.h"
 
 /* 200 ms should be enough for the longest conversion time in one-shot mode. */
drivers/iio/pressure/zpa2326.h +3 -0
index 45bd7900975b..a1ab574241eb 100644
@@ -10,6 +10,9 @@
 #ifndef _ZPA2326_H
 #define _ZPA2326_H
 
+#include <linux/bits.h>
+#include <linux/types.h>
+
 /* Register map. */
 #define ZPA2326_REF_P_XL_REG              (0x8)
 #define ZPA2326_REF_P_L_REG               (0x9)
drivers/iio/pressure/zpa2326_i2c.c +5 -2
index a6034bf05d97..ca05b84f420a 100644
@@ -7,10 +7,13 @@
  * Author: Gregor Boirie <[email protected]>
  */
 
-#include <linux/module.h>
-#include <linux/regmap.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/err.h>
 #include <linux/i2c.h>
+#include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/regmap.h>
 #include "zpa2326.h"
 
 /*
drivers/iio/pressure/zpa2326_spi.c +5 -1
index af756e2b0f31..14f8b2b809a0 100644
@@ -7,10 +7,14 @@
  * Author: Gregor Boirie <[email protected]>
  */
 
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
-#include <linux/mod_devicetable.h>
 #include "zpa2326.h"
 
 /*
Signature · 1 line
2.50.0
author maintainer
#4 lore raw

PATCH 3/7 iio: pressure: mpl115: Apply iwyu principles to includes

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Motivated by fixing the new W=1 warning for lack of include of linux/export.h this reworks all the includes for this driver along the lines of approximate include what you use principles.

One question here is what to do about gfp_types.h.
For now I've added a rule to allow GFP_KERNEL to come from linux/slab.h or linux/device.h (for devm_ calls). In this driver slab.h is never used directly so linux/device.h provides the symbol.

---
 drivers/iio/pressure/mpl115.c     | 13 ++++++++++---
 drivers/iio/pressure/mpl115.h     |  1 +
 drivers/iio/pressure/mpl115_i2c.c |  8 +++++++-
 drivers/iio/pressure/mpl115_spi.c |  5 +++++
 4 files changed, 23 insertions(+), 4 deletions(-)
drivers/iio/pressure/mpl115.c +10 -3
index 71beb28b7f2c..448d030d5621 100644
@@ -6,11 +6,18 @@
  *
  * TODO: synchronization with system suspend
  */
-
-#include <linux/module.h>
-#include <linux/iio/iio.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/export.h>
 #include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/pm_runtime.h>
+#include <linux/stddef.h>
+#include <linux/iio/iio.h>
 
 #include "mpl115.h"
 
drivers/iio/pressure/mpl115.h +1 -0
index 78a0068a17bb..480ee112f134 100644
@@ -7,6 +7,7 @@
  */
 
 #include <linux/pm_runtime.h>
+#include <linux/types.h>
 
 #ifndef _MPL115_H_
 #define _MPL115_H_
drivers/iio/pressure/mpl115_i2c.c +7 -1
index 3db9ef4e2770..160cf1e5a317 100644
@@ -9,11 +9,17 @@
  * Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MPL115A2.pdf
  */
 
-#include <linux/module.h>
+#include <linux/errno.h>
 #include <linux/i2c.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/types.h>
 
 #include "mpl115.h"
 
+struct device;
+
 static int mpl115_i2c_init(struct device *dev)
 {
 	return 0;
drivers/iio/pressure/mpl115_spi.c +5 -0
index 4e1d24beff94..26df328769a4 100644
@@ -7,8 +7,13 @@
  * Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MPL115A1.pdf
  */
 
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/pm.h>
 #include <linux/spi/spi.h>
+#include <linux/types.h>
 
 #include "mpl115.h"
 
Signature · 1 line
2.50.0
author maintainer
#5 lore raw

PATCH 4/7 iio: pressure: ms5611: Apply iwyu principles to includes

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Motivated by fixing the new W=1 warning for lack of include of linux/export.h this reworks all the includes for this driver along the lines of approximate include what you use principles.

---
 drivers/iio/pressure/ms5611_core.c | 15 ++++++++++++---
 drivers/iio/pressure/ms5611_i2c.c  |  5 ++++-
 drivers/iio/pressure/ms5611_spi.c  |  9 +++++++--
 3 files changed, 23 insertions(+), 6 deletions(-)
drivers/iio/pressure/ms5611_core.c +12 -3
index bdac27bd5a5d..e5e12b500af8 100644
@@ -9,12 +9,21 @@
  *  http://www.meas-spec.com/downloads/MS5607-02BA03.pdf
  *
  */
-
-#include <linux/module.h>
-#include <linux/iio/iio.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/regulator/consumer.h>
+#include <linux/sysfs.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
 
+#include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/triggered_buffer.h>
drivers/iio/pressure/ms5611_i2c.c +4 -1
index 1c041b9085fb..2dd4ff38f595 100644
@@ -12,12 +12,15 @@
  */
 
 #include <linux/delay.h>
+#include <linux/errno.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-
+#include <linux/types.h>
 #include <linux/unaligned.h>
 
+#include <linux/iio/iio.h>
+
 #include "ms5611.h"
 
 static int ms5611_i2c_reset(struct ms5611_state *st)
drivers/iio/pressure/ms5611_spi.c +7 -2
index 25c7bd2d8fdf..46e4188cbce2 100644
@@ -7,12 +7,17 @@
  */
 
 #include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
-#include <linux/spi/spi.h>
 #include <linux/mod_devicetable.h>
-
+#include <linux/spi/spi.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
 #include <linux/unaligned.h>
 
+#include <linux/iio/iio.h>
+
 #include "ms5611.h"
 
 static int ms5611_spi_reset(struct ms5611_state *st)
Signature · 1 line
2.50.0
author maintainer
#6 lore raw

PATCH 5/7 iio: pressure: hsc030pa: Apply IWYU principles to includes.

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Motivated by solving the W=1 warning recently added that notes that linux/export.h wasn't included here. Do a thorough job by applying approximate include what you use principles to includes. In this particular case there were quite a few unnecessary includes that are removed.

---
 drivers/iio/pressure/hsc030pa.c     | 12 ++++++------
 drivers/iio/pressure/hsc030pa.h     |  5 ++---
 drivers/iio/pressure/hsc030pa_i2c.c |  4 ----
 drivers/iio/pressure/hsc030pa_spi.c |  5 -----
 4 files changed, 8 insertions(+), 18 deletions(-)
drivers/iio/pressure/hsc030pa.c +6 -6
index 2d00c0656259..44f97ba1629f 100644
@@ -10,25 +10,25 @@
 #include <linux/array_size.h>
 #include <linux/bitfield.h>
 #include <linux/bits.h>
-#include <linux/cleanup.h>
-#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/interrupt.h>
 #include <linux/math64.h>
-#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/printk.h>
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
+#include <linux/stddef.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/unaligned.h>
 #include <linux/units.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-#include <linux/unaligned.h>
 
 #include "hsc030pa.h"
 
drivers/iio/pressure/hsc030pa.h +2 -3
index 5db46784f4c6..01f2b02a84e8 100644
@@ -8,6 +8,8 @@
 #ifndef _HSC030PA_H
 #define _HSC030PA_H
 
+#include <linux/compiler.h>
+#include <linux/minmax.h>
 #include <linux/types.h>
 
 #include <linux/iio/iio.h>
@@ -17,9 +19,6 @@
 
 struct device;
 
-struct iio_chan_spec;
-struct iio_dev;
-
 struct hsc_data;
 struct hsc_chip_data;
 
drivers/iio/pressure/hsc030pa_i2c.c +0 -4
index a34ef4653f34..96aefd9f213a 100644
@@ -9,14 +9,10 @@
  */
 
 #include <linux/delay.h>
-#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/types.h>
-
-#include <linux/iio/iio.h>
 
 #include "hsc030pa.h"
 
drivers/iio/pressure/hsc030pa_spi.c +0 -5
index 5d331b3b6da8..ae9f4bb51f30 100644
@@ -9,14 +9,9 @@
  */
 
 #include <linux/delay.h>
-#include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/spi/spi.h>
-#include <linux/stddef.h>
-#include <linux/types.h>
-
-#include <linux/iio/iio.h>
 
 #include "hsc030pa.h"
 
Signature · 1 line
2.50.0
author maintainer
#7 lore raw

PATCH 6/7 iio: pressure: mprls0025pa: Apply IWYU principles to includes.

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

General rework of this driver's includes triggered by the new W=1 warning on lack of include of export.h.

---
 drivers/iio/pressure/mprls0025pa.c     | 9 +++++++--
 drivers/iio/pressure/mprls0025pa.h     | 9 ++-------
 drivers/iio/pressure/mprls0025pa_i2c.c | 1 -
 3 files changed, 9 insertions(+), 10 deletions(-)
drivers/iio/pressure/mprls0025pa.c +7 -2
index 2336f2760eae..60f693e8e79b 100644
@@ -10,13 +10,18 @@
  */
 
 #include <linux/array_size.h>
-#include <linux/bitfield.h>
 #include <linux/bits.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/export.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
 #include <linux/math64.h>
-#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/property.h>
 #include <linux/units.h>
+#include <linux/stddef.h>
 
 #include <linux/gpio/consumer.h>
 
drivers/iio/pressure/mprls0025pa.h +2 -7
index d62a018eaff3..b2608eb69ec4 100644
@@ -11,11 +11,10 @@
 #ifndef _MPRLS0025PA_H
 #define _MPRLS0025PA_H
 
+#include <linux/compiler.h>
 #include <linux/completion.h>
-#include <linux/delay.h>
-#include <linux/device.h>
+#include <linux/minmax.h>
 #include <linux/mutex.h>
-#include <linux/stddef.h>
 #include <linux/types.h>
 
 #include <linux/iio/iio.h>
@@ -28,10 +27,6 @@
 
 struct device;
 
-struct iio_chan_spec;
-struct iio_dev;
-
-struct mpr_data;
 struct mpr_ops;
 
 enum mpr_func_id {
drivers/iio/pressure/mprls0025pa_i2c.c +0 -1
index 79811fd4a02b..32d3d437a5af 100644
@@ -8,7 +8,6 @@
  *  https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
  */
 
-#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
 #include <linux/mod_devicetable.h>
Signature · 1 line
2.50.0
author maintainer
#8 lore raw

PATCH 7/7 iio: st_sensors: Apply IWYU principles to includes

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Motivated initially by the new W=1 warning for missing linux/export.h includes, this is taking a fresh look at what should be included across the various library and type specific bits of st_sensors.

It approximately follows include what you use principles but with some fuzzy matching for things like dev_printk.h. If only dev_err() etc are used in code and device.h does not otherwise need to be included we only include linux/dev_printk.h. If device.h is needed for other reasons only include that. That is we assume device.h will continue to include dev_printk.h.

---
Note I haven't figure out what official path to PAGE_SIZE is but the relevant code needs a rewrite anyway so I've left it for now.

 drivers/iio/accel/st_accel_buffer.c           |  6 ++++--
 drivers/iio/accel/st_accel_core.c             | 12 +++++++++---
 drivers/iio/accel/st_accel_i2c.c              |  5 ++++-
 drivers/iio/accel/st_accel_spi.c              |  3 ++-
 .../iio/common/st_sensors/st_sensors_buffer.c | 15 ++++++++++-----
 .../iio/common/st_sensors/st_sensors_core.c   | 19 +++++++++++++++----
 .../iio/common/st_sensors/st_sensors_core.h   |  2 ++
 .../iio/common/st_sensors/st_sensors_i2c.c    |  8 ++++++--
 .../iio/common/st_sensors/st_sensors_spi.c    | 11 +++++++++--
 .../common/st_sensors/st_sensors_trigger.c    | 13 ++++++++++---
 drivers/iio/gyro/st_gyro_buffer.c             |  6 ++++--
 drivers/iio/gyro/st_gyro_core.c               | 11 ++++++++---
 drivers/iio/gyro/st_gyro_i2c.c                |  3 ++-
 drivers/iio/gyro/st_gyro_spi.c                |  3 ++-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c  |  5 ++++-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c   |  5 ++---
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c   |  5 ++---
 drivers/iio/magnetometer/st_magn_buffer.c     |  5 +++--
 drivers/iio/magnetometer/st_magn_core.c       | 11 ++++++++---
 drivers/iio/magnetometer/st_magn_i2c.c        |  3 ++-
 drivers/iio/magnetometer/st_magn_spi.c        |  3 ++-
 drivers/iio/pressure/st_pressure_buffer.c     |  6 ++++--
 drivers/iio/pressure/st_pressure_core.c       |  9 ++++++---
 drivers/iio/pressure/st_pressure_i2c.c        |  3 ++-
 drivers/iio/pressure/st_pressure_spi.c        |  3 ++-
 include/linux/iio/common/st_sensors_i2c.h     |  5 ++---
 include/linux/iio/common/st_sensors_spi.h     |  5 ++---
 27 files changed, 128 insertions(+), 57 deletions(-)
drivers/iio/accel/st_accel_buffer.c +4 -2
index b2977ae19b69..53ed46db122d 100644
@@ -7,9 +7,11 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
 #include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/triggered_buffer.h>
 
drivers/iio/accel/st_accel_core.c +9 -3
index 99cb661fabb2..c1a44eca4e15 100644
@@ -7,16 +7,22 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/acpi.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
 #include <linux/sysfs.h>
 #include <linux/slab.h>
-#include <linux/acpi.h>
+#include <linux/stddef.h>
+
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
 #include <linux/iio/common/st_sensors.h>
 #include "st_accel.h"
 
drivers/iio/accel/st_accel_i2c.c +4 -1
index f24449500533..3f567c63c287 100644
@@ -7,12 +7,15 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/dev_printk.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
+
 #include <linux/iio/iio.h>
 
+#include <linux/iio/common/st_sensors.h>
 #include <linux/iio/common/st_sensors_i2c.h>
 #include "st_accel.h"
 
drivers/iio/accel/st_accel_spi.c +2 -1
index d8ec0555f42a..7d9f56df3f75 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/dev_printk.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
drivers/iio/common/st_sensors/st_sensors_buffer.c +10 -5
index 57f087c2216f..56943bc37592 100644
@@ -7,14 +7,19 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/align.h>
+#include <linux/bitmap.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/math.h>
+#include <linux/irqreturn.h>
+#include <linux/regmap.h>
+#include <linux/types.h>
+
 #include <linux/iio/iio.h>
-#include <linux/iio/trigger.h>
-#include <linux/interrupt.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
-#include <linux/irqreturn.h>
-#include <linux/regmap.h>
 
 #include <linux/iio/common/st_sensors.h>
 
drivers/iio/common/st_sensors/st_sensors_core.c +15 -4
index 8ce1dccfea4f..ab6e38f1f23a 100644
@@ -7,16 +7,27 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
+#include <linux/array_size.h>
+#include <linux/bitops.h>
 #include <linux/delay.h>
-#include <linux/iio/iio.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/export.h>
+#include <linux/math.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/sprintf.h>
+#include <linux/stddef.h>
+#include <linux/string.h>
 #include <linux/unaligned.h>
+
+#include <linux/iio/iio.h>
+
+#include <linux/platform_data/st_sensors_pdata.h>
 #include <linux/iio/common/st_sensors.h>
 
 #include "st_sensors_core.h"
drivers/iio/common/st_sensors/st_sensors_core.h +2 -0
index 09f3e602a2e2..efd7cc1a97ed 100644
@@ -4,6 +4,8 @@
  */
 #ifndef __ST_SENSORS_CORE_H
 #define __ST_SENSORS_CORE_H
+#include <linux/types.h>
+
 struct iio_dev;
 int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
 				    u8 reg_addr, u8 mask, u8 data);
drivers/iio/common/st_sensors/st_sensors_i2c.c +6 -2
index 7156302fe997..e524845e4e09 100644
@@ -7,12 +7,16 @@
  * Denis Ciocca <[email protected]>
  */
 
+#include <linux/dev_printk.h>
+#include <linux/err.h>
+#include <linux/export.h>
 #include <linux/i2c.h>
-#include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/iio/iio.h>
 #include <linux/regmap.h>
 
+#include <linux/iio/iio.h>
+
+#include <linux/iio/common/st_sensors.h>
 #include <linux/iio/common/st_sensors_i2c.h>
 
 #define ST_SENSORS_I2C_MULTIREAD	0x80
drivers/iio/common/st_sensors/st_sensors_spi.c +9 -2
index 0da27013943d..8310e235c019 100644
@@ -7,13 +7,20 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/export.h>
 #include <linux/module.h>
-#include <linux/iio/iio.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+#include <linux/iio/iio.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
+#include <linux/iio/common/st_sensors.h>
 #include <linux/iio/common/st_sensors_spi.h>
 
 #define ST_SENSORS_SPI_MULTIREAD	0xc0
drivers/iio/common/st_sensors/st_sensors_trigger.c +10 -3
index 9d4bf822a15d..9746e5a30de0 100644
@@ -7,11 +7,18 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/trigger.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/regmap.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
+
 #include <linux/iio/common/st_sensors.h>
 #include "st_sensors_core.h"
 
drivers/iio/gyro/st_gyro_buffer.c +4 -2
index 1ebfe7aa6c96..cb78552e17a1 100644
@@ -7,9 +7,11 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
 #include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/triggered_buffer.h>
 
drivers/iio/gyro/st_gyro_core.c +8 -3
index 7fd82cd707c7..ac6b35fb7aac 100644
@@ -7,15 +7,20 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/interrupt.h>
+#include <linux/stddef.h>
 #include <linux/sysfs.h>
+
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
 #include <linux/iio/common/st_sensors.h>
 #include "st_gyro.h"
 
drivers/iio/gyro/st_gyro_i2c.c +2 -1
index aef5ec8f9dee..d699518a18ab 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
drivers/iio/gyro/st_gyro_spi.c +2 -1
index f645da157372..61c03b72b57e 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c +4 -1
index 8f4a67edb335..8af4ab21bd22 100644
@@ -8,7 +8,8 @@
  */
 
 #include <linux/array_size.h>
-#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/export.h>
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
@@ -18,6 +19,8 @@
 
 #include "st_lsm9ds0.h"
 
+struct regmap;
+
 static int st_lsm9ds0_probe_accel(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
 {
 	const struct st_sensor_settings *settings;
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c +2 -3
index 4232a9d800fc..0eb0564801cb 100644
@@ -7,15 +7,14 @@
  * Author: Andy Shevchenko <[email protected]>
  */
 
-#include <linux/device/devres.h>
+#include <linux/device.h>
 #include <linux/err.h>
-#include <linux/gfp_types.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 
-#include <linux/iio/common/st_sensors_i2c.h>
+#include <linux/iio/common/st_sensors.h>
 
 #include "st_lsm9ds0.h"
 
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c +2 -3
index acea8a0757d7..b72ad380aa2f 100644
@@ -7,15 +7,14 @@
  * Author: Andy Shevchenko <[email protected]>
  */
 
-#include <linux/device/devres.h>
+#include <linux/device.h>
 #include <linux/err.h>
-#include <linux/gfp_types.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
 
-#include <linux/iio/common/st_sensors_spi.h>
+#include <linux/iio/common/st_sensors.h>
 
 #include "st_lsm9ds0.h"
 
drivers/iio/magnetometer/st_magn_buffer.c +3 -2
index 79987f42e8d9..91f4b077a554 100644
@@ -6,10 +6,11 @@
  *
  * Denis Ciocca <[email protected]>
  */
+#include <linux/device.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
 
-#include <linux/kernel.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/triggered_buffer.h>
 
drivers/iio/magnetometer/st_magn_core.c +8 -3
index ef348d316c00..7508a7cf74d4 100644
@@ -6,15 +6,20 @@
  *
  * Denis Ciocca <[email protected]>
  */
-
-#include <linux/kernel.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
+#include <linux/stddef.h>
 #include <linux/sysfs.h>
+
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
 #include <linux/iio/common/st_sensors.h>
 #include "st_magn.h"
 
drivers/iio/magnetometer/st_magn_i2c.c +2 -1
index ed70e782af5e..e58fec268be1 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/dev_printk.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
drivers/iio/magnetometer/st_magn_spi.c +2 -1
index 68816362bb95..2a6b0715bb85 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
drivers/iio/pressure/st_pressure_buffer.c +4 -2
index 0dbf357c2c22..b83eb7bad11a 100644
@@ -7,9 +7,11 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
 #include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/triggered_buffer.h>
 
drivers/iio/pressure/st_pressure_core.c +6 -3
index b70d1cee82f3..cb5cca094ca9 100644
@@ -7,14 +7,17 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
+#include <linux/stddef.h>
 #include <linux/sysfs.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
-#include <linux/unaligned.h>
 
 #include <linux/iio/common/st_sensors.h>
 #include "st_pressure.h"
drivers/iio/pressure/st_pressure_i2c.c +2 -1
index 0f50bac1fb4d..c6ace6ec6e81 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/dev_printk.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
drivers/iio/pressure/st_pressure_spi.c +2 -1
index 39827e6841ca..9df0b94f9ccf 100644
@@ -7,7 +7,8 @@
  * Denis Ciocca <[email protected]>
  */
 
-#include <linux/kernel.h>
+#include <linux/dev_printk.h>
+#include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
include/linux/iio/common/st_sensors_i2c.h +2 -3
index 5f15cf01036c..e9d9a477ef67 100644
@@ -10,9 +10,8 @@
 #ifndef ST_SENSORS_I2C_H
 #define ST_SENSORS_I2C_H
 
-#include <linux/i2c.h>
-#include <linux/iio/common/st_sensors.h>
-
+struct iio_dev;
+struct i2c_client;
 int st_sensors_i2c_configure(struct iio_dev *indio_dev,
 			     struct i2c_client *client);
 
include/linux/iio/common/st_sensors_spi.h +2 -3
index 90b25f087f06..0bd341330b80 100644
@@ -10,9 +10,8 @@
 #ifndef ST_SENSORS_SPI_H
 #define ST_SENSORS_SPI_H
 
-#include <linux/spi/spi.h>
-#include <linux/iio/common/st_sensors.h>
-
+struct iio_dev;
+struct spi_device;
 int st_sensors_spi_configure(struct iio_dev *indio_dev,
 			     struct spi_device *spi);
 
Signature · 1 line
2.50.0
#9 lore raw
In reply to Jonathan Cameron
Quoted 11 lines · Jonathan Cameron

I decided to look at a slightly larger set to continue trying to come up with consistent rules (for IIO anyway) on what we want to include direclty and what assumptions we can make about a header always including another.

As the series goes on reduce the amount of info on particular choices made just because the commit descriptions were getting very long.

A few open questions.
- linux/stddef.h - do we want to included this directly?

Only if not types.h included.

Quoted 1 line

- linux/types.h - do we want to include this directly?

Yes.

Quoted 3 lines

- linux/dev_printk.h - include even if device.h is needed for other reasons or rely on that as a grouping header if present and only use dev_printk where we don't need device.h.

I slightly tend to include both as strictly speaking the dev_printk.h should be device/printk.h, but that boat already sailed long time ago...

Quoted 3 lines

I'll share a refreshed IWYU config once we come to firmer conclusions on the various choices. I haven't yet figured out now to not include anything at all for things like CONFIG*

PAGE_SIZE is in asm/page.h.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
reviewer
#10 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Jonathan Cameron

I decided to look at a slightly larger set to continue trying to come up with consistent rules (for IIO anyway) on what we want to include direclty and what assumptions we can make about a header always including another.

As the series goes on reduce the amount of info on particular choices made just because the commit descriptions were getting very long.

Quoted 8 lines
Quoted 2 lines

A few open questions.
- linux/stddef.h - do we want to included this directly?

Only if not types.h included.

Quoted 1 line

- linux/types.h - do we want to include this directly?

Yes.

Agree. It's rare, but I've had compile failures in some cases if this was missing.

Quoted 7 lines
Quoted 4 lines

- linux/dev_printk.h - include even if device.h is needed for other reasons or rely on that as a grouping header if present and only use dev_printk where we don't need device.h.

I slightly tend to include both as strictly speaking the dev_printk.h should be device/printk.h, but that boat already sailed long time ago...

+1 for not having conditional rules. Just include both.

So I would do the same for linux/stddef.h. Either always include it or always use linux/types.h instead. It just makes things simpler to not have special cases.

Quoted 7 lines
Quoted 4 lines

I'll share a refreshed IWYU config once we come to firmer conclusions on the various choices. I haven't yet figured out now to not include anything at all for things like CONFIG*

PAGE_SIZE is in asm/page.h.