Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 275340
b: refs/heads/master
c: 57e6319
h: refs/heads/master
v: v3
  • Loading branch information
Feng Tang authored and Linus Torvalds committed Nov 12, 2011
1 parent 89cf479 commit 1fe7c0a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f2ee442115c9b6219083c019939a9cc0c9abb2f8
refs/heads/master: 57e6319dd61d5ca10fe8dd57bcce8c0e2c480799
4 changes: 2 additions & 2 deletions trunk/arch/x86/platform/mrst/vrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ unsigned long vrtc_get_time(void)

spin_unlock_irqrestore(&rtc_lock, flags);

/* vRTC YEAR reg contains the offset to 1960 */
year += 1960;
/* vRTC YEAR reg contains the offset to 1972 */
year += 1972;

printk(KERN_INFO "vRTC: sec: %d min: %d hour: %d day: %d "
"mon: %d year: %d\n", sec, min, hour, mday, mon, year);
Expand Down
19 changes: 11 additions & 8 deletions trunk/drivers/rtc/rtc-mrst.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ static inline unsigned char vrtc_is_updating(void)
/*
* rtc_time's year contains the increment over 1900, but vRTC's YEAR
* register can't be programmed to value larger than 0x64, so vRTC
* driver chose to use 1960 (1970 is UNIX time start point) as the base,
* driver chose to use 1972 (1970 is UNIX time start point) as the base,
* and does the translation at read/write time.
*
* Why not just use 1970 as the offset? it's because using 1960 will
* Why not just use 1970 as the offset? it's because using 1972 will
* make it consistent in leap year setting for both vrtc and low-level
* physical rtc devices.
* physical rtc devices. Then why not use 1960 as the offset? If we use
* 1960, for a device's first use, its YEAR register is 0 and the system
* year will be parsed as 1960 which is not a valid UNIX time and will
* cause many applications to fail mysteriously.
*/
static int mrst_read_time(struct device *dev, struct rtc_time *time)
{
Expand All @@ -99,10 +102,10 @@ static int mrst_read_time(struct device *dev, struct rtc_time *time)
time->tm_year = vrtc_cmos_read(RTC_YEAR);
spin_unlock_irqrestore(&rtc_lock, flags);

/* Adjust for the 1960/1900 */
time->tm_year += 60;
/* Adjust for the 1972/1900 */
time->tm_year += 72;
time->tm_mon--;
return RTC_24H;
return rtc_valid_tm(time);
}

static int mrst_set_time(struct device *dev, struct rtc_time *time)
Expand All @@ -119,9 +122,9 @@ static int mrst_set_time(struct device *dev, struct rtc_time *time)
min = time->tm_min;
sec = time->tm_sec;

if (yrs < 70 || yrs > 138)
if (yrs < 72 || yrs > 138)
return -EINVAL;
yrs -= 60;
yrs -= 72;

spin_lock_irqsave(&rtc_lock, flags);

Expand Down

0 comments on commit 1fe7c0a

Please sign in to comment.