Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a16147965ca7a84dc08c4457961782e06ac7cd0d
Commit:     a16147965ca7a84dc08c4457961782e06ac7cd0d
Parent:     55eec11a50f4c5f53421f49e407e2c92cf25c3ca
Author:     Jamie Lenehan <[EMAIL PROTECTED]>
AuthorDate: Fri Dec 8 14:49:30 2006 +0900
Committer:  Paul Mundt <[EMAIL PROTECTED]>
CommitDate: Tue Dec 12 08:42:08 2006 +0900

    rtc: rtc-sh: fix rtc for out-by-one for the month.
    
    The RMONCNT register, which holds the month in the RTC, takes a value
    between 1 and 12 while the tm_mon field in the time structures takes
    a value between 0 and 11. This wasn't being taken into account in
    rtc-sh resulting in the month being out by one.
    
    eg, on my board during boot the RTC is set to:
    
      RTC is set to Thu Jul 01 09:00:00 1999
    
    but "hwclock -r" immediately after logging in was showing:
    
      Sun Aug  1 09:01:43 1999  0.000000 seconds
    
    Signed-off-by: Jamie Lenehan <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mundt <[EMAIL PROTECTED]>
---
 drivers/rtc/rtc-sh.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 1ffc01e..8f22eb1 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -268,7 +268,7 @@ static int sh_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
                tm->tm_hour     = BCD2BIN(readb(rtc->regbase + RHRCNT));
                tm->tm_wday     = BCD2BIN(readb(rtc->regbase + RWKCNT));
                tm->tm_mday     = BCD2BIN(readb(rtc->regbase + RDAYCNT));
-               tm->tm_mon      = BCD2BIN(readb(rtc->regbase + RMONCNT));
+               tm->tm_mon      = BCD2BIN(readb(rtc->regbase + RMONCNT)) - 1;
 
 #if defined(CONFIG_CPU_SH4)
                yr  = readw(rtc->regbase + RYRCNT);
@@ -296,7 +296,7 @@ static int sh_rtc_read_time(struct device *dev, struct 
rtc_time *tm)
                "mday=%d, mon=%d, year=%d, wday=%d\n",
                __FUNCTION__,
                tm->tm_sec, tm->tm_min, tm->tm_hour,
-               tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
+               tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday);
 
        if (rtc_valid_tm(tm) < 0)
                dev_err(dev, "invalid date\n");
@@ -323,7 +323,7 @@ static int sh_rtc_set_time(struct device *dev, struct 
rtc_time *tm)
        writeb(BIN2BCD(tm->tm_hour), rtc->regbase + RHRCNT);
        writeb(BIN2BCD(tm->tm_wday), rtc->regbase + RWKCNT);
        writeb(BIN2BCD(tm->tm_mday), rtc->regbase + RDAYCNT);
-       writeb(BIN2BCD(tm->tm_mon),  rtc->regbase + RMONCNT);
+       writeb(BIN2BCD(tm->tm_mon + 1), rtc->regbase + RMONCNT);
 
 #ifdef CONFIG_CPU_SH3
        year = tm->tm_year % 100;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to