Skip to content

Commit 03db20a

Browse files
tq-steinaBartosz Golaszewski
authored andcommitted
gpio: stmpe: Allow to compile as a module
Add the necessary boilerplate to also make this driver modular. Keep the subsys_initcall to not change registration order for built-in. Also add OF match table for module autoloading. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Link: https://lore.kernel.org/r/20250728060544.18169-1-alexander.stein@ew.tq-group.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 8f5ae30 commit 03db20a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

drivers/gpio/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ config GPIO_SL28CPLD
15591559
called gpio-sl28cpld.
15601560

15611561
config GPIO_STMPE
1562-
bool "STMPE GPIOs"
1562+
tristate "STMPE GPIOs"
15631563
depends on MFD_STMPE
15641564
depends on OF_GPIO
15651565
select GPIOLIB_IRQCHIP

drivers/gpio/gpio-stmpe.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,16 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
534534
return devm_gpiochip_add_data(dev, &stmpe_gpio->chip, stmpe_gpio);
535535
}
536536

537+
static const struct of_device_id stmpe_gpio_of_matches[] = {
538+
{ .compatible = "st,stmpe-gpio", },
539+
{ /* sentinel */ }
540+
};
541+
MODULE_DEVICE_TABLE(of, stmpe_gpio_of_matches);
542+
537543
static struct platform_driver stmpe_gpio_driver = {
538544
.driver = {
539-
.suppress_bind_attrs = true,
540-
.name = "stmpe-gpio",
545+
.name = "stmpe-gpio",
546+
.of_match_table = stmpe_gpio_of_matches,
541547
},
542548
.probe = stmpe_gpio_probe,
543549
};
@@ -547,3 +553,13 @@ static int __init stmpe_gpio_init(void)
547553
return platform_driver_register(&stmpe_gpio_driver);
548554
}
549555
subsys_initcall(stmpe_gpio_init);
556+
557+
static void __exit stmpe_gpio_exit(void)
558+
{
559+
platform_driver_unregister(&stmpe_gpio_driver);
560+
}
561+
module_exit(stmpe_gpio_exit);
562+
563+
MODULE_DESCRIPTION("STMPE expander GPIO");
564+
MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");
565+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)