diff options
| author | Uwe Kleine-König <[email protected]> | 2025-02-15 14:37:22 +0000 |
|---|---|---|
| committer | Uwe Kleine-König <[email protected]> | 2025-03-03 09:38:54 +0000 |
| commit | a2b8191ab695ab4dacd1b923a757e9b548760cec (patch) | |
| tree | eb374f83e75ec74c4dcb46f65e6bbfef654835f3 /drivers/pwm/pwm-stmpe.c | |
| parent | pwm: Check for CONFIG_PWM using IS_REACHABLE() in main header (diff) | |
| download | kernel-a2b8191ab695ab4dacd1b923a757e9b548760cec.tar.gz kernel-a2b8191ab695ab4dacd1b923a757e9b548760cec.zip | |
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Diffstat (limited to 'drivers/pwm/pwm-stmpe.c')
| -rw-r--r-- | drivers/pwm/pwm-stmpe.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c index bb91062d5f1d..73f12843999a 100644 --- a/drivers/pwm/pwm-stmpe.c +++ b/drivers/pwm/pwm-stmpe.c @@ -326,12 +326,33 @@ static int __init stmpe_pwm_probe(struct platform_device *pdev) return ret; } + platform_set_drvdata(pdev, chip); + return 0; } -static struct platform_driver stmpe_pwm_driver = { +static void __exit stmpe_pwm_remove(struct platform_device *pdev) +{ + struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); + struct pwm_chip *chip = platform_get_drvdata(pdev); + + pwmchip_remove(chip); + stmpe_disable(stmpe, STMPE_BLOCK_PWM); +} + +/* + * stmpe_pwm_remove() lives in .exit.text. For drivers registered via + * module_platform_driver_probe() this is ok because they cannot get unbound at + * runtime. So mark the driver struct with __refdata to prevent modpost + * triggering a section mismatch warning. + */ +static struct platform_driver stmpe_pwm_driver __refdata = { .driver = { .name = "stmpe-pwm", }, + .remove = __exit_p(stmpe_pwm_remove), }; -builtin_platform_driver_probe(stmpe_pwm_driver, stmpe_pwm_probe); +module_platform_driver_probe(stmpe_pwm_driver, stmpe_pwm_probe); + +MODULE_DESCRIPTION("STMPE expander PWM"); +MODULE_LICENSE("GPL"); |
