Skip to content

Commit

Permalink
rtc: pcf85063: Fix reading alarm
Browse files Browse the repository at this point in the history
[ Upstream commit a6ceee2 ]

If the alarms are disabled the topmost bit (AEN_*) is set in the alarm
registers. This is also interpreted in BCD number leading to this warning:
rtc rtc0: invalid alarm value: 2022-09-21T80:80:80

Fix this by masking alarm enabling and reserved bits.

Fixes: 05cb3a5 ("rtc: pcf85063: add alarm support")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Link: https://lore.kernel.org/r/20220921074141.3903104-1-alexander.stein@ew.tq-group.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tq-steina authored and gregkh committed Dec 31, 2022
1 parent b66aa7b commit 9383921
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/rtc/rtc-pcf85063.c
Expand Up @@ -167,10 +167,10 @@ static int pcf85063_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
if (ret)
return ret;

alrm->time.tm_sec = bcd2bin(buf[0]);
alrm->time.tm_min = bcd2bin(buf[1]);
alrm->time.tm_hour = bcd2bin(buf[2]);
alrm->time.tm_mday = bcd2bin(buf[3]);
alrm->time.tm_sec = bcd2bin(buf[0] & 0x7f);
alrm->time.tm_min = bcd2bin(buf[1] & 0x7f);
alrm->time.tm_hour = bcd2bin(buf[2] & 0x3f);
alrm->time.tm_mday = bcd2bin(buf[3] & 0x3f);

ret = regmap_read(pcf85063->regmap, PCF85063_REG_CTRL2, &val);
if (ret)
Expand Down

0 comments on commit 9383921

Please sign in to comment.