diff options
Diffstat (limited to 'drivers/rtc/rtc-m41t80.c')
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 470fb2d29545..893f7dece239 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -110,15 +110,15 @@ static int m41t80_get_datetime(struct i2c_client *client, | |||
110 | return -EIO; | 110 | return -EIO; |
111 | } | 111 | } |
112 | 112 | ||
113 | tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f); | 113 | tm->tm_sec = bcd2bin(buf[M41T80_REG_SEC] & 0x7f); |
114 | tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f); | 114 | tm->tm_min = bcd2bin(buf[M41T80_REG_MIN] & 0x7f); |
115 | tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f); | 115 | tm->tm_hour = bcd2bin(buf[M41T80_REG_HOUR] & 0x3f); |
116 | tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f); | 116 | tm->tm_mday = bcd2bin(buf[M41T80_REG_DAY] & 0x3f); |
117 | tm->tm_wday = buf[M41T80_REG_WDAY] & 0x07; | 117 | tm->tm_wday = buf[M41T80_REG_WDAY] & 0x07; |
118 | tm->tm_mon = BCD2BIN(buf[M41T80_REG_MON] & 0x1f) - 1; | 118 | tm->tm_mon = bcd2bin(buf[M41T80_REG_MON] & 0x1f) - 1; |
119 | 119 | ||
120 | /* assume 20YY not 19YY, and ignore the Century Bit */ | 120 | /* assume 20YY not 19YY, and ignore the Century Bit */ |
121 | tm->tm_year = BCD2BIN(buf[M41T80_REG_YEAR]) + 100; | 121 | tm->tm_year = bcd2bin(buf[M41T80_REG_YEAR]) + 100; |
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
@@ -161,19 +161,19 @@ static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
161 | /* Merge time-data and register flags into buf[0..7] */ | 161 | /* Merge time-data and register flags into buf[0..7] */ |
162 | buf[M41T80_REG_SSEC] = 0; | 162 | buf[M41T80_REG_SSEC] = 0; |
163 | buf[M41T80_REG_SEC] = | 163 | buf[M41T80_REG_SEC] = |
164 | BIN2BCD(tm->tm_sec) | (buf[M41T80_REG_SEC] & ~0x7f); | 164 | bin2bcd(tm->tm_sec) | (buf[M41T80_REG_SEC] & ~0x7f); |
165 | buf[M41T80_REG_MIN] = | 165 | buf[M41T80_REG_MIN] = |
166 | BIN2BCD(tm->tm_min) | (buf[M41T80_REG_MIN] & ~0x7f); | 166 | bin2bcd(tm->tm_min) | (buf[M41T80_REG_MIN] & ~0x7f); |
167 | buf[M41T80_REG_HOUR] = | 167 | buf[M41T80_REG_HOUR] = |
168 | BIN2BCD(tm->tm_hour) | (buf[M41T80_REG_HOUR] & ~0x3f) ; | 168 | bin2bcd(tm->tm_hour) | (buf[M41T80_REG_HOUR] & ~0x3f) ; |
169 | buf[M41T80_REG_WDAY] = | 169 | buf[M41T80_REG_WDAY] = |
170 | (tm->tm_wday & 0x07) | (buf[M41T80_REG_WDAY] & ~0x07); | 170 | (tm->tm_wday & 0x07) | (buf[M41T80_REG_WDAY] & ~0x07); |
171 | buf[M41T80_REG_DAY] = | 171 | buf[M41T80_REG_DAY] = |
172 | BIN2BCD(tm->tm_mday) | (buf[M41T80_REG_DAY] & ~0x3f); | 172 | bin2bcd(tm->tm_mday) | (buf[M41T80_REG_DAY] & ~0x3f); |
173 | buf[M41T80_REG_MON] = | 173 | buf[M41T80_REG_MON] = |
174 | BIN2BCD(tm->tm_mon + 1) | (buf[M41T80_REG_MON] & ~0x1f); | 174 | bin2bcd(tm->tm_mon + 1) | (buf[M41T80_REG_MON] & ~0x1f); |
175 | /* assume 20YY not 19YY */ | 175 | /* assume 20YY not 19YY */ |
176 | buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100); | 176 | buf[M41T80_REG_YEAR] = bin2bcd(tm->tm_year % 100); |
177 | 177 | ||
178 | if (i2c_transfer(client->adapter, msgs, 1) != 1) { | 178 | if (i2c_transfer(client->adapter, msgs, 1) != 1) { |
179 | dev_err(&client->dev, "write error\n"); | 179 | dev_err(&client->dev, "write error\n"); |
@@ -288,15 +288,15 @@ static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
288 | 288 | ||
289 | wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */ | 289 | wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */ |
290 | reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ? | 290 | reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ? |
291 | BIN2BCD(t->time.tm_sec) : 0x80; | 291 | bin2bcd(t->time.tm_sec) : 0x80; |
292 | reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ? | 292 | reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ? |
293 | BIN2BCD(t->time.tm_min) : 0x80; | 293 | bin2bcd(t->time.tm_min) : 0x80; |
294 | reg[M41T80_REG_ALARM_HOUR] |= t->time.tm_hour >= 0 ? | 294 | reg[M41T80_REG_ALARM_HOUR] |= t->time.tm_hour >= 0 ? |
295 | BIN2BCD(t->time.tm_hour) : 0x80; | 295 | bin2bcd(t->time.tm_hour) : 0x80; |
296 | reg[M41T80_REG_ALARM_DAY] |= t->time.tm_mday >= 0 ? | 296 | reg[M41T80_REG_ALARM_DAY] |= t->time.tm_mday >= 0 ? |
297 | BIN2BCD(t->time.tm_mday) : 0x80; | 297 | bin2bcd(t->time.tm_mday) : 0x80; |
298 | if (t->time.tm_mon >= 0) | 298 | if (t->time.tm_mon >= 0) |
299 | reg[M41T80_REG_ALARM_MON] |= BIN2BCD(t->time.tm_mon + 1); | 299 | reg[M41T80_REG_ALARM_MON] |= bin2bcd(t->time.tm_mon + 1); |
300 | else | 300 | else |
301 | reg[M41T80_REG_ALARM_DAY] |= 0x40; | 301 | reg[M41T80_REG_ALARM_DAY] |= 0x40; |
302 | 302 | ||
@@ -347,15 +347,15 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
347 | t->time.tm_mday = -1; | 347 | t->time.tm_mday = -1; |
348 | t->time.tm_mon = -1; | 348 | t->time.tm_mon = -1; |
349 | if (!(reg[M41T80_REG_ALARM_SEC] & 0x80)) | 349 | if (!(reg[M41T80_REG_ALARM_SEC] & 0x80)) |
350 | t->time.tm_sec = BCD2BIN(reg[M41T80_REG_ALARM_SEC] & 0x7f); | 350 | t->time.tm_sec = bcd2bin(reg[M41T80_REG_ALARM_SEC] & 0x7f); |
351 | if (!(reg[M41T80_REG_ALARM_MIN] & 0x80)) | 351 | if (!(reg[M41T80_REG_ALARM_MIN] & 0x80)) |
352 | t->time.tm_min = BCD2BIN(reg[M41T80_REG_ALARM_MIN] & 0x7f); | 352 | t->time.tm_min = bcd2bin(reg[M41T80_REG_ALARM_MIN] & 0x7f); |
353 | if (!(reg[M41T80_REG_ALARM_HOUR] & 0x80)) | 353 | if (!(reg[M41T80_REG_ALARM_HOUR] & 0x80)) |
354 | t->time.tm_hour = BCD2BIN(reg[M41T80_REG_ALARM_HOUR] & 0x3f); | 354 | t->time.tm_hour = bcd2bin(reg[M41T80_REG_ALARM_HOUR] & 0x3f); |
355 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x80)) | 355 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x80)) |
356 | t->time.tm_mday = BCD2BIN(reg[M41T80_REG_ALARM_DAY] & 0x3f); | 356 | t->time.tm_mday = bcd2bin(reg[M41T80_REG_ALARM_DAY] & 0x3f); |
357 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x40)) | 357 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x40)) |
358 | t->time.tm_mon = BCD2BIN(reg[M41T80_REG_ALARM_MON] & 0x1f) - 1; | 358 | t->time.tm_mon = bcd2bin(reg[M41T80_REG_ALARM_MON] & 0x1f) - 1; |
359 | t->time.tm_year = -1; | 359 | t->time.tm_year = -1; |
360 | t->time.tm_wday = -1; | 360 | t->time.tm_wday = -1; |
361 | t->time.tm_yday = -1; | 361 | t->time.tm_yday = -1; |