[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=Mew_F9ngFSNSyPL8ecm9ZgivYkbJg-jYghnWPGuy4pwVA@mail.gmail.com>
Date: Fri, 25 Jul 2025 09:13:34 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Alexander Stein <alexander.stein@...tq-group.com>
Cc: Linus Walleij <linus.walleij@...aro.org>, Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 1/1] gpio: stmpe: Allow to compile as a module
On Fri, Jul 25, 2025 at 7:52 AM Alexander Stein
<alexander.stein@...tq-group.com> wrote:
>
> Add the necessary boilerplate to also make this driver modular.
> This follows commit a2b8191ab695a ("pwm: stmpe: Allow to compile as a
> module") which does the same for pwm. Also add OF match table for module
> autoloading.
>
> Signed-off-by: Alexander Stein <alexander.stein@...tq-group.com>
> ---
> drivers/gpio/Kconfig | 2 +-
> drivers/gpio/gpio-stmpe.c | 19 +++++++++++--------
> 2 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 500d839f65ee8..0621832d045fa 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -1559,7 +1559,7 @@ config GPIO_SL28CPLD
> called gpio-sl28cpld.
>
> config GPIO_STMPE
> - bool "STMPE GPIOs"
> + tristate "STMPE GPIOs"
> depends on MFD_STMPE
> depends on OF_GPIO
> select GPIOLIB_IRQCHIP
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 0a270156e0bea..db9f4cd1e8615 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -534,16 +534,19 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
> return devm_gpiochip_add_data(dev, &stmpe_gpio->chip, stmpe_gpio);
> }
>
> +static const struct of_device_id stmpe_gpio_of_matches[] = {
> + { .compatible = "st,stmpe-gpio", },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, stmpe_gpio_of_matches);
> +
> static struct platform_driver stmpe_gpio_driver = {
> .driver = {
> - .suppress_bind_attrs = true,
> - .name = "stmpe-gpio",
> + .name = "stmpe-gpio",
> + .of_match_table = stmpe_gpio_of_matches,
> },
> - .probe = stmpe_gpio_probe,
> };
> +module_platform_driver_probe(stmpe_gpio_driver, stmpe_gpio_probe);
>
> -static int __init stmpe_gpio_init(void)
> -{
> - return platform_driver_register(&stmpe_gpio_driver);
> -}
> -subsys_initcall(stmpe_gpio_init);
Please don't reorder the registration for built-in mode.
Bart
> +MODULE_DESCRIPTION("STMPE expander GPIO");
> +MODULE_LICENSE("GPL");
> --
> 2.43.0
>
Powered by blists - more mailing lists