summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-pm8xxx.c
diff options
context:
space:
mode:
author韩科才 <hankecai@vivo.com>2020-03-21 19:50:17 +0800
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2020-03-23 09:27:17 +0100
commit34ce29774dadc24ac1a529c562c325db2b77c7b4 (patch)
tree27285562a01f00972a967919a0cf91f618178c14 /drivers/rtc/rtc-pm8xxx.c
parent4828a82e29eb77628526fd6b92d528c2f724cb32 (diff)
downloadlwn-34ce29774dadc24ac1a529c562c325db2b77c7b4.tar.gz
lwn-34ce29774dadc24ac1a529c562c325db2b77c7b4.zip
rtc: pm8xxx: clear alarm register when alarm is not enabled
Clear alarm register when alarm is not enabled otherwise the consumer may still start alarm timer if it find the alarm register is not zero. Signed-off-by: hankecai <hankecai@vivo.com> Link: https://lore.kernel.org/r/APoAZgAaCEiRpKG6PlzreaqE.1.1584791417367.Hmail.hankecai@vivo.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-pm8xxx.c')
-rw-r--r--drivers/rtc/rtc-pm8xxx.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index e3d9abb2134e..b45ee2cb2c04 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -295,6 +295,7 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
unsigned int ctrl_reg;
+ u8 value[NUM_8_BIT_RTC_REGS] = {0};
spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
@@ -313,6 +314,16 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
goto rtc_rw_fail;
}
+ /* Clear Alarm register */
+ if (!enable) {
+ rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value,
+ sizeof(value));
+ if (rc) {
+ dev_err(dev, "Clear RTC ALARM register failed\n");
+ goto rtc_rw_fail;
+ }
+ }
+
rtc_rw_fail:
spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
return rc;