rtc: sd3078: Fix BCD encoding of the month
Subsystems (2)
PATCH 1/1 rtc: sd3078: Fix BCD encoding of the month
The SD3078 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 1d67a232105b ("rtc: sd3078: new driver.")
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/rtc/rtc-sd3078.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-sd3078.c +1 -1
@@ -119,7 +119,7 @@ static int sd3078_rtc_set_time(struct device *dev, struct rtc_time *tm) rtc_data[SD3078_REG_HR ] =bin2bcd (tm->tm_hour) |0x80 ; rtc_data[SD3078_REG_DM ] =bin2bcd (tm->tm_mday); rtc_data[SD3078_REG_DW ] = tm->tm_wday &0x07 ; - rtc_data[SD3078_REG_MO ] =bin2bcd (tm->tm_mon) +1 ; + rtc_data[SD3078_REG_MO ] =bin2bcd (tm->tm_mon +1 ); rtc_data[SD3078_REG_YR ] =bin2bcd (tm->tm_year -100 );#if WRITE_PROTECT_EN
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 8 lines
The SD3078 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 1d67a232105b ("rtc: sd3078: new driver.")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