Skip to contentSkip to conversation

rtc: as3772: Fix off-by-one error in month value

PATCH In review Felix Janda 3 participants 6 messages Aug 1, 2015 – Aug 20, 2015 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: as3772: Fix off-by-one error in month value

The RTC's month value starts at 1, whereas the kernel's starts at 0.

---
This is my first kernel patch. It's content is actually from

https://chromium.googlesource.com/chromiumos/third_party/kernel-next/+/9ce8d10f39c441642fba58ab8248d78951cec7a7

How can this be acknowledged? The patch from the chromiumos kernel can't be taken as it is, can it?

---
 drivers/rtc/rtc-as3722.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-as3722.c +2 -2
index 9f38eda..56cc582 100644
@@ -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;
 }
Signature · 12 lines
2.3.6

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#1 lore raw

Hi,

Quoted 10 lines · Felix Janda

The RTC's month value starts at 1, whereas the kernel's starts at 0.

---
This is my first kernel patch. It's content is actually from

https://chromium.googlesource.com/chromiumos/third_party/kernel-next/+/9ce8d10f39c441642fba58ab8248d78951cec7a7

How can this be acknowledged? The patch from the chromiumos kernel can't be taken as it is, can it?

You should send the patch with "Bibek Basu <[email protected]>" as the author and both SoB tags, Bibek's and yours. The other, gerrit related, tags can be removed.

It will look like:
https://groups.google.com/forum/#!topic/rtc-linux/9NJUEAJWIkI

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

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#2 lore raw
Quoted 1 line · Alexandre Belloni

Hi,

Thank you very much for your help!

Quoted 12 lines · Felix Janda
Quoted 10 lines

The RTC's month value starts at 1, whereas the kernel's starts at 0.

---
This is my first kernel patch. It's content is actually from

https://chromium.googlesource.com/chromiumos/third_party/kernel-next/+/9ce8d10f39c441642fba58ab8248d78951cec7a7

How can this be acknowledged? The patch from the chromiumos kernel can't be taken as it is, can it?

Quoted 6 lines

You should send the patch with "Bibek Basu <[email protected]>" as the author and both SoB tags, Bibek's and yours. The other, gerrit related, tags can be removed.

It will look like:
https://groups.google.com/forum/#!topic/rtc-linux/9NJUEAJWIkI

So I should better not rewrite the commit message? At least the "CHROMIUM: " prefix of the title seems inappropriate.

Felix

Signature · 9 lines
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#3 lore raw
Quoted 3 lines · Felix Janda

So I should better not rewrite the commit message? At least the "CHROMIUM: " prefix of the title seems inappropriate.

Indeed, you can adjust it, it should be:
rtc: as3722: correct month value

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

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#4 lore raw

PATCH v2 1/1 drivers/rtc/rtc-as3722: correct month value

The RTCmonth value is 1-indexed, but the kernel assumes it is 0-indexed. This may result in the RTC not rolling over correctly.

---
v1 -> v2: Correct attribution and use original commit message

---
 drivers/rtc/rtc-as3722.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-as3722.c +2 -2
index 9f38eda..56cc582 100644
@@ -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;
 }
Signature · 12 lines
2.4.6

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#5 lore raw

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

Quoted 11 lines · Bibek Basu

The RTCmonth value is 1-indexed, but the kernel assumes it is 0-indexed. This may result in the RTC not rolling over correctly.

---
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.

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

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.