Linux RTC
 help / color / mirror / Atom feed
* [PATCH] rtc: sd3078: Fix BCD encoding of the month
@ 2026-11-24 13:43 Thorsten Blum
  2026-11-24 13:47 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-11-24 13:43 UTC (permalink / raw)
  To: Dianlong Li, Alexandre Belloni; +Cc: Thorsten Blum, linux-rtc

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 <blum@kernel.org>
---
 drivers/rtc/rtc-sd3078.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-sd3078.c b/drivers/rtc/rtc-sd3078.c
index 2c61f0e204a4..7ceb6f866492 100644
--- a/drivers/rtc/rtc-sd3078.c
+++ b/drivers/rtc/rtc-sd3078.c
@@ -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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:43 [PATCH] rtc: sd3078: Fix BCD encoding of the month Thorsten Blum
2026-11-24 13:47 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox