aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@kernel.org>2008-10-13 15:58:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-14 13:23:26 -0400
commit5b1d5f953bbb50dcbdf93719cb622aa128ba7527 (patch)
treed1f826b007e909bbf340498376c83a0452359af4 /arch/m68k
parent4aba41ea8bdc1b475861f5e5c1649ab20251090c (diff)
m68k: use bcd2bin/bin2bcd
This patch changes m68k to use the new bcd2bin/bin2bcd functions instead of the obsolete BCD_TO_BIN/BIN_TO_BCD/BCD2BIN/BIN2BCD macros. It also remove local bcd2bin/bin2bcd implementations in favor of the global ones. Signed-off-by: Adrian Bunk <bunk@kernel.org> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/atari/time.c35
-rw-r--r--arch/m68k/bvme6000/config.c15
-rw-r--r--arch/m68k/bvme6000/rtc.c30
-rw-r--r--arch/m68k/mvme16x/rtc.c26
-rw-r--r--arch/m68k/q40/config.c12
-rw-r--r--arch/m68k/sun3x/time.c28
6 files changed, 62 insertions, 84 deletions
diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c
index e0d3c8bfb408..e2df4a13d2bb 100644
--- a/arch/m68k/atari/time.c
+++ b/arch/m68k/atari/time.c
@@ -191,13 +191,14 @@ int atari_tt_hwclk( int op, struct rtc_time *t )
191 } 191 }
192 192
193 if (!(ctrl & RTC_DM_BINARY)) { 193 if (!(ctrl & RTC_DM_BINARY)) {
194 BIN_TO_BCD(sec); 194 sec = bin2bcd(sec);
195 BIN_TO_BCD(min); 195 min = bin2bcd(min);
196 BIN_TO_BCD(hour); 196 hour = bin2bcd(hour);
197 BIN_TO_BCD(day); 197 day = bin2bcd(day);
198 BIN_TO_BCD(mon); 198 mon = bin2bcd(mon);
199 BIN_TO_BCD(year); 199 year = bin2bcd(year);
200 if (wday >= 0) BIN_TO_BCD(wday); 200 if (wday >= 0)
201 wday = bin2bcd(wday);
201 } 202 }
202 } 203 }
203 204
@@ -252,13 +253,13 @@ int atari_tt_hwclk( int op, struct rtc_time *t )
252 } 253 }
253 254
254 if (!(ctrl & RTC_DM_BINARY)) { 255 if (!(ctrl & RTC_DM_BINARY)) {
255 BCD_TO_BIN(sec); 256 sec = bcd2bin(sec);
256 BCD_TO_BIN(min); 257 min = bcd2bin(min);
257 BCD_TO_BIN(hour); 258 hour = bcd2bin(hour);
258 BCD_TO_BIN(day); 259 day = bcd2bin(day);
259 BCD_TO_BIN(mon); 260 mon = bcd2bin(mon);
260 BCD_TO_BIN(year); 261 year = bcd2bin(year);
261 BCD_TO_BIN(wday); 262 wday = bcd2bin(wday);
262 } 263 }
263 264
264 if (!(ctrl & RTC_24H)) { 265 if (!(ctrl & RTC_24H)) {
@@ -318,7 +319,7 @@ int atari_tt_set_clock_mmss (unsigned long nowtime)
318 319
319 rtc_minutes = RTC_READ (RTC_MINUTES); 320 rtc_minutes = RTC_READ (RTC_MINUTES);
320 if (!(save_control & RTC_DM_BINARY)) 321 if (!(save_control & RTC_DM_BINARY))
321 BCD_TO_BIN (rtc_minutes); 322 rtc_minutes = bcd2bin(rtc_minutes);
322 323
323 /* Since we're only adjusting minutes and seconds, don't interfere 324 /* Since we're only adjusting minutes and seconds, don't interfere
324 with hour overflow. This avoids messing with unknown time zones 325 with hour overflow. This avoids messing with unknown time zones
@@ -329,8 +330,8 @@ int atari_tt_set_clock_mmss (unsigned long nowtime)
329 { 330 {
330 if (!(save_control & RTC_DM_BINARY)) 331 if (!(save_control & RTC_DM_BINARY))
331 { 332 {
332 BIN_TO_BCD (real_seconds); 333 real_seconds = bin2bcd(real_seconds);
333 BIN_TO_BCD (real_minutes); 334 real_minutes = bin2bcd(real_minutes);
334 } 335 }
335 RTC_WRITE (RTC_SECONDS, real_seconds); 336 RTC_WRITE (RTC_SECONDS, real_seconds);
336 RTC_WRITE (RTC_MINUTES, real_minutes); 337 RTC_WRITE (RTC_MINUTES, real_minutes);
diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c
index 9433a88a33c4..65c9204ab9ac 100644
--- a/arch/m68k/bvme6000/config.c
+++ b/arch/m68k/bvme6000/config.c
@@ -25,6 +25,7 @@
25#include <linux/genhd.h> 25#include <linux/genhd.h>
26#include <linux/rtc.h> 26#include <linux/rtc.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/bcd.h>
28 29
29#include <asm/bootinfo.h> 30#include <asm/bootinfo.h>
30#include <asm/system.h> 31#include <asm/system.h>
@@ -46,9 +47,6 @@ extern void bvme6000_reset (void);
46extern void bvme6000_waitbut(void); 47extern void bvme6000_waitbut(void);
47void bvme6000_set_vectors (void); 48void bvme6000_set_vectors (void);
48 49
49static unsigned char bcd2bin (unsigned char b);
50static unsigned char bin2bcd (unsigned char b);
51
52/* Save tick handler routine pointer, will point to do_timer() in 50/* Save tick handler routine pointer, will point to do_timer() in
53 * kernel/sched.c, called via bvme6000_process_int() */ 51 * kernel/sched.c, called via bvme6000_process_int() */
54 52
@@ -264,17 +262,6 @@ unsigned long bvme6000_gettimeoffset (void)
264 return v; 262 return v;
265} 263}
266 264
267static unsigned char bcd2bin (unsigned char b)
268{
269 return ((b>>4)*10 + (b&15));
270}
271
272static unsigned char bin2bcd (unsigned char b)
273{
274 return (((b/10)*16) + (b%10));
275}
276
277
278/* 265/*
279 * Looks like op is non-zero for setting the clock, and zero for 266 * Looks like op is non-zero for setting the clock, and zero for
280 * reading the clock. 267 * reading the clock.
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index e8ac3f7d72df..808c9018b115 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -57,16 +57,16 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
57 rtc->msr = 0x40; 57 rtc->msr = 0x40;
58 memset(&wtime, 0, sizeof(struct rtc_time)); 58 memset(&wtime, 0, sizeof(struct rtc_time));
59 do { 59 do {
60 wtime.tm_sec = BCD2BIN(rtc->bcd_sec); 60 wtime.tm_sec = bcd2bin(rtc->bcd_sec);
61 wtime.tm_min = BCD2BIN(rtc->bcd_min); 61 wtime.tm_min = bcd2bin(rtc->bcd_min);
62 wtime.tm_hour = BCD2BIN(rtc->bcd_hr); 62 wtime.tm_hour = bcd2bin(rtc->bcd_hr);
63 wtime.tm_mday = BCD2BIN(rtc->bcd_dom); 63 wtime.tm_mday = bcd2bin(rtc->bcd_dom);
64 wtime.tm_mon = BCD2BIN(rtc->bcd_mth)-1; 64 wtime.tm_mon = bcd2bin(rtc->bcd_mth)-1;
65 wtime.tm_year = BCD2BIN(rtc->bcd_year); 65 wtime.tm_year = bcd2bin(rtc->bcd_year);
66 if (wtime.tm_year < 70) 66 if (wtime.tm_year < 70)
67 wtime.tm_year += 100; 67 wtime.tm_year += 100;
68 wtime.tm_wday = BCD2BIN(rtc->bcd_dow)-1; 68 wtime.tm_wday = bcd2bin(rtc->bcd_dow)-1;
69 } while (wtime.tm_sec != BCD2BIN(rtc->bcd_sec)); 69 } while (wtime.tm_sec != bcd2bin(rtc->bcd_sec));
70 rtc->msr = msr; 70 rtc->msr = msr;
71 local_irq_restore(flags); 71 local_irq_restore(flags);
72 return copy_to_user(argp, &wtime, sizeof wtime) ? 72 return copy_to_user(argp, &wtime, sizeof wtime) ?
@@ -114,14 +114,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
114 114
115 rtc->t0cr_rtmr = yrs%4; 115 rtc->t0cr_rtmr = yrs%4;
116 rtc->bcd_tenms = 0; 116 rtc->bcd_tenms = 0;
117 rtc->bcd_sec = BIN2BCD(sec); 117 rtc->bcd_sec = bin2bcd(sec);
118 rtc->bcd_min = BIN2BCD(min); 118 rtc->bcd_min = bin2bcd(min);
119 rtc->bcd_hr = BIN2BCD(hrs); 119 rtc->bcd_hr = bin2bcd(hrs);
120 rtc->bcd_dom = BIN2BCD(day); 120 rtc->bcd_dom = bin2bcd(day);
121 rtc->bcd_mth = BIN2BCD(mon); 121 rtc->bcd_mth = bin2bcd(mon);
122 rtc->bcd_year = BIN2BCD(yrs%100); 122 rtc->bcd_year = bin2bcd(yrs%100);
123 if (rtc_tm.tm_wday >= 0) 123 if (rtc_tm.tm_wday >= 0)
124 rtc->bcd_dow = BIN2BCD(rtc_tm.tm_wday+1); 124 rtc->bcd_dow = bin2bcd(rtc_tm.tm_wday+1);
125 rtc->t0cr_rtmr = yrs%4 | 0x08; 125 rtc->t0cr_rtmr = yrs%4 | 0x08;
126 126
127 rtc->msr = msr; 127 rtc->msr = msr;
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 432a9f13b2ed..cea5e3e4e636 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -52,15 +52,15 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
52 /* Ensure clock and real-time-mode-register are accessible */ 52 /* Ensure clock and real-time-mode-register are accessible */
53 rtc->ctrl = RTC_READ; 53 rtc->ctrl = RTC_READ;
54 memset(&wtime, 0, sizeof(struct rtc_time)); 54 memset(&wtime, 0, sizeof(struct rtc_time));
55 wtime.tm_sec = BCD2BIN(rtc->bcd_sec); 55 wtime.tm_sec = bcd2bin(rtc->bcd_sec);
56 wtime.tm_min = BCD2BIN(rtc->bcd_min); 56 wtime.tm_min = bcd2bin(rtc->bcd_min);
57 wtime.tm_hour = BCD2BIN(rtc->bcd_hr); 57 wtime.tm_hour = bcd2bin(rtc->bcd_hr);
58 wtime.tm_mday = BCD2BIN(rtc->bcd_dom); 58 wtime.tm_mday = bcd2bin(rtc->bcd_dom);
59 wtime.tm_mon = BCD2BIN(rtc->bcd_mth)-1; 59 wtime.tm_mon = bcd2bin(rtc->bcd_mth)-1;
60 wtime.tm_year = BCD2BIN(rtc->bcd_year); 60 wtime.tm_year = bcd2bin(rtc->bcd_year);
61 if (wtime.tm_year < 70) 61 if (wtime.tm_year < 70)
62 wtime.tm_year += 100; 62 wtime.tm_year += 100;
63 wtime.tm_wday = BCD2BIN(rtc->bcd_dow)-1; 63 wtime.tm_wday = bcd2bin(rtc->bcd_dow)-1;
64 rtc->ctrl = 0; 64 rtc->ctrl = 0;
65 local_irq_restore(flags); 65 local_irq_restore(flags);
66 return copy_to_user(argp, &wtime, sizeof wtime) ? 66 return copy_to_user(argp, &wtime, sizeof wtime) ?
@@ -104,12 +104,12 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
104 local_irq_save(flags); 104 local_irq_save(flags);
105 rtc->ctrl = RTC_WRITE; 105 rtc->ctrl = RTC_WRITE;
106 106
107 rtc->bcd_sec = BIN2BCD(sec); 107 rtc->bcd_sec = bin2bcd(sec);
108 rtc->bcd_min = BIN2BCD(min); 108 rtc->bcd_min = bin2bcd(min);
109 rtc->bcd_hr = BIN2BCD(hrs); 109 rtc->bcd_hr = bin2bcd(hrs);
110 rtc->bcd_dom = BIN2BCD(day); 110 rtc->bcd_dom = bin2bcd(day);
111 rtc->bcd_mth = BIN2BCD(mon); 111 rtc->bcd_mth = bin2bcd(mon);
112 rtc->bcd_year = BIN2BCD(yrs%100); 112 rtc->bcd_year = bin2bcd(yrs%100);
113 113
114 rtc->ctrl = 0; 114 rtc->ctrl = 0;
115 local_irq_restore(flags); 115 local_irq_restore(flags);
diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c
index be9de2f3dc48..9c7eefa3f98a 100644
--- a/arch/m68k/q40/config.c
+++ b/arch/m68k/q40/config.c
@@ -23,6 +23,7 @@
23#include <linux/serial_reg.h> 23#include <linux/serial_reg.h>
24#include <linux/rtc.h> 24#include <linux/rtc.h>
25#include <linux/vt_kern.h> 25#include <linux/vt_kern.h>
26#include <linux/bcd.h>
26 27
27#include <asm/io.h> 28#include <asm/io.h>
28#include <asm/rtc.h> 29#include <asm/rtc.h>
@@ -216,17 +217,6 @@ int q40_parse_bootinfo(const struct bi_record *rec)
216} 217}
217 218
218 219
219static inline unsigned char bcd2bin(unsigned char b)
220{
221 return (b >> 4) * 10 + (b & 15);
222}
223
224static inline unsigned char bin2bcd(unsigned char b)
225{
226 return (b / 10) * 16 + (b % 10);
227}
228
229
230static unsigned long q40_gettimeoffset(void) 220static unsigned long q40_gettimeoffset(void)
231{ 221{
232 return 5000 * (ql_ticks != 0); 222 return 5000 * (ql_ticks != 0);
diff --git a/arch/m68k/sun3x/time.c b/arch/m68k/sun3x/time.c
index f5eaafb00d21..536a04aaf22f 100644
--- a/arch/m68k/sun3x/time.c
+++ b/arch/m68k/sun3x/time.c
@@ -47,23 +47,23 @@ int sun3x_hwclk(int set, struct rtc_time *t)
47 47
48 if(set) { 48 if(set) {
49 h->csr |= C_WRITE; 49 h->csr |= C_WRITE;
50 h->sec = BIN2BCD(t->tm_sec); 50 h->sec = bin2bcd(t->tm_sec);
51 h->min = BIN2BCD(t->tm_min); 51 h->min = bin2bcd(t->tm_min);
52 h->hour = BIN2BCD(t->tm_hour); 52 h->hour = bin2bcd(t->tm_hour);
53 h->wday = BIN2BCD(t->tm_wday); 53 h->wday = bin2bcd(t->tm_wday);
54 h->mday = BIN2BCD(t->tm_mday); 54 h->mday = bin2bcd(t->tm_mday);
55 h->month = BIN2BCD(t->tm_mon); 55 h->month = bin2bcd(t->tm_mon);
56 h->year = BIN2BCD(t->tm_year); 56 h->year = bin2bcd(t->tm_year);
57 h->csr &= ~C_WRITE; 57 h->csr &= ~C_WRITE;
58 } else { 58 } else {
59 h->csr |= C_READ; 59 h->csr |= C_READ;
60 t->tm_sec = BCD2BIN(h->sec); 60 t->tm_sec = bcd2bin(h->sec);
61 t->tm_min = BCD2BIN(h->min); 61 t->tm_min = bcd2bin(h->min);
62 t->tm_hour = BCD2BIN(h->hour); 62 t->tm_hour = bcd2bin(h->hour);
63 t->tm_wday = BCD2BIN(h->wday); 63 t->tm_wday = bcd2bin(h->wday);
64 t->tm_mday = BCD2BIN(h->mday); 64 t->tm_mday = bcd2bin(h->mday);
65 t->tm_mon = BCD2BIN(h->month); 65 t->tm_mon = bcd2bin(h->month);
66 t->tm_year = BCD2BIN(h->year); 66 t->tm_year = bcd2bin(h->year);
67 h->csr &= ~C_READ; 67 h->csr &= ~C_READ;
68 } 68 }
69 69