aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-fm3130.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-fm3130.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-fm3130.c')
-rw-r--r--drivers/rtc/rtc-fm3130.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c
index abfdfcbaa059..3a7be11cc6b9 100644
--- a/drivers/rtc/rtc-fm3130.c
+++ b/drivers/rtc/rtc-fm3130.c
@@ -131,17 +131,17 @@ static int fm3130_get_time(struct device *dev, struct rtc_time *t)
131 fm3130->regs[0xc], fm3130->regs[0xd], 131 fm3130->regs[0xc], fm3130->regs[0xd],
132 fm3130->regs[0xe]); 132 fm3130->regs[0xe]);
133 133
134 t->tm_sec = BCD2BIN(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f); 134 t->tm_sec = bcd2bin(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f);
135 t->tm_min = BCD2BIN(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); 135 t->tm_min = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f);
136 tmp = fm3130->regs[FM3130_RTC_HOURS] & 0x3f; 136 tmp = fm3130->regs[FM3130_RTC_HOURS] & 0x3f;
137 t->tm_hour = BCD2BIN(tmp); 137 t->tm_hour = bcd2bin(tmp);
138 t->tm_wday = BCD2BIN(fm3130->regs[FM3130_RTC_DAY] & 0x07) - 1; 138 t->tm_wday = bcd2bin(fm3130->regs[FM3130_RTC_DAY] & 0x07) - 1;
139 t->tm_mday = BCD2BIN(fm3130->regs[FM3130_RTC_DATE] & 0x3f); 139 t->tm_mday = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f);
140 tmp = fm3130->regs[FM3130_RTC_MONTHS] & 0x1f; 140 tmp = fm3130->regs[FM3130_RTC_MONTHS] & 0x1f;
141 t->tm_mon = BCD2BIN(tmp) - 1; 141 t->tm_mon = bcd2bin(tmp) - 1;
142 142
143 /* assume 20YY not 19YY, and ignore CF bit */ 143 /* assume 20YY not 19YY, and ignore CF bit */
144 t->tm_year = BCD2BIN(fm3130->regs[FM3130_RTC_YEARS]) + 100; 144 t->tm_year = bcd2bin(fm3130->regs[FM3130_RTC_YEARS]) + 100;
145 145
146 dev_dbg(dev, "%s secs=%d, mins=%d, " 146 dev_dbg(dev, "%s secs=%d, mins=%d, "
147 "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", 147 "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -167,16 +167,16 @@ static int fm3130_set_time(struct device *dev, struct rtc_time *t)
167 t->tm_mon, t->tm_year, t->tm_wday); 167 t->tm_mon, t->tm_year, t->tm_wday);
168 168
169 /* first register addr */ 169 /* first register addr */
170 buf[FM3130_RTC_SECONDS] = BIN2BCD(t->tm_sec); 170 buf[FM3130_RTC_SECONDS] = bin2bcd(t->tm_sec);
171 buf[FM3130_RTC_MINUTES] = BIN2BCD(t->tm_min); 171 buf[FM3130_RTC_MINUTES] = bin2bcd(t->tm_min);
172 buf[FM3130_RTC_HOURS] = BIN2BCD(t->tm_hour); 172 buf[FM3130_RTC_HOURS] = bin2bcd(t->tm_hour);
173 buf[FM3130_RTC_DAY] = BIN2BCD(t->tm_wday + 1); 173 buf[FM3130_RTC_DAY] = bin2bcd(t->tm_wday + 1);
174 buf[FM3130_RTC_DATE] = BIN2BCD(t->tm_mday); 174 buf[FM3130_RTC_DATE] = bin2bcd(t->tm_mday);
175 buf[FM3130_RTC_MONTHS] = BIN2BCD(t->tm_mon + 1); 175 buf[FM3130_RTC_MONTHS] = bin2bcd(t->tm_mon + 1);
176 176
177 /* assume 20YY not 19YY */ 177 /* assume 20YY not 19YY */
178 tmp = t->tm_year - 100; 178 tmp = t->tm_year - 100;
179 buf[FM3130_RTC_YEARS] = BIN2BCD(tmp); 179 buf[FM3130_RTC_YEARS] = bin2bcd(tmp);
180 180
181 dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x" 181 dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x"
182 "%02x %02x %02x %02x %02x %02x %02x %02x\n", 182 "%02x %02x %02x %02x %02x %02x %02x %02x\n",
@@ -222,11 +222,11 @@ static int fm3130_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
222 fm3130->regs[FM3130_ALARM_MONTHS]); 222 fm3130->regs[FM3130_ALARM_MONTHS]);
223 223
224 224
225 tm->tm_sec = BCD2BIN(fm3130->regs[FM3130_ALARM_SECONDS] & 0x7F); 225 tm->tm_sec = bcd2bin(fm3130->regs[FM3130_ALARM_SECONDS] & 0x7F);
226 tm->tm_min = BCD2BIN(fm3130->regs[FM3130_ALARM_MINUTES] & 0x7F); 226 tm->tm_min = bcd2bin(fm3130->regs[FM3130_ALARM_MINUTES] & 0x7F);
227 tm->tm_hour = BCD2BIN(fm3130->regs[FM3130_ALARM_HOURS] & 0x3F); 227 tm->tm_hour = bcd2bin(fm3130->regs[FM3130_ALARM_HOURS] & 0x3F);
228 tm->tm_mday = BCD2BIN(fm3130->regs[FM3130_ALARM_DATE] & 0x3F); 228 tm->tm_mday = bcd2bin(fm3130->regs[FM3130_ALARM_DATE] & 0x3F);
229 tm->tm_mon = BCD2BIN(fm3130->regs[FM3130_ALARM_MONTHS] & 0x1F); 229 tm->tm_mon = bcd2bin(fm3130->regs[FM3130_ALARM_MONTHS] & 0x1F);
230 if (tm->tm_mon > 0) 230 if (tm->tm_mon > 0)
231 tm->tm_mon -= 1; /* RTC is 1-12, tm_mon is 0-11 */ 231 tm->tm_mon -= 1; /* RTC is 1-12, tm_mon is 0-11 */
232 dev_dbg(dev, "%s secs=%d, mins=%d, " 232 dev_dbg(dev, "%s secs=%d, mins=%d, "
@@ -252,23 +252,23 @@ static int fm3130_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
252 252
253 if (tm->tm_sec != -1) 253 if (tm->tm_sec != -1)
254 fm3130->regs[FM3130_ALARM_SECONDS] = 254 fm3130->regs[FM3130_ALARM_SECONDS] =
255 BIN2BCD(tm->tm_sec) | 0x80; 255 bin2bcd(tm->tm_sec) | 0x80;
256 256
257 if (tm->tm_min != -1) 257 if (tm->tm_min != -1)
258 fm3130->regs[FM3130_ALARM_MINUTES] = 258 fm3130->regs[FM3130_ALARM_MINUTES] =
259 BIN2BCD(tm->tm_min) | 0x80; 259 bin2bcd(tm->tm_min) | 0x80;
260 260
261 if (tm->tm_hour != -1) 261 if (tm->tm_hour != -1)
262 fm3130->regs[FM3130_ALARM_HOURS] = 262 fm3130->regs[FM3130_ALARM_HOURS] =
263 BIN2BCD(tm->tm_hour) | 0x80; 263 bin2bcd(tm->tm_hour) | 0x80;
264 264
265 if (tm->tm_mday != -1) 265 if (tm->tm_mday != -1)
266 fm3130->regs[FM3130_ALARM_DATE] = 266 fm3130->regs[FM3130_ALARM_DATE] =
267 BIN2BCD(tm->tm_mday) | 0x80; 267 bin2bcd(tm->tm_mday) | 0x80;
268 268
269 if (tm->tm_mon != -1) 269 if (tm->tm_mon != -1)
270 fm3130->regs[FM3130_ALARM_MONTHS] = 270 fm3130->regs[FM3130_ALARM_MONTHS] =
271 BIN2BCD(tm->tm_mon + 1) | 0x80; 271 bin2bcd(tm->tm_mon + 1) | 0x80;
272 272
273 dev_dbg(dev, "alarm write %02x %02x %02x %02x %02x\n", 273 dev_dbg(dev, "alarm write %02x %02x %02x %02x %02x\n",
274 fm3130->regs[FM3130_ALARM_SECONDS], 274 fm3130->regs[FM3130_ALARM_SECONDS],
@@ -414,18 +414,18 @@ static int __devinit fm3130_probe(struct i2c_client *client,
414 /* TODO */ 414 /* TODO */
415 /* TODO need to sanity check alarm */ 415 /* TODO need to sanity check alarm */
416 tmp = fm3130->regs[FM3130_RTC_SECONDS]; 416 tmp = fm3130->regs[FM3130_RTC_SECONDS];
417 tmp = BCD2BIN(tmp & 0x7f); 417 tmp = bcd2bin(tmp & 0x7f);
418 if (tmp > 60) 418 if (tmp > 60)
419 goto exit_bad; 419 goto exit_bad;
420 tmp = BCD2BIN(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); 420 tmp = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f);
421 if (tmp > 60) 421 if (tmp > 60)
422 goto exit_bad; 422 goto exit_bad;
423 423
424 tmp = BCD2BIN(fm3130->regs[FM3130_RTC_DATE] & 0x3f); 424 tmp = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f);
425 if (tmp == 0 || tmp > 31) 425 if (tmp == 0 || tmp > 31)
426 goto exit_bad; 426 goto exit_bad;
427 427
428 tmp = BCD2BIN(fm3130->regs[FM3130_RTC_MONTHS] & 0x1f); 428 tmp = bcd2bin(fm3130->regs[FM3130_RTC_MONTHS] & 0x1f);
429 if (tmp == 0 || tmp > 12) 429 if (tmp == 0 || tmp > 12)
430 goto exit_bad; 430 goto exit_bad;
431 431