Skip to contentSkip to conversation

gpio: wean gpio/driver.h off of module.h

PATCH In review Paul Gortmaker 2 participants 17 messages Sep 12, 2016 – Sep 15, 2016

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover gpio: wean gpio/driver.h off of module.h

Most shared headers in include/linux don't need to know what the internals of a struct module are; all they care about is that it is a struct and hence they may require a pointer to one.

The advantage in this is that module.h is including a lot of stuff itself, and an otherwise empty C file that just contains module.h will result in ~750kB from CPP (compared to say 12kB from init.h)

So we have approximately 50 instances of "struct module;" in the various include/linux headers already that help us keep module.h out of other headers; here we do the same for gpio.

But before we do, we fix up seven instances of code that were implicitly relying on this module.h so that we don't introduce build failures into the git history.

Some are tristate, so we just explicitly add module.h to them. The others are non-modular, so we just prune them off of the module based macros, so that module.h is no longer required to compile.

This series built on top of linux-next for arm, arm64, i386, x86_64 without any issues (allmodconfig).

---

Cc Ajay Thomas <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Bin Gao <[email protected]>
Cc Keguang Zhang <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Mika Westerberg <[email protected]>

Paul Gortmaker (8):
gpio: palmas: fix implicit assumption module.h is present
gpio: sx150x: fix implicit assumption module.h is present
gpio: ts4800: fix implicit assumption module.h is present
gpio: altera: fix implicit assumption module.h is present
gpio: ath79: fix implicit assumption module.h is present
gpio: loongson1: fix implicit assumption module.h is present
gpio: wcove: fix implicit assumption module.h is present
gpio: don't include module.h in shared driver header

 drivers/gpio/gpio-altera.c    | 1 +
 drivers/gpio/gpio-ath79.c     | 1 +
 drivers/gpio/gpio-loongson1.c | 1 +
 drivers/gpio/gpio-palmas.c    | 1 -
 drivers/gpio/gpio-sx150x.c    | 2 --
 drivers/gpio/gpio-ts4800.c    | 1 +
 drivers/gpio/gpio-wcove.c     | 1 +
 include/linux/gpio/driver.h   | 2 +-
 8 files changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.8.4
#1 lore raw

PATCH 1/8 gpio: palmas: fix implicit assumption module.h is present

This file is currently getting module.h from a global gpio header and it will fail to build once we remove module.h from that.

However, the driver is controlled with the following Kconfig:

drivers/gpio/Kconfig:config GPIO_PALMAS
drivers/gpio/Kconfig: bool "TI PALMAS series PMICs GPIO"

and hence the line of MODULE_DEVICE_TABLE is a no-op that can simply be deleted. In fact it should have been removed in an earlier commit that did demodularization, however the unseen include prevented my build testing from detecting it.

---
 drivers/gpio/gpio-palmas.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpio/gpio-palmas.c +0 -1
index 839474430229..3d818195e351 100644
@@ -152,7 +152,6 @@ static const struct of_device_id of_palmas_gpio_match[] = {
 	{ .compatible = "ti,tps80036-gpio", .data = &tps80036_dev_data,},
 	{ },
 };
-MODULE_DEVICE_TABLE(of, of_palmas_gpio_match);
 
 static int palmas_gpio_probe(struct platform_device *pdev)
 {
Signature · 1 line
2.8.4
#2 lore raw

Re: [PATCH 1/8] gpio: palmas: fix implicit assumption module.h is present

Quoted 13 lines · Paul Gortmaker

This file is currently getting module.h from a global gpio header and it will fail to build once we remove module.h from that.

However, the driver is controlled with the following Kconfig:

drivers/gpio/Kconfig:config GPIO_PALMAS
drivers/gpio/Kconfig: bool "TI PALMAS series PMICs GPIO"

and hence the line of MODULE_DEVICE_TABLE is a no-op that can simply be deleted. In fact it should have been removed in an earlier commit that did demodularization, however the unseen include prevented my build testing from detecting it.

Quoted 4 lines

Patch applied.

Yours,
Linus Walleij

#3 lore raw

PATCH 2/8 gpio: sx150x: fix implicit assumption module.h is present

In reply to Paul Gortmaker

This file is currently getting module.h from a global gpio header and it will faii to build once we remove module.h from that.

However, the driver is controlled with the following Kconfig:

drivers/gpio/Kconfig:config GPIO_SX150X
drivers/gpio/Kconfig: bool "Semtech SX150x I2C GPIO expander"

and hence the two lines of MODULE_DEVICE_TABLE are no-ops that can simply be deleted.

---
 drivers/gpio/gpio-sx150x.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpio/gpio-sx150x.c +0 -2
index a177ebd921d5..af95de89db01 100644
@@ -236,7 +236,6 @@ static const struct i2c_device_id sx150x_id[] = {
 	{"sx1502q", 3},
 	{}
 };
-MODULE_DEVICE_TABLE(i2c, sx150x_id);
 
 static const struct of_device_id sx150x_of_match[] = {
 	{ .compatible = "semtech,sx1508q" },
@@ -245,7 +244,6 @@ static const struct of_device_id sx150x_of_match[] = {
 	{ .compatible = "semtech,sx1502q" },
 	{},
 };
-MODULE_DEVICE_TABLE(of, sx150x_of_match);
 
 static s32 sx150x_i2c_write(struct i2c_client *client, u8 reg, u8 val)
 {
Signature · 1 line
2.8.4
#4 lore raw

Re: [PATCH 2/8] gpio: sx150x: fix implicit assumption module.h is present

Quoted 8 lines · Paul Gortmaker

This file is currently getting module.h from a global gpio header and it will faii to build once we remove module.h from that.

However, the driver is controlled with the following Kconfig:

drivers/gpio/Kconfig:config GPIO_SX150X
drivers/gpio/Kconfig: bool "Semtech SX150x I2C GPIO expander"

Quoted 7 lines

and hence the two lines of MODULE_DEVICE_TABLE are no-ops that can simply be deleted.

Patch applied.

Yours,
Linus Walleij

#5 lore raw

PATCH 3/8 gpio: ts4800: fix implicit assumption module.h is present

In reply to Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_TS4800 drivers/gpio/Kconfig: tristate "TS-4800 DIO blocks and compatibles"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

---
 drivers/gpio/gpio-ts4800.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-ts4800.c +1 -0
index 0c144a72f9af..99256115bea5 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/gpio/driver.h>
+#include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
Signature · 1 line
2.8.4
#6 lore raw

Re: [PATCH 3/8] gpio: ts4800: fix implicit assumption module.h is present

Quoted 10 lines · Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_TS4800 drivers/gpio/Kconfig: tristate "TS-4800 DIO blocks and compatibles"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

Quoted 7 lines

So we fix this first to avoid putting build failures into the bisect commit history.

Patch applied.

Yours,
Linus Walleij

#7 lore raw

PATCH 4/8 gpio: altera: fix implicit assumption module.h is present

In reply to Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_ALTERA
drivers/gpio/Kconfig: tristate "Altera GPIO"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

---
 drivers/gpio/gpio-altera.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-altera.c +1 -0
index 3f87a03abc22..5bddbd507ca9 100644
@@ -17,6 +17,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 
Signature · 1 line
2.8.4
#8 lore raw

Re: [PATCH 4/8] gpio: altera: fix implicit assumption module.h is present

Quoted 10 lines · Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_ALTERA
drivers/gpio/Kconfig: tristate "Altera GPIO"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

Quoted 7 lines

So we fix this first to avoid putting build failures into the bisect commit history.

Patch applied.

Yours,
Linus Walleij

#9 lore raw

PATCH 5/8 gpio: ath79: fix implicit assumption module.h is present

In reply to Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_ATH79
drivers/gpio/Kconfig: tristate "Atheros AR71XX/AR724X/AR913X GPIO support"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

---
 drivers/gpio/gpio-ath79.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-ath79.c +1 -0
index c4f4cddc7c1a..9457e2022bf6 100644
@@ -15,6 +15,7 @@
 #include <linux/platform_data/gpio-ath79.h>
 #include <linux/of_device.h>
 #include <linux/interrupt.h>
+#include <linux/module.h>
 #include <linux/irq.h>
 
 #define AR71XX_GPIO_REG_OE		0x00
Signature · 1 line
2.8.4
#10 lore raw

Re: [PATCH 5/8] gpio: ath79: fix implicit assumption module.h is present

Quoted 10 lines · Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_ATH79
drivers/gpio/Kconfig: tristate "Atheros AR71XX/AR724X/AR913X GPIO support"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

Quoted 7 lines

So we fix this first to avoid putting build failures into the bisect commit history.

Patch applied.

Yours,
Linus Walleij

#11 lore raw

PATCH 6/8 gpio: loongson1: fix implicit assumption module.h is present

In reply to Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_LOONGSON1
drivers/gpio/Kconfig: tristate "Loongson1 GPIO support"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

---
 drivers/gpio/gpio-loongson1.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-loongson1.c +1 -0
index 10c09bdd8514..ad0a5958fcd0 100644
@@ -8,6 +8,7 @@
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/module.h>
 #include <linux/gpio/driver.h>
 #include <linux/platform_device.h>
 
Signature · 1 line
2.8.4
#12 lore raw

Re: [PATCH 6/8] gpio: loongson1: fix implicit assumption module.h is present

Quoted 13 lines · Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_LOONGSON1
drivers/gpio/Kconfig: tristate "Loongson1 GPIO support"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

Quoted 6 lines

Patch applied.

Yours,
Linus Walleij

#13 lore raw

PATCH 7/8 gpio: wcove: fix implicit assumption module.h is present

In reply to Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_WHISKEY_COVE
drivers/gpio/Kconfig: tristate "GPIO support for Whiskey Cove PMIC"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

Cc Ajay Thomas <[email protected]>
Cc Bin Gao <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-wcove.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-wcove.c +1 -0
index e11d6a3fb641..d0ddba7a9d08 100644
@@ -16,6 +16,7 @@
  */
 
 #include <linux/bitops.h>
+#include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/gpio/driver.h>
 #include <linux/mfd/intel_soc_pmic.h>
Signature · 1 line
2.8.4
#14 lore raw

Re: [PATCH 7/8] gpio: wcove: fix implicit assumption module.h is present

Quoted 13 lines · Paul Gortmaker

The Kconfig for this file is:

drivers/gpio/Kconfig:config GPIO_WHISKEY_COVE
drivers/gpio/Kconfig: tristate "GPIO support for Whiskey Cove PMIC"

...but however it does not include module.h -- it in turn gets it from another header (gpio/driver.h) and we'd like to replace that with a forward delcaration of "struct module;" but if we do, this file will fail to compile.

So we fix this first to avoid putting build failures into the bisect commit history.

Quoted 8 lines
Cc Ajay Thomas <[email protected]>
Cc Bin Gao <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>

Patch applied.

Yours,
Linus Walleij

#15 lore raw

PATCH 8/8 gpio: don't include module.h in shared driver header

In reply to Paul Gortmaker

Most shared headers in include/linux don't need to know what the internals of a struct module are; all they care about is that it is a struct and hence they may require a pointer to one.

The advantage in this is that module.h is including a lot of stuff itself, and an otherwise empty C file that just contains module.h will result in ~750kB from CPP (compared to say 12kB from init.h)

So we have approximately 50 instances of "struct module;" in the various include/linux headers already that help us keep module.h out of other headers; here we do the same for gpio.

---
 include/linux/gpio/driver.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/gpio/driver.h +1 -1
index 50882e09289b..216e6f275aa8 100644
@@ -3,7 +3,6 @@
 
 #include <linux/device.h>
 #include <linux/types.h>
-#include <linux/module.h>
 #include <linux/irq.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqdomain.h>
@@ -16,6 +15,7 @@ struct of_phandle_args;
 struct device_node;
 struct seq_file;
 struct gpio_device;
+struct module;
 
 #ifdef CONFIG_GPIOLIB
 
Signature · 1 line
2.8.4
#16 lore raw

Re: [PATCH 8/8] gpio: don't include module.h in shared driver header

Quoted 8 lines · Paul Gortmaker

Most shared headers in include/linux don't need to know what the internals of a struct module are; all they care about is that it is a struct and hence they may require a pointer to one.

The advantage in this is that module.h is including a lot of stuff itself, and an otherwise empty C file that just contains module.h will result in ~750kB from CPP (compared to say 12kB from init.h)

Quoted 8 lines

So we have approximately 50 instances of "struct module;" in the various include/linux headers already that help us keep module.h out of other headers; here we do the same for gpio.

Probably my mistake.
Thanks for tidying this up so nicely!

Patch applied.

Yours,
Linus Walleij