Skip to content

Commit a2b8191

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: stmpe: Allow to compile as a module
pwm-stmpe is the only driver that cannot be built as a module. Add the necessary boilerplate to also make this driver modular. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/20250215143723.636591-2-u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
1 parent 4b31eb5 commit a2b8191

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

drivers/pwm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ config PWM_STM32_LP
646646
will be called pwm-stm32-lp.
647647

648648
config PWM_STMPE
649-
bool "STMPE expander PWM export"
649+
tristate "STMPE expander PWM export"
650650
depends on MFD_STMPE
651651
help
652652
This enables support for the PWMs found in the STMPE I/O

drivers/pwm/pwm-stmpe.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,33 @@ static int __init stmpe_pwm_probe(struct platform_device *pdev)
326326
return ret;
327327
}
328328

329+
platform_set_drvdata(pdev, chip);
330+
329331
return 0;
330332
}
331333

332-
static struct platform_driver stmpe_pwm_driver = {
334+
static void __exit stmpe_pwm_remove(struct platform_device *pdev)
335+
{
336+
struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
337+
struct pwm_chip *chip = platform_get_drvdata(pdev);
338+
339+
pwmchip_remove(chip);
340+
stmpe_disable(stmpe, STMPE_BLOCK_PWM);
341+
}
342+
343+
/*
344+
* stmpe_pwm_remove() lives in .exit.text. For drivers registered via
345+
* module_platform_driver_probe() this is ok because they cannot get unbound at
346+
* runtime. So mark the driver struct with __refdata to prevent modpost
347+
* triggering a section mismatch warning.
348+
*/
349+
static struct platform_driver stmpe_pwm_driver __refdata = {
333350
.driver = {
334351
.name = "stmpe-pwm",
335352
},
353+
.remove = __exit_p(stmpe_pwm_remove),
336354
};
337-
builtin_platform_driver_probe(stmpe_pwm_driver, stmpe_pwm_probe);
355+
module_platform_driver_probe(stmpe_pwm_driver, stmpe_pwm_probe);
356+
357+
MODULE_DESCRIPTION("STMPE expander PWM");
358+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)