* [PATCH v1] rtc: rv8803: fix off-by-one in month counting
@ 2022-04-26 7:26 Oliver Graute
2022-04-26 7:29 ` Michael Walle
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Oliver Graute @ 2022-04-26 7:26 UTC (permalink / raw)
To: sjg; +Cc: hs, oliver.graute, michael, u-boot
tm_mon has a range from 0..11, but the RTC expects 1..12. So we adapt
the month accordingly. This was determined when comparing the driver
with the corresponding linux kernel driver.
Signed-off-by: Oliver Graute <oliver.graute@kococonnector.com>
---
drivers/rtc/rv8803.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rv8803.c b/drivers/rtc/rv8803.c
index 66b37443de..3e3c50a872 100644
--- a/drivers/rtc/rv8803.c
+++ b/drivers/rtc/rv8803.c
@@ -49,7 +49,7 @@ static int rv8803_rtc_set(struct udevice *dev, const struct rtc_time *tm)
printf("WARNING: year should be between 2000 and 2099!\n");
buf[RTC_YR_REG_ADDR] = bin2bcd(tm->tm_year % 100);
- buf[RTC_MON_REG_ADDR] = bin2bcd(tm->tm_mon);
+ buf[RTC_MON_REG_ADDR] = bin2bcd(tm->tm_mon + 1);
buf[RTC_DAY_REG_ADDR] = 1 << (tm->tm_wday & 0x7);
buf[RTC_DATE_REG_ADDR] = bin2bcd(tm->tm_mday);
buf[RTC_HR_REG_ADDR] = bin2bcd(tm->tm_hour);
@@ -90,7 +90,7 @@ static int rv8803_rtc_get(struct udevice *dev, struct rtc_time *tm)
tm->tm_min = bcd2bin(buf[RTC_MIN_REG_ADDR] & 0x7F);
tm->tm_hour = bcd2bin(buf[RTC_HR_REG_ADDR] & 0x3F);
tm->tm_mday = bcd2bin(buf[RTC_DATE_REG_ADDR] & 0x3F);
- tm->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F);
+ tm->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F) - 1;
tm->tm_year = bcd2bin(buf[RTC_YR_REG_ADDR]) + 2000;
tm->tm_wday = fls(buf[RTC_DAY_REG_ADDR] & 0x7F) - 1;
tm->tm_yday = 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] rtc: rv8803: fix off-by-one in month counting
2022-04-26 7:26 [PATCH v1] rtc: rv8803: fix off-by-one in month counting Oliver Graute
@ 2022-04-26 7:29 ` Michael Walle
2022-04-27 5:17 ` Heiko Schocher
2022-05-05 23:38 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Michael Walle @ 2022-04-26 7:29 UTC (permalink / raw)
To: Oliver Graute; +Cc: sjg, hs, u-boot
Am 2022-04-26 09:26, schrieb Oliver Graute:
> tm_mon has a range from 0..11, but the RTC expects 1..12. So we adapt
> the month accordingly. This was determined when comparing the driver
> with the corresponding linux kernel driver.
>
> Signed-off-by: Oliver Graute <oliver.graute@kococonnector.com>
Reviewed-by: Michael Walle <michael@walle.cc>
-michael
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] rtc: rv8803: fix off-by-one in month counting
2022-04-26 7:26 [PATCH v1] rtc: rv8803: fix off-by-one in month counting Oliver Graute
2022-04-26 7:29 ` Michael Walle
@ 2022-04-27 5:17 ` Heiko Schocher
2022-05-05 23:38 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2022-04-27 5:17 UTC (permalink / raw)
To: Oliver Graute, sjg; +Cc: michael, u-boot
Hello Oliver,
On 26.04.22 09:26, Oliver Graute wrote:
> tm_mon has a range from 0..11, but the RTC expects 1..12. So we adapt
> the month accordingly. This was determined when comparing the driver
> with the corresponding linux kernel driver.
>
> Signed-off-by: Oliver Graute <oliver.graute@kococonnector.com>
> ---
> drivers/rtc/rv8803.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
This seems like a bug to me, good catch!
Reviewed-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs@denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] rtc: rv8803: fix off-by-one in month counting
2022-04-26 7:26 [PATCH v1] rtc: rv8803: fix off-by-one in month counting Oliver Graute
2022-04-26 7:29 ` Michael Walle
2022-04-27 5:17 ` Heiko Schocher
@ 2022-05-05 23:38 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2022-05-05 23:38 UTC (permalink / raw)
To: Oliver Graute; +Cc: sjg, hs, michael, u-boot
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
On Tue, Apr 26, 2022 at 09:26:12AM +0200, Oliver Graute wrote:
> tm_mon has a range from 0..11, but the RTC expects 1..12. So we adapt
> the month accordingly. This was determined when comparing the driver
> with the corresponding linux kernel driver.
>
> Signed-off-by: Oliver Graute <oliver.graute@kococonnector.com>
> Reviewed-by: Michael Walle <michael@walle.cc>
> Reviewed-by: Heiko Schocher <hs@denx.de>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-05 23:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 7:26 [PATCH v1] rtc: rv8803: fix off-by-one in month counting Oliver Graute
2022-04-26 7:29 ` Michael Walle
2022-04-27 5:17 ` Heiko Schocher
2022-05-05 23:38 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.