linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: palmas: Allow building as a module
@ 2025-05-22 15:52 Aaron Kling via B4 Relay
  2025-05-22 17:42 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-05-22 15:52 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel, Aaron Kling

From: Aaron Kling <webgeek1234@gmail.com>

The driver works fine as a module, so allowing building as such. This
drops the driver specific init in favor of the module macro which does
the same, plus handling exit.

Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
 drivers/gpio/Kconfig       |  2 +-
 drivers/gpio/gpio-palmas.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f2c39bbff83a33dcb12b2d32aa3ebc358a0dd949..be5d823516d0e2bff4b4231dac6a82bf10887118 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1464,7 +1464,7 @@ config GPIO_MAX77650
 	  These chips have a single pin that can be configured as GPIO.
 
 config GPIO_PALMAS
-	bool "TI PALMAS series PMICs GPIO"
+	tristate "TI PALMAS series PMICs GPIO"
 	depends on MFD_PALMAS
 	help
 	  Select this option to enable GPIO driver for the TI PALMAS
diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
index 28dba7048509a3ef9c7972c1be53ea30adddabb0..c70782be502b2719bb30cf3e40065c89ecec3cc2 100644
--- a/drivers/gpio/gpio-palmas.c
+++ b/drivers/gpio/gpio-palmas.c
@@ -191,9 +191,9 @@ static struct platform_driver palmas_gpio_driver = {
 	.driver.of_match_table = of_palmas_gpio_match,
 	.probe		= palmas_gpio_probe,
 };
+module_platform_driver(palmas_gpio_driver);
 
-static int __init palmas_gpio_init(void)
-{
-	return platform_driver_register(&palmas_gpio_driver);
-}
-subsys_initcall(palmas_gpio_init);
+MODULE_ALIAS("platform:palmas_gpio");
+MODULE_DESCRIPTION("TI PALMAS series GPIO driver");
+MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
+MODULE_LICENSE("GPL");

---
base-commit: b36ddb9210e6812eb1c86ad46b66cc46aa193487
change-id: 20250520-gpio-palmas-gpio-a99fc046dc7f

Best regards,
-- 
Aaron Kling <webgeek1234@gmail.com>



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

* Re: [PATCH] gpio: palmas: Allow building as a module
  2025-05-22 15:52 [PATCH] gpio: palmas: Allow building as a module Aaron Kling via B4 Relay
@ 2025-05-22 17:42 ` Krzysztof Kozlowski
  2025-05-22 22:04   ` Aaron Kling
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-22 17:42 UTC (permalink / raw)
  To: Aaron Kling, Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel

On 22/05/2025 17:52, Aaron Kling wrote:
> The driver works fine as a module, so allowing building as such. This
> drops the driver specific init in favor of the module macro which does
> the same, plus handling exit.
> 
> Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> ---
>  drivers/gpio/Kconfig       |  2 +-
>  drivers/gpio/gpio-palmas.c | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index f2c39bbff83a33dcb12b2d32aa3ebc358a0dd949..be5d823516d0e2bff4b4231dac6a82bf10887118 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -1464,7 +1464,7 @@ config GPIO_MAX77650
>  	  These chips have a single pin that can be configured as GPIO.
>  
>  config GPIO_PALMAS
> -	bool "TI PALMAS series PMICs GPIO"
> +	tristate "TI PALMAS series PMICs GPIO"
>  	depends on MFD_PALMAS
>  	help
>  	  Select this option to enable GPIO driver for the TI PALMAS
> diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
> index 28dba7048509a3ef9c7972c1be53ea30adddabb0..c70782be502b2719bb30cf3e40065c89ecec3cc2 100644
> --- a/drivers/gpio/gpio-palmas.c
> +++ b/drivers/gpio/gpio-palmas.c
> @@ -191,9 +191,9 @@ static struct platform_driver palmas_gpio_driver = {
>  	.driver.of_match_table = of_palmas_gpio_match,
>  	.probe		= palmas_gpio_probe,
>  };
> +module_platform_driver(palmas_gpio_driver);
>  
> -static int __init palmas_gpio_init(void)
> -{
> -	return platform_driver_register(&palmas_gpio_driver);
> -}
> -subsys_initcall(palmas_gpio_init);
> +MODULE_ALIAS("platform:palmas_gpio");


Drop. You miss proper MODULE_DEVICE_TABLE instead. You should not need
MODULE_ALIAS() in normal cases. If you need it, usually it means your
device ID table is wrong (e.g. misses either entries or
MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute for
incomplete ID table.

There is also no user for above alias.

Best regards,
Krzysztof

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

* Re: [PATCH] gpio: palmas: Allow building as a module
  2025-05-22 17:42 ` Krzysztof Kozlowski
@ 2025-05-22 22:04   ` Aaron Kling
  2025-05-23  6:26     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Kling @ 2025-05-22 22:04 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

On Thu, May 22, 2025 at 12:42 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On 22/05/2025 17:52, Aaron Kling wrote:
> > The driver works fine as a module, so allowing building as such. This
> > drops the driver specific init in favor of the module macro which does
> > the same, plus handling exit.
> >
> > Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> > ---
> >  drivers/gpio/Kconfig       |  2 +-
> >  drivers/gpio/gpio-palmas.c | 10 +++++-----
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> > index f2c39bbff83a33dcb12b2d32aa3ebc358a0dd949..be5d823516d0e2bff4b4231dac6a82bf10887118 100644
> > --- a/drivers/gpio/Kconfig
> > +++ b/drivers/gpio/Kconfig
> > @@ -1464,7 +1464,7 @@ config GPIO_MAX77650
> >         These chips have a single pin that can be configured as GPIO.
> >
> >  config GPIO_PALMAS
> > -     bool "TI PALMAS series PMICs GPIO"
> > +     tristate "TI PALMAS series PMICs GPIO"
> >       depends on MFD_PALMAS
> >       help
> >         Select this option to enable GPIO driver for the TI PALMAS
> > diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
> > index 28dba7048509a3ef9c7972c1be53ea30adddabb0..c70782be502b2719bb30cf3e40065c89ecec3cc2 100644
> > --- a/drivers/gpio/gpio-palmas.c
> > +++ b/drivers/gpio/gpio-palmas.c
> > @@ -191,9 +191,9 @@ static struct platform_driver palmas_gpio_driver = {
> >       .driver.of_match_table = of_palmas_gpio_match,
> >       .probe          = palmas_gpio_probe,
> >  };
> > +module_platform_driver(palmas_gpio_driver);
> >
> > -static int __init palmas_gpio_init(void)
> > -{
> > -     return platform_driver_register(&palmas_gpio_driver);
> > -}
> > -subsys_initcall(palmas_gpio_init);
> > +MODULE_ALIAS("platform:palmas_gpio");
>
>
> Drop. You miss proper MODULE_DEVICE_TABLE instead. You should not need
> MODULE_ALIAS() in normal cases. If you need it, usually it means your
> device ID table is wrong (e.g. misses either entries or
> MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute for
> incomplete ID table.

I just copied from the other drivers for this mfd, like clk-palmas,
palmas-regulator, etc. I don't know if there's a reason these others
have aliases or not, but they all have it. I'll update this patch per
the suggestions and send a v2.

Aaron

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

* Re: [PATCH] gpio: palmas: Allow building as a module
  2025-05-22 22:04   ` Aaron Kling
@ 2025-05-23  6:26     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-23  6:26 UTC (permalink / raw)
  To: Aaron Kling; +Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

On 23/05/2025 00:04, Aaron Kling wrote:
>>> +++ b/drivers/gpio/gpio-palmas.c
>>> @@ -191,9 +191,9 @@ static struct platform_driver palmas_gpio_driver = {
>>>       .driver.of_match_table = of_palmas_gpio_match,
>>>       .probe          = palmas_gpio_probe,
>>>  };
>>> +module_platform_driver(palmas_gpio_driver);
>>>
>>> -static int __init palmas_gpio_init(void)
>>> -{
>>> -     return platform_driver_register(&palmas_gpio_driver);
>>> -}
>>> -subsys_initcall(palmas_gpio_init);
>>> +MODULE_ALIAS("platform:palmas_gpio");
>>
>>
>> Drop. You miss proper MODULE_DEVICE_TABLE instead. You should not need
>> MODULE_ALIAS() in normal cases. If you need it, usually it means your
>> device ID table is wrong (e.g. misses either entries or
>> MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute for
>> incomplete ID table.
> 
> I just copied from the other drivers for this mfd, like clk-palmas,
> palmas-regulator, etc. I don't know if there's a reason these others
> have aliases or not, but they all have it. I'll update this patch per
> the suggestions and send a v2.

They might be coming from old board files, so the alias was needed, but
if board files were removed then this does not apply anymore. And I
checked - no user of the alias.

Best regards,
Krzysztof

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

end of thread, other threads:[~2025-05-23  6:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22 15:52 [PATCH] gpio: palmas: Allow building as a module Aaron Kling via B4 Relay
2025-05-22 17:42 ` Krzysztof Kozlowski
2025-05-22 22:04   ` Aaron Kling
2025-05-23  6:26     ` Krzysztof Kozlowski

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