Skip to contentSkip to conversation

rtc: sd2405al: Fix BCD encoding of the month

PATCH New Thorsten Blum 2 participants 2 messages Nov 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: sd2405al: Fix BCD encoding of the month

The SD2405AL expects a one-based month encoded as BCD, while tm_mon is zero-based. Adding 1 after converting tm_mon to BCD incorrectly encodes October as 0x0a instead of 0x10.

Add 1 to tm_mon before converting it to BCD.

Fixes 5af858acea22 ("rtc: Add driver for SD2405AL")
---
 drivers/rtc/rtc-sd2405al.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-sd2405al.c +1 -1
index 990080f09457..5f023e3abac8 100644
@@ -129,7 +129,7 @@ static int sd2405al_set_time(struct device *dev, struct rtc_time *time)
 	data[SD2405AL_REG_T_HOUR] = bin2bcd(time->tm_hour) | SD2405AL_BIT_24H;
 	data[SD2405AL_REG_T_DAY] = bin2bcd(time->tm_mday);
 	data[SD2405AL_REG_T_WEEK] = bin2bcd(time->tm_wday);
-	data[SD2405AL_REG_T_MON] = bin2bcd(time->tm_mon) + 1;
+	data[SD2405AL_REG_T_MON] = bin2bcd(time->tm_mon + 1);
 	data[SD2405AL_REG_T_YEAR] = bin2bcd(time->tm_year - 100);
 
 	ret = sd2405al_enable_reg_write(sd2405al);
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

The SD2405AL expects a one-based month encoded as BCD, while tm_mon is zero-based. Adding 1 after converting tm_mon to BCD incorrectly encodes October as 0x0a instead of 0x10.

Add 1 to tm_mon before converting it to BCD.

Fixes 5af858acea22 ("rtc: Add driver for SD2405AL")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1