iio:accel: Header Cleanups.
Subsystems (5)
Jonathan Cameron
maintainercover iio:accel: Header Cleanups.
From: Jonathan Cameron <[email protected]>
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.
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(-)
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 1/12 iio:accel:adxl372: Cleanup includes
From: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/accel/adxl372.c +2 -2
@@ -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>
drivers/iio/accel/adxl372.h +2 -0
@@ -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);
drivers/iio/accel/adxl372_spi.c +1 -2
@@ -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"
Signature · 1 line
2.31.1
Re: [PATCH 01/12] iio:accel:adxl372: Cleanup includes
Quoted 10 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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 <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Michael Hennerich <[email protected]>
Thanks.
Quoted 53 lines
--- 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(-)drivers/iio/accel/adxl372.c +2
-2@@ -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> drivers/iio/accel/adxl372.h +2
-0@@ -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);drivers/iio/accel/adxl372_spi.c +1
-2@@ -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"
Jonathan Cameron
maintainerPATCH 2/12 iio:accel:bma180: Use generic device properties.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Whilst doing header cleanup I noticed this driver makes very superficial use of of_* interfaces. Hence move to the generic firmware forms.
--- drivers/iio/accel/bma180.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/accel/bma180.c +3 -4
@@ -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];
Signature · 1 line
2.31.1
Re: [PATCH 02/12] iio:accel:bma180: Use generic device properties.
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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 <[email protected]>Cc Jonathan Bakker <[email protected]>Cc Linus Walleij <[email protected]>
Looks correct!
Yours,
Linus Walleij
Jonathan Cameron
maintainerPATCH 3/12 iio:accel:bosch drivers: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/accel/bma180.c +2 -2
@@ -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>
drivers/iio/accel/bma220_spi.c +1 -1
@@ -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>
drivers/iio/accel/bma400_core.c +0 -1
@@ -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>
drivers/iio/accel/bma400_spi.c +0 -1
@@ -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>
drivers/iio/accel/bmc150-accel-core.c +1 -0
@@ -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>
drivers/iio/accel/bmc150-accel-spi.c +0 -1
@@ -4,7 +4,6 @@* Copyright © 2015 Pengutronix, Markus Pargmann <[email protected]> */ -#include <linux/device.h> #include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/acpi.h>
drivers/iio/accel/bmi088-accel-core.c +0 -3
@@ -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"
drivers/iio/accel/bmi088-accel-spi.c +2 -1
@@ -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"
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 4/12 iio:accel:miramems drivers: Cleanup headers
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/da280.c | 3 +-- drivers/iio/accel/da311.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/iio/accel/da280.c +1 -2
@@ -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
drivers/iio/accel/da311.c +2 -2
@@ -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
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 5/12 iio:accel:domintech: Cleanup includes.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/accel/dmard06.c +3 -1
@@ -5,9 +5,11 @@* Copyright (C) 2016 Aleksei Mamlin <[email protected]> */ +#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"
drivers/iio/accel/dmard09.c +2 -0
@@ -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>
drivers/iio/accel/dmard10.c +1 -1
@@ -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
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 6/12 iio:accel:fxls8962af: Add a few missing includes.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/fxls8962af-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/accel/fxls8962af-core.c +2 -1
@@ -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"
Signature · 1 line
2.31.1
Re: [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes.
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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 <[email protected]>Cc Sean Nyekjaer <[email protected]>
Quoted 30 lines
--- drivers/iio/accel/fxls8962af-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/accel/fxls8962af-core.c +2
-1@@ -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" Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 7/12 iio:accel:kionix drivers: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/accel/kxcjk-1013.c +3 -1
@@ -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>
drivers/iio/accel/kxsd9-i2c.c +0 -3
@@ -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"
drivers/iio/accel/kxsd9-spi.c +1 -4
@@ -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"
drivers/iio/accel/kxsd9.c +0 -1
@@ -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>
drivers/iio/accel/kxsd9.h +2 -0
@@ -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,
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 8/12 iio:accel:mc3220: Cleanup includes.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/mc3230.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/mc3230.c +1 -1
@@ -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
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 9/12 iio:accel:freescale drivers: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/accel/mma7455_core.c +2 -1
@@ -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>
drivers/iio/accel/mma7455_i2c.c +1 -0
@@ -6,6 +6,7 @@#include <linux/i2c.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include "mma7455.h"
drivers/iio/accel/mma7455_spi.c +1 -0
@@ -5,6 +5,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/spi/spi.h>
drivers/iio/accel/mma7660.c +3 -0
@@ -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>
drivers/iio/accel/mma8452.c +5 -0
@@ -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
drivers/iio/accel/mma9551.c +4 -3
@@ -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"
drivers/iio/accel/mma9551_core.h +2 -0
@@ -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,
drivers/iio/accel/mma9553.c +4 -2
@@ -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"
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 10/12 iio:accel:memsic drivers: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/mxc4005.c | 4 ++++ drivers/iio/accel/mxc6255.c | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/iio/accel/mxc4005.c +4 -0
@@ -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>
drivers/iio/accel/mxc6255.c +2 -3
@@ -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"
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 11/12 iio:accel:murata/vti drivers: Include cleanups for the sca**** parts.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/sca3000.c | 5 ++--- drivers/iio/accel/sca3300.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/iio/accel/sca3000.c +2 -3
@@ -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>
drivers/iio/accel/sca3300.c +2 -1
@@ -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>
Signature · 1 line
2.31.1
Re: [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts.
Quoted 11 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.
Quoted 6 lines
Signed-off-by Jonathan Cameron <[email protected]>Cc Tomas Melin <[email protected]>--- drivers/iio/accel/sca3000.c | 5 ++--- drivers/iio/accel/sca3300.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 42 lines
drivers/iio/accel/sca3000.c +2
-3@@ -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> drivers/iio/accel/sca3300.c +2
-1@@ -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>
Jonathan Cameron
maintainerPATCH 12/12 iio:accel:sensortek drivers: Add some includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/stk8312.c | 3 +++ drivers/iio/accel/stk8ba50.c | 2 ++ 2 files changed, 5 insertions(+)
drivers/iio/accel/stk8312.c +3 -0
@@ -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>
drivers/iio/accel/stk8ba50.c +2 -0
@@ -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>
Signature · 1 line
2.31.1
Quoted 11 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.
Quoted 8 lines
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).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 23 lines · On Fri, 11 Jun 2021 20:48:08 +0300 Andy Shevchenko <[email protected]>…
Quoted 11 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.
Quoted 8 lines
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.
Quoted 7 lines
I know that
kernel.hprovides some crucial everywhere used macros / helpers which are in the TODO list to be split.I would recommend dropping
kernel.hfrom the drivers and see what's missed.These series probably need to be based on splitting out
container_of()andARRAY_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
Quoted 4 lines
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
Quoted 32 lines · Jonathan Cameron
Quoted 28 lines · On Fri, 11 Jun 2021 20:48:08 +0300 Andy Shevchenko <[email protected]>…
Quoted 11 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.
Quoted 8 lines
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.hprovides some crucial everywhere used macros / helpers which are in the TODO list to be split.I would recommend dropping
kernel.hfrom the drivers and see what's missed.
Quoted 7 lines
Quoted 2 lines
These series probably need to be based on splitting out
container_of()andARRAY_SIZE()first.Tool obligingly tells me at least one item from
kernel.hand 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).
Quoted 9 lines
Quoted 3 lines
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.hup 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...
Quoted 3 lines
I 'could' just drop the
kernel.hwhere 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!)
Quoted 4 lines
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 36 lines · On Fri, 11 Jun 2021 21:35:06 +0300 Andy Shevchenko <[email protected]>…
Quoted 35 lines · Jonathan Cameron
Quoted 30 lines · On Fri, 11 Jun 2021 20:48:08 +0300 Andy Shevchenko <[email protected]>…
Quoted 11 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.
Quoted 8 lines
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.hprovides some crucial everywhere used macros / helpers which are in the TODO list to be split.I would recommend dropping
kernel.hfrom the drivers and see what's missed.These series probably need to be based on splitting out
container_of()andARRAY_SIZE()first.
Quoted 7 lines
Quoted 4 lines
Tool obligingly tells me at least one item from
kernel.hand you have the correct pair (occasionally it's the kernel specific string routines). e.g.
#include "linux/kernel.h" // for kstrtouint,ARRAY_SIZEOh yes,
kstrtox.hshould be born (I have even somewhere in my tree the preliminary split).
That set definitely make sense to break out.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
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.
Quoted 6 lines
Quoted 2 lines
Splitting
kernel.hup 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()andARRAY_SIZE()and similar to be split out fromkernel.h.
Ah fair enough. I'd not caught the earlier discussion of this.
Quoted 4 lines
But I understand you and not insisting that you have to go with it. My point is that...
Quoted 8 lines
Quoted 3 lines
I 'could' just drop the
kernel.hwhere 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.his 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 requirekernel.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.
Quoted 4 lines
Quoted 4 lines
Note I didn't include a whole bunch of other headers on the basis they were a bit more esoteric.
Quoted 8 lines
Quoted 1 line
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.hfrom the equation).
This is where the confusion lies... I haven't done that (subject to bugs of course)
Quoted 6 lines
Otherwise it will become
someone else's problem to _reinstantiate_ all those headers, and since I already had a headache withpanic.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
Quoted 1 line
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 11 Jun 2021 21:35:06 +0300 Andy Shevchenko <[email protected]>…
Quoted 2 lines · Jonathan Cameron
On Fri, 11 Jun 2021 20:48:08 +0300
Andy Shevchenko <[email protected]> wrote:
...
Quoted 12 lines
Quoted 11 lines
But I understand you and not insisting that you have to go with it. My point is that...
Quoted 3 lines
I 'could' just drop the
kernel.hwhere 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.his 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 requirekernel.h!)
Quoted 4 lines
I think I was unclear, what I was proposing was not to touch includes of
kernel.hat all. So not make anything worse, but also not make it any better. Where added in this set,kernel.hwas for things directly inkernel.h, not the files it includes.
Ah, that's good! That was my main point of worry.
Quoted 33 lines
Quoted 11 lines
Quoted 4 lines
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.hfrom the equation).This is where the confusion lies... I haven't done that (subject to bugs of course)
Quoted 6 lines
Otherwise it will become
someone else's problem to _reinstantiate_ all those headers, and since I already had a headache withpanic.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.hon the basis it is definitely included bylinux/device.hand that seems very unlikely to change.
Quoted 5 lines
There are some corner cases that are more interesting - such as whether we can rely on
interrupt.halways includingirqreturn.h. Plenty of IIO drivers don't call anything ininterrupt.hbecause 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.
Quoted 2 lines
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 76 lines · On Fri, 11 Jun 2021 22:36:52 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 11 Jun 2021 21:35:06 +0300 Andy Shevchenko <[email protected]>…
Quoted 2 lines · Jonathan Cameron
On Fri, 11 Jun 2021 20:48:08 +0300
Andy Shevchenko <[email protected]> wrote:...
Quoted 12 lines
Quoted 11 lines
But I understand you and not insisting that you have to go with it. My point is that...
Quoted 3 lines
I 'could' just drop the
kernel.hwhere 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.his 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 requirekernel.h!)Quoted 4 lines
I think I was unclear, what I was proposing was not to touch includes of
kernel.hat all. So not make anything worse, but also not make it any better. Where added in this set,kernel.hwas for things directly inkernel.h, not the files it includes.Ah, that's good! That was my main point of worry.
Quoted 33 lines
Quoted 11 lines
Quoted 4 lines
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.hfrom the equation).This is where the confusion lies... I haven't done that (subject to bugs of course)
Quoted 6 lines
Otherwise it will become
someone else's problem to _reinstantiate_ all those headers, and since I already had a headache withpanic.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.hon the basis it is definitely included bylinux/device.hand that seems very unlikely to change.Quoted 5 lines
There are some corner cases that are more interesting - such as whether we can rely on
interrupt.halways includingirqreturn.h. Plenty of IIO drivers don't call anything ininterrupt.hbecause 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?
Quoted 7 lines
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;
Quoted 6 lines
Quoted 3 lines
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
Quoted 1 line
Quoted 92 lines · Jonathan Cameron
Quoted 68 lines · On Fri, 11 Jun 2021 22:36:52 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 11 Jun 2021 21:35:06 +0300 Andy Shevchenko <[email protected]>…
Quoted 2 lines · Jonathan Cameron
On Fri, 11 Jun 2021 20:48:08 +0300
Andy Shevchenko <[email protected]> wrote:...
Quoted 6 lines
Quoted 6 lines
But I understand you and not insisting that you have to go with it. My point is that...
Quoted 3 lines
I 'could' just drop the
kernel.hwhere added on the basis we were clearly getting it indirectly. I've not included a whole bunch of other suggestions on that basis.Quoted 8 lines
Quoted 4 lines
(Which is probably not a good idea, because explicit in this case is better than implicit, i.e.
kernel.his 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 requirekernel.h!)I think I was unclear, what I was proposing was not to touch includes of
kernel.hat all. So not make anything worse, but also not make it any better. Where added in this set,kernel.hwas for things directly inkernel.h, not the files it includes.Ah, that's good! That was my main point of worry.
Quoted 30 lines
Quoted 10 lines
Quoted 4 lines
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.hfrom the equation).This is where the confusion lies... I haven't done that (subject to bugs of course)
Quoted 6 lines
Otherwise it will become
someone else's problem to _reinstantiate_ all those headers, and since I already had a headache withpanic.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.hon the basis it is definitely included bylinux/device.hand that seems very unlikely to change.Quoted 5 lines
There are some corner cases that are more interesting - such as whether we can rely on
interrupt.halways includingirqreturn.h. Plenty of IIO drivers don't call anything ininterrupt.hbecause 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?Quoted 7 lines
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.cshould 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
Quoted 6 lines
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
Quoted 9 lines
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
Quoted 70 lines
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_NSECstruct
iio_buffer;Quoted 4 lines
Quoted 2 lines
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
Quoted 6 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
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.