pm: Introduce devm_pm_set_wake_irq
Subsystems (12)
v2 cover pm: Introduce devm_pm_set_wake_irq
This was a retry to address [1][2], to let common code handle dev_pm_clear_wake_irq. Then no need to call dev_pm_clear_wake_irq in each driver.remove() hook and error handling path.
In this patchset, I include input and rtc patches to show the usage to avoid introducing an API without users. There are still other places using dev_pm_clear_wake_irq. If this patchset is good for you, I could start to clean up other drivers such as mmc and etc.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
---
Changes in v2:
- Add R-b from Linus Walleij. Thanks!
- Export devm_pm_set_wake_irq to fix module build failure.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Peng Fan (12):
PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq
input: keyboard: omap4_keypad: Use devm_pm_set_wake_irq
input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code
input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code
rtc: stm32: Use resource managed API to simplify code
rtc: nxp-bbnsm: Use resource managed API to simplify code
rtc: ds1343: Use devm_pm_set_wake_irq
rtc: pm8xxx: Use devm_pm_set_wake_irq
rtc: ab8500: Use resource managed API to simplify code
rtc: mpfs: Use devm_pm_set_wake_irq
rtc: pl031: Use resource managed API to simplify code
drivers/base/power/wakeirq.c | 26 +++++++++++++++++++ drivers/input/keyboard/ep93xx_keypad.c | 8 +----- drivers/input/keyboard/omap4-keypad.c | 8 +----- drivers/input/misc/nxp-bbnsm-pwrkey.c | 15 ++++------- drivers/input/touchscreen/ti_am335x_tsc.c | 43 ++++++++++--------------------- drivers/rtc/rtc-ab8500.c | 11 ++------ drivers/rtc/rtc-ds1343.c | 8 +----- drivers/rtc/rtc-mpfs.c | 8 +----- drivers/rtc/rtc-nxp-bbnsm.c | 29 +++++++-------------- drivers/rtc/rtc-pl031.c | 6 ++--- drivers/rtc/rtc-pm8xxx.c | 12 +-------- drivers/rtc/rtc-stm32.c | 10 ++----- include/linux/pm_wakeirq.h | 6 +++++ 13 files changed, 71 insertions(+), 119 deletions(-)
---
base-commit: 8155b4ef3466f0e289e8fcc9e6e62f3f4dceeac2
change-id: 20241227-wake_irq-b68d604dd902
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
PATCH v2 1/12 PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
From: Peng Fan <[email protected]>
Add device-managed variant of dev_pm_set_wake_irq which automatically clear the wake irq on device destruction to simplify error handling and resource management in drivers.
--- drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++ include/linux/pm_wakeirq.h | 6 ++++++ 2 files changed, 32 insertions(+)
drivers/base/power/wakeirq.c +26 -0
@@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device *dev) }EXPORT_SYMBOL_GPL (dev_pm_clear_wake_irq); +static void devm_pm_clear_wake_irq (void *dev) +{ +dev_pm_clear_wake_irq (dev); +} + +/** +* devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq +* @dev: Device entry +* @irq: Device IO interrupt +* +* +* Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq, +* but the device will be auto clear wake capability on driver detach. +*/ +int devm_pm_set_wake_irq (struct device *dev,int irq) +{ +int ret; + + ret =dev_pm_set_wake_irq (dev, irq); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, devm_pm_clear_wake_irq, dev); +} +EXPORT_SYMBOL_GPL (devm_pm_set_wake_irq); +/** * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts * @irq: Device specific dedicated wake-up interrupt
include/linux/pm_wakeirq.h +6 -0
@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device *dev, int irq);extern int dev_pm_set_dedicated_wake_irq (struct device *dev,int irq);extern int dev_pm_set_dedicated_wake_irq_reverse (struct device *dev,int irq);extern void dev_pm_clear_wake_irq (struct device *dev); +extern int devm_pm_set_wake_irq (struct device *dev,int irq);#else /* !CONFIG_PM */
@@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq(struct device *dev) { } +static inline int devm_pm_set_wake_irq (struct device *dev,int irq) +{ +return 0 ; +} +#endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */
Signature · 1 line
2.37.1
Rafael J. Wysocki
maintainerRe: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
Quoted 65 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Add device-managed variant of
dev_pm_set_wake_irqwhich automatically clear the wake irq on device destruction to simplify error handling and resource management in drivers.Signed-off-by Peng Fan <[email protected]>--- drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++ include/linux/pm_wakeirq.h | 6 ++++++ 2 files changed, 32 insertions(+)drivers/base/power/wakeirq.c +26
-0@@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device *dev) }EXPORT_SYMBOL_GPL (dev_pm_clear_wake_irq); +static void devm_pm_clear_wake_irq (void *dev) +{ +dev_pm_clear_wake_irq (dev); +} + +/** +* devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq +* @dev: Device entry +* @irq: Device IO interrupt +* +* +* Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq, +* but the device will be auto clear wake capability on driver detach. +*/ +int devm_pm_set_wake_irq (struct device *dev,int irq) +{ +int ret; + + ret =dev_pm_set_wake_irq (dev, irq); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, devm_pm_clear_wake_irq, dev); +} +EXPORT_SYMBOL_GPL (devm_pm_set_wake_irq); +/** * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts * @irq: Device specific dedicated wake-up interrupt include/linux/pm_wakeirq.h +1
-0@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device *dev, int irq);extern int dev_pm_set_dedicated_wake_irq (struct device *dev,int irq);extern int dev_pm_set_dedicated_wake_irq_reverse (struct device *dev,int irq);extern void dev_pm_clear_wake_irq (struct device *dev); +extern int devm_pm_set_wake_irq (struct device *dev,int irq);#else /* !CONFIG_PM */ @@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq(struct device *dev) { }
include/linux/pm_wakeirq.h static inline void dev_pm_clear_wake_irq(struct device *dev)
Quoted 10 lines
include/linux/pm_wakeirq.h +5
-1+static inline int devm_pm_set_wake_irq (struct device *dev,int irq) +{ +return 0 ; +} +#endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */ --
I can apply this patch for 6.14, but the rest of the series will need to be picked up by the respective driver maintainers.
I hope this works for you?
RE: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
Quoted 89 lines
Subject: Re: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device- managed variant of
dev_pm_set_wake_irqQuoted 4 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Add device-managed variant of
dev_pm_set_wake_irqwhichautomatically
Quoted 12 lines
clear the wake irq on device destruction to simplify error handling and resource management in drivers.
Signed-off-by Peng Fan <[email protected]>--- drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++ include/linux/pm_wakeirq.h | 6 ++++++ 2 files changed, 32 insertions(+)(quoted diff) +0
-0
b/drivers/base/power/wakeirq.cindex
5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..8aa28c08b2891f3af490175362ccdrivers/base/power/wakeirq.c void dev_pm_clear_wake_irq(struct device
Quoted 4 lines
1a759069bd50100644drivers/base/power/wakeirq.c +0
-0@@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device*dev) }
Quoted 15 lines
drivers/base/power/wakeirq.c +13
-0EXPORT_SYMBOL_GPL (dev_pm_clear_wake_irq); +static void devm_pm_clear_wake_irq (void *dev) { +dev_pm_clear_wake_irq (dev); +} + +/** +* devm_pm_set_wake_irq - device-managed variant of +dev_pm_set_wake_irq +* @dev: Device entry +* @irq: Device IO interrupt +* +* +* Attach a device IO interrupt as a wake IRQ, same with +dev_pm_set_wake_irq, drivers/base/power/wakeirq.c void dev_pm_clear_wake_irq(struct device *dev)
Quoted 10 lines
drivers/base/power/wakeirq.c +10
-0+* but the device will be auto clear wake capability on driver detach. +*/ +int devm_pm_set_wake_irq (struct device *dev,int irq) { +int ret; + + ret =dev_pm_set_wake_irq (dev, irq); +if (ret) +return ret; + + return devm_add_action_or_reset(dev,
devm_pm_clear_wake_irq,drivers/base/power/wakeirq.c void dev_pm_clear_wake_irq(struct device *dev)
Quoted 4 lines
drivers/base/power/wakeirq.c +2
-0+dev); } EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq); +/** * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts
Quoted 3 lines
drivers/base/power/wakeirq.c +0
-0* @irq: Device specific dedicated wake-up interrupt diff --git
a/include/linux/pm_wakeirq.hb/include/linux/pm_wakeirq.hindex
d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6919f259668ainclude/linux/pm_wakeirq.h extern int dev_pm_set_wake_irq(struct device
Quoted 4 lines
12675330835e100644include/linux/pm_wakeirq.h +0
-0@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device*dev,
include/linux/pm_wakeirq.h static inline void
Quoted 9 lines
int irq); extern int
dev_pm_set_dedicated_wake_irq(struct device *dev, int irq); extern intdev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq); extern voiddev_pm_clear_wake_irq(struct device *dev);include/linux/pm_wakeirq.h +1
-0+extern int devm_pm_set_wake_irq (struct device *dev,int irq);#else /* !CONFIG_PM */ @@ -32,5 +33,10 @@ static inline voiddev_pm_clear_wake_irq(struct
Quoted 9 lines
include/linux/pm_wakeirq.h +4
-0device *dev) { } +static inline int devm_pm_set_wake_irq (struct device *dev,int irq) { +return 0 ; +} +#endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */
Quoted 6 lines
Quoted 1 line
--
I can apply this patch for 6.14, but the rest of the series will need to be picked up by the respective driver maintainers.
I hope this works for you?
Yes. please just pick up patch 1.
Patch [2-12]/12 should go through RTC and INPUT maintainer's tree
Thanks,
Peng.
Rafael J. Wysocki
maintainerRe: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
Quoted 90 lines · Peng Fan
Quoted 90 lines
Subject: Re: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device- managed variant of
dev_pm_set_wake_irqQuoted 4 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Add device-managed variant of
dev_pm_set_wake_irqwhichautomatically
Quoted 12 lines
clear the wake irq on device destruction to simplify error handling and resource management in drivers.
Signed-off-by Peng Fan <[email protected]>--- drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++ include/linux/pm_wakeirq.h | 6 ++++++ 2 files changed, 32 insertions(+)(quoted diff) +0
-0
b/drivers/base/power/wakeirq.cindex
5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..8aa28c08b2891f3af490175362ccdrivers/base/power/wakeirq.c void dev_pm_clear_wake_irq(struct device
Quoted 4 lines
1a759069bd50100644drivers/base/power/wakeirq.c +0
-0@@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device*dev) }
Quoted 15 lines
drivers/base/power/wakeirq.c +13
-0EXPORT_SYMBOL_GPL (dev_pm_clear_wake_irq); +static void devm_pm_clear_wake_irq (void *dev) { +dev_pm_clear_wake_irq (dev); +} + +/** +* devm_pm_set_wake_irq - device-managed variant of +dev_pm_set_wake_irq +* @dev: Device entry +* @irq: Device IO interrupt +* +* +* Attach a device IO interrupt as a wake IRQ, same with +dev_pm_set_wake_irq, drivers/base/power/wakeirq.c void dev_pm_clear_wake_irq(struct device *dev)
Quoted 10 lines
drivers/base/power/wakeirq.c +10
-0+* but the device will be auto clear wake capability on driver detach. +*/ +int devm_pm_set_wake_irq (struct device *dev,int irq) { +int ret; + + ret =dev_pm_set_wake_irq (dev, irq); +if (ret) +return ret; + + return devm_add_action_or_reset(dev,
devm_pm_clear_wake_irq,drivers/base/power/wakeirq.c void dev_pm_clear_wake_irq(struct device *dev)
Quoted 4 lines
drivers/base/power/wakeirq.c +2
-0+dev); } EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq); +/** * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts
Quoted 3 lines
drivers/base/power/wakeirq.c +0
-0* @irq: Device specific dedicated wake-up interrupt diff --git
a/include/linux/pm_wakeirq.hb/include/linux/pm_wakeirq.hindex
d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6919f259668ainclude/linux/pm_wakeirq.h extern int dev_pm_set_wake_irq(struct device
Quoted 4 lines
12675330835e100644include/linux/pm_wakeirq.h +0
-0@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device*dev,
include/linux/pm_wakeirq.h static inline void
Quoted 9 lines
int irq); extern int
dev_pm_set_dedicated_wake_irq(struct device *dev, int irq); extern intdev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq); extern voiddev_pm_clear_wake_irq(struct device *dev);include/linux/pm_wakeirq.h +1
-0+extern int devm_pm_set_wake_irq (struct device *dev,int irq);#else /* !CONFIG_PM */ @@ -32,5 +33,10 @@ static inline voiddev_pm_clear_wake_irq(struct
Quoted 9 lines
include/linux/pm_wakeirq.h +4
-0device *dev) { } +static inline int devm_pm_set_wake_irq (struct device *dev,int irq) { +return 0 ; +} +#endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
--
I can apply this patch for 6.14, but the rest of the series will need to be picked up by the respective driver maintainers.
I hope this works for you?
Yes. please just pick up patch 1.
OK, applied.
Thanks!
PATCH v2 2/12 input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
--- drivers/input/keyboard/ep93xx_keypad.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/input/keyboard/ep93xx_keypad.c +1 -7
@@ -260,18 +260,13 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)platform_set_drvdata (pdev, keypad);device_init_wakeup (&pdev->dev,1 ); - err =dev_pm_set_wake_irq (&pdev->dev, keypad->irq); + err =devm_pm_set_wake_irq (&pdev->dev, keypad->irq);if (err)dev_warn (&pdev->dev,"failed to set up wakeup irq: %d\n" , err);return 0 ; } -static void ep93xx_keypad_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); -} -static const struct of_device_id ep93xx_keypad_of_ids[] = { { .compatible ="cirrus,ep9307-keypad" }, {/* sentinel */ }
@@ -285,7 +280,6 @@ static struct platform_driver ep93xx_keypad_driver = { .of_match_table = ep93xx_keypad_of_ids, }, .probe = ep93xx_keypad_probe, - .remove = ep93xx_keypad_remove, };module_platform_driver (ep93xx_keypad_driver);
Signature · 1 line
2.37.1
PATCH v2 3/12 input: keyboard: omap4_keypad: Use devm_pm_set_wake_irq
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
--- drivers/input/keyboard/omap4-keypad.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/input/keyboard/omap4-keypad.c +1 -7
@@ -465,18 +465,13 @@ static int omap4_keypad_probe(struct platform_device *pdev) }device_init_wakeup (dev, true); - error =dev_pm_set_wake_irq (dev, keypad_data->irq); + error =devm_pm_set_wake_irq (dev, keypad_data->irq);if (error)dev_warn (dev,"failed to set up wakeup irq: %d\n" , error);return 0 ; } -static void omap4_keypad_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); -} -static const struct of_device_id omap_keypad_dt_match[] = { { .compatible ="ti,omap4-keypad" }, {},
@@ -485,7 +480,6 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);static struct platform_driver omap4_keypad_driver = { .probe = omap4_keypad_probe, - .remove = omap4_keypad_remove, .driver = { .name ="omap4-keypad" , .of_match_table = omap_keypad_dt_match,
Signature · 1 line
2.37.1
PATCH v2 4/12 input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the 'driver.remove()' hook.
--- drivers/input/misc/nxp-bbnsm-pwrkey.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/input/misc/nxp-bbnsm-pwrkey.c +5 -10
@@ -179,20 +179,17 @@ static int bbnsm_pwrkey_probe(struct platform_device *pdev)return error; } -device_init_wakeup (&pdev->dev, true); - error =dev_pm_set_wake_irq (&pdev->dev, bbnsm->irq); + error =devm_device_init_wakeup (&pdev->dev); +if (error) +return error; + + error =devm_pm_set_wake_irq (&pdev->dev, bbnsm->irq);if (error)dev_warn (&pdev->dev,"irq wake enable failed.\n" );return 0 ; } -static void bbnsm_pwrkey_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); -} -static int __maybe_unused bbnsm_pwrkey_suspend (struct device *dev) {struct platform_device *pdev =to_platform_device (dev);
@@ -229,8 +226,6 @@ static struct platform_driver bbnsm_pwrkey_driver = { .of_match_table = bbnsm_pwrkey_ids, }, .probe = bbnsm_pwrkey_probe, - .remove = bbnsm_pwrkey_remove, - };module_platform_driver (bbnsm_pwrkey_driver);
Signature · 1 line
2.37.1
PATCH v2 5/12 input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_input_allocate_device/devm_kzalloc/devm_request_irq to simplify code
--- drivers/input/touchscreen/ti_am335x_tsc.c | 43 ++++++++++--------------------- 1 file changed, 14 insertions(+), 29 deletions(-)
drivers/input/touchscreen/ti_am335x_tsc.c +14 -29
@@ -418,12 +418,11 @@ static int titsc_probe(struct platform_device *pdev)int err;/* Allocate memory for device */ - ts_dev =kzalloc (sizeof (*ts_dev),GFP_KERNEL ); - input_dev =input_allocate_device (); + ts_dev =devm_kzalloc (&pdev->dev,sizeof (*ts_dev),GFP_KERNEL ); + input_dev =devm_input_allocate_device (&pdev->dev);if (!ts_dev || !input_dev) {dev_err (&pdev->dev,"failed to allocate memory.\n" ); - err = -ENOMEM ; - goto err_free_mem; +return -ENOMEM ; } tscadc_dev->tsc = ts_dev;
@@ -435,18 +434,21 @@ static int titsc_probe(struct platform_device *pdev) err =titsc_parse_dt (pdev, ts_dev);if (err) {dev_err (&pdev->dev,"Could not find valid DT data.\n" ); - goto err_free_mem; +return err; } - err =request_irq (ts_dev->irq, titsc_irq, -IRQF_SHARED , pdev->dev.driver->name, ts_dev); + err =devm_request_irq (&pdev->dev, ts_dev->irq, titsc_irq,IRQF_SHARED , + pdev->dev.driver->name, ts_dev);if (err) {dev_err (&pdev->dev,"failed to allocate irq.\n" ); - goto err_free_mem; +return err; } -device_init_wakeup (&pdev->dev, true); - err =dev_pm_set_wake_irq (&pdev->dev, ts_dev->irq); + err =devm_device_init_wakeup (&pdev->dev); +if (err) +dev_err (&pdev->dev,"device init wakeup failed.\n" ); + + err =devm_pm_set_wake_irq (&pdev->dev, ts_dev->irq);if (err)dev_err (&pdev->dev,"irq wake enable failed.\n" );
@@ -456,7 +458,7 @@ static int titsc_probe(struct platform_device *pdev) err =titsc_config_wires (ts_dev);if (err) {dev_err (&pdev->dev,"wrong i/p wire configuration\n" ); - goto err_free_irq; +return err; }titsc_step_config (ts_dev); titsc_writel(ts_dev, REG_FIFO0THR,
@@ -475,19 +477,10 @@ static int titsc_probe(struct platform_device *pdev)/* register to the input system */ err =input_register_device (input_dev);if (err) - goto err_free_irq; +return err;platform_set_drvdata (pdev, ts_dev);return 0 ; - -err_free_irq: -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); -free_irq (ts_dev->irq, ts_dev); -err_free_mem: -input_free_device (input_dev); -kfree (ts_dev); -return err; }static void titsc_remove (struct platform_device *pdev)
@@ -495,18 +488,10 @@ static void titsc_remove(struct platform_device *pdev)struct titsc *ts_dev =platform_get_drvdata (pdev);u32 steps; -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); -free_irq (ts_dev->irq, ts_dev); -/* total steps followed by the enable mask */ steps =2 * ts_dev->coordinate_readouts +2 ; steps = (1 << steps) -1 ;am335x_tsc_se_clr (ts_dev->mfd_tscadc, steps); - -input_unregister_device (ts_dev->input); - -kfree (ts_dev); }static int titsc_suspend (struct device *dev)
Signature · 1 line
2.37.1
PATCH v2 6/12 rtc: stm32: Use resource managed API to simplify code
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the error handling code and 'driver.remove()' hook.
--- drivers/rtc/rtc-stm32.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/rtc/rtc-stm32.c +2 -8
@@ -1151,11 +1151,11 @@ static int stm32_rtc_probe(struct platform_device *pdev) goto err; } - ret =device_init_wakeup (&pdev->dev, true); + ret =devm_device_init_wakeup (&pdev->dev);if (ret) goto err; - ret =dev_pm_set_wake_irq (&pdev->dev, rtc->irq_alarm); + ret =devm_pm_set_wake_irq (&pdev->dev, rtc->irq_alarm);if (ret) goto err;
@@ -1216,9 +1216,6 @@ static int stm32_rtc_probe(struct platform_device *pdev)if (rtc->data->need_dbp)regmap_update_bits (rtc->dbp, rtc->dbp_reg, rtc->dbp_mask,0 ); -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); -return ret; }
@@ -1245,9 +1242,6 @@ static void stm32_rtc_remove(struct platform_device *pdev)/* Enable backup domain write protection if needed */ if (rtc->data->need_dbp)regmap_update_bits (rtc->dbp, rtc->dbp_reg, rtc->dbp_mask,0 ); - -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); }static int stm32_rtc_suspend (struct device *dev)
Signature · 1 line
2.37.1
Re: [Linux-stm32] [PATCH v2 06/12] rtc: stm32: Use resource managed API to simplify code
Quoted 7 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Use
devm_pm_set_wake_irqanddevm_device_init_wakeupto cleanup the error handling code and 'driver.remove()' hook.Signed-off-by Peng Fan <[email protected]>---
Thanks,
Antonio
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 7/12 rtc: nxp-bbnsm: Use resource managed API to simplify code
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the error handling code and 'driver.remove()' hook.
--- drivers/rtc/rtc-nxp-bbnsm.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/rtc/rtc-nxp-bbnsm.c +9 -20
@@ -189,36 +189,26 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)/* clear all the pending events */ regmap_write (bbnsm->regmap,BBNSM_EVENTS ,0x7A ); -device_init_wakeup (&pdev->dev, true); -dev_pm_set_wake_irq (&pdev->dev, bbnsm->irq); + ret =devm_device_init_wakeup (&pdev->dev); +if (ret) +dev_err (&pdev->dev,"failed to init wakeup, %d\n" , ret); + + ret =devm_pm_set_wake_irq (&pdev->dev, bbnsm->irq); +if (ret) +dev_err (&pdev->dev,"failed to set wake irq, %d\n" , ret); ret =devm_request_irq (&pdev->dev, bbnsm->irq, bbnsm_rtc_irq_handler,IRQF_SHARED ,"rtc alarm" , &pdev->dev);if (ret) {dev_err (&pdev->dev,"failed to request irq %d: %d\n" , bbnsm->irq, ret); - goto err; +return ret; } bbnsm->rtc->ops = &bbnsm_rtc_ops; bbnsm->rtc->range_max =U32_MAX ; - ret =devm_rtc_register_device (bbnsm->rtc); -if (ret) - goto err; - -return 0 ; - -err: -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); -return ret; -} - -static void bbnsm_rtc_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); +return devm_rtc_register_device (bbnsm->rtc); }static const struct of_device_id bbnsm_dt_ids[] = {
@@ -233,7 +223,6 @@ static struct platform_driver bbnsm_rtc_driver = { .of_match_table = bbnsm_dt_ids, }, .probe = bbnsm_rtc_probe, - .remove = bbnsm_rtc_remove, };module_platform_driver (bbnsm_rtc_driver);
Signature · 1 line
2.37.1
PATCH v2 8/12 rtc: ds1343: Use devm_pm_set_wake_irq
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
--- drivers/rtc/rtc-ds1343.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/rtc/rtc-ds1343.c +1 -7
@@ -427,18 +427,13 @@ static int ds1343_probe(struct spi_device *spi) "unable to request irq for rtc ds1343\n"); }else {device_init_wakeup (&spi->dev, true); -dev_pm_set_wake_irq (&spi->dev, spi->irq); +devm_pm_set_wake_irq (&spi->dev, spi->irq); } }return 0 ; } -static void ds1343_remove (struct spi_device *spi) -{ -dev_pm_clear_wake_irq (&spi->dev); -} -#ifdef CONFIG_PM_SLEEP static int ds1343_suspend (struct device *dev)
@@ -471,7 +466,6 @@ static struct spi_driver ds1343_driver = { .pm = &ds1343_pm, }, .probe = ds1343_probe, - .remove = ds1343_remove, .id_table = ds1343_id, };
Signature · 1 line
2.37.1
PATCH v2 9/12 rtc: pm8xxx: Use devm_pm_set_wake_irq
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
--- drivers/rtc/rtc-pm8xxx.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/rtc/rtc-pm8xxx.c +1 -11
@@ -523,21 +523,11 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)if (rc)return rc; - rc =dev_pm_set_wake_irq (&pdev->dev, rtc_dd->alarm_irq); -if (rc) -return rc; - -return 0 ; -} - -static void pm8xxx_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); +return devm_pm_set_wake_irq (&pdev->dev, rtc_dd->alarm_irq); }static struct platform_driver pm8xxx_rtc_driver = { .probe = pm8xxx_rtc_probe, - .remove = pm8xxx_remove, .driver = { .name ="rtc-pm8xxx" , .of_match_table = pm8xxx_id_table,
Signature · 1 line
2.37.1
Re: [PATCH v2 09/12] rtc: pm8xxx: Use devm_pm_set_wake_irq
Quoted 5 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Use
devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.Signed-off-by Peng Fan <[email protected]>
Yours,
Linus Walleij
PATCH v2 10/12 rtc: ab8500: Use resource managed API to simplify code
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the error handling code and 'driver.remove()' hook.
--- drivers/rtc/rtc-ab8500.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/rtc/rtc-ab8500.c +2 -9
@@ -361,7 +361,7 @@ static int ab8500_rtc_probe(struct platform_device *pdev)return -ENODEV ; } -device_init_wakeup (&pdev->dev, true); +devm_device_init_wakeup (&pdev->dev); rtc =devm_rtc_allocate_device (&pdev->dev);if (IS_ERR (rtc))
@@ -375,7 +375,7 @@ static int ab8500_rtc_probe(struct platform_device *pdev)if (err <0 )return err; -dev_pm_set_wake_irq (&pdev->dev, irq); +devm_pm_set_wake_irq (&pdev->dev, irq);platform_set_drvdata (pdev, rtc);set_bit (RTC_FEATURE_ALARM_RES_MINUTE , rtc->features);
@@ -392,18 +392,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev)return devm_rtc_register_device (rtc); } -static void ab8500_rtc_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); -device_init_wakeup (&pdev->dev, false); -} -static struct platform_driver ab8500_rtc_driver = { .driver = { .name ="ab8500-rtc" , }, .probe = ab8500_rtc_probe, - .remove = ab8500_rtc_remove, .id_table = ab85xx_rtc_ids, };
Signature · 1 line
2.37.1
PATCH v2 11/12 rtc: mpfs: Use devm_pm_set_wake_irq
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
--- drivers/rtc/rtc-mpfs.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/rtc/rtc-mpfs.c +1 -7
@@ -267,18 +267,13 @@ static int mpfs_rtc_probe(struct platform_device *pdev)dev_info (&pdev->dev,"prescaler set to: %lu\n" , prescaler);device_init_wakeup (&pdev->dev, true); - ret =dev_pm_set_wake_irq (&pdev->dev, wakeup_irq); + ret =devm_pm_set_wake_irq (&pdev->dev, wakeup_irq);if (ret)dev_err (&pdev->dev,"failed to enable irq wake\n" );return devm_rtc_register_device (rtcdev->rtc); } -static void mpfs_rtc_remove (struct platform_device *pdev) -{ -dev_pm_clear_wake_irq (&pdev->dev); -} -static const struct of_device_id mpfs_rtc_of_match[] = { { .compatible ="microchip,mpfs-rtc" }, { }
@@ -288,7 +283,6 @@ MODULE_DEVICE_TABLE(of, mpfs_rtc_of_match);static struct platform_driver mpfs_rtc_driver = { .probe = mpfs_rtc_probe, - .remove = mpfs_rtc_remove, .driver = { .name ="mpfs_rtc" , .of_match_table = mpfs_rtc_of_match,
Signature · 1 line
2.37.1
PATCH v2 12/12 rtc: pl031: Use resource managed API to simplify code
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the error handling code and 'driver.remove()' hook.
--- drivers/rtc/rtc-pl031.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/rtc/rtc-pl031.c +2 -4
@@ -284,8 +284,6 @@ static void pl031_remove(struct amba_device *adev) {struct pl031_local *ldata =dev_get_drvdata (&adev->dev); -dev_pm_clear_wake_irq (&adev->dev); -device_init_wakeup (&adev->dev, false);if (adev->irq[0 ])free_irq (adev->irq[0 ], ldata);amba_release_regions (adev);
@@ -350,7 +348,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) } } -device_init_wakeup (&adev->dev, true); +devm_device_init_wakeup (&adev->dev); ldata->rtc =devm_rtc_allocate_device (&adev->dev);if (IS_ERR (ldata->rtc)) { ret =PTR_ERR (ldata->rtc);
@@ -373,7 +371,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) vendor->irqflags, "rtc-pl031", ldata);if (ret) goto out; -dev_pm_set_wake_irq (&adev->dev, adev->irq[0 ]); +devm_pm_set_wake_irq (&adev->dev, adev->irq[0 ]); }return 0 ;
Signature · 1 line
2.37.1
Hi Alexandre, Dmitry
Quoted 3 lines · Peng Fan (OSS)
This was a retry to address [1][2], to let common code handle
dev_pm_clear_wake_irq. Then no need to calldev_pm_clear_wake_irqin eachdriver.remove()hook and error handling path.
Patch 1 has been accepted into pm tree.
For the rtc and input patches, are you ok with them?
Thanks,
Peng
This series was applied to riscv/linux.git (fixes) by Rafael J. Wysocki <[email protected]>:
Hello:
This series was applied to riscv/linux.git (fixes) by Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · On Fri, 03 Jan 2025 16:41:12 +0800 you wrote:
This was a retry to address [1][2], to let common code handle
dev_pm_clear_wake_irq. Then no need to calldev_pm_clear_wake_irqin eachdriver.remove()hook and error handling path.In this patchset, I include input and rtc patches to show the usage to avoid introducing an API without users. There are still other places using
dev_pm_clear_wake_irq. If this patchset is good for you, I could start to clean up other drivers such as mmc and etc.[...]
Here is the summary with links:
- [v2,01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
https://git.kernel.org/riscv/c/fd8318a32573
- [v2,02/12] input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,03/12] input: keyboard: omap4_keypad: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,04/12] input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code (no matching commit)
- [v2,05/12] input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code (no matching commit)
- [v2,06/12] rtc: stm32: Use resource managed API to simplify code
(no matching commit)
- [v2,07/12] rtc: nxp-bbnsm: Use resource managed API to simplify code
(no matching commit)
- [v2,08/12] rtc: ds1343: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,09/12] rtc: pm8xxx: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,10/12] rtc: ab8500: Use resource managed API to simplify code
(no matching commit)
- [v2,11/12] rtc: mpfs: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,12/12] rtc: pl031: Use resource managed API to simplify code
(no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html