Skip to contentSkip to conversation

gpio: generic: Don't use 'proxy' headers

PATCH Applied Andy Shevchenko 4 participants 5 messages Feb 26 – Feb 27 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: generic: Don't use 'proxy' headers

Update header inclusions to follow IWYU (Include What You Use) principle.

---
 drivers/gpio/gpio-mmio.c     | 4 +---
 include/linux/gpio/generic.h | 8 +++++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mmio.c +1 -3
index edbcaad57d00..0941d034a49c 100644
@@ -42,18 +42,16 @@ o        `                     ~~~~\___/~~~~    ` controller in FPGA is ,.`
 
 #include <linux/bitops.h>
 #include <linux/cleanup.h>
-#include <linux/compiler.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
+#include <linux/limits.h>
 #include <linux/log2.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
include/linux/gpio/generic.h +7 -1
index ff566dc9c3cb..de43c06c83ef 100644
@@ -3,9 +3,15 @@
 #ifndef __LINUX_GPIO_GENERIC_H
 #define __LINUX_GPIO_GENERIC_H
 
+#include <linux/bits.h>
+#include <linux/bug.h>
 #include <linux/cleanup.h>
-#include <linux/gpio/driver.h>
+#include <linux/container_of.h>
+#include <linux/errno.h>
 #include <linux/spinlock.h>
+#include <linux/types.h>
+
+#include <linux/gpio/driver.h>
 
 struct device;
 
Signature · 1 line
2.50.1
#1 lore raw
Quoted 21 lines · Andy Shevchenko

Update header inclusions to follow IWYU (Include What You Use) principle.

---
 drivers/gpio/gpio-mmio.c     | 4 +---
 include/linux/gpio/generic.h | 8 +++++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mmio.c +0 -2
index edbcaad57d00..0941d034a49c 100644
@@ -42,18 +42,16 @@ o        `                     ~~~~\___/~~~~    ` controller in FPGA is ,.`
 
 #include <linux/bitops.h>
 #include <linux/cleanup.h>
-#include <linux/compiler.h>
 #include <linux/err.h>
-#include <linux/init.h>

drivers/gpio/gpio-mmio.c o ` ~~~~\___/~~~~ ` controller in FPGA is ,.` · line 56

Quoted 10 lines
drivers/gpio/gpio-mmio.c +1 -1
 #include <linux/io.h>
 #include <linux/ioport.h>
+#include <linux/limits.h>
 #include <linux/log2.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-#include <linux/slab.h>

In that case don't we need device.h for devm_kzalloc()?

Bart

Quoted 27 lines
drivers/gpio/gpio-mmio.c +0 -0
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
include/linux/gpio/generic.h +7 -2
index ff566dc9c3cb..de43c06c83ef 100644
@@ -3,9 +3,15 @@
 #ifndef __LINUX_GPIO_GENERIC_H
 #define __LINUX_GPIO_GENERIC_H
 
+#include <linux/bits.h>
+#include <linux/bug.h>
 #include <linux/cleanup.h>
-#include <linux/gpio/driver.h>
+#include <linux/container_of.h>
+#include <linux/errno.h>
 #include <linux/spinlock.h>
+#include <linux/types.h>
+
+#include <linux/gpio/driver.h>
 
 struct device;
 
--

2.50.1

#2 lore raw
Quoted 2 lines · Bartosz Golaszewski

On Thu, Feb 26, 2026 at 10:20 AM Andy Shevchenko
<[email protected]> wrote:

...

Quoted 9 lines
Quoted 9 lines

#include <linux/bitops.h>
#include <linux/cleanup.h>

drivers/gpio/gpio-mmio.c +1 -2
-#include <linux/compiler.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
+#include <linux/limits.h>
 #include <linux/log2.h>
Quoted 8 lines
Quoted 6 lines

#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/property.h>
-#include <linux/slab.h>

In that case don't we need device.h for devm_kzalloc()?

(It is device/devres.h, but read below)

It comes thru platform_device.h. And if you follow my attempts to split device.h, the state of affairs will look like not much will happen there, so the platform_device.h <- device.h <- devres/device.h is guaranteed.

TL;DR: if we have platform_device.h, it covers everything that device.h provides.

Signature · 2 lines
With Best Regards,
Andy Shevchenko