public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: light: stk3310: update includes to match IWYU
@ 2026-04-28 13:41 Rafael G. Dias
  2026-04-28 14:33 ` Joshua Crofts
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael G. Dias @ 2026-04-28 13:41 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy
  Cc: Rafael G. Dias, Felipe Khoury Dayoub, linux-iio

Clean up the included headers in stk3310.c according to the
Include-What-You-Use (IWYU) tool. Remove the generic <linux/kernel.h>
header and add explicit dependencies to improve compilation accuracy.

The list of included headers was strictly alphabetized.

Co-developed-by: Felipe Khoury Dayoub <felipedayoub@usp.br>
Signed-off-by: Felipe Khoury Dayoub <felipedayoub@usp.br>
Signed-off-by: Rafael G. Dias <rafael.guimaraes.dias@usp.br>
---
 drivers/iio/light/stk3310.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index a75a83594a7e..a4c182c83956 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -7,15 +7,30 @@
  * IIO driver for STK3310/STK3311. 7-bit I2C address: 0x48.
  */
 
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/dev_printk.h>
+#include <linux/err.h>
+#include <linux/errno.h>
 #include <linux/i2c.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/mod_devicetable.h>
-#include <linux/regmap.h>
 #include <linux/iio/events.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
+#include <linux/iio/types.h>
+#include <linux/interrupt.h>
+#include <linux/irqreturn.h>
+#include <linux/kconfig.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/pm.h>
+#include <linux/property.h>
+#include <linux/regmap.h>
+#include <linux/sprintf.h>
+#include <linux/stddef.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
 
 #define STK3310_REG_STATE			0x00
 #define STK3310_REG_PSCTRL			0x01
-- 
2.43.0


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

* Re: [PATCH] iio: light: stk3310: update includes to match IWYU
  2026-04-28 13:41 [PATCH] iio: light: stk3310: update includes to match IWYU Rafael G. Dias
@ 2026-04-28 14:33 ` Joshua Crofts
  2026-04-28 15:05   ` Jonathan Cameron
  2026-04-29 19:39   ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Joshua Crofts @ 2026-04-28 14:33 UTC (permalink / raw)
  To: Rafael G. Dias
  Cc: jic23, dlechner, nuno.sa, andy, Felipe Khoury Dayoub, linux-iio

On Tue, 28 Apr 2026 at 16:13, Rafael G. Dias
<rafael.guimaraes.dias@usp.br> wrote:
>
> +#include <linux/array_size.h>
> +#include <linux/bits.h>
> +#include <linux/device.h>
> +#include <linux/dev_printk.h>
> +#include <linux/err.h>
> +#include <linux/errno.h>
>  #include <linux/i2c.h>
> -#include <linux/interrupt.h>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/mod_devicetable.h>
> -#include <linux/regmap.h>
>  #include <linux/iio/events.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> +#include <linux/iio/types.h>

It's better to group the <linux/iio/*> headers separately from
the generic <linux/*> headers, usually below them.

> +#include <linux/interrupt.h>
> +#include <linux/irqreturn.h>
> +#include <linux/kconfig.h>

I don't think you need this.

> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/pm.h>
> +#include <linux/property.h>
> +#include <linux/regmap.h>
> +#include <linux/sprintf.h>
> +#include <linux/stddef.h>

You don't need to include this.

> +#include <linux/sysfs.h>

Remove this too, the driver already uses the linux/iio/sysfs.h
variant.

> +#include <linux/types.h>

It would be better if you split this change into two patches,
first the ordering, then the removal/addition of headers. It
improves the reviewing process.

Although IWYU is a pretty good tool, it generates a lot of
noise, some of it not really valid.

-- 
Kind regards

CJD

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

* Re: [PATCH] iio: light: stk3310: update includes to match IWYU
  2026-04-28 14:33 ` Joshua Crofts
@ 2026-04-28 15:05   ` Jonathan Cameron
  2026-04-29 19:39   ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-04-28 15:05 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Rafael G. Dias, dlechner, nuno.sa, andy, Felipe Khoury Dayoub,
	linux-iio

On Tue, 28 Apr 2026 16:33:17 +0200
Joshua Crofts <joshua.crofts1@gmail.com> wrote:

> On Tue, 28 Apr 2026 at 16:13, Rafael G. Dias
> <rafael.guimaraes.dias@usp.br> wrote:
> >
Reviewing on top to avoid repeating the stuff Joshua has
already pointed out (thanks Joshua!)

> > +#include <linux/array_size.h>
> > +#include <linux/bits.h>
> > +#include <linux/device.h>
This is a bit like kernel.h in that it's mostly a catch all header
that we are trying stop including directly.  However, it does still
contain some stuff. I'm not immediately seeing why need it here?
struct device * is used a lot but a forward definition will do for that
(put any of those needed after the headers0

> > +#include <linux/dev_printk.h>
> > +#include <linux/err.h>
> > +#include <linux/errno.h>
> >  #include <linux/i2c.h>
> > -#include <linux/interrupt.h>
> > -#include <linux/kernel.h>
> > -#include <linux/module.h>
> > -#include <linux/mod_devicetable.h>
> > -#include <linux/regmap.h>
> >  #include <linux/iio/events.h>
> >  #include <linux/iio/iio.h>
> >  #include <linux/iio/sysfs.h>
> > +#include <linux/iio/types.h>  
> 
> It's better to group the <linux/iio/*> headers separately from
> the generic <linux/*> headers, usually below them.
> 
> > +#include <linux/interrupt.h>
> > +#include <linux/irqreturn.h>
> > +#include <linux/kconfig.h>  
> 
> I don't think you need this.
> 
> > +#include <linux/mod_devicetable.h>
> > +#include <linux/module.h>
> > +#include <linux/mutex.h>
> > +#include <linux/pm.h>
> > +#include <linux/property.h>
> > +#include <linux/regmap.h>
> > +#include <linux/sprintf.h>
> > +#include <linux/stddef.h>  
> 
> You don't need to include this.
> 
> > +#include <linux/sysfs.h>  
> 
> Remove this too, the driver already uses the linux/iio/sysfs.h
> variant.
> 
> > +#include <linux/types.h>  
> 
> It would be better if you split this change into two patches,
> first the ordering, then the removal/addition of headers. It
> improves the reviewing process.
Agreed!
> 
> Although IWYU is a pretty good tool, it generates a lot of
> noise, some of it not really valid.
> 
Absolutely - I've had a few goes at putting together a 'standard'
config file for it, but never managed to make it do things correctly
for some corner cases.

Jonathan



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

* Re: [PATCH] iio: light: stk3310: update includes to match IWYU
  2026-04-28 14:33 ` Joshua Crofts
  2026-04-28 15:05   ` Jonathan Cameron
@ 2026-04-29 19:39   ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-04-29 19:39 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Rafael G. Dias, jic23, dlechner, nuno.sa, andy,
	Felipe Khoury Dayoub, linux-iio

On Tue, Apr 28, 2026 at 04:33:17PM +0200, Joshua Crofts wrote:
> On Tue, 28 Apr 2026 at 16:13, Rafael G. Dias
> <rafael.guimaraes.dias@usp.br> wrote:

...

> > +#include <linux/interrupt.h>
> > +#include <linux/irqreturn.h>

This is implied by interrupt.h

> > +#include <linux/kconfig.h>
> 
> I don't think you need this.

Definitely. This actually should be removed from any driver using it. This
header is so special (hint: it's ALWAYS included by a Kbuild system).

...

> > +#include <linux/stddef.h>
> 
> You don't need to include this.

Depends, but since we have types.h, this is not needed.

> > +#include <linux/sysfs.h>
> 
> Remove this too, the driver already uses the linux/iio/sysfs.h
> variant.

Depends. If we use something from linux/sysfs.h it's still needed.

> > +#include <linux/types.h>

(left for a context for the above)

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-04-29 19:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 13:41 [PATCH] iio: light: stk3310: update includes to match IWYU Rafael G. Dias
2026-04-28 14:33 ` Joshua Crofts
2026-04-28 15:05   ` Jonathan Cameron
2026-04-29 19:39   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox