All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] iio:accel: Header Cleanups.
@ 2021-06-11 17:13 Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 01/12] iio:accel:adxl372: Cleanup includes Jonathan Cameron
                   ` (13 more replies)
  0 siblings, 14 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio
  Cc: Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin, Dan Robertson,
	Hans de Goede, Harinath Nampally, Jelle van der Waa,
	Jonathan Bakker, Lars-Peter Clausen, Linus Walleij,
	Michael Hennerich, Mike Looijmans, Sean Nyekjaer, Tomas Melin

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

0-day recently started running the include-what-you-use checker with LLVM builds.
After it identified a header we should have dropped in a particular patch,
I decided to experiment with it a little and see if it was useful for tidying
up includes that have gotten rather out of sync with the code over the years.

Note the tool is something I'd only advocate using to give you hints on what
might want adjusting so each of these was done by hand inspection.

I've grouped them by manufacturer as otherwise we would have a lot of patches.
Note that the big 'many device / device type' drivers have been done separately
so you won't see them in this series.

I'm rather hoping this approach may ease getting reviews of these, but we
shall see.  If people have time to look at ones I haven't directly cc'd them
on that would be great. There are some drivers touched in here where I don't
know of a current maintainer.

Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Aleksei Mamlin <mamlinav@gmail.com>
Cc: Dan Robertson <dan@dlrobertson.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Harinath Nampally <harinath922@gmail.com>
Cc: Jelle van der Waa <jelle@vdwaa.nl>
Cc: Jonathan Bakker <xc-racer2@live.ca>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Cc: Sean Nyekjaer <sean@geanix.com>
Cc: Tomas Melin <tomas.melin@vaisala.com>

Jonathan Cameron (12):
  iio:accel:adxl372: Cleanup includes
  iio:accel:bma180: Use generic device properties.
  iio:accel:bosch drivers: Cleanup includes
  iio:accel:miramems drivers: Cleanup headers
  iio:accel:domintech: Cleanup includes.
  iio:accel:fxls8962af: Add a few missing includes.
  iio:accel:kionix drivers: Cleanup includes
  iio:accel:mc3220: Cleanup includes.
  iio:accel:freescale drivers: Cleanup includes
  iio:accel:memsic drivers: Cleanup includes
  iio:accel:murata/vti drivers: Include cleanups for the sca**** parts.
  iio:accel:sensortek drivers: Add some includes

 drivers/iio/accel/adxl372.c           |  4 ++--
 drivers/iio/accel/adxl372.h           |  2 ++
 drivers/iio/accel/adxl372_spi.c       |  3 +--
 drivers/iio/accel/bma180.c            | 11 +++++------
 drivers/iio/accel/bma220_spi.c        |  2 +-
 drivers/iio/accel/bma400_core.c       |  1 -
 drivers/iio/accel/bma400_spi.c        |  1 -
 drivers/iio/accel/bmc150-accel-core.c |  1 +
 drivers/iio/accel/bmc150-accel-spi.c  |  1 -
 drivers/iio/accel/bmi088-accel-core.c |  3 ---
 drivers/iio/accel/bmi088-accel-spi.c  |  3 ++-
 drivers/iio/accel/da280.c             |  3 +--
 drivers/iio/accel/da311.c             |  4 ++--
 drivers/iio/accel/dmard06.c           |  4 +++-
 drivers/iio/accel/dmard09.c           |  2 ++
 drivers/iio/accel/dmard10.c           |  2 +-
 drivers/iio/accel/fxls8962af-core.c   |  3 ++-
 drivers/iio/accel/kxcjk-1013.c        |  4 +++-
 drivers/iio/accel/kxsd9-i2c.c         |  3 ---
 drivers/iio/accel/kxsd9-spi.c         |  5 +----
 drivers/iio/accel/kxsd9.c             |  1 -
 drivers/iio/accel/kxsd9.h             |  2 ++
 drivers/iio/accel/mc3230.c            |  2 +-
 drivers/iio/accel/mma7455_core.c      |  3 ++-
 drivers/iio/accel/mma7455_i2c.c       |  1 +
 drivers/iio/accel/mma7455_spi.c       |  1 +
 drivers/iio/accel/mma7660.c           |  3 +++
 drivers/iio/accel/mma8452.c           |  5 +++++
 drivers/iio/accel/mma9551.c           |  7 ++++---
 drivers/iio/accel/mma9551_core.h      |  2 ++
 drivers/iio/accel/mma9553.c           |  6 ++++--
 drivers/iio/accel/mxc4005.c           |  4 ++++
 drivers/iio/accel/mxc6255.c           |  5 ++---
 drivers/iio/accel/sca3000.c           |  5 ++---
 drivers/iio/accel/sca3300.c           |  3 ++-
 drivers/iio/accel/stk8312.c           |  3 +++
 drivers/iio/accel/stk8ba50.c          |  2 ++
 37 files changed, 69 insertions(+), 48 deletions(-)

-- 
2.31.1


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

* [PATCH 01/12] iio:accel:adxl372: Cleanup includes
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-15 13:16   ` Lars-Peter Clausen
  2021-06-11 17:13 ` [PATCH 02/12] iio:accel:bma180: Use generic device properties Jonathan Cameron
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich

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

Based on consideration of the output of include-what-you-use.
Drop some unused headers and include others that should probably be
there based on direct use.  Also a few forward definitions to avoid
any potential future include ordering issues.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
---
 drivers/iio/accel/adxl372.c     | 4 ++--
 drivers/iio/accel/adxl372.h     | 2 ++
 drivers/iio/accel/adxl372_spi.c | 3 +--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
index fc9592407717..c679cb9f3ed1 100644
--- a/drivers/iio/accel/adxl372.c
+++ b/drivers/iio/accel/adxl372.c
@@ -6,12 +6,12 @@
  */
 
 #include <linux/bitfield.h>
+#include <linux/bitmap.h>
 #include <linux/bitops.h>
 #include <linux/interrupt.h>
-#include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/regmap.h>
-#include <linux/spi/spi.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
diff --git a/drivers/iio/accel/adxl372.h b/drivers/iio/accel/adxl372.h
index 80a0aa9714fc..86bf8955d60c 100644
--- a/drivers/iio/accel/adxl372.h
+++ b/drivers/iio/accel/adxl372.h
@@ -9,6 +9,8 @@
 #define _ADXL372_H_
 
 #define ADXL372_REVID	0x03
+struct device;
+struct regmap;
 
 int adxl372_probe(struct device *dev, struct regmap *regmap,
 		  int irq, const char *name);
diff --git a/drivers/iio/accel/adxl372_spi.c b/drivers/iio/accel/adxl372_spi.c
index 1f1352fee99a..927379f9b497 100644
--- a/drivers/iio/accel/adxl372_spi.c
+++ b/drivers/iio/accel/adxl372_spi.c
@@ -6,9 +6,8 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/spi/spi.h>
 
 #include "adxl372.h"
-- 
2.31.1


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

* [PATCH 02/12] iio:accel:bma180: Use generic device properties.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 01/12] iio:accel:adxl372: Cleanup includes Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 21:48   ` Linus Walleij
  2021-06-11 17:13 ` [PATCH 03/12] iio:accel:bosch drivers: Cleanup includes Jonathan Cameron
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Jonathan Bakker, Linus Walleij

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

Whilst doing header cleanup I noticed this driver makes very superficial
use of of_* interfaces.  Hence move to the generic firmware forms.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jonathan Bakker <xc-racer2@live.ca>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/accel/bma180.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 4a07e60c0e21..0e0d9317c084 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -17,8 +17,7 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
-#include <linux/of_device.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/bitops.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
@@ -995,8 +994,8 @@ static int bma180_probe(struct i2c_client *client,
 	data = iio_priv(indio_dev);
 	i2c_set_clientdata(client, indio_dev);
 	data->client = client;
-	if (client->dev.of_node)
-		chip = (enum chip_ids)of_device_get_match_data(dev);
+	if (dev_fwnode(dev))
+		chip = (enum chip_ids)device_get_match_data(dev);
 	else
 		chip = id->driver_data;
 	data->part_info = &bma180_part_info[chip];
-- 
2.31.1


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

* [PATCH 03/12] iio:accel:bosch drivers: Cleanup includes
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 01/12] iio:accel:adxl372: Cleanup includes Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 02/12] iio:accel:bma180: Use generic device properties Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 04/12] iio:accel:miramems drivers: Cleanup headers Jonathan Cameron
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio
  Cc: Jonathan Cameron, Dan Robertson, Hans de Goede, Mike Looijmans,
	Linus Walleij, Andy Shevchenko

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

Based on consideration of the output of the include-what-you-use tool.
Remove unused headers and add some that are directly used in the
files.

There are no hard rules on when to use direct includes and when to
rely on a chain of headers.  Here I'm trying to make those
decisions approximately the same across IIO.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Dan Robertson <dan@dlrobertson.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/accel/bma180.c            | 4 ++--
 drivers/iio/accel/bma220_spi.c        | 2 +-
 drivers/iio/accel/bma400_core.c       | 1 -
 drivers/iio/accel/bma400_spi.c        | 1 -
 drivers/iio/accel/bmc150-accel-core.c | 1 +
 drivers/iio/accel/bmc150-accel-spi.c  | 1 -
 drivers/iio/accel/bmi088-accel-core.c | 3 ---
 drivers/iio/accel/bmi088-accel-spi.c  | 3 ++-
 8 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 0e0d9317c084..2042cf86b199 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -14,14 +14,14 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/property.h>
+#include <linux/mutex.h>
 #include <linux/bitops.h>
 #include <linux/regulator/consumer.h>
-#include <linux/slab.h>
-#include <linux/string.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/buffer.h>
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index 0622c7936499..c447463d0844 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -9,11 +9,11 @@
 #include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/spi/spi.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>
 
diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index 21520e022a21..8595dd666c44 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -14,7 +14,6 @@
 #include <linux/bitops.h>
 #include <linux/device.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
diff --git a/drivers/iio/accel/bma400_spi.c b/drivers/iio/accel/bma400_spi.c
index 7c2825904e08..0ae3d1a203b4 100644
--- a/drivers/iio/accel/bma400_spi.c
+++ b/drivers/iio/accel/bma400_spi.c
@@ -6,7 +6,6 @@
  *
  */
 #include <linux/bits.h>
-#include <linux/init.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 46ab7675186c..06e396b66e02 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/mutex.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/iio/iio.h>
diff --git a/drivers/iio/accel/bmc150-accel-spi.c b/drivers/iio/accel/bmc150-accel-spi.c
index 74a8aee4f612..0786c9a0dcbb 100644
--- a/drivers/iio/accel/bmc150-accel-spi.c
+++ b/drivers/iio/accel/bmc150-accel-spi.c
@@ -4,7 +4,6 @@
  * Copyright © 2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
  */
 
-#include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/acpi.h>
diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index a06dae5c971d..d50db25cce64 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -8,13 +8,10 @@
 
 #include <linux/delay.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
-#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include "bmi088-accel.h"
diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
index dd1e3f6cf211..ae999c08e038 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -6,9 +6,10 @@
  * Copyright (c) 2018-2020, Topic Embedded Products
  */
 
+#include <linux/bits.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
-#include <linux/slab.h>
 #include <linux/spi/spi.h>
 
 #include "bmi088-accel.h"
-- 
2.31.1


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

* [PATCH 04/12] iio:accel:miramems drivers: Cleanup headers
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (2 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 03/12] iio:accel:bosch drivers: Cleanup includes Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 05/12] iio:accel:domintech: Cleanup includes Jonathan Cameron
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

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

Based on consideration of the output of the include-what-you-use tool.
Drop unused headers and include some that are directly used inside
the files.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/da280.c | 3 +--
 drivers/iio/accel/da311.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c
index 5edff9ba72da..0fb20dbde49b 100644
--- a/drivers/iio/accel/da280.c
+++ b/drivers/iio/accel/da280.c
@@ -7,11 +7,10 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/acpi.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/byteorder/generic.h>
 
 #define DA280_REG_CHIP_ID		0x01
 #define DA280_REG_ACC_X_LSB		0x02
diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index 92593a1cd1aa..c944e18c97f0 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -6,11 +6,11 @@
  * Copyright (c) 2011-2013 MiraMEMS Sensing Technology Co., Ltd.
  */
 
+#include <linux/bits.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/byteorder/generic.h>
 
 #define DA311_CHIP_ID			0x13
 
-- 
2.31.1


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

* [PATCH 05/12] iio:accel:domintech: Cleanup includes.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (3 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 04/12] iio:accel:miramems drivers: Cleanup headers Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes Jonathan Cameron
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio
  Cc: Jonathan Cameron, Hans de Goede, Jelle van der Waa, Aleksei Mamlin

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

Based on consideration of the output of the include-what-you-use tool.
In this case, mostly additions of includes.  A lot of this is about
consistency across IIO rather than them being strictly required.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jelle van der Waa <jelle@vdwaa.nl>
Cc: Aleksei Mamlin <mamlinav@gmail.com>
---
 drivers/iio/accel/dmard06.c | 4 +++-
 drivers/iio/accel/dmard09.c | 2 ++
 drivers/iio/accel/dmard10.c | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c
index de2868c28d95..6edc474f51c1 100644
--- a/drivers/iio/accel/dmard06.c
+++ b/drivers/iio/accel/dmard06.c
@@ -5,9 +5,11 @@
  * Copyright (C) 2016 Aleksei Mamlin <mamlinav@gmail.com>
  */
 
+#include <linux/bitops.h>
+#include <linux/i2c.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-#include <linux/i2c.h>
 #include <linux/iio/iio.h>
 
 #define DMARD06_DRV_NAME		"dmard06"
diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c
index e6e28c964777..9155b3a232f4 100644
--- a/drivers/iio/accel/dmard09.c
+++ b/drivers/iio/accel/dmard09.c
@@ -6,7 +6,9 @@
  */
 
 #include <asm/unaligned.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 
diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c
index e84bf8db1e89..c928c67c0857 100644
--- a/drivers/iio/accel/dmard10.c
+++ b/drivers/iio/accel/dmard10.c
@@ -7,9 +7,9 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 #include <linux/byteorder/generic.h>
 
 #define DMARD10_REG_ACTR			0x00
-- 
2.31.1


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

* [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (4 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 05/12] iio:accel:domintech: Cleanup includes Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-14  5:57   ` Sean Nyekjaer
  2021-06-11 17:13 ` [PATCH 07/12] iio:accel:kionix drivers: Cleanup includes Jonathan Cameron
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Sean Nyekjaer

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

Based on consideration of the output of the include-what-you-use tool.
Note that in this driver the main reason to do this is to ensure
consistency across IIO.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/accel/fxls8962af-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
index 078d87865fde..6882f082d581 100644
--- a/drivers/iio/accel/fxls8962af-core.c
+++ b/drivers/iio/accel/fxls8962af-core.c
@@ -15,16 +15,17 @@
 #include <linux/bits.h>
 #include <linux/bitfield.h>
 #include <linux/i2c.h>
+#include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
-#include <linux/iio/sysfs.h>
 
 #include "fxls8962af.h"
 
-- 
2.31.1


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

* [PATCH 07/12] iio:accel:kionix drivers: Cleanup includes
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (5 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 08/12] iio:accel:mc3220: " Jonathan Cameron
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Hans de Goede

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

Based on consideration of the output of include-what-you-use
Mixture of removing unused headers, adding some that are directly used
from the code and a few forwards definitions to avoid any potential
future issues with header ordering.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/kxcjk-1013.c | 4 +++-
 drivers/iio/accel/kxsd9-i2c.c  | 3 ---
 drivers/iio/accel/kxsd9-spi.c  | 5 +----
 drivers/iio/accel/kxsd9.c      | 1 -
 drivers/iio/accel/kxsd9.h      | 2 ++
 5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index a51fdd3c9b5b..e4813706a52a 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -5,13 +5,15 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/bitops.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/acpi.h>
+#include <linux/mutex.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
index b580d605f848..7e1d1158f80e 100644
--- a/drivers/iio/accel/kxsd9-i2c.c
+++ b/drivers/iio/accel/kxsd9-i2c.c
@@ -1,11 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-#include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/delay.h>
 #include <linux/regmap.h>
 
 #include "kxsd9.h"
diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c
index 7971ec1eeb7e..78a168d5b1fa 100644
--- a/drivers/iio/accel/kxsd9-spi.c
+++ b/drivers/iio/accel/kxsd9-spi.c
@@ -1,11 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-only
-#include <linux/device.h>
 #include <linux/kernel.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/spi/spi.h>
 #include <linux/module.h>
-#include <linux/slab.h>
+#include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 
 #include "kxsd9.h"
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index bf7ed9e7d00f..3d15f590ed4a 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -14,7 +14,6 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/bitops.h>
diff --git a/drivers/iio/accel/kxsd9.h b/drivers/iio/accel/kxsd9.h
index 5e3ca212f5be..172b756eb901 100644
--- a/drivers/iio/accel/kxsd9.h
+++ b/drivers/iio/accel/kxsd9.h
@@ -4,6 +4,8 @@
 
 #define KXSD9_STATE_RX_SIZE 2
 #define KXSD9_STATE_TX_SIZE 2
+struct device;
+struct regmap;
 
 int kxsd9_common_probe(struct device *dev,
 		       struct regmap *map,
-- 
2.31.1


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

* [PATCH 08/12] iio:accel:mc3220: Cleanup includes.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (6 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 07/12] iio:accel:kionix drivers: Cleanup includes Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 09/12] iio:accel:freescale drivers: " Jonathan Cameron
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Hans de Goede

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

Based on consideration of output of include-what-you-use.
Drop iio/sysfs.h on basis we don't use anything in there in this driver
and add mod_devicetable.h as I'm aiming for consistency on that across
IIO.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/mc3230.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
index 735002b716f3..da0cb428d6e1 100644
--- a/drivers/iio/accel/mc3230.c
+++ b/drivers/iio/accel/mc3230.c
@@ -9,8 +9,8 @@
 
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 
 #define MC3230_REG_XOUT			0x00
 #define MC3230_REG_YOUT			0x01
-- 
2.31.1


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

* [PATCH 09/12] iio:accel:freescale drivers: Cleanup includes
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (7 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 08/12] iio:accel:mc3220: " Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 10/12] iio:accel:memsic " Jonathan Cameron
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Harinath Nampally

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

Based on consideration of the output of the include-what-you-use checker.
For these drivers most of the changes are the addition of includes
for headers directly used in the files
There is no hard and fast rule for when to include and when to assume
included by another header, so this is partly a matter of taste
and consistency.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Harinath Nampally <harinath922@gmail.com>
---
 drivers/iio/accel/mma7455_core.c | 3 ++-
 drivers/iio/accel/mma7455_i2c.c  | 1 +
 drivers/iio/accel/mma7455_spi.c  | 1 +
 drivers/iio/accel/mma7660.c      | 3 +++
 drivers/iio/accel/mma8452.c      | 5 +++++
 drivers/iio/accel/mma9551.c      | 7 ++++---
 drivers/iio/accel/mma9551_core.h | 2 ++
 drivers/iio/accel/mma9553.c      | 6 ++++--
 8 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c
index 922bd38ff6ea..94160c3e0e64 100644
--- a/drivers/iio/accel/mma7455_core.c
+++ b/drivers/iio/accel/mma7455_core.c
@@ -11,12 +11,13 @@
  */
 
 #include <linux/delay.h>
+#include <linux/device.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/kernel.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 
diff --git a/drivers/iio/accel/mma7455_i2c.c b/drivers/iio/accel/mma7455_i2c.c
index cddeaa9e230a..c0dc648e4ada 100644
--- a/drivers/iio/accel/mma7455_i2c.c
+++ b/drivers/iio/accel/mma7455_i2c.c
@@ -6,6 +6,7 @@
 
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 
 #include "mma7455.h"
diff --git a/drivers/iio/accel/mma7455_spi.c b/drivers/iio/accel/mma7455_spi.c
index eb82cdfa8abc..8339099e8e3d 100644
--- a/drivers/iio/accel/mma7455_spi.c
+++ b/drivers/iio/accel/mma7455_spi.c
@@ -5,6 +5,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
 
diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c
index 47f5cd66e996..32d132749ebd 100644
--- a/drivers/iio/accel/mma7660.c
+++ b/drivers/iio/accel/mma7660.c
@@ -9,7 +9,10 @@
 
 #include <linux/acpi.h>
 #include <linux/i2c.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 715b8138fb71..1f5f6a24b7b8 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -28,9 +29,13 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/events.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/pm_runtime.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
 #include <linux/regulator/consumer.h>
 
 #define MMA8452_STATUS				0x00
diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 4c359fb05480..dc9824eef7f7 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -5,15 +5,16 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/acpi.h>
-#include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 #include <linux/iio/events.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
 #include <linux/pm_runtime.h>
 #include "mma9551_core.h"
 
diff --git a/drivers/iio/accel/mma9551_core.h b/drivers/iio/accel/mma9551_core.h
index 543454a31dc0..3d6c774d33f8 100644
--- a/drivers/iio/accel/mma9551_core.h
+++ b/drivers/iio/accel/mma9551_core.h
@@ -38,6 +38,8 @@ enum mma9551_gpio_pin {
 	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),	\
 }
 
+struct i2c_client;
+struct iio_chan_spec;
 int mma9551_read_config_byte(struct i2c_client *client, u8 app_id,
 			     u16 reg, u8 *val);
 int mma9551_write_config_byte(struct i2c_client *client, u8 app_id,
diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c
index ba3ecb3b57dc..56664193500c 100644
--- a/drivers/iio/accel/mma9553.c
+++ b/drivers/iio/accel/mma9553.c
@@ -5,13 +5,15 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/device.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 #include <linux/iio/events.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
 #include <linux/pm_runtime.h>
 #include "mma9551_core.h"
 
-- 
2.31.1


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

* [PATCH 10/12] iio:accel:memsic drivers: Cleanup includes
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (8 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 09/12] iio:accel:freescale drivers: " Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:13 ` [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts Jonathan Cameron
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

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

Based on consideration of the output of the include-what-you-use tool.
Mixture of removing unused headers and adding includes for some of those
directly used in these files.

There are no hard rules on when to include a header and when to assume
it is included by another one.  This is an attempt to be more consistent
in IIO on that choice.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/mxc4005.c | 4 ++++
 drivers/iio/accel/mxc6255.c | 5 ++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
index b3afbf064915..2f4c9bdbfc9e 100644
--- a/drivers/iio/accel/mxc4005.c
+++ b/drivers/iio/accel/mxc4005.c
@@ -9,6 +9,10 @@
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 #include <linux/acpi.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/regmap.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c
index 9aeeadc420d3..9ab0c66636a7 100644
--- a/drivers/iio/accel/mxc6255.c
+++ b/drivers/iio/accel/mxc6255.c
@@ -8,13 +8,12 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
-#include <linux/init.h>
 #include <linux/iio/iio.h>
-#include <linux/delay.h>
+#include <linux/kernel.h>
 #include <linux/acpi.h>
 #include <linux/regmap.h>
-#include <linux/iio/sysfs.h>
 
 #define MXC6255_DRV_NAME		"mxc6255"
 #define MXC6255_REGMAP_NAME		"mxc6255_regmap"
-- 
2.31.1


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

* [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (9 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 10/12] iio:accel:memsic " Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-14  7:15   ` Tomas Melin
  2021-06-11 17:13 ` [PATCH 12/12] iio:accel:sensortek drivers: Add some includes Jonathan Cameron
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Tomas Melin

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

Based on consideration of the output of include-what-you-use.
Some unused includes dropped and some that are directly used in the
files added.

There are no hard rules for when we should rely on includes being
there as part of including another header and when we should do them
directly.  This is part of an attempt to be more consistent on that
in IIO.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomas Melin <tomas.melin@vaisala.com>
---
 drivers/iio/accel/sca3000.c | 5 ++---
 drivers/iio/accel/sca3300.c | 3 ++-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index cb753a43533c..9f4bbf23834f 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -8,14 +8,13 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/fs.h>
 #include <linux/device.h>
-#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
 #include <linux/module.h>
-#include <linux/uaccess.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/events.h>
diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c
index f7ef8ecfd34a..2042d8baf7b8 100644
--- a/drivers/iio/accel/sca3300.c
+++ b/drivers/iio/accel/sca3300.c
@@ -10,13 +10,14 @@
 #include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/spi/spi.h>
 
 #include <asm/unaligned.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>
 
-- 
2.31.1


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

* [PATCH 12/12] iio:accel:sensortek drivers: Add some includes
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (10 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts Jonathan Cameron
@ 2021-06-11 17:13 ` Jonathan Cameron
  2021-06-11 17:48 ` [PATCH 00/12] iio:accel: Header Cleanups Andy Shevchenko
  2021-06-15 13:12 ` Lars-Peter Clausen
  13 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 17:13 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron

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

Based on consideration of the output of the include-what-you-use tool.
Include a few more headers for things directly used in these files.
Note that there are no hard rules for when to include a header directly
vs rely on it coming in via another include.  This is an attempt
to improve consistency on this decision in IIO.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/stk8312.c  | 3 +++
 drivers/iio/accel/stk8ba50.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index 43c621d0f11e..1f4cab0e31bf 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -7,10 +7,13 @@
  * IIO driver for STK8312; 7-bit I2C address: 0x3D.
  */
 
+#include <linux/device.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index e137a34b5c9a..9049f1a5ace4 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -12,6 +12,8 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-- 
2.31.1


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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (11 preceding siblings ...)
  2021-06-11 17:13 ` [PATCH 12/12] iio:accel:sensortek drivers: Add some includes Jonathan Cameron
@ 2021-06-11 17:48 ` Andy Shevchenko
  2021-06-11 18:23   ` Jonathan Cameron
  2021-06-15 13:12 ` Lars-Peter Clausen
  13 siblings, 1 reply; 25+ messages in thread
From: Andy Shevchenko @ 2021-06-11 17:48 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin

On Fri, Jun 11, 2021 at 8:14 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 0-day recently started running the include-what-you-use checker with LLVM builds.
> After it identified a header we should have dropped in a particular patch,
> I decided to experiment with it a little and see if it was useful for tidying
> up includes that have gotten rather out of sync with the code over the years.
>
> Note the tool is something I'd only advocate using to give you hints on what
> might want adjusting so each of these was done by hand inspection.
>
> I've grouped them by manufacturer as otherwise we would have a lot of patches.
> Note that the big 'many device / device type' drivers have been done separately
> so you won't see them in this series.
>
> I'm rather hoping this approach may ease getting reviews of these, but we
> shall see.  If people have time to look at ones I haven't directly cc'd them
> on that would be great. There are some drivers touched in here where I don't
> know of a current maintainer.

Same comment as per staging series.

I know that kernel.h provides some crucial everywhere used macros /
helpers which are in the TODO list to be split.

I would recommend dropping kernel.h from the drivers and see what's missed.

These series probably need to be based on splitting out container_of()
and ARRAY_SIZE() first.

So, no tag from me for now (but I like the idea in general, and thanks
for looking into this).

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 17:48 ` [PATCH 00/12] iio:accel: Header Cleanups Andy Shevchenko
@ 2021-06-11 18:23   ` Jonathan Cameron
  2021-06-11 18:35     ` Andy Shevchenko
  0 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 18:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin

On Fri, 11 Jun 2021 20:48:08 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 11, 2021 at 8:14 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > 0-day recently started running the include-what-you-use checker with LLVM builds.
> > After it identified a header we should have dropped in a particular patch,
> > I decided to experiment with it a little and see if it was useful for tidying
> > up includes that have gotten rather out of sync with the code over the years.
> >
> > Note the tool is something I'd only advocate using to give you hints on what
> > might want adjusting so each of these was done by hand inspection.
> >
> > I've grouped them by manufacturer as otherwise we would have a lot of patches.
> > Note that the big 'many device / device type' drivers have been done separately
> > so you won't see them in this series.
> >
> > I'm rather hoping this approach may ease getting reviews of these, but we
> > shall see.  If people have time to look at ones I haven't directly cc'd them
> > on that would be great. There are some drivers touched in here where I don't
> > know of a current maintainer.  
> 
> Same comment as per staging series.
> 
> I know that kernel.h provides some crucial everywhere used macros /
> helpers which are in the TODO list to be split.
> 
> I would recommend dropping kernel.h from the drivers and see what's missed.
> 
> These series probably need to be based on splitting out container_of()
> and ARRAY_SIZE() first.

Tool obligingly tells me at least one item from kernel.h and you have
the correct pair (occasionally it's the kernel specific string routines).
e.g.
 #include "linux/kernel.h"                         // for kstrtouint, ARRAY_SIZE

> 
> So, no tag from me for now (but I like the idea in general, and thanks
> for looking into this).
> 

The tool is rather a blunderbuss for this job which makes it rather time
consuming to use.

Splitting kernel.h up is a step beyond where I'm interested in going
at this stage because it's sure to involve a lot of bike shedding.

I 'could' just drop the kernel.h where added on the basis we were clearly
getting it indirectly. I've not included a whole bunch of other suggestions
on that basis.

Note I didn't include a whole bunch of other headers on the basis
they were a bit more esoteric.

To give an idea of how noisy this is here's the output another file...

drivers/iio/trigger/stm32-timer-trigger.c should add these lines:
#include <stddef.h>                               // for NULL, size_t
#include <stdint.h>                               // for uintptr_t
#include <sys/types.h>                            // for ssize_t
#include "asm-generic/div64.h"                    // for do_div
#include "asm-generic/errno-base.h"               // for EINVAL, ENOMEM, EBUSY
#include "asm-generic/int-ll64.h"                 // for u32
#include "asm/page_types.h"                       // for PAGE_SIZE
#include "linux/clk.h"                            // for clk_enable, clk_dis...
#include "linux/compiler_attributes.h"            // for __maybe_unused
#include "linux/dev_printk.h"                     // for dev_err
#include "linux/device.h"                         // for dev_get_drvdata
#include "linux/device/driver.h"                  // for device_driver
#include "linux/export.h"                         // for EXPORT_SYMBOL
#include "linux/gfp.h"                            // for GFP_KERNEL
#include "linux/iio/types.h"                      // for IIO_CHAN_INFO_ENABLE
#include "linux/kernel.h"                         // for kstrtouint, ARRAY_SIZE
#include "linux/list.h"                           // for INIT_LIST_HEAD, lis...
#include "linux/mod_devicetable.h"                // for of_device_id
#include "linux/mutex.h"                          // for mutex_lock, mutex_u...
#include "linux/of.h"                             // for of_property_read_u32
#include "linux/pm.h"                             // for SIMPLE_DEV_PM_OPS
#include "linux/regmap.h"                         // for regmap_update_bits
#include "linux/stddef.h"                         // for true, false
#include "linux/string.h"                         // for strstr, strlen, str...
#include "linux/sysfs.h"                          // for sysfs_emit, attribu...
#include "linux/types.h"                          // for bool, list_head
#include "vdso/bits.h"                            // for BIT

drivers/iio/trigger/stm32-timer-trigger.c should remove these lines:

The full include-list for drivers/iio/trigger/stm32-timer-trigger.c:
#include <linux/iio/iio.h>                        // for iio_priv, IIO_SEPARATE
#include <linux/iio/sysfs.h>                      // for iio_dev_attr, IIO_D...
#include <linux/iio/timer/stm32-timer-trigger.h>  // for TIM4_TRGO, TIM1_TRGO
#include <linux/iio/trigger.h>                    // for iio_trigger, to_iio...
#include <linux/mfd/stm32-timers.h>               // for TIM_CR1, TIM_CR2
#include <linux/module.h>                         // for MODULE_ALIAS, MODUL...
#include <linux/of_device.h>                      // for of_match_device
#include <linux/platform_device.h>                // for platform_get_drvdata
#include <stddef.h>                               // for NULL, size_t
#include <stdint.h>                               // for uintptr_t
#include <sys/types.h>                            // for ssize_t
#include "asm-generic/div64.h"                    // for do_div
#include "asm-generic/errno-base.h"               // for EINVAL, ENOMEM, EBUSY
#include "asm-generic/int-ll64.h"                 // for u32
#include "asm/page_types.h"                       // for PAGE_SIZE
#include "linux/clk.h"                            // for clk_enable, clk_dis...
#include "linux/compiler_attributes.h"            // for __maybe_unused
#include "linux/dev_printk.h"                     // for dev_err
#include "linux/device.h"                         // for dev_get_drvdata
#include "linux/device/driver.h"                  // for device_driver
#include "linux/export.h"                         // for EXPORT_SYMBOL
#include "linux/gfp.h"                            // for GFP_KERNEL
#include "linux/iio/types.h"                      // for IIO_CHAN_INFO_ENABLE
#include "linux/kernel.h"                         // for kstrtouint, ARRAY_SIZE
#include "linux/list.h"                           // for INIT_LIST_HEAD, lis...
#include "linux/mod_devicetable.h"                // for of_device_id
#include "linux/mutex.h"                          // for mutex_lock, mutex_u...
#include "linux/of.h"                             // for of_property_read_u32
#include "linux/pm.h"                             // for SIMPLE_DEV_PM_OPS
#include "linux/regmap.h"                         // for regmap_update_bits
#include "linux/stddef.h"                         // for true, false
#include "linux/string.h"                         // for strstr, strlen, str...
#include "linux/sysfs.h"                          // for sysfs_emit, attribu...
#include "linux/types.h"                          // for bool, list_head
#include "vdso/bits.h"                            // for BIT

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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 18:23   ` Jonathan Cameron
@ 2021-06-11 18:35     ` Andy Shevchenko
  2021-06-11 19:19       ` Jonathan Cameron
  0 siblings, 1 reply; 25+ messages in thread
From: Andy Shevchenko @ 2021-06-11 18:35 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin

On Fri, Jun 11, 2021 at 9:21 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Fri, 11 Jun 2021 20:48:08 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
> > On Fri, Jun 11, 2021 at 8:14 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > >
> > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > >
> > > 0-day recently started running the include-what-you-use checker with LLVM builds.
> > > After it identified a header we should have dropped in a particular patch,
> > > I decided to experiment with it a little and see if it was useful for tidying
> > > up includes that have gotten rather out of sync with the code over the years.
> > >
> > > Note the tool is something I'd only advocate using to give you hints on what
> > > might want adjusting so each of these was done by hand inspection.
> > >
> > > I've grouped them by manufacturer as otherwise we would have a lot of patches.
> > > Note that the big 'many device / device type' drivers have been done separately
> > > so you won't see them in this series.
> > >
> > > I'm rather hoping this approach may ease getting reviews of these, but we
> > > shall see.  If people have time to look at ones I haven't directly cc'd them
> > > on that would be great. There are some drivers touched in here where I don't
> > > know of a current maintainer.
> >
> > Same comment as per staging series.
> >
> > I know that kernel.h provides some crucial everywhere used macros /
> > helpers which are in the TODO list to be split.
> >
> > I would recommend dropping kernel.h from the drivers and see what's missed.
> >
> > These series probably need to be based on splitting out container_of()
> > and ARRAY_SIZE() first.
>
> Tool obligingly tells me at least one item from kernel.h and you have
> the correct pair (occasionally it's the kernel specific string routines).
> e.g.
>  #include "linux/kernel.h"                         // for kstrtouint, ARRAY_SIZE

Oh yes, kstrtox.h should be born (I have even somewhere in my tree the
preliminary split).

> > So, no tag from me for now (but I like the idea in general, and thanks
> > for looking into this).
> >
>
> The tool is rather a blunderbuss for this job which makes it rather time
> consuming to use.
>
> Splitting kernel.h up is a step beyond where I'm interested in going
> at this stage because it's sure to involve a lot of bike shedding.

Not really. There is a kind of consensus about the mentioned
container_of() and ARRAY_SIZE() and similar to be split out from
kernel.h.

But I understand you and not insisting that you have to go with it. My
point is that...

> I 'could' just drop the kernel.h where added on the basis we were clearly
> getting it indirectly. I've not included a whole bunch of other suggestions
> on that basis.

(Which is probably not a good idea, because explicit in this case is
better than implicit, i.e. kernel.h is not guaranteed to be included
by other headers and I have long standing work to actually make sure
that most of the headers won't require kernel.h!)

> Note I didn't include a whole bunch of other headers on the basis
> they were a bit more esoteric.
>
> To give an idea of how noisy this is here's the output another file...

...the tool simply doesn't know anything about kernel and header
guarantees. That's why it tries play dumb.

If you would like to continue with this, please drop the removal of
the headers that are not guaranteed to be included by others
(excluding kernel.h from the equation). Otherwise it will become
someone else's problem to _reinstantiate_ all those headers, and since
I already had a headache with panic.h, I won't repeat it. Still no tag
from me, although no explicit NAK (actually opposite, no explicit ACK
because of the dependencies), you just really need to spend more time
on this.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 18:35     ` Andy Shevchenko
@ 2021-06-11 19:19       ` Jonathan Cameron
  2021-06-11 19:36         ` Andy Shevchenko
  0 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 19:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin

On Fri, 11 Jun 2021 21:35:06 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 11, 2021 at 9:21 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Fri, 11 Jun 2021 20:48:08 +0300
> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> >  
> > > On Fri, Jun 11, 2021 at 8:14 PM Jonathan Cameron <jic23@kernel.org> wrote:  
> > > >
> > > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > >
> > > > 0-day recently started running the include-what-you-use checker with LLVM builds.
> > > > After it identified a header we should have dropped in a particular patch,
> > > > I decided to experiment with it a little and see if it was useful for tidying
> > > > up includes that have gotten rather out of sync with the code over the years.
> > > >
> > > > Note the tool is something I'd only advocate using to give you hints on what
> > > > might want adjusting so each of these was done by hand inspection.
> > > >
> > > > I've grouped them by manufacturer as otherwise we would have a lot of patches.
> > > > Note that the big 'many device / device type' drivers have been done separately
> > > > so you won't see them in this series.
> > > >
> > > > I'm rather hoping this approach may ease getting reviews of these, but we
> > > > shall see.  If people have time to look at ones I haven't directly cc'd them
> > > > on that would be great. There are some drivers touched in here where I don't
> > > > know of a current maintainer.  
> > >
> > > Same comment as per staging series.
> > >
> > > I know that kernel.h provides some crucial everywhere used macros /
> > > helpers which are in the TODO list to be split.
> > >
> > > I would recommend dropping kernel.h from the drivers and see what's missed.
> > >
> > > These series probably need to be based on splitting out container_of()
> > > and ARRAY_SIZE() first.  
> >
> > Tool obligingly tells me at least one item from kernel.h and you have
> > the correct pair (occasionally it's the kernel specific string routines).
> > e.g.
> >  #include "linux/kernel.h"                         // for kstrtouint, ARRAY_SIZE  
> 
> Oh yes, kstrtox.h should be born (I have even somewhere in my tree the
> preliminary split).

That set definitely make sense to break out.

> 
> > > So, no tag from me for now (but I like the idea in general, and thanks
> > > for looking into this).
> > >  
> >
> > The tool is rather a blunderbuss for this job which makes it rather time
> > consuming to use.
> >
> > Splitting kernel.h up is a step beyond where I'm interested in going
> > at this stage because it's sure to involve a lot of bike shedding.  
> 
> Not really. There is a kind of consensus about the mentioned
> container_of() and ARRAY_SIZE() and similar to be split out from
> kernel.h.

Ah fair enough. I'd not caught the earlier discussion of this.

> 
> But I understand you and not insisting that you have to go with it. My
> point is that...
> 
> > I 'could' just drop the kernel.h where added on the basis we were clearly
> > getting it indirectly. I've not included a whole bunch of other suggestions
> > on that basis.  
> 
> (Which is probably not a good idea, because explicit in this case is
> better than implicit, i.e. kernel.h is not guaranteed to be included
> by other headers and I have long standing work to actually make sure
> that most of the headers won't require kernel.h!)

I think I was unclear, what I was proposing was not to touch includes of
kernel.h at all. So not make anything worse, but also not make it any better.
Where added in this set, kernel.h was for things directly in kernel.h,
not the files it includes.

> 
> > Note I didn't include a whole bunch of other headers on the basis
> > they were a bit more esoteric.
> >
> > To give an idea of how noisy this is here's the output another file...  
> 
> ...the tool simply doesn't know anything about kernel and header
> guarantees. That's why it tries play dumb.
> 
> If you would like to continue with this, please drop the removal of
> the headers that are not guaranteed to be included by others
> (excluding kernel.h from the equation).

This is where the confusion lies... I haven't done that (subject to bugs
of course)

> Otherwise it will become
> someone else's problem to _reinstantiate_ all those headers, and since
> I already had a headache with panic.h, I won't repeat it. Still no tag
> from me, although no explicit NAK (actually opposite, no explicit ACK
> because of the dependencies), you just really need to spend more time
> on this.

I've not removed any headers on the basis they were guaranteed to be
included by others. The tool assumes the opposite model - everything
should be explicitly included directly in the file where it's used.
For some files it lists 50+ headers.
These patches are very conservative on that front.

What I haven't done is included everything under the sun that wasn't
already included.  e.g. I've not included
linux/device/driver.h on the basis it is definitely included by
linux/device.h and that seems very unlikely to change.

There are some corner cases that are more interesting - such as whether
we can rely on interrupt.h always including irqreturn.h.  Plenty of IIO
drivers don't call anything in interrupt.h because of various wrappers but
do use the return values. So in this case we could switch many of them
to the more specific header, but I haven't done that yet.

So, in short, the headers for which includes are removed in this series are
not used at all in the files in question (unless I messed up of course!).

Jonathan

> 


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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 19:19       ` Jonathan Cameron
@ 2021-06-11 19:36         ` Andy Shevchenko
  2021-06-11 20:10           ` Jonathan Cameron
  0 siblings, 1 reply; 25+ messages in thread
From: Andy Shevchenko @ 2021-06-11 19:36 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin

On Fri, Jun 11, 2021 at 10:17 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Fri, 11 Jun 2021 21:35:06 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > On Fri, Jun 11, 2021 at 9:21 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > > On Fri, 11 Jun 2021 20:48:08 +0300
> > > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

...

> > But I understand you and not insisting that you have to go with it. My
> > point is that...
> >
> > > I 'could' just drop the kernel.h where added on the basis we were clearly
> > > getting it indirectly. I've not included a whole bunch of other suggestions
> > > on that basis.
> >
> > (Which is probably not a good idea, because explicit in this case is
> > better than implicit, i.e. kernel.h is not guaranteed to be included
> > by other headers and I have long standing work to actually make sure
> > that most of the headers won't require kernel.h!)
>
> I think I was unclear, what I was proposing was not to touch includes of
> kernel.h at all. So not make anything worse, but also not make it any better.
> Where added in this set, kernel.h was for things directly in kernel.h,
> not the files it includes.

Ah, that's good! That was my main point of worry.

> > > Note I didn't include a whole bunch of other headers on the basis
> > > they were a bit more esoteric.
> > >
> > > To give an idea of how noisy this is here's the output another file...
> >
> > ...the tool simply doesn't know anything about kernel and header
> > guarantees. That's why it tries play dumb.
> >
> > If you would like to continue with this, please drop the removal of
> > the headers that are not guaranteed to be included by others
> > (excluding kernel.h from the equation).
>
> This is where the confusion lies... I haven't done that (subject to bugs
> of course)
>
> > Otherwise it will become
> > someone else's problem to _reinstantiate_ all those headers, and since
> > I already had a headache with panic.h, I won't repeat it. Still no tag
> > from me, although no explicit NAK (actually opposite, no explicit ACK
> > because of the dependencies), you just really need to spend more time
> > on this.
>
> I've not removed any headers on the basis they were guaranteed to be
> included by others. The tool assumes the opposite model - everything
> should be explicitly included directly in the file where it's used.
> For some files it lists 50+ headers.
> These patches are very conservative on that front.
>
> What I haven't done is included everything under the sun that wasn't
> already included.  e.g. I've not included
> linux/device/driver.h on the basis it is definitely included by
> linux/device.h and that seems very unlikely to change.
>
> There are some corner cases that are more interesting - such as whether
> we can rely on interrupt.h always including irqreturn.h.  Plenty of IIO
> drivers don't call anything in interrupt.h because of various wrappers but
> do use the return values. So in this case we could switch many of them
> to the more specific header, but I haven't done that yet.

I guess you may consider a guarantee there.

Actually what kernel header mess misses right now is the list of those
guarantees.

But you see there cases like

using dev_err() and struct device * in the same C file, what do you include?

Temptation is to go with device.h, but I would go with

#include <linux/dev_printk.h>

struct device;

Not sure if that tool can handle this kind of use.

> So, in short, the headers for which includes are removed in this series are
> not used at all in the files in question (unless I messed up of course!).

Cool! So, let bots and other people have more time on eyeballing this.
Will see how it goes.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 19:36         ` Andy Shevchenko
@ 2021-06-11 20:10           ` Jonathan Cameron
  2021-06-15  9:13             ` Rong Chen
  0 siblings, 1 reply; 25+ messages in thread
From: Jonathan Cameron @ 2021-06-11 20:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin, rong.a.chen

On Fri, 11 Jun 2021 22:36:52 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 11, 2021 at 10:17 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > On Fri, 11 Jun 2021 21:35:06 +0300
> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:  
> > > On Fri, Jun 11, 2021 at 9:21 PM Jonathan Cameron <jic23@kernel.org> wrote:  
> > > > On Fri, 11 Jun 2021 20:48:08 +0300
> > > > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:  
> 
> ...
> 
> > > But I understand you and not insisting that you have to go with it. My
> > > point is that...
> > >  
> > > > I 'could' just drop the kernel.h where added on the basis we were clearly
> > > > getting it indirectly. I've not included a whole bunch of other suggestions
> > > > on that basis.  
> > >
> > > (Which is probably not a good idea, because explicit in this case is
> > > better than implicit, i.e. kernel.h is not guaranteed to be included
> > > by other headers and I have long standing work to actually make sure
> > > that most of the headers won't require kernel.h!)  
> >
> > I think I was unclear, what I was proposing was not to touch includes of
> > kernel.h at all. So not make anything worse, but also not make it any better.
> > Where added in this set, kernel.h was for things directly in kernel.h,
> > not the files it includes.  
> 
> Ah, that's good! That was my main point of worry.
> 
> > > > Note I didn't include a whole bunch of other headers on the basis
> > > > they were a bit more esoteric.
> > > >
> > > > To give an idea of how noisy this is here's the output another file...  
> > >
> > > ...the tool simply doesn't know anything about kernel and header
> > > guarantees. That's why it tries play dumb.
> > >
> > > If you would like to continue with this, please drop the removal of
> > > the headers that are not guaranteed to be included by others
> > > (excluding kernel.h from the equation).  
> >
> > This is where the confusion lies... I haven't done that (subject to bugs
> > of course)
> >  
> > > Otherwise it will become
> > > someone else's problem to _reinstantiate_ all those headers, and since
> > > I already had a headache with panic.h, I won't repeat it. Still no tag
> > > from me, although no explicit NAK (actually opposite, no explicit ACK
> > > because of the dependencies), you just really need to spend more time
> > > on this.  
> >
> > I've not removed any headers on the basis they were guaranteed to be
> > included by others. The tool assumes the opposite model - everything
> > should be explicitly included directly in the file where it's used.
> > For some files it lists 50+ headers.
> > These patches are very conservative on that front.
> >
> > What I haven't done is included everything under the sun that wasn't
> > already included.  e.g. I've not included
> > linux/device/driver.h on the basis it is definitely included by
> > linux/device.h and that seems very unlikely to change.
> >
> > There are some corner cases that are more interesting - such as whether
> > we can rely on interrupt.h always including irqreturn.h.  Plenty of IIO
> > drivers don't call anything in interrupt.h because of various wrappers but
> > do use the return values. So in this case we could switch many of them
> > to the more specific header, but I haven't done that yet.  
> 
> I guess you may consider a guarantee there.
> 
> Actually what kernel header mess misses right now is the list of those
> guarantees.
> 
> But you see there cases like
> 
> using dev_err() and struct device * in the same C file, what do you include?
> 
> Temptation is to go with device.h, but I would go with
> 
> #include <linux/dev_printk.h>
> 
> struct device;
> 
> Not sure if that tool can handle this kind of use.

It does.  I decided it was a step too far and didn't act on this one
for da311.c, but here is an example of that case.

drivers/iio/accel/da311.c should add these lines:
#include "asm-generic/errno-base.h"  // for EINVAL, ENODEV, ENOMEM
#include "asm-generic/int-ll64.h"    // for u8, u16
#include "generated/autoconf.h"      // for CONFIG_PM_SLEEP
#include "linux/dev_printk.h"        // for dev_err
#include "linux/iio/types.h"         // for IIO_CHAN_INFO_RAW, IIO_CHAN_INFO...
#include "linux/kernel.h"            // for ARRAY_SIZE
#include "linux/pm.h"                // for SIMPLE_DEV_PM_OPS
#include "linux/stddef.h"            // for false, true
#include "linux/types.h"             // for bool
#include "vdso/bits.h"               // for BIT
struct device;

If we can teach the tool (or post process it a bit) about places we
want to do something beyond the direct (e.g. asm-generic/ernrno-base.h)
that would make it much more useful.  Even then I think we'll want
a human in the loop.

I'm running an older version than 0-day has been using I think.

+Cc 0-day person who kind of kicked this off :)

Note the warning from 0-day was about a header no longer needing to be included
(the mutex in the ADIS drivers got recently moved to a wrapper in the library).
Those warnings are almost certain to be correct - and many of the removals
in here are things that would have been picked up in similar circumstances.

Note things can get a bit silly, even if technically correct...
+ it gets confused on where headers are coming from sometimes.

The full include-list for drivers/iio/industrialio-core.c:
#include <asm/bug.h>                                 // for WARN
#include <linux/cdev.h>                              // for cdev_init, cdev_...
#include <linux/debugfs.h>                           // for debugfs_create_dir
#include <linux/device.h>                            // for device, device_a...
#include <linux/err.h>                               // for IS_ERR, PTR_ERR
#include <linux/fs.h>                                // for noop_llseek, inode
#include <linux/idr.h>                               // for DEFINE_IDA, ida_...
#include <linux/iio/iio-opaque.h>                    // for iio_dev_opaque
#include <linux/iio/iio.h>                           // for iio_dev, iio_cha...
#include <linux/iio/sysfs.h>                         // for iio_dev_attr
#include <linux/kdev_t.h>                            // for MAJOR, MKDEV
#include <linux/kernel.h>                            // for kasprintf, sscanf
#include <linux/ktime.h>                             // for ktime_get_bootti...
#include <linux/module.h>                            // for MODULE_AUTHOR
#include <linux/mutex.h>                             // for mutex_unlock
#include <linux/property.h>                          // for device_property_...
#include <linux/slab.h>                              // for kfree, kzalloc
#include <stddef.h>                                  // for NULL, size_t
#include <stdint.h>                                  // for uintptr_t
#include <sys/types.h>                               // for ssize_t, dev_t
#include "asm-generic/bitops/instrumented-atomic.h"  // for clear_bit, test_...
#include "asm-generic/errno-base.h"                  // for EINVAL, EBUSY
#include "asm-generic/int-ll64.h"                    // for s64, u64
#include "asm/bug.h"                                 // for BUG
#include "asm/page_types.h"                          // for PAGE_SIZE
#include "asm/string_64.h"                           // for memcpy
#include "generated/autoconf.h"                      // for CONFIG_DEBUG_FS
#include "iio_core.h"                                // for iio_ioctl_handler
#include "iio_core_trigger.h"                        // for iio_device_regis...
#include "linux/align.h"                             // for ALIGN
#include "linux/bitops.h"                            // for for_each_set_bit
#include "linux/compiler_attributes.h"               // for fallthrough
#include "linux/compiler_types.h"                    // for __user
#include "linux/dev_printk.h"                        // for dev_err, dev_info
#include "linux/device/bus.h"                        // for bus_unregister
#include "linux/export.h"                            // for EXPORT_SYMBOL_GPL
#include "linux/gfp.h"                               // for GFP_KERNEL
#include "linux/hrtimer.h"                           // for hrtimer_resolution
#include "linux/iio/types.h"                         // for IIO_VAL_INT, IIO...
#include "linux/init.h"                              // for __exit, __init
#include "linux/ktime.h"                             // for ktime_to_ns
#include "linux/list.h"                              // for INIT_LIST_HEAD
#include "linux/math.h"                              // for abs
#include "linux/math64.h"                            // for div_s64_rem, div...
#include "linux/minmax.h"                            // for min_t
#include "linux/of.h"                                // for of_get_property
#include "linux/printk.h"                            // for pr_err
#include "linux/stat.h"                              // for S_IRUGO, S_IWUSR
#include "linux/stddef.h"                            // for false, true
#include "linux/string.h"                            // for sysfs_streq, str...
#include "linux/sysfs.h"                             // for sysfs_emit_at
#include "linux/time.h"                              // for CLOCK_BOOTTIME
#include "linux/time64.h"                            // for timespec64_to_ns
#include "linux/timex.h"                             // for shift_right
#include "linux/types.h"                             // for list_head, bool
#include "linux/uaccess.h"                           // for copy_from_user
#include "vdso/ktime.h"                              // for LOW_RES_NSEC
struct iio_buffer;
> 
> > So, in short, the headers for which includes are removed in this series are
> > not used at all in the files in question (unless I messed up of course!).  
> 
> Cool! So, let bots and other people have more time on eyeballing this.
> Will see how it goes.

Sure.

Jonathan
> 


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

* Re: [PATCH 02/12] iio:accel:bma180: Use generic device properties.
  2021-06-11 17:13 ` [PATCH 02/12] iio:accel:bma180: Use generic device properties Jonathan Cameron
@ 2021-06-11 21:48   ` Linus Walleij
  0 siblings, 0 replies; 25+ messages in thread
From: Linus Walleij @ 2021-06-11 21:48 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron, Jonathan Bakker

On Fri, Jun 11, 2021 at 7:12 PM Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Whilst doing header cleanup I noticed this driver makes very superficial
> use of of_* interfaces.  Hence move to the generic firmware forms.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jonathan Bakker <xc-racer2@live.ca>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Looks correct!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes.
  2021-06-11 17:13 ` [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes Jonathan Cameron
@ 2021-06-14  5:57   ` Sean Nyekjaer
  0 siblings, 0 replies; 25+ messages in thread
From: Sean Nyekjaer @ 2021-06-14  5:57 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron

On Fri, Jun 11, 2021 at 06:13:48PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Based on consideration of the output of the include-what-you-use tool.
> Note that in this driver the main reason to do this is to ensure
> consistency across IIO.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Sean Nyekjaer <sean@geanix.com>

Reviewed-by: Sean Nyekjaer <sean@geanix.com>

> ---
>  drivers/iio/accel/fxls8962af-core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
> index 078d87865fde..6882f082d581 100644
> --- a/drivers/iio/accel/fxls8962af-core.c
> +++ b/drivers/iio/accel/fxls8962af-core.c
> @@ -15,16 +15,17 @@
>  #include <linux/bits.h>
>  #include <linux/bitfield.h>
>  #include <linux/i2c.h>
> +#include <linux/interrupt.h>
>  #include <linux/module.h>
>  #include <linux/of_irq.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/regmap.h>
>  
>  #include <linux/iio/buffer.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/kfifo_buf.h>
> -#include <linux/iio/sysfs.h>
>  
>  #include "fxls8962af.h"
>  
> -- 
> 2.31.1
> 

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

* Re: [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts.
  2021-06-11 17:13 ` [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts Jonathan Cameron
@ 2021-06-14  7:15   ` Tomas Melin
  0 siblings, 0 replies; 25+ messages in thread
From: Tomas Melin @ 2021-06-14  7:15 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: Jonathan Cameron


On 6/11/21 8:13 PM, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Based on consideration of the output of include-what-you-use.
> Some unused includes dropped and some that are directly used in the
> files added.
>
> There are no hard rules for when we should rely on includes being
> there as part of including another header and when we should do them
> directly.  This is part of an attempt to be more consistent on that
> in IIO.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Tomas Melin <tomas.melin@vaisala.com>
> ---
>   drivers/iio/accel/sca3000.c | 5 ++---
>   drivers/iio/accel/sca3300.c | 3 ++-
>   2 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Tomas Melin <tomas.melin@vaisala.com>


>
> diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> index cb753a43533c..9f4bbf23834f 100644
> --- a/drivers/iio/accel/sca3000.c
> +++ b/drivers/iio/accel/sca3000.c
> @@ -8,14 +8,13 @@
>    */
>   
>   #include <linux/interrupt.h>
> -#include <linux/fs.h>
>   #include <linux/device.h>
> -#include <linux/slab.h>
>   #include <linux/kernel.h>
>   #include <linux/spi/spi.h>
>   #include <linux/sysfs.h>
>   #include <linux/module.h>
> -#include <linux/uaccess.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/mutex.h>
>   #include <linux/iio/iio.h>
>   #include <linux/iio/sysfs.h>
>   #include <linux/iio/events.h>
> diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c
> index f7ef8ecfd34a..2042d8baf7b8 100644
> --- a/drivers/iio/accel/sca3300.c
> +++ b/drivers/iio/accel/sca3300.c
> @@ -10,13 +10,14 @@
>   #include <linux/delay.h>
>   #include <linux/kernel.h>
>   #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/mutex.h>
>   #include <linux/spi/spi.h>
>   
>   #include <asm/unaligned.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>
>   

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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 20:10           ` Jonathan Cameron
@ 2021-06-15  9:13             ` Rong Chen
  0 siblings, 0 replies; 25+ messages in thread
From: Rong Chen @ 2021-06-15  9:13 UTC (permalink / raw)
  To: Jonathan Cameron, Andy Shevchenko
  Cc: linux-iio, Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin,
	Dan Robertson, Hans de Goede, Harinath Nampally,
	Jelle van der Waa, Jonathan Bakker, Lars-Peter Clausen,
	Linus Walleij, Michael Hennerich, Mike Looijmans, Sean Nyekjaer,
	Tomas Melin



On 6/12/21 4:10 AM, Jonathan Cameron wrote:
> On Fri, 11 Jun 2021 22:36:52 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
>> On Fri, Jun 11, 2021 at 10:17 PM Jonathan Cameron <jic23@kernel.org> wrote:
>>> On Fri, 11 Jun 2021 21:35:06 +0300
>>> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>>>> On Fri, Jun 11, 2021 at 9:21 PM Jonathan Cameron <jic23@kernel.org> wrote:
>>>>> On Fri, 11 Jun 2021 20:48:08 +0300
>>>>> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>> ...
>>
>>>> But I understand you and not insisting that you have to go with it. My
>>>> point is that...
>>>>   
>>>>> I 'could' just drop the kernel.h where added on the basis we were clearly
>>>>> getting it indirectly. I've not included a whole bunch of other suggestions
>>>>> on that basis.
>>>> (Which is probably not a good idea, because explicit in this case is
>>>> better than implicit, i.e. kernel.h is not guaranteed to be included
>>>> by other headers and I have long standing work to actually make sure
>>>> that most of the headers won't require kernel.h!)
>>> I think I was unclear, what I was proposing was not to touch includes of
>>> kernel.h at all. So not make anything worse, but also not make it any better.
>>> Where added in this set, kernel.h was for things directly in kernel.h,
>>> not the files it includes.
>> Ah, that's good! That was my main point of worry.
>>
>>>>> Note I didn't include a whole bunch of other headers on the basis
>>>>> they were a bit more esoteric.
>>>>>
>>>>> To give an idea of how noisy this is here's the output another file...
>>>> ...the tool simply doesn't know anything about kernel and header
>>>> guarantees. That's why it tries play dumb.
>>>>
>>>> If you would like to continue with this, please drop the removal of
>>>> the headers that are not guaranteed to be included by others
>>>> (excluding kernel.h from the equation).
>>> This is where the confusion lies... I haven't done that (subject to bugs
>>> of course)
>>>   
>>>> Otherwise it will become
>>>> someone else's problem to _reinstantiate_ all those headers, and since
>>>> I already had a headache with panic.h, I won't repeat it. Still no tag
>>>> from me, although no explicit NAK (actually opposite, no explicit ACK
>>>> because of the dependencies), you just really need to spend more time
>>>> on this.
>>> I've not removed any headers on the basis they were guaranteed to be
>>> included by others. The tool assumes the opposite model - everything
>>> should be explicitly included directly in the file where it's used.
>>> For some files it lists 50+ headers.
>>> These patches are very conservative on that front.
>>>
>>> What I haven't done is included everything under the sun that wasn't
>>> already included.  e.g. I've not included
>>> linux/device/driver.h on the basis it is definitely included by
>>> linux/device.h and that seems very unlikely to change.
>>>
>>> There are some corner cases that are more interesting - such as whether
>>> we can rely on interrupt.h always including irqreturn.h.  Plenty of IIO
>>> drivers don't call anything in interrupt.h because of various wrappers but
>>> do use the return values. So in this case we could switch many of them
>>> to the more specific header, but I haven't done that yet.
>> I guess you may consider a guarantee there.
>>
>> Actually what kernel header mess misses right now is the list of those
>> guarantees.
>>
>> But you see there cases like
>>
>> using dev_err() and struct device * in the same C file, what do you include?
>>
>> Temptation is to go with device.h, but I would go with
>>
>> #include <linux/dev_printk.h>
>>
>> struct device;
>>
>> Not sure if that tool can handle this kind of use.
> It does.  I decided it was a step too far and didn't act on this one
> for da311.c, but here is an example of that case.
>
> drivers/iio/accel/da311.c should add these lines:
> #include "asm-generic/errno-base.h"  // for EINVAL, ENODEV, ENOMEM
> #include "asm-generic/int-ll64.h"    // for u8, u16
> #include "generated/autoconf.h"      // for CONFIG_PM_SLEEP
> #include "linux/dev_printk.h"        // for dev_err
> #include "linux/iio/types.h"         // for IIO_CHAN_INFO_RAW, IIO_CHAN_INFO...
> #include "linux/kernel.h"            // for ARRAY_SIZE
> #include "linux/pm.h"                // for SIMPLE_DEV_PM_OPS
> #include "linux/stddef.h"            // for false, true
> #include "linux/types.h"             // for bool
> #include "vdso/bits.h"               // for BIT
> struct device;
>
> If we can teach the tool (or post process it a bit) about places we
> want to do something beyond the direct (e.g. asm-generic/ernrno-base.h)
> that would make it much more useful.  Even then I think we'll want
> a human in the loop.

Hi,

The tool allows to correct the recommended headers, please see

https://github.com/include-what-you-use/include-what-you-use#how-to-correct-iwyu-mistakes

>
> I'm running an older version than 0-day has been using I think.
>
> +Cc 0-day person who kind of kicked this off :)
>
> Note the warning from 0-day was about a header no longer needing to be included
> (the mutex in the ADIS drivers got recently moved to a wrapper in the library).
> Those warnings are almost certain to be correct - and many of the removals
> in here are things that would have been picked up in similar circumstances.

Yes, 0day only detects useless headers experimentally, we're willing to 
extend the range
if include-what-you-use tool (or other tool) can output a more friendly 
header list.

Best Regards,
Rong Chen

>
> Note things can get a bit silly, even if technically correct...
> + it gets confused on where headers are coming from sometimes.
>
> The full include-list for drivers/iio/industrialio-core.c:
> #include <asm/bug.h>                                 // for WARN
> #include <linux/cdev.h>                              // for cdev_init, cdev_...
> #include <linux/debugfs.h>                           // for debugfs_create_dir
> #include <linux/device.h>                            // for device, device_a...
> #include <linux/err.h>                               // for IS_ERR, PTR_ERR
> #include <linux/fs.h>                                // for noop_llseek, inode
> #include <linux/idr.h>                               // for DEFINE_IDA, ida_...
> #include <linux/iio/iio-opaque.h>                    // for iio_dev_opaque
> #include <linux/iio/iio.h>                           // for iio_dev, iio_cha...
> #include <linux/iio/sysfs.h>                         // for iio_dev_attr
> #include <linux/kdev_t.h>                            // for MAJOR, MKDEV
> #include <linux/kernel.h>                            // for kasprintf, sscanf
> #include <linux/ktime.h>                             // for ktime_get_bootti...
> #include <linux/module.h>                            // for MODULE_AUTHOR
> #include <linux/mutex.h>                             // for mutex_unlock
> #include <linux/property.h>                          // for device_property_...
> #include <linux/slab.h>                              // for kfree, kzalloc
> #include <stddef.h>                                  // for NULL, size_t
> #include <stdint.h>                                  // for uintptr_t
> #include <sys/types.h>                               // for ssize_t, dev_t
> #include "asm-generic/bitops/instrumented-atomic.h"  // for clear_bit, test_...
> #include "asm-generic/errno-base.h"                  // for EINVAL, EBUSY
> #include "asm-generic/int-ll64.h"                    // for s64, u64
> #include "asm/bug.h"                                 // for BUG
> #include "asm/page_types.h"                          // for PAGE_SIZE
> #include "asm/string_64.h"                           // for memcpy
> #include "generated/autoconf.h"                      // for CONFIG_DEBUG_FS
> #include "iio_core.h"                                // for iio_ioctl_handler
> #include "iio_core_trigger.h"                        // for iio_device_regis...
> #include "linux/align.h"                             // for ALIGN
> #include "linux/bitops.h"                            // for for_each_set_bit
> #include "linux/compiler_attributes.h"               // for fallthrough
> #include "linux/compiler_types.h"                    // for __user
> #include "linux/dev_printk.h"                        // for dev_err, dev_info
> #include "linux/device/bus.h"                        // for bus_unregister
> #include "linux/export.h"                            // for EXPORT_SYMBOL_GPL
> #include "linux/gfp.h"                               // for GFP_KERNEL
> #include "linux/hrtimer.h"                           // for hrtimer_resolution
> #include "linux/iio/types.h"                         // for IIO_VAL_INT, IIO...
> #include "linux/init.h"                              // for __exit, __init
> #include "linux/ktime.h"                             // for ktime_to_ns
> #include "linux/list.h"                              // for INIT_LIST_HEAD
> #include "linux/math.h"                              // for abs
> #include "linux/math64.h"                            // for div_s64_rem, div...
> #include "linux/minmax.h"                            // for min_t
> #include "linux/of.h"                                // for of_get_property
> #include "linux/printk.h"                            // for pr_err
> #include "linux/stat.h"                              // for S_IRUGO, S_IWUSR
> #include "linux/stddef.h"                            // for false, true
> #include "linux/string.h"                            // for sysfs_streq, str...
> #include "linux/sysfs.h"                             // for sysfs_emit_at
> #include "linux/time.h"                              // for CLOCK_BOOTTIME
> #include "linux/time64.h"                            // for timespec64_to_ns
> #include "linux/timex.h"                             // for shift_right
> #include "linux/types.h"                             // for list_head, bool
> #include "linux/uaccess.h"                           // for copy_from_user
> #include "vdso/ktime.h"                              // for LOW_RES_NSEC
> struct iio_buffer;
>>> So, in short, the headers for which includes are removed in this series are
>>> not used at all in the files in question (unless I messed up of course!).
>> Cool! So, let bots and other people have more time on eyeballing this.
>> Will see how it goes.
> Sure.
>
> Jonathan


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

* Re: [PATCH 00/12] iio:accel: Header Cleanups.
  2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
                   ` (12 preceding siblings ...)
  2021-06-11 17:48 ` [PATCH 00/12] iio:accel: Header Cleanups Andy Shevchenko
@ 2021-06-15 13:12 ` Lars-Peter Clausen
  13 siblings, 0 replies; 25+ messages in thread
From: Lars-Peter Clausen @ 2021-06-15 13:12 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Jonathan Cameron, Andy Shevchenko, Aleksei Mamlin, Dan Robertson,
	Hans de Goede, Harinath Nampally, Jelle van der Waa,
	Jonathan Bakker, Linus Walleij, Michael Hennerich,
	Mike Looijmans, Sean Nyekjaer, Tomas Melin

On 6/11/21 7:13 PM, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 0-day recently started running the include-what-you-use checker with LLVM builds.
> After it identified a header we should have dropped in a particular patch,
> I decided to experiment with it a little and see if it was useful for tidying
> up includes that have gotten rather out of sync with the code over the years.
Oh, that's nice! I've always been looking for something like that.

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

* Re: [PATCH 01/12] iio:accel:adxl372: Cleanup includes
  2021-06-11 17:13 ` [PATCH 01/12] iio:accel:adxl372: Cleanup includes Jonathan Cameron
@ 2021-06-15 13:16   ` Lars-Peter Clausen
  0 siblings, 0 replies; 25+ messages in thread
From: Lars-Peter Clausen @ 2021-06-15 13:16 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: Jonathan Cameron, Michael Hennerich

On 6/11/21 7:13 PM, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Based on consideration of the output of include-what-you-use.
> Drop some unused headers and include others that should probably be
> there based on direct use.  Also a few forward definitions to avoid
> any potential future include ordering issues.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Michael Hennerich <Michael.Hennerich@analog.com>


Acked-by:  Lars-Peter Clausen <lars@metafoo.de>

Thanks.

> ---
>   drivers/iio/accel/adxl372.c     | 4 ++--
>   drivers/iio/accel/adxl372.h     | 2 ++
>   drivers/iio/accel/adxl372_spi.c | 3 +--
>   3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> index fc9592407717..c679cb9f3ed1 100644
> --- a/drivers/iio/accel/adxl372.c
> +++ b/drivers/iio/accel/adxl372.c
> @@ -6,12 +6,12 @@
>    */
>   
>   #include <linux/bitfield.h>
> +#include <linux/bitmap.h>
>   #include <linux/bitops.h>
>   #include <linux/interrupt.h>
> -#include <linux/irq.h>
>   #include <linux/module.h>
> +#include <linux/mutex.h>
>   #include <linux/regmap.h>
> -#include <linux/spi/spi.h>
>   
>   #include <linux/iio/iio.h>
>   #include <linux/iio/sysfs.h>
> diff --git a/drivers/iio/accel/adxl372.h b/drivers/iio/accel/adxl372.h
> index 80a0aa9714fc..86bf8955d60c 100644
> --- a/drivers/iio/accel/adxl372.h
> +++ b/drivers/iio/accel/adxl372.h
> @@ -9,6 +9,8 @@
>   #define _ADXL372_H_
>   
>   #define ADXL372_REVID	0x03
> +struct device;
> +struct regmap;
>   
>   int adxl372_probe(struct device *dev, struct regmap *regmap,
>   		  int irq, const char *name);
> diff --git a/drivers/iio/accel/adxl372_spi.c b/drivers/iio/accel/adxl372_spi.c
> index 1f1352fee99a..927379f9b497 100644
> --- a/drivers/iio/accel/adxl372_spi.c
> +++ b/drivers/iio/accel/adxl372_spi.c
> @@ -6,9 +6,8 @@
>    */
>   
>   #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
>   #include <linux/regmap.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
>   #include <linux/spi/spi.h>
>   
>   #include "adxl372.h"



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

end of thread, other threads:[~2021-06-15 13:16 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
2021-06-11 17:13 ` [PATCH 01/12] iio:accel:adxl372: Cleanup includes Jonathan Cameron
2021-06-15 13:16   ` Lars-Peter Clausen
2021-06-11 17:13 ` [PATCH 02/12] iio:accel:bma180: Use generic device properties Jonathan Cameron
2021-06-11 21:48   ` Linus Walleij
2021-06-11 17:13 ` [PATCH 03/12] iio:accel:bosch drivers: Cleanup includes Jonathan Cameron
2021-06-11 17:13 ` [PATCH 04/12] iio:accel:miramems drivers: Cleanup headers Jonathan Cameron
2021-06-11 17:13 ` [PATCH 05/12] iio:accel:domintech: Cleanup includes Jonathan Cameron
2021-06-11 17:13 ` [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes Jonathan Cameron
2021-06-14  5:57   ` Sean Nyekjaer
2021-06-11 17:13 ` [PATCH 07/12] iio:accel:kionix drivers: Cleanup includes Jonathan Cameron
2021-06-11 17:13 ` [PATCH 08/12] iio:accel:mc3220: " Jonathan Cameron
2021-06-11 17:13 ` [PATCH 09/12] iio:accel:freescale drivers: " Jonathan Cameron
2021-06-11 17:13 ` [PATCH 10/12] iio:accel:memsic " Jonathan Cameron
2021-06-11 17:13 ` [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts Jonathan Cameron
2021-06-14  7:15   ` Tomas Melin
2021-06-11 17:13 ` [PATCH 12/12] iio:accel:sensortek drivers: Add some includes Jonathan Cameron
2021-06-11 17:48 ` [PATCH 00/12] iio:accel: Header Cleanups Andy Shevchenko
2021-06-11 18:23   ` Jonathan Cameron
2021-06-11 18:35     ` Andy Shevchenko
2021-06-11 19:19       ` Jonathan Cameron
2021-06-11 19:36         ` Andy Shevchenko
2021-06-11 20:10           ` Jonathan Cameron
2021-06-15  9:13             ` Rong Chen
2021-06-15 13:12 ` Lars-Peter Clausen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.