mfd: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Subsystems (4)
PATCH RESEND v2 1/1 mfd: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Convert the deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This allows us to drop the __maybe_unused annotations from PM callbacks. This is a straightforward cleanup with no functional change intended.
---
Changes in v2:
- Change commit message prefix from "drivers/mfd: " to "mfd: ".
- Wrap to 75 ish chars for commit messages.
Link to v1: https://lore.kernel.org/all/[email protected]/
Link to v2: https://lore.kernel.org/all/[email protected]/
--- drivers/mfd/iqs62x.c | 8 ++++---- drivers/mfd/max77843.c | 8 ++++---- drivers/mfd/mt6360-core.c | 8 ++++---- drivers/mfd/rk8xx-i2c.c | 4 ++-- drivers/mfd/rn5t618.c | 8 ++++---- drivers/mfd/ti_am335x_tscadc.c | 8 ++++---- drivers/mfd/tps6586x.c | 8 ++++---- drivers/mfd/twl-core.c | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-)
drivers/mfd/iqs62x.c +4 -4
@@ -1015,7 +1015,7 @@ static void iqs62x_remove(struct i2c_client *client)wait_for_completion (&iqs62x->fw_done); } -static int __maybe_unused iqs62x_suspend (struct device *dev) +static int iqs62x_suspend (struct device *dev) {struct iqs62x_core *iqs62x =dev_get_drvdata (dev);int ret;
@@ -1036,7 +1036,7 @@ static int __maybe_unused iqs62x_suspend(struct device *dev) IQS62X_PWR_SETTINGS_PWR_MODE_HALT); } -static int __maybe_unused iqs62x_resume (struct device *dev) +static int iqs62x_resume (struct device *dev) {struct iqs62x_core *iqs62x =dev_get_drvdata (dev);int ret;
@@ -1051,7 +1051,7 @@ static int __maybe_unused iqs62x_resume(struct device *dev) IQS62X_PWR_SETTINGS_DIS_AUTO, 0); } -static SIMPLE_DEV_PM_OPS(iqs62x_pm, iqs62x_suspend, iqs62x_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(iqs62x_pm, iqs62x_suspend, iqs62x_resume);static const struct of_device_id iqs62x_of_match[] = { { .compatible ="azoteq,iqs620a" },
@@ -1067,7 +1067,7 @@ static struct i2c_driver iqs62x_i2c_driver = { .driver = { .name = "iqs62x", .of_match_table = iqs62x_of_match, - .pm = &iqs62x_pm, + .pm = pm_sleep_ptr(&iqs62x_pm), }, .probe = iqs62x_probe, .remove = iqs62x_remove,
drivers/mfd/max77843.c +4 -4
@@ -173,7 +173,7 @@ static const struct i2c_device_id max77843_id[] = { { }, }; -static int __maybe_unused max77843_suspend (struct device *dev) +static int max77843_suspend (struct device *dev) {struct i2c_client *i2c =to_i2c_client (dev);struct max77693_dev *max77843 =i2c_get_clientdata (i2c);
@@ -185,7 +185,7 @@ static int __maybe_unused max77843_suspend(struct device *dev)return 0 ; } -static int __maybe_unused max77843_resume (struct device *dev) +static int max77843_resume (struct device *dev) {struct i2c_client *i2c =to_i2c_client (dev);struct max77693_dev *max77843 =i2c_get_clientdata (i2c);
@@ -197,12 +197,12 @@ static int __maybe_unused max77843_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(max77843_pm, max77843_suspend, max77843_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max77843_pm, max77843_suspend, max77843_resume);static struct i2c_driver max77843_i2c_driver = { .driver = { .name ="max77843" , - .pm = &max77843_pm, + .pm =pm_sleep_ptr (&max77843_pm), .of_match_table = max77843_dt_match, .suppress_bind_attrs = true, },
drivers/mfd/mt6360-core.c +4 -4
@@ -583,7 +583,7 @@ static int mt6360_probe(struct i2c_client *client)return 0 ; } -static int __maybe_unused mt6360_suspend (struct device *dev) +static int mt6360_suspend (struct device *dev) {struct i2c_client *i2c =to_i2c_client (dev);
@@ -593,7 +593,7 @@ static int __maybe_unused mt6360_suspend(struct device *dev)return 0 ; } -static int __maybe_unused mt6360_resume (struct device *dev) +static int mt6360_resume (struct device *dev) {struct i2c_client *i2c =to_i2c_client (dev);
@@ -604,7 +604,7 @@ static int __maybe_unused mt6360_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(mt6360_pm_ops, mt6360_suspend, mt6360_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(mt6360_pm_ops, mt6360_suspend, mt6360_resume);static const struct of_device_id __maybe_unused mt6360_of_id[] = { { .compatible ="mediatek,mt6360" , },
@@ -615,7 +615,7 @@ MODULE_DEVICE_TABLE(of, mt6360_of_id);static struct i2c_driver mt6360_driver = { .driver = { .name ="mt6360" , - .pm = &mt6360_pm_ops, + .pm =pm_sleep_ptr (&mt6360_pm_ops), .of_match_table =of_match_ptr (mt6360_of_id), }, .probe = mt6360_probe,
drivers/mfd/rk8xx-i2c.c +2 -2
@@ -251,7 +251,7 @@ static void rk8xx_i2c_shutdown(struct i2c_client *client)rk8xx_shutdown (&client->dev); } -static SIMPLE_DEV_PM_OPS(rk8xx_i2c_pm_ops, rk8xx_suspend, rk8xx_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(rk8xx_i2c_pm_ops, rk8xx_suspend, rk8xx_resume);static const struct of_device_id rk8xx_i2c_of_match[] = { { .compatible ="rockchip,rk801" , .data = &rk801_data },
@@ -270,7 +270,7 @@ static struct i2c_driver rk8xx_i2c_driver = { .driver = { .name = "rk8xx-i2c", .of_match_table = rk8xx_i2c_of_match, - .pm = &rk8xx_i2c_pm_ops, + .pm = pm_sleep_ptr(&rk8xx_i2c_pm_ops), }, .probe = rk8xx_i2c_probe, .shutdown = rk8xx_i2c_shutdown,
drivers/mfd/rn5t618.c +4 -4
@@ -243,7 +243,7 @@ static void rn5t618_i2c_remove(struct i2c_client *i2c)unregister_restart_handler (&rn5t618_restart_handler); } -static int __maybe_unused rn5t618_i2c_suspend (struct device *dev) +static int rn5t618_i2c_suspend (struct device *dev) {struct rn5t618 *priv =dev_get_drvdata (dev);
@@ -253,7 +253,7 @@ static int __maybe_unused rn5t618_i2c_suspend(struct device *dev)return 0 ; } -static int __maybe_unused rn5t618_i2c_resume (struct device *dev) +static int rn5t618_i2c_resume (struct device *dev) {struct rn5t618 *priv =dev_get_drvdata (dev);
@@ -263,7 +263,7 @@ static int __maybe_unused rn5t618_i2c_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(rn5t618_i2c_dev_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(rn5t618_i2c_dev_pm_ops, rn5t618_i2c_suspend, rn5t618_i2c_resume);
@@ -271,7 +271,7 @@ static struct i2c_driver rn5t618_i2c_driver = { .driver = { .name = "rn5t618", .of_match_table = rn5t618_of_match, - .pm = &rn5t618_i2c_dev_pm_ops, + .pm = pm_sleep_ptr(&rn5t618_i2c_dev_pm_ops), }, .probe = rn5t618_i2c_probe, .remove = rn5t618_i2c_remove,
drivers/mfd/ti_am335x_tscadc.c +4 -4
@@ -313,7 +313,7 @@ static int __maybe_unused ti_tscadc_can_wakeup(struct device *dev, void *data)return device_may_wakeup (dev); } -static int __maybe_unused tscadc_suspend (struct device *dev) +static int tscadc_suspend (struct device *dev) {struct ti_tscadc_dev *tscadc =dev_get_drvdata (dev);
@@ -331,7 +331,7 @@ static int __maybe_unused tscadc_suspend(struct device *dev)return 0 ; } -static int __maybe_unused tscadc_resume (struct device *dev) +static int tscadc_resume (struct device *dev) {struct ti_tscadc_dev *tscadc =dev_get_drvdata (dev);
@@ -345,7 +345,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);static const struct ti_tscadc_data tscdata = { .adc_feature_name ="TI-am335x-adc" ,
@@ -373,7 +373,7 @@ MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids);static struct platform_driver ti_tscadc_driver = { .driver = { .name ="ti_am3359-tscadc" , - .pm = &tscadc_pm_ops, + .pm =pm_sleep_ptr (&tscadc_pm_ops), .of_match_table = ti_tscadc_dt_ids, }, .probe = ti_tscadc_probe,
drivers/mfd/tps6586x.c +4 -4
@@ -618,7 +618,7 @@ static void tps6586x_i2c_remove(struct i2c_client *client)free_irq (client->irq, tps6586x); } -static int __maybe_unused tps6586x_i2c_suspend (struct device *dev) +static int tps6586x_i2c_suspend (struct device *dev) {struct tps6586x *tps6586x =dev_get_drvdata (dev);
@@ -628,7 +628,7 @@ static int __maybe_unused tps6586x_i2c_suspend(struct device *dev)return 0 ; } -static int __maybe_unused tps6586x_i2c_resume (struct device *dev) +static int tps6586x_i2c_resume (struct device *dev) {struct tps6586x *tps6586x =dev_get_drvdata (dev);
@@ -638,7 +638,7 @@ static int __maybe_unused tps6586x_i2c_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_i2c_suspend, +static DEFINE_SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_i2c_suspend, tps6586x_i2c_resume);static const struct i2c_device_id tps6586x_id_table[] = {
@@ -651,7 +651,7 @@ static struct i2c_driver tps6586x_driver = { .driver = { .name = "tps6586x", .of_match_table = of_match_ptr(tps6586x_of_match), - .pm = &tps6586x_pm_ops, + .pm = pm_sleep_ptr(&tps6586x_pm_ops), }, .probe = tps6586x_i2c_probe, .remove = tps6586x_i2c_remove,
drivers/mfd/twl-core.c +4 -4
@@ -903,7 +903,7 @@ twl_probe(struct i2c_client *client)return status; } -static int __maybe_unused twl_suspend (struct device *dev) +static int twl_suspend (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -913,7 +913,7 @@ static int __maybe_unused twl_suspend(struct device *dev)return 0 ; } -static int __maybe_unused twl_resume (struct device *dev) +static int twl_resume (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -923,7 +923,7 @@ static int __maybe_unused twl_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(twl_dev_pm_ops, twl_suspend, twl_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(twl_dev_pm_ops, twl_suspend, twl_resume);static const struct i2c_device_id twl_ids[] = { {"twl4030" ,TWL4030_VAUX2 },/* "Triton 2" */
@@ -942,7 +942,7 @@ static const struct i2c_device_id twl_ids[] = {/* One Client Driver , 4 Clients */ static struct i2c_driver twl_driver = { .driver.name =DRIVER_NAME , - .driver.pm = &twl_dev_pm_ops, + .driver.pm =pm_sleep_ptr (&twl_dev_pm_ops), .id_table = twl_ids, .probe = twl_probe, .remove = twl_remove,
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] rn5t618 PMIC probe leaves restart handler and power-off callback registered on failure. --
commit 29ccad5e24cd4a702e3d9e1445050ff871b456b5
Author: Triet Hoang <[email protected]>
mfd: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
This commit converts the deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and uses pm_sleep_ptr() across several MFD drivers. It also cleans up the __maybe_unused annotations from PM callbacks since they are no longer necessary.
[ ... ]
drivers/mfd/rn5t618.c
Quoted 4 lines
drivers/mfd/rn5t618.c +0
-0
[Severity: High]
This is a pre-existing issue, but while reviewing this file I noticed that although rn5t618_i2c_remove() cleans up global callbacks, rn5t618_i2c_probe() can return an error without doing the same.
In rn5t618_i2c_probe(), the driver registers a global power-off callback (pm_power_off) and a restart handler via register_restart_handler(). Immediately after, it initializes IRQs:
return rn5t618_irq_init(priv);
If rn5t618_irq_init() fails (for example, returning -ENOENT for unsupported variants, or if IRQ chip registration fails), the probe function returns the error directly. It does not unregister the restart handler or clear pm_power_off.
Could this lead to a kernel crash? If the probe fails, the driver is not bound and the module can be unloaded, leaving dangling function pointers in the global system state. A subsequent system reboot or power-off would then execute these invalid pointers.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Lee Jones
maintainerQuoted 14 lines · Triet Hoang
Convert the deprecated
SIMPLE_DEV_PM_OPS()toDEFINE_SIMPLE_DEV_PM_OPS()andpm_sleep_ptr().This allows us to drop the
__maybe_unusedannotations from PM callbacks. This is a straightforward cleanup with no functional change intended.Signed-off-by Triet Hoang <[email protected]>---
Changes in v2:
- Change commit message prefix from "drivers/mfd: " to "mfd: ".
- Wrap to 75 ish chars for commit messages.Link to v1: https://lore.kernel.org/all/[email protected]/
Link to v2: https://lore.kernel.org/all/[email protected]/
Quoted 10 lines
--- drivers/mfd/iqs62x.c | 8 ++++---- drivers/mfd/max77843.c | 8 ++++---- drivers/mfd/mt6360-core.c | 8 ++++---- drivers/mfd/rk8xx-i2c.c | 4 ++-- drivers/mfd/rn5t618.c | 8 ++++---- drivers/mfd/ti_am335x_tscadc.c | 8 ++++---- drivers/mfd/tps6586x.c | 8 ++++---- drivers/mfd/twl-core.c | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-)
Already applied.
Signature · 1 line
Lee Jones