staging:iio: Header cleanup
Subsystems (4)
Jonathan Cameron
maintainercover staging:iio: Header cleanup
From: Jonathan Cameron <[email protected]>
0-day recently started giving some reports from the include-what-you-use tool (needs LLVM builds).
I was curious so decided to give it a spin. It produces a wealth of information, but the suggestions require a high degree of interpretation and some choices are down to personal taste.
This set covers resulting changes that I think make sense for remaining IIO drivers in staging (which I just noticed are all Analog devices ones :)
Jonathan Cameron (7):
staging:iio:adc: Cleanup includes staging:iio:addac:adt7316: Cleanup includes staging:iio:cdc:ad7746: Cleanup includes staging:iio:frequency: Cleanup includes staging:iio:impedance-analyzer: Cleanup includes staging:iio:meter:ade7854: Cleanup includes staging:iio:resolver:ad2s1210: Cleanup includes
drivers/staging/iio/adc/ad7280a.c | 2 ++ drivers/staging/iio/adc/ad7816.c | 3 +-- drivers/staging/iio/addac/adt7316.c | 5 ----- drivers/staging/iio/addac/adt7316.h | 1 + drivers/staging/iio/cdc/ad7746.c | 6 +++--- drivers/staging/iio/frequency/ad9832.c | 3 ++- drivers/staging/iio/frequency/ad9834.c | 6 ++---- drivers/staging/iio/impedance-analyzer/ad5933.c | 5 ++++- drivers/staging/iio/meter/ade7854-i2c.c | 3 ++- drivers/staging/iio/meter/ade7854-spi.c | 3 ++- drivers/staging/iio/meter/ade7854.c | 4 ---- drivers/staging/iio/meter/ade7854.h | 5 +++++ drivers/staging/iio/resolver/ad2s1210.c | 5 +++-- 13 files changed, 27 insertions(+), 24 deletions(-)
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 1/7 staging:iio:adc: Cleanup includes
From: Jonathan Cameron <[email protected]>
Result of considering the output of the include-what-you-use tool. Note that this is partly a case of taste and consistency.
--- drivers/staging/iio/adc/ad7280a.c | 2 ++ drivers/staging/iio/adc/ad7816.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/staging/iio/adc/ad7280a.c +2 -0
@@ -15,6 +15,8 @@#include <linux/delay.h> #include <linux/interrupt.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/staging/iio/adc/ad7816.c +1 -2
@@ -9,11 +9,10 @@#include <linux/gpio/consumer.h> #include <linux/device.h> #include <linux/kernel.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/list.h> #include <linux/spi/spi.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 2/7 staging:iio:addac:adt7316: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Result of consideration of the output of the include-what-you-use tool. Also a forwards definition of device to avoid any ordering of headers issues.
--- drivers/staging/iio/addac/adt7316.c | 5 ----- drivers/staging/iio/addac/adt7316.h | 1 + 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/staging/iio/addac/adt7316.c +0 -5
@@ -8,14 +8,9 @@#include <linux/interrupt.h> #include <linux/gpio/consumer.h> #include <linux/irq.h> -#include <linux/workqueue.h> #include <linux/device.h> #include <linux/kernel.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/list.h> -#include <linux/i2c.h> -#include <linux/rtc.h> #include <linux/module.h> #include <linux/iio/iio.h>
drivers/staging/iio/addac/adt7316.h +1 -0
@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/pm.h> +struct device ;#define ADT7316_REG_MAX_ADDR 0x3F
Signature · 1 line
2.31.1
Re: [PATCH 2/7] staging:iio:addac:adt7316: Cleanup includes
Quoted 37 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Result of consideration of the output of the include-what-you-use tool. Also a forwards definition of device to avoid any ordering of headers issues.
Signed-off-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/addac/adt7316.c | 5 ----- drivers/staging/iio/addac/adt7316.h | 1 + 2 files changed, 1 insertion(+), 5 deletions(-)drivers/staging/iio/addac/adt7316.c +0
-5@@ -8,14 +8,9 @@#include <linux/interrupt.h> #include <linux/gpio/consumer.h> #include <linux/irq.h> -#include <linux/workqueue.h> #include <linux/device.h> #include <linux/kernel.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/list.h> -#include <linux/i2c.h> -#include <linux/rtc.h> #include <linux/module.h> #include <linux/iio/iio.h> drivers/staging/iio/addac/adt7316.h +0
-0
drivers/staging/iio/addac/adt7316.h line 12
Quoted 3 lines
drivers/staging/iio/addac/adt7316.h +0
-0@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/pm.h>
+ blank line?
Quoted 7 lines
drivers/staging/iio/addac/adt7316.h +1
-1+struct device ;#define ADT7316_REG_MAX_ADDR 0x3F --2.31.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerPATCH 3/7 staging:iio:cdc:ad7746: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Based on consideration of the output of the include-what-you-use tool. Drop some unused includes + include some which probably should have been there in the first place.
--- drivers/staging/iio/cdc/ad7746.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/cdc/ad7746.c +3 -3
@@ -8,11 +8,11 @@#include <linux/delay.h> #include <linux/device.h> #include <linux/i2c.h> -#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/slab.h> -#include <linux/stat.h> +#include <linux/mod_devicetable.h> +#include <linux/mutex.h> +#include <linux/property.h> #include <linux/sysfs.h> #include <linux/iio/iio.h>
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 4/7 staging:iio:frequency: 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 some unused headers and add some that should be directly included.
--- drivers/staging/iio/frequency/ad9832.c | 3 ++- drivers/staging/iio/frequency/ad9834.c | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/staging/iio/frequency/ad9832.c +2 -1
@@ -12,8 +12,9 @@#include <linux/err.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/mutex.h> #include <linux/regulator/consumer.h> -#include <linux/slab.h> #include <linux/spi/spi.h> #include <linux/sysfs.h>
drivers/staging/iio/frequency/ad9834.c +2 -4
@@ -6,17 +6,15 @@*/ #include <linux/clk.h> -#include <linux/interrupt.h> -#include <linux/workqueue.h> #include <linux/device.h> #include <linux/kernel.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/list.h> #include <linux/spi/spi.h> #include <linux/regulator/consumer.h> #include <linux/err.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/mutex.h> #include <asm/div64.h> #include <linux/iio/iio.h>
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 5/7 staging:iio:impedance-analyzer: Cleanup includes
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 should probably have always been included.
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +4 -1
@@ -5,17 +5,20 @@* Copyright 2011 Analog Devices Inc. */ +#include <linux/bitmap.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/err.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/regulator/consumer.h> #include <linux/sysfs.h> #include <linux/types.h> +#include <linux/workqueue.h> #include <linux/iio/buffer.h> #include <linux/iio/iio.h>
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 6/7 staging:iio:meter:ade7854: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Based on consideration of the output of the include-what-you-use tool. Drop some unused headers and some that should probably have always been included. Also a few forwards definitions to avoid any future issues with header ordering.
--- drivers/staging/iio/meter/ade7854-i2c.c | 3 ++- drivers/staging/iio/meter/ade7854-spi.c | 3 ++- drivers/staging/iio/meter/ade7854.c | 4 ---- drivers/staging/iio/meter/ade7854.h | 5 +++++ 4 files changed, 9 insertions(+), 6 deletions(-)
drivers/staging/iio/meter/ade7854-i2c.c +2 -1
@@ -8,8 +8,9 @@#include <linux/device.h> #include <linux/kernel.h> #include <linux/i2c.h> -#include <linux/slab.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/mutex.h> #include <linux/iio/iio.h> #include "ade7854.h"
drivers/staging/iio/meter/ade7854-spi.c +2 -1
@@ -8,8 +8,9 @@#include <linux/device.h> #include <linux/kernel.h> #include <linux/spi/spi.h> -#include <linux/slab.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/mutex.h> #include <linux/iio/iio.h> #include "ade7854.h"
drivers/staging/iio/meter/ade7854.c +0 -4
@@ -5,15 +5,11 @@* Copyright 2010 Analog Devices Inc. */ -#include <linux/interrupt.h> -#include <linux/irq.h> #include <linux/delay.h> #include <linux/mutex.h> #include <linux/device.h> #include <linux/kernel.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/list.h> #include <linux/module.h> #include <linux/iio/iio.h>
drivers/staging/iio/meter/ade7854.h +5 -0
@@ -1,4 +1,9 @@/* SPDX-License-Identifier: GPL-2.0 */ + +#include <linux/mutex.h> +struct device ; +struct iio_device ; +#ifndef _ADE7854_H#define _ADE7854_H
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH 7/7 staging:iio:resolver:ad2s1210: Cleanup includes
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Based on consideration of the output of the include-what-you-use tool. Drop unused includes and add some that should be there.
--- drivers/staging/iio/resolver/ad2s1210.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/iio/resolver/ad2s1210.c +3 -2
@@ -4,15 +4,16 @@* * Copyright (c) 2010-2010 Analog Devices Inc. */ +#include <linux/kernel.h> #include <linux/types.h> #include <linux/mutex.h> #include <linux/device.h> #include <linux/spi/spi.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/of.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerRe: [PATCH 7/7] staging:iio:resolver:ad2s1210: Cleanup includes
Quoted 16 lines · On Fri, 11 Jun 2021 16:26:14 +0100 Jonathan Cameron <[email protected]> wrote:
From: Jonathan Cameron <[email protected]>
Based on consideration of the output of the include-what-you-use tool. Drop unused includes and add some that should be there.
Signed-off-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/resolver/ad2s1210.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/staging/iio/resolver/ad2s1210.c +0
-0@@ -4,15 +4,16 @@*
drivers/staging/iio/resolver/ad2s1210.c line 13
Quoted 10 lines
drivers/staging/iio/resolver/ad2s1210.c +1
-2* Copyright (c) 2010-2010 Analog Devices Inc. */ +#include <linux/kernel.h> #include <linux/types.h> #include <linux/mutex.h> #include <linux/device.h> #include <linux/spi/spi.h> -#include <linux/slab.h> #include <linux/sysfs.h> -#include <linux/delay.h>
Let's pretend I didn't remove this one by accident as it is needed. I don't want to resend the whole set for that however so will leave it for now.
Quoted 7 lines
drivers/staging/iio/resolver/ad2s1210.c +2
-0#include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/of.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
Quoted 6 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
0-day recently started giving some reports from the include-what-you-use tool (needs LLVM builds).
Quoted 6 lines
I was curious so decided to give it a spin. It produces a wealth of information, but the suggestions require a high degree of interpretation and some choices are down to personal taste.
This set covers resulting changes that I think make sense for remaining IIO drivers in staging (which I just noticed are all Analog devices ones :)
In general it's a good idea, but the tool doesn't know the project specifics. I believe that half of what you have done is simply wrong. That is, we have a lot of drivers that include kernel.h which is in its turn a rabbit hole of all possible headers and (circular) dependencies. So, for this and the other series, please double check that removed headers are not removed due to kernel.h (I believe this is the case for almost all if not all entries of slab.h, for example).
The other half seems correct. But due to the above I can't give any tag on these...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 14 lines · On Fri, 11 Jun 2021 20:45:03 +0300 Andy Shevchenko <[email protected]>…
Quoted 6 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
0-day recently started giving some reports from the include-what-you-use tool (needs LLVM builds).
Quoted 6 lines
I was curious so decided to give it a spin. It produces a wealth of information, but the suggestions require a high degree of interpretation and some choices are down to personal taste.
This set covers resulting changes that I think make sense for remaining IIO drivers in staging (which I just noticed are all Analog devices ones :)
Quoted 7 lines
In general it's a good idea, but the tool doesn't know the project specifics. I believe that half of what you have done is simply wrong. That is, we have a lot of drivers that include
kernel.hwhich is in its turn a rabbit hole of all possible headers and (circular) dependencies. So, for this and the other series, please double check that removed headers are not removed due tokernel.h(I believe this is the case for almost all if not all entries ofslab.h, for example).
The tool seems to go rather the other way and suggest including things that are 'obviously' included via another header that we need.
The reason for kernel.h includes when being added is almost always ARRAY_SIZE or container_of as you identified.
The drivers where I'm removing slab.h don't actually make any direct allocate or free calls, they are all wrapped up in various IIO core function (devm_iio_device_alloc etc.)
Jonathan
Quoted 4 lines
The other half seems correct. But due to the above I can't give any tag on these...
Quoted 3 lines · Jonathan Cameron
Quoted 1 line · On Fri, 11 Jun 2021 20:45:03 +0300 Andy Shevchenko <[email protected]>…
On Fri, Jun 11, 2021 at 6:25 PM Jonathan Cameron <[email protected]> wrote:
...
Quoted 2 lines
The reason for
kernel.hincludes when being added is almost alwaysARRAY_SIZEorcontainer_ofas you identified.
Give me some time. I will cook a couple of patches for ya to test (splitting those from kernel.h).
Signature · 2 lines
With Best Regards, Andy Shevchenko