Commit 357c6e63590895dc87cc9300f5a1c27544ea69e8
Committed by
Linus Torvalds
1 parent
fe20ba70ab
Exists in
master
and in
39 other branches
rtc: use bcd2bin/bin2bcd
Change various rtc related code 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>
Showing 6 changed files with 83 additions and 83 deletions Side-by-side Diff
arch/x86/kernel/rtc.c
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | |
53 | 53 | cmos_minutes = CMOS_READ(RTC_MINUTES); |
54 | 54 | if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) |
55 | - BCD_TO_BIN(cmos_minutes); | |
55 | + cmos_minutes = bcd2bin(cmos_minutes); | |
56 | 56 | |
57 | 57 | /* |
58 | 58 | * since we're only adjusting minutes and seconds, |
... | ... | @@ -69,8 +69,8 @@ |
69 | 69 | |
70 | 70 | if (abs(real_minutes - cmos_minutes) < 30) { |
71 | 71 | if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { |
72 | - BIN_TO_BCD(real_seconds); | |
73 | - BIN_TO_BCD(real_minutes); | |
72 | + real_seconds = bin2bcd(real_seconds); | |
73 | + real_minutes = bin2bcd(real_minutes); | |
74 | 74 | } |
75 | 75 | CMOS_WRITE(real_seconds,RTC_SECONDS); |
76 | 76 | CMOS_WRITE(real_minutes,RTC_MINUTES); |
77 | 77 | |
... | ... | @@ -124,16 +124,16 @@ |
124 | 124 | WARN_ON_ONCE(RTC_ALWAYS_BCD && (status & RTC_DM_BINARY)); |
125 | 125 | |
126 | 126 | if (RTC_ALWAYS_BCD || !(status & RTC_DM_BINARY)) { |
127 | - BCD_TO_BIN(sec); | |
128 | - BCD_TO_BIN(min); | |
129 | - BCD_TO_BIN(hour); | |
130 | - BCD_TO_BIN(day); | |
131 | - BCD_TO_BIN(mon); | |
132 | - BCD_TO_BIN(year); | |
127 | + sec = bcd2bin(sec); | |
128 | + min = bcd2bin(min); | |
129 | + hour = bcd2bin(hour); | |
130 | + day = bcd2bin(day); | |
131 | + mon = bcd2bin(mon); | |
132 | + year = bcd2bin(year); | |
133 | 133 | } |
134 | 134 | |
135 | 135 | if (century) { |
136 | - BCD_TO_BIN(century); | |
136 | + century = bcd2bin(century); | |
137 | 137 | year += century * 100; |
138 | 138 | printk(KERN_INFO "Extended CMOS year: %d\n", century * 100); |
139 | 139 | } else |
drivers/char/ds1286.c
... | ... | @@ -210,8 +210,8 @@ |
210 | 210 | if (sec != 0) |
211 | 211 | return -EINVAL; |
212 | 212 | |
213 | - min = BIN2BCD(min); | |
214 | - min = BIN2BCD(hrs); | |
213 | + min = bin2bcd(min); | |
214 | + min = bin2bcd(hrs); | |
215 | 215 | |
216 | 216 | spin_lock(&ds1286_lock); |
217 | 217 | rtc_write(hrs, RTC_HOURS_ALARM); |
... | ... | @@ -353,7 +353,7 @@ |
353 | 353 | |
354 | 354 | ds1286_get_time(&tm); |
355 | 355 | hundredth = rtc_read(RTC_HUNDREDTH_SECOND); |
356 | - BCD_TO_BIN(hundredth); | |
356 | + hundredth = bcd2bin(hundredth); | |
357 | 357 | |
358 | 358 | p += sprintf(p, |
359 | 359 | "rtc_time\t: %02d:%02d:%02d.%02d\n" |
... | ... | @@ -477,12 +477,12 @@ |
477 | 477 | rtc_write(save_control, RTC_CMD); |
478 | 478 | spin_unlock_irqrestore(&ds1286_lock, flags); |
479 | 479 | |
480 | - BCD_TO_BIN(rtc_tm->tm_sec); | |
481 | - BCD_TO_BIN(rtc_tm->tm_min); | |
482 | - BCD_TO_BIN(rtc_tm->tm_hour); | |
483 | - BCD_TO_BIN(rtc_tm->tm_mday); | |
484 | - BCD_TO_BIN(rtc_tm->tm_mon); | |
485 | - BCD_TO_BIN(rtc_tm->tm_year); | |
480 | + rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | |
481 | + rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | |
482 | + rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | |
483 | + rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); | |
484 | + rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); | |
485 | + rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | |
486 | 486 | |
487 | 487 | /* |
488 | 488 | * Account for differences between how the RTC uses the values |
... | ... | @@ -531,12 +531,12 @@ |
531 | 531 | if (yrs >= 100) |
532 | 532 | yrs -= 100; |
533 | 533 | |
534 | - BIN_TO_BCD(sec); | |
535 | - BIN_TO_BCD(min); | |
536 | - BIN_TO_BCD(hrs); | |
537 | - BIN_TO_BCD(day); | |
538 | - BIN_TO_BCD(mon); | |
539 | - BIN_TO_BCD(yrs); | |
534 | + sec = bin2bcd(sec); | |
535 | + min = bin2bcd(min); | |
536 | + hrs = bin2bcd(hrs); | |
537 | + day = bin2bcd(day); | |
538 | + mon = bin2bcd(mon); | |
539 | + yrs = bin2bcd(yrs); | |
540 | 540 | |
541 | 541 | spin_lock_irqsave(&ds1286_lock, flags); |
542 | 542 | save_control = rtc_read(RTC_CMD); |
... | ... | @@ -572,8 +572,8 @@ |
572 | 572 | cmd = rtc_read(RTC_CMD); |
573 | 573 | spin_unlock_irqrestore(&ds1286_lock, flags); |
574 | 574 | |
575 | - BCD_TO_BIN(alm_tm->tm_min); | |
576 | - BCD_TO_BIN(alm_tm->tm_hour); | |
575 | + alm_tm->tm_min = bcd2bin(alm_tm->tm_min); | |
576 | + alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour); | |
577 | 577 | alm_tm->tm_sec = 0; |
578 | 578 | } |
579 | 579 |
drivers/char/ds1302.c
... | ... | @@ -131,12 +131,12 @@ |
131 | 131 | |
132 | 132 | local_irq_restore(flags); |
133 | 133 | |
134 | - BCD_TO_BIN(rtc_tm->tm_sec); | |
135 | - BCD_TO_BIN(rtc_tm->tm_min); | |
136 | - BCD_TO_BIN(rtc_tm->tm_hour); | |
137 | - BCD_TO_BIN(rtc_tm->tm_mday); | |
138 | - BCD_TO_BIN(rtc_tm->tm_mon); | |
139 | - BCD_TO_BIN(rtc_tm->tm_year); | |
134 | + rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | |
135 | + rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | |
136 | + rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | |
137 | + rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); | |
138 | + rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); | |
139 | + rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | |
140 | 140 | |
141 | 141 | /* |
142 | 142 | * Account for differences between how the RTC uses the values |
... | ... | @@ -211,12 +211,12 @@ |
211 | 211 | else |
212 | 212 | yrs -= 1900; /* RTC (70, 71, ... 99) */ |
213 | 213 | |
214 | - BIN_TO_BCD(sec); | |
215 | - BIN_TO_BCD(min); | |
216 | - BIN_TO_BCD(hrs); | |
217 | - BIN_TO_BCD(day); | |
218 | - BIN_TO_BCD(mon); | |
219 | - BIN_TO_BCD(yrs); | |
214 | + sec = bin2bcd(sec); | |
215 | + min = bin2bcd(min); | |
216 | + hrs = bin2bcd(hrs); | |
217 | + day = bin2bcd(day); | |
218 | + mon = bin2bcd(mon); | |
219 | + yrs = bin2bcd(yrs); | |
220 | 220 | |
221 | 221 | lock_kernel(); |
222 | 222 | local_irq_save(flags); |
drivers/char/ip27-rtc.c
... | ... | @@ -130,12 +130,12 @@ |
130 | 130 | if (yrs >= 100) |
131 | 131 | yrs -= 100; |
132 | 132 | |
133 | - sec = BIN2BCD(sec); | |
134 | - min = BIN2BCD(min); | |
135 | - hrs = BIN2BCD(hrs); | |
136 | - day = BIN2BCD(day); | |
137 | - mon = BIN2BCD(mon); | |
138 | - yrs = BIN2BCD(yrs); | |
133 | + sec = bin2bcd(sec); | |
134 | + min = bin2bcd(min); | |
135 | + hrs = bin2bcd(hrs); | |
136 | + day = bin2bcd(day); | |
137 | + mon = bin2bcd(mon); | |
138 | + yrs = bin2bcd(yrs); | |
139 | 139 | |
140 | 140 | spin_lock_irq(&rtc_lock); |
141 | 141 | rtc->control |= M48T35_RTC_SET; |
... | ... | @@ -311,12 +311,12 @@ |
311 | 311 | rtc->control &= ~M48T35_RTC_READ; |
312 | 312 | spin_unlock_irq(&rtc_lock); |
313 | 313 | |
314 | - rtc_tm->tm_sec = BCD2BIN(rtc_tm->tm_sec); | |
315 | - rtc_tm->tm_min = BCD2BIN(rtc_tm->tm_min); | |
316 | - rtc_tm->tm_hour = BCD2BIN(rtc_tm->tm_hour); | |
317 | - rtc_tm->tm_mday = BCD2BIN(rtc_tm->tm_mday); | |
318 | - rtc_tm->tm_mon = BCD2BIN(rtc_tm->tm_mon); | |
319 | - rtc_tm->tm_year = BCD2BIN(rtc_tm->tm_year); | |
314 | + rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | |
315 | + rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | |
316 | + rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | |
317 | + rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); | |
318 | + rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); | |
319 | + rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | |
320 | 320 | |
321 | 321 | /* |
322 | 322 | * Account for differences between how the RTC uses the values |
drivers/char/rtc.c
... | ... | @@ -518,17 +518,17 @@ |
518 | 518 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || |
519 | 519 | RTC_ALWAYS_BCD) { |
520 | 520 | if (sec < 60) |
521 | - BIN_TO_BCD(sec); | |
521 | + sec = bin2bcd(sec); | |
522 | 522 | else |
523 | 523 | sec = 0xff; |
524 | 524 | |
525 | 525 | if (min < 60) |
526 | - BIN_TO_BCD(min); | |
526 | + min = bin2bcd(min); | |
527 | 527 | else |
528 | 528 | min = 0xff; |
529 | 529 | |
530 | 530 | if (hrs < 24) |
531 | - BIN_TO_BCD(hrs); | |
531 | + hrs = bin2bcd(hrs); | |
532 | 532 | else |
533 | 533 | hrs = 0xff; |
534 | 534 | } |
... | ... | @@ -614,12 +614,12 @@ |
614 | 614 | |
615 | 615 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) |
616 | 616 | || RTC_ALWAYS_BCD) { |
617 | - BIN_TO_BCD(sec); | |
618 | - BIN_TO_BCD(min); | |
619 | - BIN_TO_BCD(hrs); | |
620 | - BIN_TO_BCD(day); | |
621 | - BIN_TO_BCD(mon); | |
622 | - BIN_TO_BCD(yrs); | |
617 | + sec = bin2bcd(sec); | |
618 | + min = bin2bcd(min); | |
619 | + hrs = bin2bcd(hrs); | |
620 | + day = bin2bcd(day); | |
621 | + mon = bin2bcd(mon); | |
622 | + yrs = bin2bcd(yrs); | |
623 | 623 | } |
624 | 624 | |
625 | 625 | save_control = CMOS_READ(RTC_CONTROL); |
... | ... | @@ -1099,7 +1099,7 @@ |
1099 | 1099 | spin_unlock_irq(&rtc_lock); |
1100 | 1100 | |
1101 | 1101 | if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) |
1102 | - BCD_TO_BIN(year); /* This should never happen... */ | |
1102 | + year = bcd2bin(year); /* This should never happen... */ | |
1103 | 1103 | |
1104 | 1104 | if (year < 20) { |
1105 | 1105 | epoch = 2000; |
... | ... | @@ -1352,13 +1352,13 @@ |
1352 | 1352 | spin_unlock_irqrestore(&rtc_lock, flags); |
1353 | 1353 | |
1354 | 1354 | if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { |
1355 | - BCD_TO_BIN(rtc_tm->tm_sec); | |
1356 | - BCD_TO_BIN(rtc_tm->tm_min); | |
1357 | - BCD_TO_BIN(rtc_tm->tm_hour); | |
1358 | - BCD_TO_BIN(rtc_tm->tm_mday); | |
1359 | - BCD_TO_BIN(rtc_tm->tm_mon); | |
1360 | - BCD_TO_BIN(rtc_tm->tm_year); | |
1361 | - BCD_TO_BIN(rtc_tm->tm_wday); | |
1355 | + rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | |
1356 | + rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | |
1357 | + rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | |
1358 | + rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); | |
1359 | + rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); | |
1360 | + rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | |
1361 | + rtc_tm->tm_wday = bcd2bin(rtc_tm->tm_wday); | |
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | #ifdef CONFIG_MACH_DECSTATION |
... | ... | @@ -1392,9 +1392,9 @@ |
1392 | 1392 | spin_unlock_irq(&rtc_lock); |
1393 | 1393 | |
1394 | 1394 | if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { |
1395 | - BCD_TO_BIN(alm_tm->tm_sec); | |
1396 | - BCD_TO_BIN(alm_tm->tm_min); | |
1397 | - BCD_TO_BIN(alm_tm->tm_hour); | |
1395 | + alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec); | |
1396 | + alm_tm->tm_min = bcd2bin(alm_tm->tm_min); | |
1397 | + alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour); | |
1398 | 1398 | } |
1399 | 1399 | } |
1400 | 1400 |
include/asm-generic/rtc.h
... | ... | @@ -84,12 +84,12 @@ |
84 | 84 | |
85 | 85 | if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) |
86 | 86 | { |
87 | - BCD_TO_BIN(time->tm_sec); | |
88 | - BCD_TO_BIN(time->tm_min); | |
89 | - BCD_TO_BIN(time->tm_hour); | |
90 | - BCD_TO_BIN(time->tm_mday); | |
91 | - BCD_TO_BIN(time->tm_mon); | |
92 | - BCD_TO_BIN(time->tm_year); | |
87 | + time->tm_sec = bcd2bin(time->tm_sec); | |
88 | + time->tm_min = bcd2bin(time->tm_min); | |
89 | + time->tm_hour = bcd2bin(time->tm_hour); | |
90 | + time->tm_mday = bcd2bin(time->tm_mday); | |
91 | + time->tm_mon = bcd2bin(time->tm_mon); | |
92 | + time->tm_year = bcd2bin(time->tm_year); | |
93 | 93 | } |
94 | 94 | |
95 | 95 | #ifdef CONFIG_MACH_DECSTATION |
... | ... | @@ -159,12 +159,12 @@ |
159 | 159 | |
160 | 160 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) |
161 | 161 | || RTC_ALWAYS_BCD) { |
162 | - BIN_TO_BCD(sec); | |
163 | - BIN_TO_BCD(min); | |
164 | - BIN_TO_BCD(hrs); | |
165 | - BIN_TO_BCD(day); | |
166 | - BIN_TO_BCD(mon); | |
167 | - BIN_TO_BCD(yrs); | |
162 | + sec = bin2bcd(sec); | |
163 | + min = bin2bcd(min); | |
164 | + hrs = bin2bcd(hrs); | |
165 | + day = bin2bcd(day); | |
166 | + mon = bin2bcd(mon); | |
167 | + yrs = bin2bcd(yrs); | |
168 | 168 | } |
169 | 169 | |
170 | 170 | save_control = CMOS_READ(RTC_CONTROL); |