rtc: sd2405al: Fix BCD encoding of the month
Subsystems (2)
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")
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/rtc/rtc-sd2405al.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-sd2405al.c +1 -1
@@ -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);
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 8 lines
The SD2405AL expects a one-based month encoded as BCD, while
tm_monis zero-based. Adding 1 after convertingtm_monto BCD incorrectly encodes October as0x0ainstead of0x10.Add 1 to
tm_monbefore converting it to BCD.Fixes 5af858acea22 ("rtc: Add driver for SD2405AL")Signed-off-by Thorsten Blum <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1