public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] gpio: sifive: Module support
@ 2023-07-17 20:53 Samuel Holland
  2023-07-17 20:53 ` [PATCH 1/2] of/irq: Export of_irq_count() Samuel Holland
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Samuel Holland @ 2023-07-17 20:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Rob Herring,
	Frank Rowand
  Cc: Samuel Holland, Palmer Dabbelt, Paul Walmsley, devicetree,
	linux-gpio, linux-kernel, linux-riscv

With of_irq_count() exported, the SiFive GPIO driver can be built as a
module. This helps to minimize the size of a multiplatform kernel, and
is required by some downstream distributions (Android GKI).


Samuel Holland (2):
  of/irq: Export of_irq_count()
  gpio: sifive: Allow building the driver as a module

 drivers/gpio/Kconfig       | 2 +-
 drivers/gpio/gpio-sifive.c | 4 +++-
 drivers/of/irq.c           | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

-- 
2.40.1


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

* [PATCH 1/2] of/irq: Export of_irq_count()
  2023-07-17 20:53 [PATCH 0/2] gpio: sifive: Module support Samuel Holland
@ 2023-07-17 20:53 ` Samuel Holland
  2023-07-17 21:40   ` Andy Shevchenko
  2023-07-17 20:53 ` [PATCH 2/2] gpio: sifive: Allow building the driver as a module Samuel Holland
  2023-07-17 22:18 ` [PATCH 0/2] gpio: sifive: Module support Palmer Dabbelt
  2 siblings, 1 reply; 9+ messages in thread
From: Samuel Holland @ 2023-07-17 20:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Rob Herring,
	Frank Rowand
  Cc: Samuel Holland, devicetree, linux-kernel

This function is used by the SiFive GPIO driver. Export it so that
driver can be built as a module.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 drivers/of/irq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 174900072c18..9cea7632dd6a 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -489,6 +489,7 @@ int of_irq_count(struct device_node *dev)
 
 	return nr;
 }
+EXPORT_SYMBOL_GPL(of_irq_count);
 
 /**
  * of_irq_to_resource_table - Fill in resource table with node's IRQ info
-- 
2.40.1


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

* [PATCH 2/2] gpio: sifive: Allow building the driver as a module
  2023-07-17 20:53 [PATCH 0/2] gpio: sifive: Module support Samuel Holland
  2023-07-17 20:53 ` [PATCH 1/2] of/irq: Export of_irq_count() Samuel Holland
@ 2023-07-17 20:53 ` Samuel Holland
  2023-07-19 11:29   ` Bartosz Golaszewski
  2023-07-19 14:12   ` Emil Renner Berthing
  2023-07-17 22:18 ` [PATCH 0/2] gpio: sifive: Module support Palmer Dabbelt
  2 siblings, 2 replies; 9+ messages in thread
From: Samuel Holland @ 2023-07-17 20:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Rob Herring,
	Frank Rowand
  Cc: Samuel Holland, Palmer Dabbelt, Paul Walmsley, linux-gpio,
	linux-kernel, linux-riscv

This can reduce the kernel image size in multiplatform configurations.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 drivers/gpio/Kconfig       | 2 +-
 drivers/gpio/gpio-sifive.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index e382dfebad7c..1a8e8a8c85d6 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -564,7 +564,7 @@ config GPIO_SAMA5D2_PIOBU
 	  maintain their value during backup/self-refresh.
 
 config GPIO_SIFIVE
-	bool "SiFive GPIO support"
+	tristate "SiFive GPIO support"
 	depends on OF_GPIO
 	select IRQ_DOMAIN_HIERARCHY
 	select GPIO_GENERIC
diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index 745e5f67254e..5941a817491c 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -277,4 +277,6 @@ static struct platform_driver sifive_gpio_driver = {
 		.of_match_table = sifive_gpio_match,
 	},
 };
-builtin_platform_driver(sifive_gpio_driver)
+module_platform_driver(sifive_gpio_driver)
+
+MODULE_LICENSE("GPL");
-- 
2.40.1


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

* Re: [PATCH 1/2] of/irq: Export of_irq_count()
  2023-07-17 20:53 ` [PATCH 1/2] of/irq: Export of_irq_count() Samuel Holland
@ 2023-07-17 21:40   ` Andy Shevchenko
  2023-07-18 22:42     ` Rob Herring
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2023-07-17 21:40 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Rob Herring,
	Frank Rowand, devicetree, linux-kernel

On Mon, Jul 17, 2023 at 11:54 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> This function is used by the SiFive GPIO driver. Export it so that
> driver can be built as a module.

Can we rather reduce use of of_*() APIs?
For example, why not use platform_irq_count()?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 0/2] gpio: sifive: Module support
  2023-07-17 20:53 [PATCH 0/2] gpio: sifive: Module support Samuel Holland
  2023-07-17 20:53 ` [PATCH 1/2] of/irq: Export of_irq_count() Samuel Holland
  2023-07-17 20:53 ` [PATCH 2/2] gpio: sifive: Allow building the driver as a module Samuel Holland
@ 2023-07-17 22:18 ` Palmer Dabbelt
  2 siblings, 0 replies; 9+ messages in thread
From: Palmer Dabbelt @ 2023-07-17 22:18 UTC (permalink / raw)
  To: samuel.holland
  Cc: linus.walleij, brgl, andy, robh+dt, frowand.list, samuel.holland,
	Paul Walmsley, devicetree, linux-gpio, linux-kernel, linux-riscv

On Mon, 17 Jul 2023 13:53:55 PDT (-0700), samuel.holland@sifive.com wrote:
> With of_irq_count() exported, the SiFive GPIO driver can be built as a
> module. This helps to minimize the size of a multiplatform kernel, and
> is required by some downstream distributions (Android GKI).
>
>
> Samuel Holland (2):
>   of/irq: Export of_irq_count()
>   gpio: sifive: Allow building the driver as a module
>
>  drivers/gpio/Kconfig       | 2 +-
>  drivers/gpio/gpio-sifive.c | 4 +++-
>  drivers/of/irq.c           | 1 +
>  3 files changed, 5 insertions(+), 2 deletions(-)

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>

I guess we probably should have just done that the first time around?  
Either way it seems reasonable to me, aside from sorting out the OF 
stuff.

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

* Re: [PATCH 1/2] of/irq: Export of_irq_count()
  2023-07-17 21:40   ` Andy Shevchenko
@ 2023-07-18 22:42     ` Rob Herring
  0 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2023-07-18 22:42 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Samuel Holland, Linus Walleij, Bartosz Golaszewski,
	Andy Shevchenko, Frank Rowand, devicetree, linux-kernel

On Tue, Jul 18, 2023 at 12:40:53AM +0300, Andy Shevchenko wrote:
> On Mon, Jul 17, 2023 at 11:54 PM Samuel Holland
> <samuel.holland@sifive.com> wrote:
> >
> > This function is used by the SiFive GPIO driver. Export it so that
> > driver can be built as a module.
> 
> Can we rather reduce use of of_*() APIs?
> For example, why not use platform_irq_count()?

+1

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

* Re: [PATCH 2/2] gpio: sifive: Allow building the driver as a module
  2023-07-17 20:53 ` [PATCH 2/2] gpio: sifive: Allow building the driver as a module Samuel Holland
@ 2023-07-19 11:29   ` Bartosz Golaszewski
  2023-07-19 14:12   ` Emil Renner Berthing
  1 sibling, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2023-07-19 11:29 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Linus Walleij, Andy Shevchenko, Rob Herring, Frank Rowand,
	Palmer Dabbelt, Paul Walmsley, linux-gpio, linux-kernel,
	linux-riscv

On Mon, Jul 17, 2023 at 10:54 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> This can reduce the kernel image size in multiplatform configurations.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
>  drivers/gpio/Kconfig       | 2 +-
>  drivers/gpio/gpio-sifive.c | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index e382dfebad7c..1a8e8a8c85d6 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -564,7 +564,7 @@ config GPIO_SAMA5D2_PIOBU
>           maintain their value during backup/self-refresh.
>
>  config GPIO_SIFIVE
> -       bool "SiFive GPIO support"
> +       tristate "SiFive GPIO support"
>         depends on OF_GPIO
>         select IRQ_DOMAIN_HIERARCHY
>         select GPIO_GENERIC
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index 745e5f67254e..5941a817491c 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -277,4 +277,6 @@ static struct platform_driver sifive_gpio_driver = {
>                 .of_match_table = sifive_gpio_match,
>         },
>  };
> -builtin_platform_driver(sifive_gpio_driver)
> +module_platform_driver(sifive_gpio_driver)
> +
> +MODULE_LICENSE("GPL");
> --
> 2.40.1
>

This looks good but please follow Andy's suggestion and convert all
of_*() uses in the driver to generic helpers, then drop patch 1.

Bart

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

* Re: [PATCH 2/2] gpio: sifive: Allow building the driver as a module
  2023-07-17 20:53 ` [PATCH 2/2] gpio: sifive: Allow building the driver as a module Samuel Holland
  2023-07-19 11:29   ` Bartosz Golaszewski
@ 2023-07-19 14:12   ` Emil Renner Berthing
  2023-07-19 14:37     ` Andy Shevchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Emil Renner Berthing @ 2023-07-19 14:12 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Rob Herring,
	Frank Rowand, Palmer Dabbelt, Paul Walmsley, linux-gpio,
	linux-kernel, linux-riscv

On Wed, 19 Jul 2023 at 08:26, Samuel Holland <samuel.holland@sifive.com> wrote:
>
> This can reduce the kernel image size in multiplatform configurations.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
>  drivers/gpio/Kconfig       | 2 +-
>  drivers/gpio/gpio-sifive.c | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index e382dfebad7c..1a8e8a8c85d6 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -564,7 +564,7 @@ config GPIO_SAMA5D2_PIOBU
>           maintain their value during backup/self-refresh.
>
>  config GPIO_SIFIVE
> -       bool "SiFive GPIO support"
> +       tristate "SiFive GPIO support"
>         depends on OF_GPIO
>         select IRQ_DOMAIN_HIERARCHY
>         select GPIO_GENERIC
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index 745e5f67254e..5941a817491c 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -277,4 +277,6 @@ static struct platform_driver sifive_gpio_driver = {
>                 .of_match_table = sifive_gpio_match,
>         },
>  };
> -builtin_platform_driver(sifive_gpio_driver)
> +module_platform_driver(sifive_gpio_driver)
> +

While you're at it maybe also add the MODULE_AUTHOR() and
MODULE_DESCRIPTION() macros.

> +MODULE_LICENSE("GPL");
> --
> 2.40.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 2/2] gpio: sifive: Allow building the driver as a module
  2023-07-19 14:12   ` Emil Renner Berthing
@ 2023-07-19 14:37     ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2023-07-19 14:37 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Samuel Holland, Linus Walleij, Bartosz Golaszewski,
	Andy Shevchenko, Rob Herring, Frank Rowand, Palmer Dabbelt,
	Paul Walmsley, linux-gpio, linux-kernel, linux-riscv

On Wed, Jul 19, 2023 at 5:12 PM Emil Renner Berthing
<emil.renner.berthing@canonical.com> wrote:
> On Wed, 19 Jul 2023 at 08:26, Samuel Holland <samuel.holland@sifive.com> wrote:

...

> While you're at it maybe also add the MODULE_AUTHOR() and
> MODULE_DESCRIPTION() macros.

+1, as now we have a new warning that MODULE_DESCRIPTION() is not set.

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2023-07-19 14:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 20:53 [PATCH 0/2] gpio: sifive: Module support Samuel Holland
2023-07-17 20:53 ` [PATCH 1/2] of/irq: Export of_irq_count() Samuel Holland
2023-07-17 21:40   ` Andy Shevchenko
2023-07-18 22:42     ` Rob Herring
2023-07-17 20:53 ` [PATCH 2/2] gpio: sifive: Allow building the driver as a module Samuel Holland
2023-07-19 11:29   ` Bartosz Golaszewski
2023-07-19 14:12   ` Emil Renner Berthing
2023-07-19 14:37     ` Andy Shevchenko
2023-07-17 22:18 ` [PATCH 0/2] gpio: sifive: Module support Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox