From: Thorsten Blum <blum@kernel.org>
To: Dianlong Li <long17.cool@163.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Thorsten Blum <blum@kernel.org>, linux-rtc@vger.kernel.org
Subject: [PATCH] rtc: sd3078: Fix BCD encoding of the month
Date: Tue, 24 Nov 2026 14:43:09 +0100 [thread overview]
Message-ID: <20261124134309.237707-2-blum@kernel.org> (raw)
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
next reply other threads:[~2026-11-24 13:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:43 Thorsten Blum [this message]
2026-11-24 13:47 ` [PATCH] rtc: sd3078: Fix BCD encoding of the month sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124134309.237707-2-blum@kernel.org \
--to=blum@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-rtc@vger.kernel.org \
--cc=long17.cool@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox