Commit fad0738d authored by Kevin Liu's avatar Kevin Liu Committed by Linus Torvalds

drivers/rtc/rtc-max8925.c: fix alarm->enabled mistake in...

drivers/rtc/rtc-max8925.c: fix alarm->enabled mistake in max8925_rtc_read_alarm/max8925_rtc_set_alarm

max8925_rtc_read_alarm() should set alrm->enabled based on both
ALARM_IRQ_MASK and ALARM_CTRL setting.  max8925_rtc_set_alarm() should
enable/disable alarm according to ALARM_CTRL reg setting.
Signed-off-by: default avatarKevin Liu <kliu5@marvell.com>
Signed-off-by: default avatarHaojian Zhuang <haojian.zhuang@marvell.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0cf30bdd
...@@ -193,10 +193,17 @@ static int max8925_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -193,10 +193,17 @@ static int max8925_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK); ret = max8925_reg_read(info->rtc, MAX8925_RTC_IRQ_MASK);
if (ret < 0) if (ret < 0)
goto out; goto out;
if ((ret & ALARM0_IRQ) == 0) if (ret & ALARM0_IRQ) {
alrm->enabled = 1; alrm->enabled = 0;
else } else {
ret = max8925_reg_read(info->rtc, MAX8925_ALARM0_CNTL);
if (ret < 0)
goto out;
if (!ret)
alrm->enabled = 0; alrm->enabled = 0;
else
alrm->enabled = 1;
}
ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS); ret = max8925_reg_read(info->rtc, MAX8925_RTC_STATUS);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -221,8 +228,11 @@ static int max8925_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -221,8 +228,11 @@ static int max8925_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf); ret = max8925_bulk_write(info->rtc, MAX8925_ALARM0_SEC, TIME_NUM, buf);
if (ret < 0) if (ret < 0)
goto out; goto out;
if (alrm->enabled)
/* only enable alarm on year/month/day/hour/min/sec */ /* only enable alarm on year/month/day/hour/min/sec */
ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77); ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x77);
else
ret = max8925_reg_write(info->rtc, MAX8925_ALARM0_CNTL, 0x0);
if (ret < 0) if (ret < 0)
goto out; goto out;
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment