linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: spear_adc: cleans up and sorts the existing includes
@ 2025-10-09 18:24 Rodrigo Gobbi
  2025-10-10 17:16 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Rodrigo Gobbi @ 2025-10-09 18:24 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy; +Cc: ~lkcamp/patches, linux-iio, linux-kernel

Remove unused includes and sort the remaining ones.

Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
---
At [1] it was suggested to sort and remove some unused includes,
that is the reason for this patch. Removed the following includes
due not being used or because some of them, like device.h/kernel.h
are included indirectly from another .h file. What was removed:

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/iio/sysfs.h>

Also ordered them alphabetically as other adc/iio drivers.
Tks and regards.

[1] https://lore.kernel.org/linux-iio/e748d82b-43c7-48e6-b441-cef464f189e6@baylibre.com/#t
---
 drivers/iio/adc/spear_adc.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
index 50b0a607baeb..6d974e58637a 100644
--- a/drivers/iio/adc/spear_adc.c
+++ b/drivers/iio/adc/spear_adc.c
@@ -5,22 +5,17 @@
  * Copyright 2012 Stefan Roese <sr@denx.de>
  */
 
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/completion.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-#include <linux/interrupt.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/bitfield.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/completion.h>
 
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
 
 /* SPEAR registers definitions */
 #define SPEAR600_ADC_SCAN_RATE_LO(x)	((x) & 0xFFFF)
-- 
2.48.1


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

* Re: [PATCH] iio: adc: spear_adc: cleans up and sorts the existing includes
  2025-10-09 18:24 [PATCH] iio: adc: spear_adc: cleans up and sorts the existing includes Rodrigo Gobbi
@ 2025-10-10 17:16 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2025-10-10 17:16 UTC (permalink / raw)
  To: Rodrigo Gobbi
  Cc: jic23, dlechner, nuno.sa, andy, ~lkcamp/patches, linux-iio,
	linux-kernel

On Thu,  9 Oct 2025 15:24:20 -0300
Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com> wrote:

> Remove unused includes and sort the remaining ones.
> 
> Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
> ---
Hi Rodrigo,

> At [1] it was suggested to sort and remove some unused includes,
> that is the reason for this patch. Removed the following includes
> due not being used or because some of them, like device.h/kernel.h
> are included indirectly from another .h file. What was removed:
>

The indirectly included thing was not what the email you reference
is intended to suggest.

It's actually about the general principle of IWYU (include what you use)
I only know that though from previous discussions!

The idea is to include what is directly used in the .c /.h file. So we
don't care about things embedded in structures that we are using
(they are guaranteed to be provided by the included headers that
defines the containing structure) but we do care about struct
types that are used directly or function declarations etc.

For example dropping device.h makes sense as whilst struct device *
pointers are found in this driver no accesses to specific elements
of that are made, it's just a magic token that is passed to other calls.

An example that was included in the email you reference is
dev_err_probe() and similar which are defined dev_printk.h.

Hence that should be included.

There are commonly made exceptions to this such as including
only mutex.h rather than that and mutex_types.h when
mutex_lock() and struct mutex are used.

It's a little tricky to get a universally agreed perfect set
of includes, but in this case you are referencing an email that called
out why dev_printk() should be there and this reasoning under the ---
doesn't correspond to common practice.

Jonathan



> #include <linux/device.h>
> #include <linux/kernel.h>
> #include <linux/slab.h>
> #include <linux/err.h>
> #include <linux/iio/sysfs.h>
> 
> Also ordered them alphabetically as other adc/iio drivers.
> Tks and regards.
> 
> [1] https://lore.kernel.org/linux-iio/e748d82b-43c7-48e6-b441-cef464f189e6@baylibre.com/#t
> ---
>  drivers/iio/adc/spear_adc.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
> index 50b0a607baeb..6d974e58637a 100644
> --- a/drivers/iio/adc/spear_adc.c
> +++ b/drivers/iio/adc/spear_adc.c
> @@ -5,22 +5,17 @@
>   * Copyright 2012 Stefan Roese <sr@denx.de>
>   */
>  
> +#include <linux/bitfield.h>
> +#include <linux/clk.h>
> +#include <linux/completion.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
> -#include <linux/interrupt.h>
> -#include <linux/device.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -#include <linux/io.h>
> -#include <linux/bitfield.h>
> -#include <linux/clk.h>
> -#include <linux/err.h>
> -#include <linux/completion.h>
>  
>  #include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
>  
>  /* SPEAR registers definitions */
>  #define SPEAR600_ADC_SCAN_RATE_LO(x)	((x) & 0xFFFF)


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

end of thread, other threads:[~2025-10-10 17:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-09 18:24 [PATCH] iio: adc: spear_adc: cleans up and sorts the existing includes Rodrigo Gobbi
2025-10-10 17:16 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).