gpio: wean gpio/driver.h off of module.h
Subsystems (7)
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).
---
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
PATCH 2/8 gpio: sx150x: fix implicit assumption module.h is present
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_SX150Xdrivers/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
@@ -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
PATCH 4/8 gpio: altera: fix implicit assumption module.h is present
In reply to Paul GortmakerThe Kconfig for this file is:
drivers/gpio/Kconfig:config GPIO_ALTERAdrivers/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
@@ -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
PATCH 5/8 gpio: ath79: fix implicit assumption module.h is present
In reply to Paul GortmakerThe Kconfig for this file is:
drivers/gpio/Kconfig:config GPIO_ATH79drivers/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
@@ -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
PATCH 6/8 gpio: loongson1: fix implicit assumption module.h is present
In reply to Paul GortmakerThe Kconfig for this file is:
drivers/gpio/Kconfig:config GPIO_LOONGSON1drivers/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
@@ -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
PATCH 1/8 gpio: palmas: fix implicit assumption module.h is present
In reply to Paul GortmakerThis 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_PALMASdrivers/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
@@ -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
PATCH 3/8 gpio: ts4800: fix implicit assumption module.h is present
In reply to Paul GortmakerThe 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
@@ -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
PATCH 7/8 gpio: wcove: fix implicit assumption module.h is present
In reply to Paul GortmakerThe Kconfig for this file is:
drivers/gpio/Kconfig:config GPIO_WHISKEY_COVEdrivers/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.
--- drivers/gpio/gpio-wcove.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-wcove.c +1 -0
@@ -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
PATCH 8/8 gpio: don't include module.h in shared driver header
In reply to Paul GortmakerMost 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
@@ -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
Re: [PATCH 1/8] gpio: palmas: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 13 lines · Paul Gortmaker
This file is currently getting
module.hfrom a global gpio header and it will fail to build once we removemodule.hfrom that.However, the driver is controlled with the following
Kconfig:drivers/gpio/Kconfig:config
GPIO_PALMASdrivers/gpio/Kconfig: bool "TI PALMAS series PMICs GPIO"and hence the line of
MODULE_DEVICE_TABLEis 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
Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 2/8] gpio: sx150x: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 8 lines · Paul Gortmaker
This file is currently getting
module.hfrom a global gpio header and it will faii to build once we removemodule.hfrom that.However, the driver is controlled with the following
Kconfig:drivers/gpio/Kconfig:config
GPIO_SX150Xdrivers/gpio/Kconfig: bool "Semtech SX150x I2C GPIO expander"
Quoted 7 lines
and hence the two lines of
MODULE_DEVICE_TABLEare no-ops that can simply be deleted.Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 3/8] gpio: ts4800: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 10 lines · Paul Gortmaker
The
Kconfigfor this file is:drivers/gpio/Kconfig:config
GPIO_TS4800drivers/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.
Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 4/8] gpio: altera: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 10 lines · Paul Gortmaker
The
Kconfigfor this file is:drivers/gpio/Kconfig:config
GPIO_ALTERAdrivers/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.
Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 5/8] gpio: ath79: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 10 lines · Paul Gortmaker
The
Kconfigfor this file is:drivers/gpio/Kconfig:config
GPIO_ATH79drivers/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.
Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 6/8] gpio: loongson1: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 13 lines · Paul Gortmaker
The
Kconfigfor this file is:drivers/gpio/Kconfig:config
GPIO_LOONGSON1drivers/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
Cc Keguang Zhang <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 7/8] gpio: wcove: fix implicit assumption module.h is present
In reply to Paul GortmakerQuoted 13 lines · Paul Gortmaker
The
Kconfigfor this file is:drivers/gpio/Kconfig:config
GPIO_WHISKEY_COVEdrivers/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]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 8/8] gpio: don't include module.h in shared driver header
In reply to Paul GortmakerQuoted 8 lines · Paul Gortmaker
Most shared headers in
include/linuxdon'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.his including a lot of stuff itself, and an otherwise empty C file that just containsmodule.hwill result in ~750kB from CPP (compared to say 12kB frominit.h)
Quoted 8 lines
So we have approximately 50 instances of "struct module;" in the various
include/linuxheaders already that help us keepmodule.hout of other headers; here we do the same for gpio.Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Probably my mistake.
Thanks for tidying this up so nicely!
Patch applied.
Yours,
Linus Walleij