linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] Support building gpio-tegra driver as loadable module
@ 2021-01-22 18:55 Dmitry Osipenko
  2021-01-22 18:55 ` [PATCH v1 1/3] gpio: tegra: Use debugfs_create_devm_seqfile() Dmitry Osipenko
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2021-01-22 18:55 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, Linus Walleij
  Cc: linux-tegra, linux-gpio, linux-kernel

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(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 1/3] gpio: tegra: Use debugfs_create_devm_seqfile()
  2021-01-22 18:55 [PATCH v1 0/3] Support building gpio-tegra driver as loadable module Dmitry Osipenko
@ 2021-01-22 18:55 ` Dmitry Osipenko
  2021-01-22 18:55 ` [PATCH v1 2/3] gpio: tegra: Clean up whitespaces in tegra_gpio_driver Dmitry Osipenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2021-01-22 18:55 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, Linus Walleij
  Cc: linux-tegra, linux-gpio, linux-kernel

Use resource-managed variant of debugfs_create_file(0444) to prepare code
for the modularization of the driver.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/gpio/gpio-tegra.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 9a43129313fa..06f033375e40 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -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
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] gpio: tegra: Clean up whitespaces in tegra_gpio_driver
  2021-01-22 18:55 [PATCH v1 0/3] Support building gpio-tegra driver as loadable module Dmitry Osipenko
  2021-01-22 18:55 ` [PATCH v1 1/3] gpio: tegra: Use debugfs_create_devm_seqfile() Dmitry Osipenko
@ 2021-01-22 18:55 ` Dmitry Osipenko
  2021-01-22 18:55 ` [PATCH v1 3/3] gpio: tegra: Support building driver as a loadable module Dmitry Osipenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2021-01-22 18:55 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, Linus Walleij
  Cc: linux-tegra, linux-gpio, linux-kernel

Clean up inconsistent whitespaces and tabs in the definition of
tegra_gpio_driver to make code look better a tad.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/gpio/gpio-tegra.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 06f033375e40..1efd6fb642c7 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -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)
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 3/3] gpio: tegra: Support building driver as a loadable module
  2021-01-22 18:55 [PATCH v1 0/3] Support building gpio-tegra driver as loadable module Dmitry Osipenko
  2021-01-22 18:55 ` [PATCH v1 1/3] gpio: tegra: Use debugfs_create_devm_seqfile() Dmitry Osipenko
  2021-01-22 18:55 ` [PATCH v1 2/3] gpio: tegra: Clean up whitespaces in tegra_gpio_driver Dmitry Osipenko
@ 2021-01-22 18:55 ` Dmitry Osipenko
  2021-01-23 22:50 ` [PATCH v1 0/3] Support building gpio-tegra driver as " Linus Walleij
  2021-01-27 14:41 ` Bartosz Golaszewski
  4 siblings, 0 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2021-01-22 18:55 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, Linus Walleij
  Cc: linux-tegra, linux-gpio, linux-kernel

Support 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

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/gpio/Kconfig      |  2 +-
 drivers/gpio/gpio-tegra.c | 15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 1b0acca28c59..c3ce43cc4c31 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -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
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 1efd6fb642c7..0be24248280a 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -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 <ldewangan@nvidia.com>");
+MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
+MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
+MODULE_AUTHOR("Erik Gilling <konkers@google.com>");
+MODULE_LICENSE("GPL v2");
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] Support building gpio-tegra driver as loadable module
  2021-01-22 18:55 [PATCH v1 0/3] Support building gpio-tegra driver as loadable module Dmitry Osipenko
                   ` (2 preceding siblings ...)
  2021-01-22 18:55 ` [PATCH v1 3/3] gpio: tegra: Support building driver as a loadable module Dmitry Osipenko
@ 2021-01-23 22:50 ` Linus Walleij
  2021-01-23 23:56   ` Dmitry Osipenko
  2021-01-27 14:41 ` Bartosz Golaszewski
  4 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2021-01-23 22:50 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, linux-tegra, open list:GPIO SUBSYSTEM,
	linux-kernel

On Fri, Jan 22, 2021 at 7:59 PM Dmitry Osipenko <digetx@gmail.com> wrote:

> 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

As these three patches clearly make the kernel look better after
than before:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] Support building gpio-tegra driver as loadable module
  2021-01-23 22:50 ` [PATCH v1 0/3] Support building gpio-tegra driver as " Linus Walleij
@ 2021-01-23 23:56   ` Dmitry Osipenko
  2021-01-24 22:46     ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Osipenko @ 2021-01-23 23:56 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, linux-tegra, open list:GPIO SUBSYSTEM,
	linux-kernel

24.01.2021 01:50, Linus Walleij пишет:
> On Fri, Jan 22, 2021 at 7:59 PM Dmitry Osipenko <digetx@gmail.com> wrote:
> 
>> 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
> 
> As these three patches clearly make the kernel look better after
> than before:
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] Support building gpio-tegra driver as loadable module
  2021-01-23 23:56   ` Dmitry Osipenko
@ 2021-01-24 22:46     ` Linus Walleij
  2021-01-25 14:08       ` Dmitry Osipenko
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2021-01-24 22:46 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, linux-tegra, open list:GPIO SUBSYSTEM,
	linux-kernel

On Sun, Jan 24, 2021 at 12:56 AM Dmitry Osipenko <digetx@gmail.com> wrote:
> 24.01.2021 01:50, Linus Walleij пишет:
> > On Fri, Jan 22, 2021 at 7:59 PM Dmitry Osipenko <digetx@gmail.com> wrote:
> >
> >> 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
> >
> > As these three patches clearly make the kernel look better after
> > than before:
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> >
> > 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] Support building gpio-tegra driver as loadable module
  2021-01-24 22:46     ` Linus Walleij
@ 2021-01-25 14:08       ` Dmitry Osipenko
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2021-01-25 14:08 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan,
	Bartosz Golaszewski, linux-tegra, open list:GPIO SUBSYSTEM,
	linux-kernel

25.01.2021 01:46, Linus Walleij пишет:
> On Sun, Jan 24, 2021 at 12:56 AM Dmitry Osipenko <digetx@gmail.com> wrote:
>> 24.01.2021 01:50, Linus Walleij пишет:
>>> On Fri, Jan 22, 2021 at 7:59 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>>
>>>> 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
>>>
>>> As these three patches clearly make the kernel look better after
>>> than before:
>>> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>>>
>>> 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

> OK then! :) the work is finished.

The work on the modularization indeed should be finished, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] Support building gpio-tegra driver as loadable module
  2021-01-22 18:55 [PATCH v1 0/3] Support building gpio-tegra driver as loadable module Dmitry Osipenko
                   ` (3 preceding siblings ...)
  2021-01-23 22:50 ` [PATCH v1 0/3] Support building gpio-tegra driver as " Linus Walleij
@ 2021-01-27 14:41 ` Bartosz Golaszewski
  4 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2021-01-27 14:41 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan, Linus Walleij,
	linux-tegra, linux-gpio, LKML

On Fri, Jan 22, 2021 at 7:59 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> 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(-)
>
> --
> 2.29.2
>

Series applied, thanks!

Bartosz

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-27 14:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 18:55 [PATCH v1 0/3] Support building gpio-tegra driver as loadable module Dmitry Osipenko
2021-01-22 18:55 ` [PATCH v1 1/3] gpio: tegra: Use debugfs_create_devm_seqfile() Dmitry Osipenko
2021-01-22 18:55 ` [PATCH v1 2/3] gpio: tegra: Clean up whitespaces in tegra_gpio_driver Dmitry Osipenko
2021-01-22 18:55 ` [PATCH v1 3/3] gpio: tegra: Support building driver as a loadable module Dmitry Osipenko
2021-01-23 22:50 ` [PATCH v1 0/3] Support building gpio-tegra driver as " Linus Walleij
2021-01-23 23:56   ` Dmitry Osipenko
2021-01-24 22:46     ` Linus Walleij
2021-01-25 14:08       ` Dmitry Osipenko
2021-01-27 14:41 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).