All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: pm8xxx: Attach wake irq to device
@ 2022-02-16 15:24 Loic Poulain
  2022-03-25 10:42 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Loic Poulain @ 2022-02-16 15:24 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni; +Cc: linux-rtc, Loic Poulain

Attach the interrupt as a wake-irq to the device, so that:
- A corresponding wakeup source is created (and reported in e.g
  /sys/kernel/debug/wakeup_sources).
- The power subsystem take cares of arming/disarming
  irq-wake automatically on suspend/resume.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/rtc/rtc-pm8xxx.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 29a1c65..75954dd 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -7,6 +7,7 @@
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
@@ -527,40 +528,28 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
 		return rc;
 	}
 
-	return devm_rtc_register_device(rtc_dd->rtc);
-}
-
-#ifdef CONFIG_PM_SLEEP
-static int pm8xxx_rtc_resume(struct device *dev)
-{
-	struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
+	rc = devm_rtc_register_device(rtc_dd->rtc);
+	if (rc)
+		return rc;
 
-	if (device_may_wakeup(dev))
-		disable_irq_wake(rtc_dd->rtc_alarm_irq);
+	rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->rtc_alarm_irq);
+	if (rc)
+		return rc;
 
 	return 0;
 }
 
-static int pm8xxx_rtc_suspend(struct device *dev)
+static int pm8xxx_remove(struct platform_device *pdev)
 {
-	struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
-
-	if (device_may_wakeup(dev))
-		enable_irq_wake(rtc_dd->rtc_alarm_irq);
-
+	dev_pm_clear_wake_irq(&pdev->dev);
 	return 0;
 }
-#endif
-
-static SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops,
-			 pm8xxx_rtc_suspend,
-			 pm8xxx_rtc_resume);
 
 static struct platform_driver pm8xxx_rtc_driver = {
 	.probe		= pm8xxx_rtc_probe,
+	.remove		= pm8xxx_remove,
 	.driver	= {
 		.name		= "rtc-pm8xxx",
-		.pm		= &pm8xxx_rtc_pm_ops,
 		.of_match_table	= pm8xxx_id_table,
 	},
 };
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: pm8xxx: Attach wake irq to device
  2022-02-16 15:24 [PATCH] rtc: pm8xxx: Attach wake irq to device Loic Poulain
@ 2022-03-25 10:42 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-03-25 10:42 UTC (permalink / raw)
  To: Loic Poulain, a.zummo; +Cc: linux-rtc

On Wed, 16 Feb 2022 16:24:42 +0100, Loic Poulain wrote:
> Attach the interrupt as a wake-irq to the device, so that:
> - A corresponding wakeup source is created (and reported in e.g
>   /sys/kernel/debug/wakeup_sources).
> - The power subsystem take cares of arming/disarming
>   irq-wake automatically on suspend/resume.
> 
> 
> [...]

Applied, thanks!

[1/1] rtc: pm8xxx: Attach wake irq to device
      commit: b5bf5b283d07bd1f4d49657557fb99ec5fbfc588

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-25 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 15:24 [PATCH] rtc: pm8xxx: Attach wake irq to device Loic Poulain
2022-03-25 10:42 ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.