gpio: batch #3: remove modular code from non-modular drivers
Subsystems (3)
PATCH 1/4 gpio: sodaville: make it explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/gpio/Kconfig:config GPIO_SODAVILLEdrivers/gpio/Kconfig: bool "Intel Sodaville GPIO support"
...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Since module_pci_driver() uses the same init level as the builtin_pci_driver() does, there is no init ordering change caused by this commit.
We don't replace module.h with init.h since the file already has that.
We also delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.
--- drivers/gpio/gpio-sodaville.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/gpio/gpio-sodaville.c +6 -22
@@ -3,6 +3,8 @@* * Copyright (c) 2010, 2011 Intel Corporation * +* Author: Hans J. Koch <[email protected]> +* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License 2 as published * by the Free Software Foundation.
@@ -15,7 +17,6 @@#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/kernel.h> -#include <linux/module.h> #include <linux/pci.h> #include <linux/platform_device.h> #include <linux/of_irq.h>
@@ -257,34 +258,17 @@ done:return ret; } -static void sdv_gpio_remove (struct pci_dev *pdev) -{ -struct sdv_gpio_chip_data *sd =pci_get_drvdata (pdev); - -free_irq (pdev->irq, sd); -irq_free_descs (sd->irq_base,SDV_NUM_PUB_GPIOS ); - -gpiochip_remove (&sd->chip); -pci_release_region (pdev,GPIO_BAR ); -iounmap (sd->gpio_pub_base); -pci_disable_device (pdev); -kfree (sd); -} -static const struct pci_device_id sdv_gpio_pci_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_SDV_GPIO ) }, {0 , }, };static struct pci_driver sdv_gpio_driver = { + .driver = { + .suppress_bind_attrs = true, + }, .name =DRV_NAME , .id_table = sdv_gpio_pci_ids, .probe = sdv_gpio_probe, - .remove = sdv_gpio_remove, }; - -module_pci_driver (sdv_gpio_driver); - -MODULE_AUTHOR ("Hans J. Koch <[email protected]>" ); -MODULE_DESCRIPTION ("GPIO interface for Intel Sodaville SoCs" ); -MODULE_LICENSE ("GPL v2" ); +builtin_pci_driver (sdv_gpio_driver);
Signature · 1 line
2.8.0
PATCH 3/4 gpio: timberdale: make it explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/gpio/Kconfig:config GPIO_TIMBERDALEdrivers/gpio/Kconfig: bool "Support for timberdale GPIO IP"
...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.
We also delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.
--- drivers/gpio/gpio-timberdale.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-)
drivers/gpio/gpio-timberdale.c +5 -30
@@ -1,5 +1,6 @@/* * Timberdale FPGA GPIO driver +* Author: Mocean Laboratories * Copyright (c) 2009 Intel Corporation * * This program is free software; you can redistribute it and/or modify
@@ -20,7 +21,7 @@* Timberdale FPGA GPIO */ -#include <linux/module.h> +#include <linux/init.h> #include <linux/gpio.h> #include <linux/platform_device.h> #include <linux/irq.h>
@@ -290,40 +291,14 @@ static int timbgpio_probe(struct platform_device *pdev)return 0 ; } -static int timbgpio_remove (struct platform_device *pdev) -{ -struct timbgpio_platform_data *pdata =dev_get_platdata (&pdev->dev); -struct timbgpio *tgpio =platform_get_drvdata (pdev); -int irq =platform_get_irq (pdev,0 ); - -if (irq >=0 && tgpio->irq_base >0 ) { -int i; -for (i =0 ; i < pdata->nr_pins; i++) { -irq_set_chip (tgpio->irq_base + i,NULL ); -irq_set_chip_data (tgpio->irq_base + i,NULL ); - } - -irq_set_handler (irq,NULL ); -irq_set_handler_data (irq,NULL ); - } - -return 0 ; -} -static struct platform_driver timbgpio_platform_driver = { .driver = { - .name =DRIVER_NAME , + .name =DRIVER_NAME , + .suppress_bind_attrs = true, }, .probe = timbgpio_probe, - .remove = timbgpio_remove, };/*--------------------------------------------------------------------------*/ -module_platform_driver (timbgpio_platform_driver); - -MODULE_DESCRIPTION ("Timberdale GPIO driver" ); -MODULE_LICENSE ("GPL v2" ); -MODULE_AUTHOR ("Mocean Laboratories" ); -MODULE_ALIAS ("platform:" DRIVER_NAME ); - +builtin_platform_driver (timbgpio_platform_driver);
Signature · 1 line
2.8.0
PATCH 4/4 gpio: zevio: make it explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/gpio/Kconfig:config GPIO_ZEVIOdrivers/gpio/Kconfig: bool "LSI ZEVIO SoC memory mapped GPIOs"
...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/gpio/gpio-zevio.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
drivers/gpio/gpio-zevio.c +3 -18
@@ -10,7 +10,7 @@#include <linux/spinlock.h> #include <linux/errno.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/bitops.h> #include <linux/io.h> #include <linux/of_device.h>
@@ -203,32 +203,17 @@ static int zevio_gpio_probe(struct platform_device *pdev)return 0 ; } -static int zevio_gpio_remove (struct platform_device *pdev) -{ -struct zevio_gpio *controller =platform_get_drvdata (pdev); - -of_mm_gpiochip_remove (&controller->chip); - -return 0 ; -} -static const struct of_device_id zevio_gpio_of_match[] = { { .compatible ="lsi,zevio-gpio" , }, { }, }; -MODULE_DEVICE_TABLE (of, zevio_gpio_of_match); -static struct platform_driver zevio_gpio_driver = { .driver = { .name ="gpio-zevio" , .of_match_table = zevio_gpio_of_match, + .suppress_bind_attrs = true, }, .probe = zevio_gpio_probe, - .remove = zevio_gpio_remove, }; -module_platform_driver (zevio_gpio_driver); - -MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Fabian Vogt <[email protected]>" ); -MODULE_DESCRIPTION ("LSI ZEVIO SoC GPIO driver" ); +builtin_platform_driver (zevio_gpio_driver);
Signature · 1 line
2.8.0
PATCH 2/4 gpio: stmpe: make it explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/gpio/Kconfig:config GPIO_STMPEdrivers/gpio/Kconfig: bool "STMPE GPIOs"
...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Curiously, this driver was using subsys_initcall since day one, so we don't have the "normal" module_init replacement in this change like we've done in other similar driver updates.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/gpio/gpio-stmpe.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-)
drivers/gpio/gpio-stmpe.c +5 -26
@@ -5,7 +5,6 @@* Author: Rabin Vincent <[email protected]> for ST-Ericsson */ -#include <linux/module.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/slab.h>
@@ -413,23 +412,13 @@ out_free:return ret; } -static int stmpe_gpio_remove (struct platform_device *pdev) -{ -struct stmpe_gpio *stmpe_gpio =platform_get_drvdata (pdev); -struct stmpe *stmpe = stmpe_gpio->stmpe; - -gpiochip_remove (&stmpe_gpio->chip); -stmpe_disable (stmpe,STMPE_BLOCK_GPIO ); -kfree (stmpe_gpio); - -return 0 ; -} -static struct platform_driver stmpe_gpio_driver = { - .driver.name ="stmpe-gpio" , - .driver.owner =THIS_MODULE , + .driver = { + .suppress_bind_attrs = true, + .name ="stmpe-gpio" , + .owner =THIS_MODULE , + }, .probe = stmpe_gpio_probe, - .remove = stmpe_gpio_remove, };static int __init stmpe_gpio_init (void )
@@ -437,13 +426,3 @@ static int __init stmpe_gpio_init(void)return platform_driver_register (&stmpe_gpio_driver); }subsys_initcall (stmpe_gpio_init); - -static void __exit stmpe_gpio_exit(void) -{ -platform_driver_unregister (&stmpe_gpio_driver); -} -module_exit (stmpe_gpio_exit); - -MODULE_LICENSE ("GPL v2" ); -MODULE_DESCRIPTION ("STMPExxxx GPIO driver" ); -MODULE_AUTHOR ("Rabin Vincent <[email protected]>" );
Signature · 1 line
2.8.0
cover gpio: batch #3: remove modular code from non-modular drivers
For GPIO, I'd divided up the the audit of modular usage in non-modular drivers into three categories to ease review and limit the batch size. Group #1 & #2 have been submitted and merged ; this here is group #3.
The breakdown of the three groups was as follows:
1) just replacement of modular macros with their non-modular equivalents that CPP would have inserted anyway ; this means runtime equivalence and actually also binary equivalence.
2) as per #1 but also with the removal of unused/orphaned __exit functions that could never be called/exercised. This also maintains runtime equivalence, but since the unused __exit function is gone, there is a reduction in the object file size and hence not binary equivalence, eg:
before: -rw-rw-r-- 1 8828 drivers/gpio/gpio-rc5t583.o
after: -rw-rw-r-- 1 7396 drivers/gpio/gpio-rc5t583.o3) as per #2 but also with the removal of a ".remove" function that is
hooked into the driver struct. This ".remove" function would of
course not be called from the __exit function since that is never run. However in theory, someone could have triggered it via sysfs unbind, even though there isn't a sensible use case for doing so. So to cover that possibility, we've also disabled sysfs unbind in these drivers.
Since this is the #3 of 3, an additional bind comment is warranted. One could argue that the suppress bind is overkill, since it isn't used by all non-modular drivers everywhere, but it does ensure that anyone who was manually trying to (ab)use it with _these_ drivers gets a clear signal that it was never meant to be used like that.
For anyone new to the underlying goal of this cleanup, we are trying to not use module support for code that can never be built as a module since:
(1) it is easy to accidentally write unused module_exit and remove code
(2) it can be misleading when reading the source, thinking it can be modular when the Makefile and/or Kconfig prohibit it
(3) it requires the include of the module.h header file which in turn includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other code and spreads like weeds.
There are no initcall level changes here; everything was at the level of device_initcall and remains so, by using the builtin equivalents.
I fixed up the shortlogs in this lot to match the existing gpio shortlog format (no "device/" in the prefix, etc.) -- apologies for not catching that for the earlier lot of commits in #1 and #2.
Build tested for 5-6 different key arch on today's linux-next to ensure no silly typos crept in.
There is one remaining trivial bool ---> tristate gpio conversion I have to send that didn't fit #1/#2/#3, but getting these groups done is 99% of it, so thanks in advance for handling these and getting them off of my queue.
Paul.
---
Paul Gortmaker (4):
gpio: sodaville: make it explicitly non-modular
gpio: stmpe: make it explicitly non-modular
gpio: timberdale: make it explicitly non-modular
gpio: zevio: make it explicitly non-modular
drivers/gpio/gpio-sodaville.c | 28 ++++++---------------------- drivers/gpio/gpio-stmpe.c | 31 +++++-------------------------- drivers/gpio/gpio-timberdale.c | 35 +++++------------------------------ drivers/gpio/gpio-zevio.c | 21 +++------------------ 4 files changed, 19 insertions(+), 96 deletions(-)
Signature · 1 line
2.8.0
Re: [PATCH 1/4] gpio: sodaville: make it explicitly non-modular
In reply to Paul GortmakerQuoted 20 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/gpio/Kconfig:config
GPIO_SODAVILLEdrivers/gpio/Kconfig: bool "Intel Sodaville GPIO support"...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Since
module_pci_driver()uses the same init level as thebuiltin_pci_driver()does, there is no init ordering change caused by this commit.We don't replace
module.hwithinit.hsince the file already has that.
Quoted 8 lines
We also delete the
MODULE_LICENSEtag etc. since all that information was (or is now) contained at the top of the file in the comments.Cc Hans J. Koch <[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 2/4] gpio: stmpe: make it explicitly non-modular
In reply to Paul GortmakerQuoted 18 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/gpio/Kconfig:config
GPIO_STMPEdrivers/gpio/Kconfig: bool "STMPE GPIOs"...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Curiously, this driver was using
subsys_initcallsince day one, so we don't have the "normal"module_initreplacement in this change like we've done in other similar driver updates.
Quoted 8 lines
We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Cc Rabin Vincent <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH 3/4] gpio: timberdale: make it explicitly non-modular
In reply to Paul GortmakerQuoted 18 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/gpio/Kconfig:config
GPIO_TIMBERDALEdrivers/gpio/Kconfig: bool "Support for timberdale GPIO IP"...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Since
module_platform_driver()uses the same init level priority asbuiltin_platform_driver()the init ordering remains unchanged with this commit.
Quoted 7 lines
We also delete the
MODULE_LICENSEtag etc. since all that information was (or is now) contained at the top of the file in the comments.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/4] gpio: zevio: make it explicitly non-modular
In reply to Paul GortmakerQuoted 20 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/gpio/Kconfig:config
GPIO_ZEVIOdrivers/gpio/Kconfig: bool "LSI ZEVIO SoC memory mapped GPIOs"...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.
We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.
Since
module_platform_driver()uses the same init level priority asbuiltin_platform_driver()the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.
Quoted 8 lines
We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Cc Fabian Vogt <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Patch applied.
Yours,
Linus Walleij