2016-03-06 09:43:58

by Alexander Kochetkov

[permalink] [raw]
Subject: [PATCH] rtc: hym8563: fix invalid year calculation

Year field must be in BCD format, according to
hym8563 datasheet.

Due to the bug year 2016 became 2010.

Signed-off-by: Alexander Kochetkov <[email protected]>
---
drivers/rtc/rtc-hym8563.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 097325d..b1b4746 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -144,7 +144,7 @@ static int hym8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
* it does not seem to carry it over a subsequent write/read.
* So we'll limit ourself to 100 years, starting at 2000 for now.
*/
- buf[6] = tm->tm_year - 100;
+ buf[6] = bin2bcd(tm->tm_year - 100);

/*
* CTL1 only contains TEST-mode bits apart from stop,
--
1.7.9.5


2016-03-10 22:42:25

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH] rtc: hym8563: fix invalid year calculation

On 06/03/2016 at 12:43:57 +0300, Alexander Kochetkov wrote :
> Year field must be in BCD format, according to
> hym8563 datasheet.
>
> Due to the bug year 2016 became 2010.
>
> Signed-off-by: Alexander Kochetkov <[email protected]>
> ---
> drivers/rtc/rtc-hym8563.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Applied, thanks.

--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com