Commit 357c6e63 authored by Adrian Bunk's avatar Adrian Bunk Committed by Linus Torvalds

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: default avatarAdrian Bunk <bunk@kernel.org>
Acked-by: default avatarAlessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fe20ba70
...@@ -52,7 +52,7 @@ int mach_set_rtc_mmss(unsigned long nowtime) ...@@ -52,7 +52,7 @@ int mach_set_rtc_mmss(unsigned long nowtime)
cmos_minutes = CMOS_READ(RTC_MINUTES); cmos_minutes = CMOS_READ(RTC_MINUTES);
if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
BCD_TO_BIN(cmos_minutes); cmos_minutes = bcd2bin(cmos_minutes);
/* /*
* since we're only adjusting minutes and seconds, * since we're only adjusting minutes and seconds,
...@@ -69,8 +69,8 @@ int mach_set_rtc_mmss(unsigned long nowtime) ...@@ -69,8 +69,8 @@ int mach_set_rtc_mmss(unsigned long nowtime)
if (abs(real_minutes - cmos_minutes) < 30) { if (abs(real_minutes - cmos_minutes) < 30) {
if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
BIN_TO_BCD(real_seconds); real_seconds = bin2bcd(real_seconds);
BIN_TO_BCD(real_minutes); real_minutes = bin2bcd(real_minutes);
} }
CMOS_WRITE(real_seconds,RTC_SECONDS); CMOS_WRITE(real_seconds,RTC_SECONDS);
CMOS_WRITE(real_minutes,RTC_MINUTES); CMOS_WRITE(real_minutes,RTC_MINUTES);
...@@ -124,16 +124,16 @@ unsigned long mach_get_cmos_time(void) ...@@ -124,16 +124,16 @@ unsigned long mach_get_cmos_time(void)
WARN_ON_ONCE(RTC_ALWAYS_BCD && (status & RTC_DM_BINARY)); WARN_ON_ONCE(RTC_ALWAYS_BCD && (status & RTC_DM_BINARY));
if (RTC_ALWAYS_BCD || !(status & RTC_DM_BINARY)) { if (RTC_ALWAYS_BCD || !(status & RTC_DM_BINARY)) {
BCD_TO_BIN(sec); sec = bcd2bin(sec);
BCD_TO_BIN(min); min = bcd2bin(min);
BCD_TO_BIN(hour); hour = bcd2bin(hour);
BCD_TO_BIN(day); day = bcd2bin(day);
BCD_TO_BIN(mon); mon = bcd2bin(mon);
BCD_TO_BIN(year); year = bcd2bin(year);
} }
if (century) { if (century) {
BCD_TO_BIN(century); century = bcd2bin(century);
year += century * 100; year += century * 100;
printk(KERN_INFO "Extended CMOS year: %d\n", century * 100); printk(KERN_INFO "Extended CMOS year: %d\n", century * 100);
} else } else
......
...@@ -210,8 +210,8 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, ...@@ -210,8 +210,8 @@ static int ds1286_ioctl(struct inode *inode, struct file *file,
if (sec != 0) if (sec != 0)
return -EINVAL; return -EINVAL;
min = BIN2BCD(min); min = bin2bcd(min);
min = BIN2BCD(hrs); min = bin2bcd(hrs);
spin_lock(&ds1286_lock); spin_lock(&ds1286_lock);
rtc_write(hrs, RTC_HOURS_ALARM); rtc_write(hrs, RTC_HOURS_ALARM);
...@@ -353,7 +353,7 @@ static int ds1286_proc_output(char *buf) ...@@ -353,7 +353,7 @@ static int ds1286_proc_output(char *buf)
ds1286_get_time(&tm); ds1286_get_time(&tm);
hundredth = rtc_read(RTC_HUNDREDTH_SECOND); hundredth = rtc_read(RTC_HUNDREDTH_SECOND);
BCD_TO_BIN(hundredth); hundredth = bcd2bin(hundredth);
p += sprintf(p, p += sprintf(p,
"rtc_time\t: %02d:%02d:%02d.%02d\n" "rtc_time\t: %02d:%02d:%02d.%02d\n"
...@@ -477,12 +477,12 @@ static void ds1286_get_time(struct rtc_time *rtc_tm) ...@@ -477,12 +477,12 @@ static void ds1286_get_time(struct rtc_time *rtc_tm)
rtc_write(save_control, RTC_CMD); rtc_write(save_control, RTC_CMD);
spin_unlock_irqrestore(&ds1286_lock, flags); spin_unlock_irqrestore(&ds1286_lock, flags);
BCD_TO_BIN(rtc_tm->tm_sec); rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec);
BCD_TO_BIN(rtc_tm->tm_min); rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min);
BCD_TO_BIN(rtc_tm->tm_hour); rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour);
BCD_TO_BIN(rtc_tm->tm_mday); rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday);
BCD_TO_BIN(rtc_tm->tm_mon); rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon);
BCD_TO_BIN(rtc_tm->tm_year); rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year);
/* /*
* Account for differences between how the RTC uses the values * Account for differences between how the RTC uses the values
...@@ -531,12 +531,12 @@ static int ds1286_set_time(struct rtc_time *rtc_tm) ...@@ -531,12 +531,12 @@ static int ds1286_set_time(struct rtc_time *rtc_tm)
if (yrs >= 100) if (yrs >= 100)
yrs -= 100; yrs -= 100;
BIN_TO_BCD(sec); sec = bin2bcd(sec);
BIN_TO_BCD(min); min = bin2bcd(min);
BIN_TO_BCD(hrs); hrs = bin2bcd(hrs);
BIN_TO_BCD(day); day = bin2bcd(day);
BIN_TO_BCD(mon); mon = bin2bcd(mon);
BIN_TO_BCD(yrs); yrs = bin2bcd(yrs);
spin_lock_irqsave(&ds1286_lock, flags); spin_lock_irqsave(&ds1286_lock, flags);
save_control = rtc_read(RTC_CMD); save_control = rtc_read(RTC_CMD);
...@@ -572,8 +572,8 @@ static void ds1286_get_alm_time(struct rtc_time *alm_tm) ...@@ -572,8 +572,8 @@ static void ds1286_get_alm_time(struct rtc_time *alm_tm)
cmd = rtc_read(RTC_CMD); cmd = rtc_read(RTC_CMD);
spin_unlock_irqrestore(&ds1286_lock, flags); spin_unlock_irqrestore(&ds1286_lock, flags);
BCD_TO_BIN(alm_tm->tm_min); alm_tm->tm_min = bcd2bin(alm_tm->tm_min);
BCD_TO_BIN(alm_tm->tm_hour); alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour);
alm_tm->tm_sec = 0; alm_tm->tm_sec = 0;
} }
......
...@@ -131,12 +131,12 @@ get_rtc_time(struct rtc_time *rtc_tm) ...@@ -131,12 +131,12 @@ get_rtc_time(struct rtc_time *rtc_tm)
local_irq_restore(flags); local_irq_restore(flags);
BCD_TO_BIN(rtc_tm->tm_sec); rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec);
BCD_TO_BIN(rtc_tm->tm_min); rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min);
BCD_TO_BIN(rtc_tm->tm_hour); rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour);
BCD_TO_BIN(rtc_tm->tm_mday); rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday);
BCD_TO_BIN(rtc_tm->tm_mon); rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon);
BCD_TO_BIN(rtc_tm->tm_year); rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year);
/* /*
* Account for differences between how the RTC uses the values * Account for differences between how the RTC uses the values
...@@ -211,12 +211,12 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -211,12 +211,12 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
else else
yrs -= 1900; /* RTC (70, 71, ... 99) */ yrs -= 1900; /* RTC (70, 71, ... 99) */
BIN_TO_BCD(sec); sec = bin2bcd(sec);
BIN_TO_BCD(min); min = bin2bcd(min);
BIN_TO_BCD(hrs); hrs = bin2bcd(hrs);
BIN_TO_BCD(day); day = bin2bcd(day);
BIN_TO_BCD(mon); mon = bin2bcd(mon);
BIN_TO_BCD(yrs); yrs = bin2bcd(yrs);
lock_kernel(); lock_kernel();
local_irq_save(flags); local_irq_save(flags);
......
...@@ -130,12 +130,12 @@ static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -130,12 +130,12 @@ static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (yrs >= 100) if (yrs >= 100)
yrs -= 100; yrs -= 100;
sec = BIN2BCD(sec); sec = bin2bcd(sec);
min = BIN2BCD(min); min = bin2bcd(min);
hrs = BIN2BCD(hrs); hrs = bin2bcd(hrs);
day = BIN2BCD(day); day = bin2bcd(day);
mon = BIN2BCD(mon); mon = bin2bcd(mon);
yrs = BIN2BCD(yrs); yrs = bin2bcd(yrs);
spin_lock_irq(&rtc_lock); spin_lock_irq(&rtc_lock);
rtc->control |= M48T35_RTC_SET; rtc->control |= M48T35_RTC_SET;
...@@ -311,12 +311,12 @@ static void get_rtc_time(struct rtc_time *rtc_tm) ...@@ -311,12 +311,12 @@ static void get_rtc_time(struct rtc_time *rtc_tm)
rtc->control &= ~M48T35_RTC_READ; rtc->control &= ~M48T35_RTC_READ;
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
rtc_tm->tm_sec = BCD2BIN(rtc_tm->tm_sec); rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec);
rtc_tm->tm_min = BCD2BIN(rtc_tm->tm_min); rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min);
rtc_tm->tm_hour = BCD2BIN(rtc_tm->tm_hour); rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour);
rtc_tm->tm_mday = BCD2BIN(rtc_tm->tm_mday); rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday);
rtc_tm->tm_mon = BCD2BIN(rtc_tm->tm_mon); rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon);
rtc_tm->tm_year = BCD2BIN(rtc_tm->tm_year); rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year);
/* /*
* Account for differences between how the RTC uses the values * Account for differences between how the RTC uses the values
......
...@@ -518,17 +518,17 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -518,17 +518,17 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||
RTC_ALWAYS_BCD) { RTC_ALWAYS_BCD) {
if (sec < 60) if (sec < 60)
BIN_TO_BCD(sec); sec = bin2bcd(sec);
else else
sec = 0xff; sec = 0xff;
if (min < 60) if (min < 60)
BIN_TO_BCD(min); min = bin2bcd(min);
else else
min = 0xff; min = 0xff;
if (hrs < 24) if (hrs < 24)
BIN_TO_BCD(hrs); hrs = bin2bcd(hrs);
else else
hrs = 0xff; hrs = 0xff;
} }
...@@ -614,12 +614,12 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -614,12 +614,12 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
|| RTC_ALWAYS_BCD) { || RTC_ALWAYS_BCD) {
BIN_TO_BCD(sec); sec = bin2bcd(sec);
BIN_TO_BCD(min); min = bin2bcd(min);
BIN_TO_BCD(hrs); hrs = bin2bcd(hrs);
BIN_TO_BCD(day); day = bin2bcd(day);
BIN_TO_BCD(mon); mon = bin2bcd(mon);
BIN_TO_BCD(yrs); yrs = bin2bcd(yrs);
} }
save_control = CMOS_READ(RTC_CONTROL); save_control = CMOS_READ(RTC_CONTROL);
...@@ -1099,7 +1099,7 @@ static int __init rtc_init(void) ...@@ -1099,7 +1099,7 @@ static int __init rtc_init(void)
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
BCD_TO_BIN(year); /* This should never happen... */ year = bcd2bin(year); /* This should never happen... */
if (year < 20) { if (year < 20) {
epoch = 2000; epoch = 2000;
...@@ -1352,13 +1352,13 @@ static void rtc_get_rtc_time(struct rtc_time *rtc_tm) ...@@ -1352,13 +1352,13 @@ static void rtc_get_rtc_time(struct rtc_time *rtc_tm)
spin_unlock_irqrestore(&rtc_lock, flags); spin_unlock_irqrestore(&rtc_lock, flags);
if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
BCD_TO_BIN(rtc_tm->tm_sec); rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec);
BCD_TO_BIN(rtc_tm->tm_min); rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min);
BCD_TO_BIN(rtc_tm->tm_hour); rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour);
BCD_TO_BIN(rtc_tm->tm_mday); rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday);
BCD_TO_BIN(rtc_tm->tm_mon); rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon);
BCD_TO_BIN(rtc_tm->tm_year); rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year);
BCD_TO_BIN(rtc_tm->tm_wday); rtc_tm->tm_wday = bcd2bin(rtc_tm->tm_wday);
} }
#ifdef CONFIG_MACH_DECSTATION #ifdef CONFIG_MACH_DECSTATION
...@@ -1392,9 +1392,9 @@ static void get_rtc_alm_time(struct rtc_time *alm_tm) ...@@ -1392,9 +1392,9 @@ static void get_rtc_alm_time(struct rtc_time *alm_tm)
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
BCD_TO_BIN(alm_tm->tm_sec); alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec);
BCD_TO_BIN(alm_tm->tm_min); alm_tm->tm_min = bcd2bin(alm_tm->tm_min);
BCD_TO_BIN(alm_tm->tm_hour); alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour);
} }
} }
......
...@@ -84,12 +84,12 @@ static inline unsigned int get_rtc_time(struct rtc_time *time) ...@@ -84,12 +84,12 @@ static inline unsigned int get_rtc_time(struct rtc_time *time)
if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
{ {
BCD_TO_BIN(time->tm_sec); time->tm_sec = bcd2bin(time->tm_sec);
BCD_TO_BIN(time->tm_min); time->tm_min = bcd2bin(time->tm_min);
BCD_TO_BIN(time->tm_hour); time->tm_hour = bcd2bin(time->tm_hour);
BCD_TO_BIN(time->tm_mday); time->tm_mday = bcd2bin(time->tm_mday);
BCD_TO_BIN(time->tm_mon); time->tm_mon = bcd2bin(time->tm_mon);
BCD_TO_BIN(time->tm_year); time->tm_year = bcd2bin(time->tm_year);
} }
#ifdef CONFIG_MACH_DECSTATION #ifdef CONFIG_MACH_DECSTATION
...@@ -159,12 +159,12 @@ static inline int set_rtc_time(struct rtc_time *time) ...@@ -159,12 +159,12 @@ static inline int set_rtc_time(struct rtc_time *time)
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
|| RTC_ALWAYS_BCD) { || RTC_ALWAYS_BCD) {
BIN_TO_BCD(sec); sec = bin2bcd(sec);
BIN_TO_BCD(min); min = bin2bcd(min);
BIN_TO_BCD(hrs); hrs = bin2bcd(hrs);
BIN_TO_BCD(day); day = bin2bcd(day);
BIN_TO_BCD(mon); mon = bin2bcd(mon);
BIN_TO_BCD(yrs); yrs = bin2bcd(yrs);
} }
save_control = CMOS_READ(RTC_CONTROL); save_control = CMOS_READ(RTC_CONTROL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment