aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-rs5c372.c
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@kernel.org>2008-10-18 23:28:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-20 11:52:41 -0400
commitfe20ba70abf7d6e5855c3dacc729490b3d0d077f (patch)
tree918619427cc051d22cb38b44e94c7e65f29ee928 /drivers/rtc/rtc-rs5c372.c
parent4110a0d6206bd175419cc5503f80cc296d184cbf (diff)
drivers/rtc/: use bcd2bin/bin2bcd
Change drivers/rtc/ to use the new bcd2bin/bin2bcd functions instead of the obsolete BCD_TO_BIN/BIN_TO_BCD/BCD2BIN/BIN2BCD macros. Signed-off-by: Adrian Bunk <bunk@kernel.org> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-rs5c372.c')
-rw-r--r--drivers/rtc/rtc-rs5c372.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 8b561958fb1e..2f2c68d476da 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -148,9 +148,9 @@ static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg)
148 unsigned hour; 148 unsigned hour;
149 149
150 if (rs5c->time24) 150 if (rs5c->time24)
151 return BCD2BIN(reg & 0x3f); 151 return bcd2bin(reg & 0x3f);
152 152
153 hour = BCD2BIN(reg & 0x1f); 153 hour = bcd2bin(reg & 0x1f);
154 if (hour == 12) 154 if (hour == 12)
155 hour = 0; 155 hour = 0;
156 if (reg & 0x20) 156 if (reg & 0x20)
@@ -161,15 +161,15 @@ static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg)
161static unsigned rs5c_hr2reg(struct rs5c372 *rs5c, unsigned hour) 161static unsigned rs5c_hr2reg(struct rs5c372 *rs5c, unsigned hour)
162{ 162{
163 if (rs5c->time24) 163 if (rs5c->time24)
164 return BIN2BCD(hour); 164 return bin2bcd(hour);
165 165
166 if (hour > 12) 166 if (hour > 12)
167 return 0x20 | BIN2BCD(hour - 12); 167 return 0x20 | bin2bcd(hour - 12);
168 if (hour == 12) 168 if (hour == 12)
169 return 0x20 | BIN2BCD(12); 169 return 0x20 | bin2bcd(12);
170 if (hour == 0) 170 if (hour == 0)
171 return BIN2BCD(12); 171 return bin2bcd(12);
172 return BIN2BCD(hour); 172 return bin2bcd(hour);
173} 173}
174 174
175static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) 175static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
@@ -180,18 +180,18 @@ static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
180 if (status < 0) 180 if (status < 0)
181 return status; 181 return status;
182 182
183 tm->tm_sec = BCD2BIN(rs5c->regs[RS5C372_REG_SECS] & 0x7f); 183 tm->tm_sec = bcd2bin(rs5c->regs[RS5C372_REG_SECS] & 0x7f);
184 tm->tm_min = BCD2BIN(rs5c->regs[RS5C372_REG_MINS] & 0x7f); 184 tm->tm_min = bcd2bin(rs5c->regs[RS5C372_REG_MINS] & 0x7f);
185 tm->tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C372_REG_HOURS]); 185 tm->tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C372_REG_HOURS]);
186 186
187 tm->tm_wday = BCD2BIN(rs5c->regs[RS5C372_REG_WDAY] & 0x07); 187 tm->tm_wday = bcd2bin(rs5c->regs[RS5C372_REG_WDAY] & 0x07);
188 tm->tm_mday = BCD2BIN(rs5c->regs[RS5C372_REG_DAY] & 0x3f); 188 tm->tm_mday = bcd2bin(rs5c->regs[RS5C372_REG_DAY] & 0x3f);
189 189
190 /* tm->tm_mon is zero-based */ 190 /* tm->tm_mon is zero-based */
191 tm->tm_mon = BCD2BIN(rs5c->regs[RS5C372_REG_MONTH] & 0x1f) - 1; 191 tm->tm_mon = bcd2bin(rs5c->regs[RS5C372_REG_MONTH] & 0x1f) - 1;
192 192
193 /* year is 1900 + tm->tm_year */ 193 /* year is 1900 + tm->tm_year */
194 tm->tm_year = BCD2BIN(rs5c->regs[RS5C372_REG_YEAR]) + 100; 194 tm->tm_year = bcd2bin(rs5c->regs[RS5C372_REG_YEAR]) + 100;
195 195
196 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 196 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
197 "mday=%d, mon=%d, year=%d, wday=%d\n", 197 "mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -216,13 +216,13 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
216 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 216 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
217 217
218 addr = RS5C_ADDR(RS5C372_REG_SECS); 218 addr = RS5C_ADDR(RS5C372_REG_SECS);
219 buf[0] = BIN2BCD(tm->tm_sec); 219 buf[0] = bin2bcd(tm->tm_sec);
220 buf[1] = BIN2BCD(tm->tm_min); 220 buf[1] = bin2bcd(tm->tm_min);
221 buf[2] = rs5c_hr2reg(rs5c, tm->tm_hour); 221 buf[2] = rs5c_hr2reg(rs5c, tm->tm_hour);
222 buf[3] = BIN2BCD(tm->tm_wday); 222 buf[3] = bin2bcd(tm->tm_wday);
223 buf[4] = BIN2BCD(tm->tm_mday); 223 buf[4] = bin2bcd(tm->tm_mday);
224 buf[5] = BIN2BCD(tm->tm_mon + 1); 224 buf[5] = bin2bcd(tm->tm_mon + 1);
225 buf[6] = BIN2BCD(tm->tm_year - 100); 225 buf[6] = bin2bcd(tm->tm_year - 100);
226 226
227 if (i2c_smbus_write_i2c_block_data(client, addr, sizeof(buf), buf) < 0) { 227 if (i2c_smbus_write_i2c_block_data(client, addr, sizeof(buf), buf) < 0) {
228 dev_err(&client->dev, "%s: write error\n", __func__); 228 dev_err(&client->dev, "%s: write error\n", __func__);
@@ -367,7 +367,7 @@ static int rs5c_read_alarm(struct device *dev, struct rtc_wkalrm *t)
367 367
368 /* report alarm time */ 368 /* report alarm time */
369 t->time.tm_sec = 0; 369 t->time.tm_sec = 0;
370 t->time.tm_min = BCD2BIN(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f); 370 t->time.tm_min = bcd2bin(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f);
371 t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]); 371 t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]);
372 t->time.tm_mday = -1; 372 t->time.tm_mday = -1;
373 t->time.tm_mon = -1; 373 t->time.tm_mon = -1;
@@ -413,7 +413,7 @@ static int rs5c_set_alarm(struct device *dev, struct rtc_wkalrm *t)
413 } 413 }
414 414
415 /* set alarm */ 415 /* set alarm */
416 buf[0] = BIN2BCD(t->time.tm_min); 416 buf[0] = bin2bcd(t->time.tm_min);
417 buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour); 417 buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour);
418 buf[2] = 0x7f; /* any/all days */ 418 buf[2] = 0x7f; /* any/all days */
419 419