diff mbox

[v2] drivers/rtc/rtc-as3722: correct month value

Message ID 20150814184402.GA8953@nyan
State Accepted
Headers show

Commit Message

Bibek Basu Aug. 14, 2015, 6:44 p.m. UTC
The RTCmonth value is 1-indexed, but the kernel assumes it is 0-indexed.
This may result in the RTC not rolling over correctly.

Signed-off-by: Bibek Basu <bbasu@nvidia.com>
Signed-off-by: Felix Janda <felix.janda@posteo.de>
---
v1 -> v2: Correct attribution and use original commit message
---
 drivers/rtc/rtc-as3722.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexandre Belloni Aug. 20, 2015, 11:45 p.m. UTC | #1
On 14/08/2015 at 20:44:02 +0200, Bibek Basu wrote :
> The RTCmonth value is 1-indexed, but the kernel assumes it is 0-indexed.
> This may result in the RTC not rolling over correctly.
> 
> Signed-off-by: Bibek Basu <bbasu@nvidia.com>
> Signed-off-by: Felix Janda <felix.janda@posteo.de>
> ---
> v1 -> v2: Correct attribution and use original commit message
> ---
>  drivers/rtc/rtc-as3722.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Applied, thanks. However, it was not necessary to spoof the From: in
your email, It is enough to have a From: line in the body of the mail.
diff mbox

Patch

diff --git a/drivers/rtc/rtc-as3722.c b/drivers/rtc/rtc-as3722.c
index 9f38eda..56cc582 100644
--- a/drivers/rtc/rtc-as3722.c
+++ b/drivers/rtc/rtc-as3722.c
@@ -45,7 +45,7 @@  static void as3722_time_to_reg(u8 *rbuff, struct rtc_time *tm)
 	rbuff[1] = bin2bcd(tm->tm_min);
 	rbuff[2] = bin2bcd(tm->tm_hour);
 	rbuff[3] = bin2bcd(tm->tm_mday);
-	rbuff[4] = bin2bcd(tm->tm_mon);
+	rbuff[4] = bin2bcd(tm->tm_mon + 1);
 	rbuff[5] = bin2bcd(tm->tm_year - (AS3722_RTC_START_YEAR - 1900));
 }
 
@@ -55,7 +55,7 @@  static void as3722_reg_to_time(u8 *rbuff, struct rtc_time *tm)
 	tm->tm_min = bcd2bin(rbuff[1] & 0x7F);
 	tm->tm_hour = bcd2bin(rbuff[2] & 0x3F);
 	tm->tm_mday = bcd2bin(rbuff[3] & 0x3F);
-	tm->tm_mon = bcd2bin(rbuff[4] & 0x1F);
+	tm->tm_mon = bcd2bin(rbuff[4] & 0x1F) - 1;
 	tm->tm_year = (AS3722_RTC_START_YEAR - 1900) + bcd2bin(rbuff[5] & 0x7F);
 	return;
 }