Re: [PATCH 1/2] iio: st_sensors: Remove some redundant includes

From: Jonathan Cameron
Date: Sat Jun 17 2023 - 14:47:46 EST


On Mon, 12 Jun 2023 22:13:36 +0200
Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> wrote:

> st_sensors_(i2c|spi).h already include st_sensors.h, so there is no need
> to include it explicitly.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>

Mostly we try to avoid implicit includes that might not be around
for ever as it makes changing internals of headers have messy side effects.
In this particular case I'd argue that the _spi.h and _i2c.h should
not be including st_sensors.h rather than the other way around.

There is nothing in those headers that uses anything from
st_sensors.h

They should probably use forward definitions of
struct iio_dev and struct spi_device etc to avoid need to include
anything at all.

Jonathan



> ---
> drivers/iio/accel/st_accel_spi.c | 1 -
> drivers/iio/gyro/st_gyro_i2c.c | 1 -
> drivers/iio/gyro/st_gyro_spi.c | 1 -
> drivers/iio/magnetometer/st_magn_i2c.c | 1 -
> drivers/iio/magnetometer/st_magn_spi.c | 1 -
> drivers/iio/pressure/st_pressure_i2c.c | 1 -
> drivers/iio/pressure/st_pressure_spi.c | 1 -
> 7 files changed, 7 deletions(-)
>
> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
> index f72a24f45322..ae5bf3b47209 100644
> --- a/drivers/iio/accel/st_accel_spi.c
> +++ b/drivers/iio/accel/st_accel_spi.c
> @@ -13,7 +13,6 @@
> #include <linux/spi/spi.h>
> #include <linux/iio/iio.h>
>
> -#include <linux/iio/common/st_sensors.h>
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_accel.h"
>
> diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
> index 5a10a3556ab0..ceebd246100c 100644
> --- a/drivers/iio/gyro/st_gyro_i2c.c
> +++ b/drivers/iio/gyro/st_gyro_i2c.c
> @@ -13,7 +13,6 @@
> #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_gyro.h"
>
> diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
> index 22aaabe48e4a..afdb8dffd72d 100644
> --- a/drivers/iio/gyro/st_gyro_spi.c
> +++ b/drivers/iio/gyro/st_gyro_spi.c
> @@ -13,7 +13,6 @@
> #include <linux/spi/spi.h>
> #include <linux/iio/iio.h>
>
> -#include <linux/iio/common/st_sensors.h>
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_gyro.h"
>
> diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
> index 950826dd20bf..b9221794cf00 100644
> --- a/drivers/iio/magnetometer/st_magn_i2c.c
> +++ b/drivers/iio/magnetometer/st_magn_i2c.c
> @@ -13,7 +13,6 @@
> #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_magn.h"
>
> diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
> index f203e1f87eec..5540500ba9fa 100644
> --- a/drivers/iio/magnetometer/st_magn_spi.c
> +++ b/drivers/iio/magnetometer/st_magn_spi.c
> @@ -13,7 +13,6 @@
> #include <linux/spi/spi.h>
> #include <linux/iio/iio.h>
>
> -#include <linux/iio/common/st_sensors.h>
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_magn.h"
>
> diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
> index 5101552e3f38..8ba0d1212401 100644
> --- a/drivers/iio/pressure/st_pressure_i2c.c
> +++ b/drivers/iio/pressure/st_pressure_i2c.c
> @@ -14,7 +14,6 @@
> #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_pressure.h"
>
> diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
> index 25cca5ad7c55..ffa1970a5aeb 100644
> --- a/drivers/iio/pressure/st_pressure_spi.c
> +++ b/drivers/iio/pressure/st_pressure_spi.c
> @@ -13,7 +13,6 @@
> #include <linux/spi/spi.h>
> #include <linux/iio/iio.h>
>
> -#include <linux/iio/common/st_sensors.h>
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_pressure.h"
>