aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/ds1337.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/ds1337.c')
-rw-r--r--drivers/i2c/chips/ds1337.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 89fc02b3c6d9..0967ec6d7947 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -130,8 +130,8 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
130 dt->tm_wday = BCD2BIN(buf[3]) - 1; 130 dt->tm_wday = BCD2BIN(buf[3]) - 1;
131 dt->tm_mday = BCD2BIN(buf[4]); 131 dt->tm_mday = BCD2BIN(buf[4]);
132 val = buf[5] & 0x7f; 132 val = buf[5] & 0x7f;
133 dt->tm_mon = BCD2BIN(val); 133 dt->tm_mon = BCD2BIN(val) - 1;
134 dt->tm_year = 1900 + BCD2BIN(buf[6]); 134 dt->tm_year = BCD2BIN(buf[6]);
135 if (buf[5] & 0x80) 135 if (buf[5] & 0x80)
136 dt->tm_year += 100; 136 dt->tm_year += 100;
137 137
@@ -171,12 +171,11 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
171 buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6); 171 buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6);
172 buf[4] = BIN2BCD(dt->tm_wday) + 1; 172 buf[4] = BIN2BCD(dt->tm_wday) + 1;
173 buf[5] = BIN2BCD(dt->tm_mday); 173 buf[5] = BIN2BCD(dt->tm_mday);
174 buf[6] = BIN2BCD(dt->tm_mon); 174 buf[6] = BIN2BCD(dt->tm_mon) + 1;
175 if (dt->tm_year >= 2000) { 175 val = dt->tm_year;
176 val = dt->tm_year - 2000; 176 if (val >= 100) {
177 val -= 100;
177 buf[6] |= (1 << 7); 178 buf[6] |= (1 << 7);
178 } else {
179 val = dt->tm_year - 1900;
180 } 179 }
181 buf[7] = BIN2BCD(val); 180 buf[7] = BIN2BCD(val);
182 181