diff options
-rw-r--r-- | arch/m68k/mvme16x/rtc.c | 4 | ||||
-rw-r--r-- | arch/mips/momentum/ocelot_3/setup.c | 34 | ||||
-rw-r--r-- | arch/mips/tx4938/common/rtc_rx5c348.c | 12 | ||||
-rw-r--r-- | arch/sh/boards/mpc1211/rtc.c | 9 | ||||
-rw-r--r-- | arch/sh/boards/sh03/rtc.c | 9 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/rtc.c | 10 | ||||
-rw-r--r-- | arch/sh64/kernel/time.c | 9 |
7 files changed, 22 insertions, 65 deletions
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c index a69fe3048edc..b0e4c084df8a 100644 --- a/arch/m68k/mvme16x/rtc.c +++ b/arch/m68k/mvme16x/rtc.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/poll.h> | 17 | #include <linux/poll.h> |
18 | #include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ | 18 | #include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ |
19 | #include <linux/smp_lock.h> | 19 | #include <linux/smp_lock.h> |
20 | #include <linux/bcd.h> | ||
20 | #include <asm/mvme16xhw.h> | 21 | #include <asm/mvme16xhw.h> |
21 | 22 | ||
22 | #include <asm/io.h> | 23 | #include <asm/io.h> |
@@ -31,9 +32,6 @@ | |||
31 | * ioctls. | 32 | * ioctls. |
32 | */ | 33 | */ |
33 | 34 | ||
34 | #define BCD2BIN(val) (((val)&15) + ((val)>>4)*10) | ||
35 | #define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) | ||
36 | |||
37 | static const unsigned char days_in_mo[] = | 35 | static const unsigned char days_in_mo[] = |
38 | {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | 36 | {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
39 | 37 | ||
diff --git a/arch/mips/momentum/ocelot_3/setup.c b/arch/mips/momentum/ocelot_3/setup.c index 969612eab8a6..370e75d0e75c 100644 --- a/arch/mips/momentum/ocelot_3/setup.c +++ b/arch/mips/momentum/ocelot_3/setup.c | |||
@@ -58,6 +58,7 @@ | |||
58 | #include <linux/bootmem.h> | 58 | #include <linux/bootmem.h> |
59 | #include <linux/mv643xx.h> | 59 | #include <linux/mv643xx.h> |
60 | #include <linux/pm.h> | 60 | #include <linux/pm.h> |
61 | #include <linux/bcd.h> | ||
61 | 62 | ||
62 | #include <asm/time.h> | 63 | #include <asm/time.h> |
63 | #include <asm/page.h> | 64 | #include <asm/page.h> |
@@ -131,9 +132,6 @@ void setup_wired_tlb_entries(void) | |||
131 | add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M); | 132 | add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M); |
132 | } | 133 | } |
133 | 134 | ||
134 | #define CONV_BCD_TO_BIN(val) (((val) & 0xf) + (((val) >> 4) * 10)) | ||
135 | #define CONV_BIN_TO_BCD(val) (((val) % 10) + (((val) / 10) << 4)) | ||
136 | |||
137 | unsigned long m48t37y_get_time(void) | 135 | unsigned long m48t37y_get_time(void) |
138 | { | 136 | { |
139 | unsigned int year, month, day, hour, min, sec; | 137 | unsigned int year, month, day, hour, min, sec; |
@@ -143,16 +141,16 @@ unsigned long m48t37y_get_time(void) | |||
143 | /* stop the update */ | 141 | /* stop the update */ |
144 | rtc_base[0x7ff8] = 0x40; | 142 | rtc_base[0x7ff8] = 0x40; |
145 | 143 | ||
146 | year = CONV_BCD_TO_BIN(rtc_base[0x7fff]); | 144 | year = BCD2BIN(rtc_base[0x7fff]); |
147 | year += CONV_BCD_TO_BIN(rtc_base[0x7ff1]) * 100; | 145 | year += BCD2BIN(rtc_base[0x7ff1]) * 100; |
148 | 146 | ||
149 | month = CONV_BCD_TO_BIN(rtc_base[0x7ffe]); | 147 | month = BCD2BIN(rtc_base[0x7ffe]); |
150 | 148 | ||
151 | day = CONV_BCD_TO_BIN(rtc_base[0x7ffd]); | 149 | day = BCD2BIN(rtc_base[0x7ffd]); |
152 | 150 | ||
153 | hour = CONV_BCD_TO_BIN(rtc_base[0x7ffb]); | 151 | hour = BCD2BIN(rtc_base[0x7ffb]); |
154 | min = CONV_BCD_TO_BIN(rtc_base[0x7ffa]); | 152 | min = BCD2BIN(rtc_base[0x7ffa]); |
155 | sec = CONV_BCD_TO_BIN(rtc_base[0x7ff9]); | 153 | sec = BCD2BIN(rtc_base[0x7ff9]); |
156 | 154 | ||
157 | /* start the update */ | 155 | /* start the update */ |
158 | rtc_base[0x7ff8] = 0x00; | 156 | rtc_base[0x7ff8] = 0x00; |
@@ -175,22 +173,22 @@ int m48t37y_set_time(unsigned long sec) | |||
175 | rtc_base[0x7ff8] = 0x80; | 173 | rtc_base[0x7ff8] = 0x80; |
176 | 174 | ||
177 | /* year */ | 175 | /* year */ |
178 | rtc_base[0x7fff] = CONV_BIN_TO_BCD(tm.tm_year % 100); | 176 | rtc_base[0x7fff] = BIN2BCD(tm.tm_year % 100); |
179 | rtc_base[0x7ff1] = CONV_BIN_TO_BCD(tm.tm_year / 100); | 177 | rtc_base[0x7ff1] = BIN2BCD(tm.tm_year / 100); |
180 | 178 | ||
181 | /* month */ | 179 | /* month */ |
182 | rtc_base[0x7ffe] = CONV_BIN_TO_BCD(tm.tm_mon); | 180 | rtc_base[0x7ffe] = BIN2BCD(tm.tm_mon); |
183 | 181 | ||
184 | /* day */ | 182 | /* day */ |
185 | rtc_base[0x7ffd] = CONV_BIN_TO_BCD(tm.tm_mday); | 183 | rtc_base[0x7ffd] = BIN2BCD(tm.tm_mday); |
186 | 184 | ||
187 | /* hour/min/sec */ | 185 | /* hour/min/sec */ |
188 | rtc_base[0x7ffb] = CONV_BIN_TO_BCD(tm.tm_hour); | 186 | rtc_base[0x7ffb] = BIN2BCD(tm.tm_hour); |
189 | rtc_base[0x7ffa] = CONV_BIN_TO_BCD(tm.tm_min); | 187 | rtc_base[0x7ffa] = BIN2BCD(tm.tm_min); |
190 | rtc_base[0x7ff9] = CONV_BIN_TO_BCD(tm.tm_sec); | 188 | rtc_base[0x7ff9] = BIN2BCD(tm.tm_sec); |
191 | 189 | ||
192 | /* day of week -- not really used, but let's keep it up-to-date */ | 190 | /* day of week -- not really used, but let's keep it up-to-date */ |
193 | rtc_base[0x7ffc] = CONV_BIN_TO_BCD(tm.tm_wday + 1); | 191 | rtc_base[0x7ffc] = BIN2BCD(tm.tm_wday + 1); |
194 | 192 | ||
195 | /* disable writing */ | 193 | /* disable writing */ |
196 | rtc_base[0x7ff8] = 0x00; | 194 | rtc_base[0x7ff8] = 0x00; |
diff --git a/arch/mips/tx4938/common/rtc_rx5c348.c b/arch/mips/tx4938/common/rtc_rx5c348.c index f74295f28527..07f782fc0725 100644 --- a/arch/mips/tx4938/common/rtc_rx5c348.c +++ b/arch/mips/tx4938/common/rtc_rx5c348.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/string.h> | 14 | #include <linux/string.h> |
15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
16 | #include <linux/time.h> | 16 | #include <linux/time.h> |
17 | #include <linux/bcd.h> | ||
17 | #include <asm/time.h> | 18 | #include <asm/time.h> |
18 | #include <asm/tx4938/spi.h> | 19 | #include <asm/tx4938/spi.h> |
19 | 20 | ||
@@ -77,17 +78,6 @@ spi_rtc_io(unsigned char *inbuf, unsigned char *outbuf, unsigned int count) | |||
77 | inbufs, incounts, outbufs, outcounts, 0); | 78 | inbufs, incounts, outbufs, outcounts, 0); |
78 | } | 79 | } |
79 | 80 | ||
80 | /* | ||
81 | * Conversion between binary and BCD. | ||
82 | */ | ||
83 | #ifndef BCD_TO_BIN | ||
84 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
85 | #endif | ||
86 | |||
87 | #ifndef BIN_TO_BCD | ||
88 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
89 | #endif | ||
90 | |||
91 | /* RTC-dependent code for time.c */ | 81 | /* RTC-dependent code for time.c */ |
92 | 82 | ||
93 | static int | 83 | static int |
diff --git a/arch/sh/boards/mpc1211/rtc.c b/arch/sh/boards/mpc1211/rtc.c index 8ae2dc11d8e5..a76c655dceee 100644 --- a/arch/sh/boards/mpc1211/rtc.c +++ b/arch/sh/boards/mpc1211/rtc.c | |||
@@ -9,16 +9,9 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | #include <linux/bcd.h> | ||
12 | #include <linux/mc146818rtc.h> | 13 | #include <linux/mc146818rtc.h> |
13 | 14 | ||
14 | #ifndef BCD_TO_BIN | ||
15 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
16 | #endif | ||
17 | |||
18 | #ifndef BIN_TO_BCD | ||
19 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
20 | #endif | ||
21 | |||
22 | unsigned long get_cmos_time(void) | 15 | unsigned long get_cmos_time(void) |
23 | { | 16 | { |
24 | unsigned int year, mon, day, hour, min, sec; | 17 | unsigned int year, mon, day, hour, min, sec; |
diff --git a/arch/sh/boards/sh03/rtc.c b/arch/sh/boards/sh03/rtc.c index e8bec67be84d..d609863cfe53 100644 --- a/arch/sh/boards/sh03/rtc.c +++ b/arch/sh/boards/sh03/rtc.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | #include <linux/bcd.h> | ||
12 | #include <asm/io.h> | 13 | #include <asm/io.h> |
13 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
14 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
@@ -33,14 +34,6 @@ | |||
33 | #define RTC_BUSY 1 | 34 | #define RTC_BUSY 1 |
34 | #define RTC_STOP 2 | 35 | #define RTC_STOP 2 |
35 | 36 | ||
36 | #ifndef BCD_TO_BIN | ||
37 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
38 | #endif | ||
39 | |||
40 | #ifndef BIN_TO_BCD | ||
41 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
42 | #endif | ||
43 | |||
44 | extern void (*rtc_get_time)(struct timespec *); | 37 | extern void (*rtc_get_time)(struct timespec *); |
45 | extern int (*rtc_set_time)(const time_t); | 38 | extern int (*rtc_set_time)(const time_t); |
46 | extern spinlock_t rtc_lock; | 39 | extern spinlock_t rtc_lock; |
diff --git a/arch/sh/kernel/cpu/rtc.c b/arch/sh/kernel/cpu/rtc.c index f8361f5e788b..4304cf75cfa2 100644 --- a/arch/sh/kernel/cpu/rtc.c +++ b/arch/sh/kernel/cpu/rtc.c | |||
@@ -9,18 +9,10 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | 12 | #include <linux/bcd.h> | |
13 | #include <asm/io.h> | 13 | #include <asm/io.h> |
14 | #include <asm/rtc.h> | 14 | #include <asm/rtc.h> |
15 | 15 | ||
16 | #ifndef BCD_TO_BIN | ||
17 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
18 | #endif | ||
19 | |||
20 | #ifndef BIN_TO_BCD | ||
21 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
22 | #endif | ||
23 | |||
24 | void sh_rtc_gettimeofday(struct timespec *ts) | 16 | void sh_rtc_gettimeofday(struct timespec *ts) |
25 | { | 17 | { |
26 | unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; | 18 | unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; |
diff --git a/arch/sh64/kernel/time.c b/arch/sh64/kernel/time.c index 0773c9f389f3..6b8f4d22abc6 100644 --- a/arch/sh64/kernel/time.c +++ b/arch/sh64/kernel/time.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/profile.h> | 30 | #include <linux/profile.h> |
31 | #include <linux/smp.h> | 31 | #include <linux/smp.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/bcd.h> | ||
33 | 34 | ||
34 | #include <asm/registers.h> /* required by inline __asm__ stmt. */ | 35 | #include <asm/registers.h> /* required by inline __asm__ stmt. */ |
35 | 36 | ||
@@ -105,14 +106,6 @@ | |||
105 | #define RCR1 rtc_base+0x38 | 106 | #define RCR1 rtc_base+0x38 |
106 | #define RCR2 rtc_base+0x3c | 107 | #define RCR2 rtc_base+0x3c |
107 | 108 | ||
108 | #ifndef BCD_TO_BIN | ||
109 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
110 | #endif | ||
111 | |||
112 | #ifndef BIN_TO_BCD | ||
113 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
114 | #endif | ||
115 | |||
116 | #define TICK_SIZE (tick_nsec / 1000) | 109 | #define TICK_SIZE (tick_nsec / 1000) |
117 | 110 | ||
118 | extern unsigned long wall_jiffies; | 111 | extern unsigned long wall_jiffies; |