summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-snvs.c
diff options
context:
space:
mode:
authorAnson Huang <anson.huang@nxp.com>2019-03-27 06:18:20 +0000
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-04-04 10:07:11 +0200
commite7afddb2b4d24fba318f5e74216bae06dcb36a10 (patch)
tree921ca809c9d11d83b4cd4fea831ca735981b5c12 /drivers/rtc/rtc-snvs.c
parent184a182ed52a9b224cfa081a01e920c6ab1ce0bd (diff)
rtc: snvs: use dev_pm_set_wake_irq() to simplify code
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> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-snvs.c')
-rw-r--r--drivers/rtc/rtc-snvs.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index 0b9eff19149b..ce73eab76f36 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 @@ error_rtc_device_register:
}
#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,
};