linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: snvs: use dev_pm_set_wake_irq() to simplify code
@ 2019-03-27  6:18 Anson Huang
  2019-04-01 15:28 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Anson Huang @ 2019-03-27  6:18 UTC (permalink / raw)
  To: a.zummo@towertech.it, alexandre.belloni@bootlin.com,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
  Cc: dl-linux-imx

With calling dev_pm_set_wake_irq() to set SNVS RTC as wakeup
source for suspend, generic wake irq mechanism will automatically
enable it as wakeup source when suspend, then the suspend/resume
callback which are ONLY for enabling/disabling irq wake can be
removed, it simplifies the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/rtc/rtc-snvs.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index 0b9eff1..ce73eab 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -9,6 +9,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/rtc.h>
 #include <linux/clk.h>
 #include <linux/mfd/syscon.h>
@@ -332,6 +333,9 @@ static int snvs_rtc_probe(struct platform_device *pdev)
 	}
 
 	device_init_wakeup(&pdev->dev, true);
+	ret = dev_pm_set_wake_irq(&pdev->dev, data->irq);
+	if (ret)
+		dev_err(&pdev->dev, "failed to enable irq wake\n");
 
 	ret = devm_request_irq(&pdev->dev, data->irq, snvs_rtc_irq_handler,
 			       IRQF_SHARED, "rtc alarm", &pdev->dev);
@@ -359,15 +363,6 @@ static int snvs_rtc_probe(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
-static int snvs_rtc_suspend(struct device *dev)
-{
-	struct snvs_rtc_data *data = dev_get_drvdata(dev);
-
-	if (device_may_wakeup(dev))
-		return enable_irq_wake(data->irq);
-
-	return 0;
-}
 
 static int snvs_rtc_suspend_noirq(struct device *dev)
 {
@@ -379,16 +374,6 @@ static int snvs_rtc_suspend_noirq(struct device *dev)
 	return 0;
 }
 
-static int snvs_rtc_resume(struct device *dev)
-{
-	struct snvs_rtc_data *data = dev_get_drvdata(dev);
-
-	if (device_may_wakeup(dev))
-		return disable_irq_wake(data->irq);
-
-	return 0;
-}
-
 static int snvs_rtc_resume_noirq(struct device *dev)
 {
 	struct snvs_rtc_data *data = dev_get_drvdata(dev);
@@ -400,9 +385,7 @@ static int snvs_rtc_resume_noirq(struct device *dev)
 }
 
 static const struct dev_pm_ops snvs_rtc_pm_ops = {
-	.suspend = snvs_rtc_suspend,
 	.suspend_noirq = snvs_rtc_suspend_noirq,
-	.resume = snvs_rtc_resume,
 	.resume_noirq = snvs_rtc_resume_noirq,
 };
 
-- 
2.7.4


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

* Re: [PATCH] rtc: snvs: use dev_pm_set_wake_irq() to simplify code
  2019-03-27  6:18 [PATCH] rtc: snvs: use dev_pm_set_wake_irq() to simplify code Anson Huang
@ 2019-04-01 15:28 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2019-04-01 15:28 UTC (permalink / raw)
  To: Anson Huang
  Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org,
	linux-kernel@vger.kernel.org, dl-linux-imx

On 27/03/2019 06:18:20+0000, Anson Huang wrote:
> With calling dev_pm_set_wake_irq() to set SNVS RTC as wakeup
> source for suspend, generic wake irq mechanism will automatically
> enable it as wakeup source when suspend, then the suspend/resume
> callback which are ONLY for enabling/disabling irq wake can be
> removed, it simplifies the code.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
>  drivers/rtc/rtc-snvs.c | 25 ++++---------------------
>  1 file changed, 4 insertions(+), 21 deletions(-)
> 
Applied, thanks.

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

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

end of thread, other threads:[~2019-04-01 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-27  6:18 [PATCH] rtc: snvs: use dev_pm_set_wake_irq() to simplify code Anson Huang
2019-04-01 15:28 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).