diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2007-03-04 15:13:13 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-03-04 15:13:13 -0500 |
commit | 0ed8f210e68236f2034f827596f0a8201a907a9f (patch) | |
tree | 4e33c0ecdcb9d3abbf4643df2890faad3beaa425 /drivers/rtc/rtc-pcf8583.c | |
parent | f5e5b734d4c9ccc1f5f68bdf545bdc4b19681d28 (diff) |
[ARM] rtc-pcf8583: correct month and year offsets
No, today is not 4th April 3907, it's 4th March 2007.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/rtc/rtc-pcf8583.c')
-rw-r--r-- | drivers/rtc/rtc-pcf8583.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index a69db6185530..a33a2d69859c 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -85,7 +85,7 @@ static int pcf8583_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
85 | dt->tm_min = BCD2BIN(buf[2]); | 85 | dt->tm_min = BCD2BIN(buf[2]); |
86 | dt->tm_hour = BCD2BIN(buf[3]); | 86 | dt->tm_hour = BCD2BIN(buf[3]); |
87 | dt->tm_mday = BCD2BIN(buf[4]); | 87 | dt->tm_mday = BCD2BIN(buf[4]); |
88 | dt->tm_mon = BCD2BIN(buf[5]); | 88 | dt->tm_mon = BCD2BIN(buf[5]) - 1; |
89 | } | 89 | } |
90 | 90 | ||
91 | return ret == 2 ? 0 : -EIO; | 91 | return ret == 2 ? 0 : -EIO; |
@@ -106,7 +106,7 @@ static int pcf8583_set_datetime(struct i2c_client *client, struct rtc_time *dt, | |||
106 | if (datetoo) { | 106 | if (datetoo) { |
107 | len = 8; | 107 | len = 8; |
108 | buf[6] = BIN2BCD(dt->tm_mday) | (dt->tm_year << 6); | 108 | buf[6] = BIN2BCD(dt->tm_mday) | (dt->tm_year << 6); |
109 | buf[7] = BIN2BCD(dt->tm_mon) | (dt->tm_wday << 5); | 109 | buf[7] = BIN2BCD(dt->tm_mon + 1) | (dt->tm_wday << 5); |
110 | } | 110 | } |
111 | 111 | ||
112 | ret = i2c_master_send(client, (char *)buf, len); | 112 | ret = i2c_master_send(client, (char *)buf, len); |
@@ -226,7 +226,7 @@ static int pcf8583_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
226 | */ | 226 | */ |
227 | year_offset += 4; | 227 | year_offset += 4; |
228 | 228 | ||
229 | tm->tm_year = real_year + year_offset + year[1] * 100; | 229 | tm->tm_year = (real_year + year_offset + year[1] * 100) - 1900; |
230 | 230 | ||
231 | return 0; | 231 | return 0; |
232 | } | 232 | } |
@@ -237,6 +237,7 @@ static int pcf8583_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
237 | unsigned char year[2], chk; | 237 | unsigned char year[2], chk; |
238 | struct rtc_mem cmos_year = { CMOS_YEAR, sizeof(year), year }; | 238 | struct rtc_mem cmos_year = { CMOS_YEAR, sizeof(year), year }; |
239 | struct rtc_mem cmos_check = { CMOS_CHECKSUM, 1, &chk }; | 239 | struct rtc_mem cmos_check = { CMOS_CHECKSUM, 1, &chk }; |
240 | unsigned int proper_year = tm->tm_year + 1900; | ||
240 | int ret; | 241 | int ret; |
241 | 242 | ||
242 | /* | 243 | /* |
@@ -258,8 +259,8 @@ static int pcf8583_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
258 | 259 | ||
259 | chk -= year[1] + year[0]; | 260 | chk -= year[1] + year[0]; |
260 | 261 | ||
261 | year[1] = tm->tm_year / 100; | 262 | year[1] = proper_year / 100; |
262 | year[0] = tm->tm_year % 100; | 263 | year[0] = proper_year % 100; |
263 | 264 | ||
264 | chk += year[1] + year[0]; | 265 | chk += year[1] + year[0]; |
265 | 266 | ||