* [PATCH] rtc: mxc: use dev_pm_set_wake_irq() to simplify code
@ 2019-04-11 2:06 Anson Huang
2019-04-12 8:33 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Anson Huang @ 2019-04-11 2:06 UTC (permalink / raw)
To: a.zummo, alexandre.belloni, linux-rtc, linux-kernel; +Cc: dl-linux-imx
With calling dev_pm_set_wake_irq() to set MXC 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-mxc.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 28a15bd..708b9e9 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -8,6 +8,7 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
#include <linux/clk.h>
#include <linux/of.h>
#include <linux/of_device.h>
@@ -394,8 +395,12 @@ static int mxc_rtc_probe(struct platform_device *pdev)
pdata->irq = -1;
}
- if (pdata->irq >= 0)
+ if (pdata->irq >= 0) {
device_init_wakeup(&pdev->dev, 1);
+ ret = dev_pm_set_wake_irq(&pdev->dev, pdata->irq);
+ if (ret)
+ dev_err(&pdev->dev, "failed to enable irq wake\n");
+ }
rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &mxc_rtc_ops,
THIS_MODULE);
@@ -426,35 +431,10 @@ static int mxc_rtc_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_PM_SLEEP
-static int mxc_rtc_suspend(struct device *dev)
-{
- struct rtc_plat_data *pdata = dev_get_drvdata(dev);
-
- if (device_may_wakeup(dev))
- enable_irq_wake(pdata->irq);
-
- return 0;
-}
-
-static int mxc_rtc_resume(struct device *dev)
-{
- struct rtc_plat_data *pdata = dev_get_drvdata(dev);
-
- if (device_may_wakeup(dev))
- disable_irq_wake(pdata->irq);
-
- return 0;
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
-
static struct platform_driver mxc_rtc_driver = {
.driver = {
.name = "mxc_rtc",
.of_match_table = of_match_ptr(imx_rtc_dt_ids),
- .pm = &mxc_rtc_pm_ops,
},
.id_table = imx_rtc_devtype,
.probe = mxc_rtc_probe,
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: mxc: use dev_pm_set_wake_irq() to simplify code
2019-04-11 2:06 [PATCH] rtc: mxc: use dev_pm_set_wake_irq() to simplify code Anson Huang
@ 2019-04-12 8:33 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2019-04-12 8:33 UTC (permalink / raw)
To: Anson Huang; +Cc: a.zummo, linux-rtc, linux-kernel, dl-linux-imx
On 11/04/2019 02:06:04+0000, Anson Huang wrote:
> With calling dev_pm_set_wake_irq() to set MXC 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-mxc.c | 32 ++++++--------------------------
> 1 file changed, 6 insertions(+), 26 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-12 8:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 2:06 [PATCH] rtc: mxc: use dev_pm_set_wake_irq() to simplify code Anson Huang
2019-04-12 8:33 ` 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).