rtc: tps6591x: Limiting years in the 0 - 99 range
Venu Byravarasu [Wed, 16 May 2012 10:15:45 +0000 (15:15 +0530)]
As RTC can store year in the 0 - 99 range only,
handling it accordingly

bug 985890

Change-Id: Idcfb29028f482283ae2658579a3283c7d4f230f1
Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com>
Reviewed-on: http://git-master/r/102798
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

Rebase-Id: Ra9843487e04b6d01e5201a65ae73a0ee20dab78b

drivers/rtc/rtc-tps6591x.c

index 1e48d66..49c90b4 100644 (file)
@@ -163,7 +163,7 @@ static int tps6591x_rtc_read_time(struct device *dev, struct rtc_time *tm)
        tm->tm_hour = buff[2];
        tm->tm_mday = buff[3];
        tm->tm_mon = buff[4] - 1;
-       tm->tm_year = buff[5];
+       tm->tm_year = buff[5] + RTC_YEAR_OFFSET;
        tm->tm_wday = buff[6];
        print_time(dev, tm);
        return tps6591x_rtc_valid_tm(tm);
@@ -251,7 +251,7 @@ static int tps6591x_rtc_set_time(struct device *dev, struct rtc_time *tm)
        buff[2] = tm->tm_hour;
        buff[3] = tm->tm_mday;
        buff[4] = tm->tm_mon + 1;
-       buff[5] = tm->tm_year;
+       buff[5] = tm->tm_year % RTC_YEAR_OFFSET;
        buff[6] = tm->tm_wday;
 
        print_time(dev, tm);
@@ -346,7 +346,7 @@ static int tps6591x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        buff[2] = alrm->time.tm_hour;
        buff[3] = alrm->time.tm_mday;
        buff[4] = alrm->time.tm_mon + 1;
-       buff[5] = alrm->time.tm_year;
+       buff[5] = alrm->time.tm_year % RTC_YEAR_OFFSET;
        convert_decimal_to_bcd(buff, sizeof(buff));
        err = tps6591x_write_regs(dev, RTC_ALARM, sizeof(buff), buff);
        if (err)
@@ -370,7 +370,7 @@ static int tps6591x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        alrm->time.tm_hour = buff[2];
        alrm->time.tm_mday = buff[3];
        alrm->time.tm_mon = buff[4] - 1;
-       alrm->time.tm_year = buff[5];
+       alrm->time.tm_year = buff[5] + RTC_YEAR_OFFSET;
 
        dev_info(dev->parent, "\n getting alarm time::\n");
        print_time(dev, &alrm->time);