提交 4f3a36a7 编写于 作者: M Matt Mackall 提交者: Linus Torvalds

[PATCH] RTC: Remove some duplicate BCD definitions

Remove some duplicate BCD definitions
Signed-off-by: NMatt Mackall <mpm@selenic.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 41623b06
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ #include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/bcd.h>
#include <asm/mvme16xhw.h> #include <asm/mvme16xhw.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -31,9 +32,6 @@ ...@@ -31,9 +32,6 @@
* ioctls. * ioctls.
*/ */
#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
static const unsigned char days_in_mo[] = static const unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/mv643xx.h> #include <linux/mv643xx.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/bcd.h>
#include <asm/time.h> #include <asm/time.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -131,9 +132,6 @@ void setup_wired_tlb_entries(void) ...@@ -131,9 +132,6 @@ void setup_wired_tlb_entries(void)
add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M); add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M);
} }
#define CONV_BCD_TO_BIN(val) (((val) & 0xf) + (((val) >> 4) * 10))
#define CONV_BIN_TO_BCD(val) (((val) % 10) + (((val) / 10) << 4))
unsigned long m48t37y_get_time(void) unsigned long m48t37y_get_time(void)
{ {
unsigned int year, month, day, hour, min, sec; unsigned int year, month, day, hour, min, sec;
...@@ -143,16 +141,16 @@ unsigned long m48t37y_get_time(void) ...@@ -143,16 +141,16 @@ unsigned long m48t37y_get_time(void)
/* stop the update */ /* stop the update */
rtc_base[0x7ff8] = 0x40; rtc_base[0x7ff8] = 0x40;
year = CONV_BCD_TO_BIN(rtc_base[0x7fff]); year = BCD2BIN(rtc_base[0x7fff]);
year += CONV_BCD_TO_BIN(rtc_base[0x7ff1]) * 100; year += BCD2BIN(rtc_base[0x7ff1]) * 100;
month = CONV_BCD_TO_BIN(rtc_base[0x7ffe]); month = BCD2BIN(rtc_base[0x7ffe]);
day = CONV_BCD_TO_BIN(rtc_base[0x7ffd]); day = BCD2BIN(rtc_base[0x7ffd]);
hour = CONV_BCD_TO_BIN(rtc_base[0x7ffb]); hour = BCD2BIN(rtc_base[0x7ffb]);
min = CONV_BCD_TO_BIN(rtc_base[0x7ffa]); min = BCD2BIN(rtc_base[0x7ffa]);
sec = CONV_BCD_TO_BIN(rtc_base[0x7ff9]); sec = BCD2BIN(rtc_base[0x7ff9]);
/* start the update */ /* start the update */
rtc_base[0x7ff8] = 0x00; rtc_base[0x7ff8] = 0x00;
...@@ -175,22 +173,22 @@ int m48t37y_set_time(unsigned long sec) ...@@ -175,22 +173,22 @@ int m48t37y_set_time(unsigned long sec)
rtc_base[0x7ff8] = 0x80; rtc_base[0x7ff8] = 0x80;
/* year */ /* year */
rtc_base[0x7fff] = CONV_BIN_TO_BCD(tm.tm_year % 100); rtc_base[0x7fff] = BIN2BCD(tm.tm_year % 100);
rtc_base[0x7ff1] = CONV_BIN_TO_BCD(tm.tm_year / 100); rtc_base[0x7ff1] = BIN2BCD(tm.tm_year / 100);
/* month */ /* month */
rtc_base[0x7ffe] = CONV_BIN_TO_BCD(tm.tm_mon); rtc_base[0x7ffe] = BIN2BCD(tm.tm_mon);
/* day */ /* day */
rtc_base[0x7ffd] = CONV_BIN_TO_BCD(tm.tm_mday); rtc_base[0x7ffd] = BIN2BCD(tm.tm_mday);
/* hour/min/sec */ /* hour/min/sec */
rtc_base[0x7ffb] = CONV_BIN_TO_BCD(tm.tm_hour); rtc_base[0x7ffb] = BIN2BCD(tm.tm_hour);
rtc_base[0x7ffa] = CONV_BIN_TO_BCD(tm.tm_min); rtc_base[0x7ffa] = BIN2BCD(tm.tm_min);
rtc_base[0x7ff9] = CONV_BIN_TO_BCD(tm.tm_sec); rtc_base[0x7ff9] = BIN2BCD(tm.tm_sec);
/* day of week -- not really used, but let's keep it up-to-date */ /* day of week -- not really used, but let's keep it up-to-date */
rtc_base[0x7ffc] = CONV_BIN_TO_BCD(tm.tm_wday + 1); rtc_base[0x7ffc] = BIN2BCD(tm.tm_wday + 1);
/* disable writing */ /* disable writing */
rtc_base[0x7ff8] = 0x00; rtc_base[0x7ff8] = 0x00;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/bcd.h>
#include <asm/time.h> #include <asm/time.h>
#include <asm/tx4938/spi.h> #include <asm/tx4938/spi.h>
...@@ -77,17 +78,6 @@ spi_rtc_io(unsigned char *inbuf, unsigned char *outbuf, unsigned int count) ...@@ -77,17 +78,6 @@ spi_rtc_io(unsigned char *inbuf, unsigned char *outbuf, unsigned int count)
inbufs, incounts, outbufs, outcounts, 0); inbufs, incounts, outbufs, outcounts, 0);
} }
/*
* Conversion between binary and BCD.
*/
#ifndef BCD_TO_BIN
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
#endif
#ifndef BIN_TO_BCD
#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
#endif
/* RTC-dependent code for time.c */ /* RTC-dependent code for time.c */
static int static int
......
...@@ -9,16 +9,9 @@ ...@@ -9,16 +9,9 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/bcd.h>
#include <linux/mc146818rtc.h> #include <linux/mc146818rtc.h>
#ifndef BCD_TO_BIN
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
#endif
#ifndef BIN_TO_BCD
#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
#endif
unsigned long get_cmos_time(void) unsigned long get_cmos_time(void)
{ {
unsigned int year, mon, day, hour, min, sec; unsigned int year, mon, day, hour, min, sec;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/bcd.h>
#include <asm/io.h> #include <asm/io.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -33,14 +34,6 @@ ...@@ -33,14 +34,6 @@
#define RTC_BUSY 1 #define RTC_BUSY 1
#define RTC_STOP 2 #define RTC_STOP 2
#ifndef BCD_TO_BIN
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
#endif
#ifndef BIN_TO_BCD
#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
#endif
extern void (*rtc_get_time)(struct timespec *); extern void (*rtc_get_time)(struct timespec *);
extern int (*rtc_set_time)(const time_t); extern int (*rtc_set_time)(const time_t);
extern spinlock_t rtc_lock; extern spinlock_t rtc_lock;
......
...@@ -9,18 +9,10 @@ ...@@ -9,18 +9,10 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/bcd.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/rtc.h> #include <asm/rtc.h>
#ifndef BCD_TO_BIN
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
#endif
#ifndef BIN_TO_BCD
#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
#endif
void sh_rtc_gettimeofday(struct timespec *ts) void sh_rtc_gettimeofday(struct timespec *ts)
{ {
unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/profile.h> #include <linux/profile.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/bcd.h>
#include <asm/registers.h> /* required by inline __asm__ stmt. */ #include <asm/registers.h> /* required by inline __asm__ stmt. */
...@@ -105,14 +106,6 @@ ...@@ -105,14 +106,6 @@
#define RCR1 rtc_base+0x38 #define RCR1 rtc_base+0x38
#define RCR2 rtc_base+0x3c #define RCR2 rtc_base+0x3c
#ifndef BCD_TO_BIN
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
#endif
#ifndef BIN_TO_BCD
#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
#endif
#define TICK_SIZE (tick_nsec / 1000) #define TICK_SIZE (tick_nsec / 1000)
extern unsigned long wall_jiffies; extern unsigned long wall_jiffies;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册