Skip to content

Commit b5bf5b2

Browse files
Loic Poulainalexandrebelloni
authored andcommitted
rtc: pm8xxx: Attach wake irq to device
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> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/1645025082-6138-1-git-send-email-loic.poulain@linaro.org
1 parent 1521ca5 commit b5bf5b2

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

drivers/rtc/rtc-pm8xxx.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/rtc.h>
88
#include <linux/platform_device.h>
99
#include <linux/pm.h>
10+
#include <linux/pm_wakeirq.h>
1011
#include <linux/regmap.h>
1112
#include <linux/slab.h>
1213
#include <linux/spinlock.h>
@@ -527,40 +528,28 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
527528
return rc;
528529
}
529530

530-
return devm_rtc_register_device(rtc_dd->rtc);
531-
}
532-
533-
#ifdef CONFIG_PM_SLEEP
534-
static int pm8xxx_rtc_resume(struct device *dev)
535-
{
536-
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
531+
rc = devm_rtc_register_device(rtc_dd->rtc);
532+
if (rc)
533+
return rc;
537534

538-
if (device_may_wakeup(dev))
539-
disable_irq_wake(rtc_dd->rtc_alarm_irq);
535+
rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->rtc_alarm_irq);
536+
if (rc)
537+
return rc;
540538

541539
return 0;
542540
}
543541

544-
static int pm8xxx_rtc_suspend(struct device *dev)
542+
static int pm8xxx_remove(struct platform_device *pdev)
545543
{
546-
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
547-
548-
if (device_may_wakeup(dev))
549-
enable_irq_wake(rtc_dd->rtc_alarm_irq);
550-
544+
dev_pm_clear_wake_irq(&pdev->dev);
551545
return 0;
552546
}
553-
#endif
554-
555-
static SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops,
556-
pm8xxx_rtc_suspend,
557-
pm8xxx_rtc_resume);
558547

559548
static struct platform_driver pm8xxx_rtc_driver = {
560549
.probe = pm8xxx_rtc_probe,
550+
.remove = pm8xxx_remove,
561551
.driver = {
562552
.name = "rtc-pm8xxx",
563-
.pm = &pm8xxx_rtc_pm_ops,
564553
.of_match_table = pm8xxx_id_table,
565554
},
566555
};

0 commit comments

Comments
 (0)