Support building gpio-tegra driver as loadable module
Subsystems (2)
cover Support building gpio-tegra driver as loadable module
Hi,
This small series adds modularization support to the gpio-tegra driver, i.e. driver now could be built as a loadable kernel module.
Dmitry Osipenko (3):
gpio: tegra: Use debugfs_create_devm_seqfile()
gpio: tegra: Clean up whitespaces in tegra_gpio_driver
gpio: tegra: Support building driver as a loadable module
drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tegra.c | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/3 gpio: tegra: Use debugfs_create_devm_seqfile()
Use resource-managed variant of debugfs_create_file(0444) to prepare code for the modularization of the driver.
--- drivers/gpio/gpio-tegra.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpio/gpio-tegra.c +3 -5
@@ -605,7 +605,7 @@ static void tegra_gpio_irq_release_resources(struct irq_data *d)static int tegra_dbg_gpio_show (struct seq_file *s,void *unused) { -struct tegra_gpio_info *tgi = s->private; +struct tegra_gpio_info *tgi =dev_get_drvdata (s->private);unsigned int i, j;for (i =0 ; i < tgi->bank_count; i++) {
@@ -627,12 +627,10 @@ static int tegra_dbg_gpio_show(struct seq_file *s, void *unused) return 0; } -DEFINE_SHOW_ATTRIBUTE (tegra_dbg_gpio); -static void tegra_gpio_debuginit (struct tegra_gpio_info *tgi) { -debugfs_create_file ("tegra_gpio" ,0444 ,NULL , tgi, - &tegra_dbg_gpio_fops); +debugfs_create_devm_seqfile (tgi->dev,"tegra_gpio" ,NULL , + tegra_dbg_gpio_show); }#else
Signature · 1 line
2.29.2
PATCH 2/3 gpio: tegra: Clean up whitespaces in tegra_gpio_driver
In reply to Dmitry OsipenkoClean up inconsistent whitespaces and tabs in the definition of tegra_gpio_driver to make code look better a tad.
--- drivers/gpio/gpio-tegra.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-tegra.c +4 -4
@@ -800,12 +800,12 @@ static const struct of_device_id tegra_gpio_of_match[] = { };static struct platform_driver tegra_gpio_driver = { - .driver = { - .name ="tegra-gpio" , - .pm = &tegra_gpio_pm_ops, + .driver = { + .name ="tegra-gpio" , + .pm = &tegra_gpio_pm_ops, .of_match_table = tegra_gpio_of_match, }, - .probe = tegra_gpio_probe, + .probe = tegra_gpio_probe, };static int __init tegra_gpio_init (void )
Signature · 1 line
2.29.2
PATCH 3/3 gpio: tegra: Support building driver as a loadable module
In reply to Dmitry OsipenkoSupport building driver as a loadable kernel module. This allows to reduce size of a kernel zImage, which is important for some devices since size of kernel partition may be limited and since some bootloader variants have known problems in regards to the initrd placement if kernel image is too big.
$ lsmod Module Size Used by gpio_tegra 16384 27
--- drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tegra.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/gpio/Kconfig +1 -1
@@ -594,7 +594,7 @@ config GPIO_TB10X select OF_GPIO config GPIO_TEGRA - bool "NVIDIA Tegra GPIO support" + tristate "NVIDIA Tegra GPIO support" default ARCH_TEGRA depends on ARCH_TEGRA || COMPILE_TEST depends on OF_GPIO
drivers/gpio/gpio-tegra.c +9 -6
@@ -798,6 +798,7 @@ static const struct of_device_id tegra_gpio_of_match[] = { { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config }, { }, }; +MODULE_DEVICE_TABLE (of, tegra_gpio_of_match);static struct platform_driver tegra_gpio_driver = { .driver = {
@@ -807,9 +808,11 @@ static struct platform_driver tegra_gpio_driver = { }, .probe = tegra_gpio_probe, }; - -static int __init tegra_gpio_init (void ) -{ -return platform_driver_register (&tegra_gpio_driver); -} -subsys_initcall (tegra_gpio_init); +module_platform_driver (tegra_gpio_driver); + +MODULE_DESCRIPTION ("NVIDIA Tegra GPIO controller driver" ); +MODULE_AUTHOR ("Laxman Dewangan <[email protected]>" ); +MODULE_AUTHOR ("Stephen Warren <[email protected]>" ); +MODULE_AUTHOR ("Thierry Reding <[email protected]>" ); +MODULE_AUTHOR ("Erik Gilling <[email protected]>" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.29.2
Quoted 7 lines · Dmitry Osipenko
This small series adds modularization support to the gpio-tegra driver, i.e. driver now could be built as a loadable kernel module.
Dmitry Osipenko (3):
gpio: tegra: Usedebugfs_create_devm_seqfile()
gpio: tegra: Clean up whitespaces integra_gpio_driver
gpio: tegra: Support building driver as a loadable module
As these three patches clearly make the kernel look better after than before:
However when we are doing this I would strongly encourage you to also make a patch implementing remove() so you can insmod rmmod the module at runtime.
Yours,
Linus Walleij
24.01.2021 01:50, Linus Walleij пишет:
Quoted 10 lines · Dmitry Osipenko
Quoted 8 lines
This small series adds modularization support to the gpio-tegra driver, i.e. driver now could be built as a loadable kernel module.
Dmitry Osipenko (3):
gpio: tegra: Usedebugfs_create_devm_seqfile()
gpio: tegra: Clean up whitespaces integra_gpio_driver
gpio: tegra: Support building driver as a loadable module
Quoted 7 lines
As these three patches clearly make the kernel look better after than before:
Reviewed-by Linus Walleij <[email protected]>However when we are doing this I would strongly encourage you to also make a patch implementing
remove()so you can insmod rmmod the module at runtime.
The remove() is optional for drivers, it doesn't prevent the rmmod.
Quoted 15 lines · Dmitry Osipenko
24.01.2021 01:50, Linus Walleij пишет:
Quoted 14 lines · Dmitry Osipenko
Quoted 8 lines
This small series adds modularization support to the gpio-tegra driver, i.e. driver now could be built as a loadable kernel module.
Dmitry Osipenko (3):
gpio: tegra: Usedebugfs_create_devm_seqfile()
gpio: tegra: Clean up whitespaces integra_gpio_driver
gpio: tegra: Support building driver as a loadable moduleAs these three patches clearly make the kernel look better after than before:
Reviewed-by Linus Walleij <[email protected]>
Quoted 5 lines
Quoted 3 lines
However when we are doing this I would strongly encourage you to also make a patch implementing
remove()so you can insmod rmmod the module at runtime.The
remove()is optional for drivers, it doesn't prevent the rmmod.
Aha you mean all resources are managed (devm_*) so that rmmod/insmod works fine with this driver?
OK then! :) the work is finished.
Yours,
Linus Walleij
25.01.2021 01:46, Linus Walleij пишет:
Quoted 16 lines · Dmitry Osipenko
Quoted 15 lines
24.01.2021 01:50, Linus Walleij пишет:
Quoted 14 lines · Dmitry Osipenko
Quoted 8 lines
This small series adds modularization support to the gpio-tegra driver, i.e. driver now could be built as a loadable kernel module.
Dmitry Osipenko (3):
gpio: tegra: Usedebugfs_create_devm_seqfile()
gpio: tegra: Clean up whitespaces integra_gpio_driver
gpio: tegra: Support building driver as a loadable moduleAs these three patches clearly make the kernel look better after than before:
Reviewed-by Linus Walleij <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
However when we are doing this I would strongly encourage you to also make a patch implementing
remove()so you can insmod rmmod the module at runtime.The
remove()is optional for drivers, it doesn't prevent the rmmod.Aha you mean all resources are managed (devm_*) so that rmmod/insmod works fine with this driver?
yes
Quoted 1 line
OK then! :) the work is finished.
The work on the modularization indeed should be finished, thanks.
Quoted 11 lines · Dmitry Osipenko
Hi,
This small series adds modularization support to the gpio-tegra driver, i.e. driver now could be built as a loadable kernel module.
Dmitry Osipenko (3):
gpio: tegra: Usedebugfs_create_devm_seqfile()
gpio: tegra: Clean up whitespaces integra_gpio_driver
gpio: tegra: Support building driver as a loadable module
Quoted 7 lines
drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tegra.c | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-)--
2.29.2
Series applied, thanks!
Bartosz