diff mbox series

[1/1] rtc: pcf85063: Fix reading alarm

Message ID 20220921074141.3903104-1-alexander.stein@ew.tq-group.com
State Accepted
Headers show
Series [1/1] rtc: pcf85063: Fix reading alarm | expand

Commit Message

Alexander Stein Sept. 21, 2022, 7:41 a.m. UTC
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: 05cb3a56ee8c ("rtc: pcf85063: add alarm support")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/rtc/rtc-pcf85063.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Alexandre Belloni Nov. 16, 2022, 10:23 p.m. UTC | #1
On Wed, 21 Sep 2022 09:41:41 +0200, Alexander Stein wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] rtc: pcf85063: Fix reading alarm
      commit: a6ceee26fd5ed9b5bd37322b1ca88e4548cee4a3

Best regards,
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 095891999da1..99f9cc57c7b3 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -169,10 +169,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)