diff options
Diffstat (limited to 'drivers/rtc')
35 files changed, 724 insertions, 547 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index f660ef3e5b29..814f49fde530 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -610,6 +610,14 @@ config RTC_DRV_RS5C313 | |||
610 | help | 610 | help |
611 | If you say yes here you get support for the Ricoh RS5C313 RTC chips. | 611 | If you say yes here you get support for the Ricoh RS5C313 RTC chips. |
612 | 612 | ||
613 | config RTC_DRV_PARISC | ||
614 | tristate "PA-RISC firmware RTC support" | ||
615 | depends on PARISC | ||
616 | help | ||
617 | Say Y or M here to enable RTC support on PA-RISC systems using | ||
618 | firmware calls. If you do not know what you are doing, you should | ||
619 | just say Y. | ||
620 | |||
613 | config RTC_DRV_PPC | 621 | config RTC_DRV_PPC |
614 | tristate "PowerPC machine dependent RTC support" | 622 | tristate "PowerPC machine dependent RTC support" |
615 | depends on PPC | 623 | depends on PPC |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index d05928b3ca94..d6a9ac7176ea 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -51,6 +51,7 @@ obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o | |||
51 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o | 51 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o |
52 | obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o | 52 | obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o |
53 | obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o | 53 | obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o |
54 | obj-$(CONFIG_RTC_DRV_PARISC) += rtc-parisc.o | ||
54 | obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o | 55 | obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o |
55 | obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o | 56 | obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o |
56 | obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o | 57 | obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 37082616482b..b5bf93706913 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -53,21 +53,21 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg, | |||
53 | } while ((time != at91_sys_read(timereg)) || | 53 | } while ((time != at91_sys_read(timereg)) || |
54 | (date != at91_sys_read(calreg))); | 54 | (date != at91_sys_read(calreg))); |
55 | 55 | ||
56 | tm->tm_sec = BCD2BIN((time & AT91_RTC_SEC) >> 0); | 56 | tm->tm_sec = bcd2bin((time & AT91_RTC_SEC) >> 0); |
57 | tm->tm_min = BCD2BIN((time & AT91_RTC_MIN) >> 8); | 57 | tm->tm_min = bcd2bin((time & AT91_RTC_MIN) >> 8); |
58 | tm->tm_hour = BCD2BIN((time & AT91_RTC_HOUR) >> 16); | 58 | tm->tm_hour = bcd2bin((time & AT91_RTC_HOUR) >> 16); |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * The Calendar Alarm register does not have a field for | 61 | * The Calendar Alarm register does not have a field for |
62 | * the year - so these will return an invalid value. When an | 62 | * the year - so these will return an invalid value. When an |
63 | * alarm is set, at91_alarm_year wille store the current year. | 63 | * alarm is set, at91_alarm_year wille store the current year. |
64 | */ | 64 | */ |
65 | tm->tm_year = BCD2BIN(date & AT91_RTC_CENT) * 100; /* century */ | 65 | tm->tm_year = bcd2bin(date & AT91_RTC_CENT) * 100; /* century */ |
66 | tm->tm_year += BCD2BIN((date & AT91_RTC_YEAR) >> 8); /* year */ | 66 | tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8); /* year */ |
67 | 67 | ||
68 | tm->tm_wday = BCD2BIN((date & AT91_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */ | 68 | tm->tm_wday = bcd2bin((date & AT91_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */ |
69 | tm->tm_mon = BCD2BIN((date & AT91_RTC_MONTH) >> 16) - 1; | 69 | tm->tm_mon = bcd2bin((date & AT91_RTC_MONTH) >> 16) - 1; |
70 | tm->tm_mday = BCD2BIN((date & AT91_RTC_DATE) >> 24); | 70 | tm->tm_mday = bcd2bin((date & AT91_RTC_DATE) >> 24); |
71 | } | 71 | } |
72 | 72 | ||
73 | /* | 73 | /* |
@@ -106,16 +106,16 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
106 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD); | 106 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD); |
107 | 107 | ||
108 | at91_sys_write(AT91_RTC_TIMR, | 108 | at91_sys_write(AT91_RTC_TIMR, |
109 | BIN2BCD(tm->tm_sec) << 0 | 109 | bin2bcd(tm->tm_sec) << 0 |
110 | | BIN2BCD(tm->tm_min) << 8 | 110 | | bin2bcd(tm->tm_min) << 8 |
111 | | BIN2BCD(tm->tm_hour) << 16); | 111 | | bin2bcd(tm->tm_hour) << 16); |
112 | 112 | ||
113 | at91_sys_write(AT91_RTC_CALR, | 113 | at91_sys_write(AT91_RTC_CALR, |
114 | BIN2BCD((tm->tm_year + 1900) / 100) /* century */ | 114 | bin2bcd((tm->tm_year + 1900) / 100) /* century */ |
115 | | BIN2BCD(tm->tm_year % 100) << 8 /* year */ | 115 | | bin2bcd(tm->tm_year % 100) << 8 /* year */ |
116 | | BIN2BCD(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */ | 116 | | bin2bcd(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */ |
117 | | BIN2BCD(tm->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */ | 117 | | bin2bcd(tm->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */ |
118 | | BIN2BCD(tm->tm_mday) << 24); | 118 | | bin2bcd(tm->tm_mday) << 24); |
119 | 119 | ||
120 | /* Restart Time/Calendar */ | 120 | /* Restart Time/Calendar */ |
121 | cr = at91_sys_read(AT91_RTC_CR); | 121 | cr = at91_sys_read(AT91_RTC_CR); |
@@ -162,13 +162,13 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
162 | 162 | ||
163 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); | 163 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); |
164 | at91_sys_write(AT91_RTC_TIMALR, | 164 | at91_sys_write(AT91_RTC_TIMALR, |
165 | BIN2BCD(tm.tm_sec) << 0 | 165 | bin2bcd(tm.tm_sec) << 0 |
166 | | BIN2BCD(tm.tm_min) << 8 | 166 | | bin2bcd(tm.tm_min) << 8 |
167 | | BIN2BCD(tm.tm_hour) << 16 | 167 | | bin2bcd(tm.tm_hour) << 16 |
168 | | AT91_RTC_HOUREN | AT91_RTC_MINEN | AT91_RTC_SECEN); | 168 | | AT91_RTC_HOUREN | AT91_RTC_MINEN | AT91_RTC_SECEN); |
169 | at91_sys_write(AT91_RTC_CALALR, | 169 | at91_sys_write(AT91_RTC_CALALR, |
170 | BIN2BCD(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */ | 170 | bin2bcd(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */ |
171 | | BIN2BCD(tm.tm_mday) << 24 | 171 | | bin2bcd(tm.tm_mday) << 24 |
172 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); | 172 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); |
173 | 173 | ||
174 | if (alrm->enabled) { | 174 | if (alrm->enabled) { |
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c index 189a018bdf34..d00a274df8fc 100644 --- a/drivers/rtc/rtc-bq4802.c +++ b/drivers/rtc/rtc-bq4802.c | |||
@@ -71,14 +71,14 @@ static int bq4802_read_time(struct device *dev, struct rtc_time *tm) | |||
71 | 71 | ||
72 | spin_unlock_irqrestore(&p->lock, flags); | 72 | spin_unlock_irqrestore(&p->lock, flags); |
73 | 73 | ||
74 | BCD_TO_BIN(tm->tm_sec); | 74 | tm->tm_sec = bcd2bin(tm->tm_sec); |
75 | BCD_TO_BIN(tm->tm_min); | 75 | tm->tm_min = bcd2bin(tm->tm_min); |
76 | BCD_TO_BIN(tm->tm_hour); | 76 | tm->tm_hour = bcd2bin(tm->tm_hour); |
77 | BCD_TO_BIN(tm->tm_mday); | 77 | tm->tm_mday = bcd2bin(tm->tm_mday); |
78 | BCD_TO_BIN(tm->tm_mon); | 78 | tm->tm_mon = bcd2bin(tm->tm_mon); |
79 | BCD_TO_BIN(tm->tm_year); | 79 | tm->tm_year = bcd2bin(tm->tm_year); |
80 | BCD_TO_BIN(tm->tm_wday); | 80 | tm->tm_wday = bcd2bin(tm->tm_wday); |
81 | BCD_TO_BIN(century); | 81 | century = bcd2bin(century); |
82 | 82 | ||
83 | tm->tm_year += (century * 100); | 83 | tm->tm_year += (century * 100); |
84 | tm->tm_year -= 1900; | 84 | tm->tm_year -= 1900; |
@@ -106,13 +106,13 @@ static int bq4802_set_time(struct device *dev, struct rtc_time *tm) | |||
106 | min = tm->tm_min; | 106 | min = tm->tm_min; |
107 | sec = tm->tm_sec; | 107 | sec = tm->tm_sec; |
108 | 108 | ||
109 | BIN_TO_BCD(sec); | 109 | sec = bin2bcd(sec); |
110 | BIN_TO_BCD(min); | 110 | min = bin2bcd(min); |
111 | BIN_TO_BCD(hrs); | 111 | hrs = bin2bcd(hrs); |
112 | BIN_TO_BCD(day); | 112 | day = bin2bcd(day); |
113 | BIN_TO_BCD(mon); | 113 | mon = bin2bcd(mon); |
114 | BIN_TO_BCD(yrs); | 114 | yrs = bin2bcd(yrs); |
115 | BIN_TO_BCD(century); | 115 | century = bin2bcd(century); |
116 | 116 | ||
117 | spin_lock_irqsave(&p->lock, flags); | 117 | spin_lock_irqsave(&p->lock, flags); |
118 | 118 | ||
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 963ad0b6a4e9..5549231179a2 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -143,6 +143,43 @@ static inline int hpet_unregister_irq_handler(irq_handler_t handler) | |||
143 | 143 | ||
144 | /*----------------------------------------------------------------*/ | 144 | /*----------------------------------------------------------------*/ |
145 | 145 | ||
146 | #ifdef RTC_PORT | ||
147 | |||
148 | /* Most newer x86 systems have two register banks, the first used | ||
149 | * for RTC and NVRAM and the second only for NVRAM. Caller must | ||
150 | * own rtc_lock ... and we won't worry about access during NMI. | ||
151 | */ | ||
152 | #define can_bank2 true | ||
153 | |||
154 | static inline unsigned char cmos_read_bank2(unsigned char addr) | ||
155 | { | ||
156 | outb(addr, RTC_PORT(2)); | ||
157 | return inb(RTC_PORT(3)); | ||
158 | } | ||
159 | |||
160 | static inline void cmos_write_bank2(unsigned char val, unsigned char addr) | ||
161 | { | ||
162 | outb(addr, RTC_PORT(2)); | ||
163 | outb(val, RTC_PORT(2)); | ||
164 | } | ||
165 | |||
166 | #else | ||
167 | |||
168 | #define can_bank2 false | ||
169 | |||
170 | static inline unsigned char cmos_read_bank2(unsigned char addr) | ||
171 | { | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static inline void cmos_write_bank2(unsigned char val, unsigned char addr) | ||
176 | { | ||
177 | } | ||
178 | |||
179 | #endif | ||
180 | |||
181 | /*----------------------------------------------------------------*/ | ||
182 | |||
146 | static int cmos_read_time(struct device *dev, struct rtc_time *t) | 183 | static int cmos_read_time(struct device *dev, struct rtc_time *t) |
147 | { | 184 | { |
148 | /* REVISIT: if the clock has a "century" register, use | 185 | /* REVISIT: if the clock has a "century" register, use |
@@ -203,26 +240,26 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
203 | /* REVISIT this assumes PC style usage: always BCD */ | 240 | /* REVISIT this assumes PC style usage: always BCD */ |
204 | 241 | ||
205 | if (((unsigned)t->time.tm_sec) < 0x60) | 242 | if (((unsigned)t->time.tm_sec) < 0x60) |
206 | t->time.tm_sec = BCD2BIN(t->time.tm_sec); | 243 | t->time.tm_sec = bcd2bin(t->time.tm_sec); |
207 | else | 244 | else |
208 | t->time.tm_sec = -1; | 245 | t->time.tm_sec = -1; |
209 | if (((unsigned)t->time.tm_min) < 0x60) | 246 | if (((unsigned)t->time.tm_min) < 0x60) |
210 | t->time.tm_min = BCD2BIN(t->time.tm_min); | 247 | t->time.tm_min = bcd2bin(t->time.tm_min); |
211 | else | 248 | else |
212 | t->time.tm_min = -1; | 249 | t->time.tm_min = -1; |
213 | if (((unsigned)t->time.tm_hour) < 0x24) | 250 | if (((unsigned)t->time.tm_hour) < 0x24) |
214 | t->time.tm_hour = BCD2BIN(t->time.tm_hour); | 251 | t->time.tm_hour = bcd2bin(t->time.tm_hour); |
215 | else | 252 | else |
216 | t->time.tm_hour = -1; | 253 | t->time.tm_hour = -1; |
217 | 254 | ||
218 | if (cmos->day_alrm) { | 255 | if (cmos->day_alrm) { |
219 | if (((unsigned)t->time.tm_mday) <= 0x31) | 256 | if (((unsigned)t->time.tm_mday) <= 0x31) |
220 | t->time.tm_mday = BCD2BIN(t->time.tm_mday); | 257 | t->time.tm_mday = bcd2bin(t->time.tm_mday); |
221 | else | 258 | else |
222 | t->time.tm_mday = -1; | 259 | t->time.tm_mday = -1; |
223 | if (cmos->mon_alrm) { | 260 | if (cmos->mon_alrm) { |
224 | if (((unsigned)t->time.tm_mon) <= 0x12) | 261 | if (((unsigned)t->time.tm_mon) <= 0x12) |
225 | t->time.tm_mon = BCD2BIN(t->time.tm_mon) - 1; | 262 | t->time.tm_mon = bcd2bin(t->time.tm_mon) - 1; |
226 | else | 263 | else |
227 | t->time.tm_mon = -1; | 264 | t->time.tm_mon = -1; |
228 | } | 265 | } |
@@ -294,19 +331,19 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
294 | /* Writing 0xff means "don't care" or "match all". */ | 331 | /* Writing 0xff means "don't care" or "match all". */ |
295 | 332 | ||
296 | mon = t->time.tm_mon + 1; | 333 | mon = t->time.tm_mon + 1; |
297 | mon = (mon <= 12) ? BIN2BCD(mon) : 0xff; | 334 | mon = (mon <= 12) ? bin2bcd(mon) : 0xff; |
298 | 335 | ||
299 | mday = t->time.tm_mday; | 336 | mday = t->time.tm_mday; |
300 | mday = (mday >= 1 && mday <= 31) ? BIN2BCD(mday) : 0xff; | 337 | mday = (mday >= 1 && mday <= 31) ? bin2bcd(mday) : 0xff; |
301 | 338 | ||
302 | hrs = t->time.tm_hour; | 339 | hrs = t->time.tm_hour; |
303 | hrs = (hrs < 24) ? BIN2BCD(hrs) : 0xff; | 340 | hrs = (hrs < 24) ? bin2bcd(hrs) : 0xff; |
304 | 341 | ||
305 | min = t->time.tm_min; | 342 | min = t->time.tm_min; |
306 | min = (min < 60) ? BIN2BCD(min) : 0xff; | 343 | min = (min < 60) ? bin2bcd(min) : 0xff; |
307 | 344 | ||
308 | sec = t->time.tm_sec; | 345 | sec = t->time.tm_sec; |
309 | sec = (sec < 60) ? BIN2BCD(sec) : 0xff; | 346 | sec = (sec < 60) ? bin2bcd(sec) : 0xff; |
310 | 347 | ||
311 | spin_lock_irq(&rtc_lock); | 348 | spin_lock_irq(&rtc_lock); |
312 | 349 | ||
@@ -491,12 +528,21 @@ cmos_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
491 | 528 | ||
492 | if (unlikely(off >= attr->size)) | 529 | if (unlikely(off >= attr->size)) |
493 | return 0; | 530 | return 0; |
531 | if (unlikely(off < 0)) | ||
532 | return -EINVAL; | ||
494 | if ((off + count) > attr->size) | 533 | if ((off + count) > attr->size) |
495 | count = attr->size - off; | 534 | count = attr->size - off; |
496 | 535 | ||
536 | off += NVRAM_OFFSET; | ||
497 | spin_lock_irq(&rtc_lock); | 537 | spin_lock_irq(&rtc_lock); |
498 | for (retval = 0, off += NVRAM_OFFSET; count--; retval++, off++) | 538 | for (retval = 0; count; count--, off++, retval++) { |
499 | *buf++ = CMOS_READ(off); | 539 | if (off < 128) |
540 | *buf++ = CMOS_READ(off); | ||
541 | else if (can_bank2) | ||
542 | *buf++ = cmos_read_bank2(off); | ||
543 | else | ||
544 | break; | ||
545 | } | ||
500 | spin_unlock_irq(&rtc_lock); | 546 | spin_unlock_irq(&rtc_lock); |
501 | 547 | ||
502 | return retval; | 548 | return retval; |
@@ -512,6 +558,8 @@ cmos_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | |||
512 | cmos = dev_get_drvdata(container_of(kobj, struct device, kobj)); | 558 | cmos = dev_get_drvdata(container_of(kobj, struct device, kobj)); |
513 | if (unlikely(off >= attr->size)) | 559 | if (unlikely(off >= attr->size)) |
514 | return -EFBIG; | 560 | return -EFBIG; |
561 | if (unlikely(off < 0)) | ||
562 | return -EINVAL; | ||
515 | if ((off + count) > attr->size) | 563 | if ((off + count) > attr->size) |
516 | count = attr->size - off; | 564 | count = attr->size - off; |
517 | 565 | ||
@@ -520,15 +568,20 @@ cmos_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | |||
520 | * here. If userspace is smart enough to know what fields of | 568 | * here. If userspace is smart enough to know what fields of |
521 | * NVRAM to update, updating checksums is also part of its job. | 569 | * NVRAM to update, updating checksums is also part of its job. |
522 | */ | 570 | */ |
571 | off += NVRAM_OFFSET; | ||
523 | spin_lock_irq(&rtc_lock); | 572 | spin_lock_irq(&rtc_lock); |
524 | for (retval = 0, off += NVRAM_OFFSET; count--; retval++, off++) { | 573 | for (retval = 0; count; count--, off++, retval++) { |
525 | /* don't trash RTC registers */ | 574 | /* don't trash RTC registers */ |
526 | if (off == cmos->day_alrm | 575 | if (off == cmos->day_alrm |
527 | || off == cmos->mon_alrm | 576 | || off == cmos->mon_alrm |
528 | || off == cmos->century) | 577 | || off == cmos->century) |
529 | buf++; | 578 | buf++; |
530 | else | 579 | else if (off < 128) |
531 | CMOS_WRITE(*buf++, off); | 580 | CMOS_WRITE(*buf++, off); |
581 | else if (can_bank2) | ||
582 | cmos_write_bank2(*buf++, off); | ||
583 | else | ||
584 | break; | ||
532 | } | 585 | } |
533 | spin_unlock_irq(&rtc_lock); | 586 | spin_unlock_irq(&rtc_lock); |
534 | 587 | ||
@@ -539,7 +592,6 @@ static struct bin_attribute nvram = { | |||
539 | .attr = { | 592 | .attr = { |
540 | .name = "nvram", | 593 | .name = "nvram", |
541 | .mode = S_IRUGO | S_IWUSR, | 594 | .mode = S_IRUGO | S_IWUSR, |
542 | .owner = THIS_MODULE, | ||
543 | }, | 595 | }, |
544 | 596 | ||
545 | .read = cmos_nvram_read, | 597 | .read = cmos_nvram_read, |
@@ -631,8 +683,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
631 | 683 | ||
632 | /* Heuristic to deduce NVRAM size ... do what the legacy NVRAM | 684 | /* Heuristic to deduce NVRAM size ... do what the legacy NVRAM |
633 | * driver did, but don't reject unknown configs. Old hardware | 685 | * driver did, but don't reject unknown configs. Old hardware |
634 | * won't address 128 bytes, and for now we ignore the way newer | 686 | * won't address 128 bytes. Newer chips have multiple banks, |
635 | * chips can address 256 bytes (using two more i/o ports). | 687 | * though they may not be listed in one I/O resource. |
636 | */ | 688 | */ |
637 | #if defined(CONFIG_ATARI) | 689 | #if defined(CONFIG_ATARI) |
638 | address_space = 64; | 690 | address_space = 64; |
@@ -642,6 +694,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
642 | #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes. | 694 | #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes. |
643 | address_space = 128; | 695 | address_space = 128; |
644 | #endif | 696 | #endif |
697 | if (can_bank2 && ports->end > (ports->start + 1)) | ||
698 | address_space = 256; | ||
645 | 699 | ||
646 | /* For ACPI systems extension info comes from the FADT. On others, | 700 | /* For ACPI systems extension info comes from the FADT. On others, |
647 | * board specific setup provides it as appropriate. Systems where | 701 | * board specific setup provides it as appropriate. Systems where |
@@ -740,7 +794,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
740 | goto cleanup2; | 794 | goto cleanup2; |
741 | } | 795 | } |
742 | 796 | ||
743 | pr_info("%s: alarms up to one %s%s%s\n", | 797 | pr_info("%s: alarms up to one %s%s, %zd bytes nvram, %s irqs\n", |
744 | cmos_rtc.rtc->dev.bus_id, | 798 | cmos_rtc.rtc->dev.bus_id, |
745 | is_valid_irq(rtc_irq) | 799 | is_valid_irq(rtc_irq) |
746 | ? (cmos_rtc.mon_alrm | 800 | ? (cmos_rtc.mon_alrm |
@@ -749,6 +803,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
749 | ? "month" : "day")) | 803 | ? "month" : "day")) |
750 | : "no", | 804 | : "no", |
751 | cmos_rtc.century ? ", y3k" : "", | 805 | cmos_rtc.century ? ", y3k" : "", |
806 | nvram.size, | ||
752 | is_hpet_enabled() ? ", hpet irqs" : ""); | 807 | is_hpet_enabled() ? ", hpet irqs" : ""); |
753 | 808 | ||
754 | return 0; | 809 | return 0; |
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c index 0b17770b032b..9a234a4ec06d 100644 --- a/drivers/rtc/rtc-ds1216.c +++ b/drivers/rtc/rtc-ds1216.c | |||
@@ -86,19 +86,19 @@ static int ds1216_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
86 | ds1216_switch_ds_to_clock(priv->ioaddr); | 86 | ds1216_switch_ds_to_clock(priv->ioaddr); |
87 | ds1216_read(priv->ioaddr, (u8 *)®s); | 87 | ds1216_read(priv->ioaddr, (u8 *)®s); |
88 | 88 | ||
89 | tm->tm_sec = BCD2BIN(regs.sec); | 89 | tm->tm_sec = bcd2bin(regs.sec); |
90 | tm->tm_min = BCD2BIN(regs.min); | 90 | tm->tm_min = bcd2bin(regs.min); |
91 | if (regs.hour & DS1216_HOUR_1224) { | 91 | if (regs.hour & DS1216_HOUR_1224) { |
92 | /* AM/PM mode */ | 92 | /* AM/PM mode */ |
93 | tm->tm_hour = BCD2BIN(regs.hour & 0x1f); | 93 | tm->tm_hour = bcd2bin(regs.hour & 0x1f); |
94 | if (regs.hour & DS1216_HOUR_AMPM) | 94 | if (regs.hour & DS1216_HOUR_AMPM) |
95 | tm->tm_hour += 12; | 95 | tm->tm_hour += 12; |
96 | } else | 96 | } else |
97 | tm->tm_hour = BCD2BIN(regs.hour & 0x3f); | 97 | tm->tm_hour = bcd2bin(regs.hour & 0x3f); |
98 | tm->tm_wday = (regs.wday & 7) - 1; | 98 | tm->tm_wday = (regs.wday & 7) - 1; |
99 | tm->tm_mday = BCD2BIN(regs.mday & 0x3f); | 99 | tm->tm_mday = bcd2bin(regs.mday & 0x3f); |
100 | tm->tm_mon = BCD2BIN(regs.month & 0x1f); | 100 | tm->tm_mon = bcd2bin(regs.month & 0x1f); |
101 | tm->tm_year = BCD2BIN(regs.year); | 101 | tm->tm_year = bcd2bin(regs.year); |
102 | if (tm->tm_year < 70) | 102 | if (tm->tm_year < 70) |
103 | tm->tm_year += 100; | 103 | tm->tm_year += 100; |
104 | return 0; | 104 | return 0; |
@@ -114,19 +114,19 @@ static int ds1216_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
114 | ds1216_read(priv->ioaddr, (u8 *)®s); | 114 | ds1216_read(priv->ioaddr, (u8 *)®s); |
115 | 115 | ||
116 | regs.tsec = 0; /* clear 0.1 and 0.01 seconds */ | 116 | regs.tsec = 0; /* clear 0.1 and 0.01 seconds */ |
117 | regs.sec = BIN2BCD(tm->tm_sec); | 117 | regs.sec = bin2bcd(tm->tm_sec); |
118 | regs.min = BIN2BCD(tm->tm_min); | 118 | regs.min = bin2bcd(tm->tm_min); |
119 | regs.hour &= DS1216_HOUR_1224; | 119 | regs.hour &= DS1216_HOUR_1224; |
120 | if (regs.hour && tm->tm_hour > 12) { | 120 | if (regs.hour && tm->tm_hour > 12) { |
121 | regs.hour |= DS1216_HOUR_AMPM; | 121 | regs.hour |= DS1216_HOUR_AMPM; |
122 | tm->tm_hour -= 12; | 122 | tm->tm_hour -= 12; |
123 | } | 123 | } |
124 | regs.hour |= BIN2BCD(tm->tm_hour); | 124 | regs.hour |= bin2bcd(tm->tm_hour); |
125 | regs.wday &= ~7; | 125 | regs.wday &= ~7; |
126 | regs.wday |= tm->tm_wday; | 126 | regs.wday |= tm->tm_wday; |
127 | regs.mday = BIN2BCD(tm->tm_mday); | 127 | regs.mday = bin2bcd(tm->tm_mday); |
128 | regs.month = BIN2BCD(tm->tm_mon); | 128 | regs.month = bin2bcd(tm->tm_mon); |
129 | regs.year = BIN2BCD(tm->tm_year % 100); | 129 | regs.year = bin2bcd(tm->tm_year % 100); |
130 | 130 | ||
131 | ds1216_switch_ds_to_clock(priv->ioaddr); | 131 | ds1216_switch_ds_to_clock(priv->ioaddr); |
132 | ds1216_write(priv->ioaddr, (u8 *)®s); | 132 | ds1216_write(priv->ioaddr, (u8 *)®s); |
diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index b9397818f73a..184556620778 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #define RTC_SCLK 0x0400 | 40 | #define RTC_SCLK 0x0400 |
41 | 41 | ||
42 | #ifdef CONFIG_SH_SECUREEDGE5410 | 42 | #ifdef CONFIG_SH_SECUREEDGE5410 |
43 | #include <asm/snapgear.h> | 43 | #include <mach/snapgear.h> |
44 | #define set_dp(x) SECUREEDGE_WRITE_IOPORT(x, 0x1c00) | 44 | #define set_dp(x) SECUREEDGE_WRITE_IOPORT(x, 0x1c00) |
45 | #define get_dp() SECUREEDGE_READ_IOPORT() | 45 | #define get_dp() SECUREEDGE_READ_IOPORT() |
46 | #else | 46 | #else |
@@ -107,13 +107,13 @@ static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
107 | 107 | ||
108 | spin_lock_irq(&rtc->lock); | 108 | spin_lock_irq(&rtc->lock); |
109 | 109 | ||
110 | tm->tm_sec = BCD2BIN(ds1302_readbyte(RTC_ADDR_SEC)); | 110 | tm->tm_sec = bcd2bin(ds1302_readbyte(RTC_ADDR_SEC)); |
111 | tm->tm_min = BCD2BIN(ds1302_readbyte(RTC_ADDR_MIN)); | 111 | tm->tm_min = bcd2bin(ds1302_readbyte(RTC_ADDR_MIN)); |
112 | tm->tm_hour = BCD2BIN(ds1302_readbyte(RTC_ADDR_HOUR)); | 112 | tm->tm_hour = bcd2bin(ds1302_readbyte(RTC_ADDR_HOUR)); |
113 | tm->tm_wday = BCD2BIN(ds1302_readbyte(RTC_ADDR_DAY)); | 113 | tm->tm_wday = bcd2bin(ds1302_readbyte(RTC_ADDR_DAY)); |
114 | tm->tm_mday = BCD2BIN(ds1302_readbyte(RTC_ADDR_DATE)); | 114 | tm->tm_mday = bcd2bin(ds1302_readbyte(RTC_ADDR_DATE)); |
115 | tm->tm_mon = BCD2BIN(ds1302_readbyte(RTC_ADDR_MON)) - 1; | 115 | tm->tm_mon = bcd2bin(ds1302_readbyte(RTC_ADDR_MON)) - 1; |
116 | tm->tm_year = BCD2BIN(ds1302_readbyte(RTC_ADDR_YEAR)); | 116 | tm->tm_year = bcd2bin(ds1302_readbyte(RTC_ADDR_YEAR)); |
117 | 117 | ||
118 | if (tm->tm_year < 70) | 118 | if (tm->tm_year < 70) |
119 | tm->tm_year += 100; | 119 | tm->tm_year += 100; |
@@ -141,13 +141,13 @@ static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
141 | /* Stop RTC */ | 141 | /* Stop RTC */ |
142 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); | 142 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); |
143 | 143 | ||
144 | ds1302_writebyte(RTC_ADDR_SEC, BIN2BCD(tm->tm_sec)); | 144 | ds1302_writebyte(RTC_ADDR_SEC, bin2bcd(tm->tm_sec)); |
145 | ds1302_writebyte(RTC_ADDR_MIN, BIN2BCD(tm->tm_min)); | 145 | ds1302_writebyte(RTC_ADDR_MIN, bin2bcd(tm->tm_min)); |
146 | ds1302_writebyte(RTC_ADDR_HOUR, BIN2BCD(tm->tm_hour)); | 146 | ds1302_writebyte(RTC_ADDR_HOUR, bin2bcd(tm->tm_hour)); |
147 | ds1302_writebyte(RTC_ADDR_DAY, BIN2BCD(tm->tm_wday)); | 147 | ds1302_writebyte(RTC_ADDR_DAY, bin2bcd(tm->tm_wday)); |
148 | ds1302_writebyte(RTC_ADDR_DATE, BIN2BCD(tm->tm_mday)); | 148 | ds1302_writebyte(RTC_ADDR_DATE, bin2bcd(tm->tm_mday)); |
149 | ds1302_writebyte(RTC_ADDR_MON, BIN2BCD(tm->tm_mon + 1)); | 149 | ds1302_writebyte(RTC_ADDR_MON, bin2bcd(tm->tm_mon + 1)); |
150 | ds1302_writebyte(RTC_ADDR_YEAR, BIN2BCD(tm->tm_year % 100)); | 150 | ds1302_writebyte(RTC_ADDR_YEAR, bin2bcd(tm->tm_year % 100)); |
151 | 151 | ||
152 | /* Start RTC */ | 152 | /* Start RTC */ |
153 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); | 153 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index b91d02a3ace9..fc372df6534b 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -114,10 +114,10 @@ static unsigned bcd2hour(u8 bcd) | |||
114 | hour = 12; | 114 | hour = 12; |
115 | bcd &= ~DS1305_HR_PM; | 115 | bcd &= ~DS1305_HR_PM; |
116 | } | 116 | } |
117 | hour += BCD2BIN(bcd); | 117 | hour += bcd2bin(bcd); |
118 | return hour - 1; | 118 | return hour - 1; |
119 | } | 119 | } |
120 | return BCD2BIN(bcd); | 120 | return bcd2bin(bcd); |
121 | } | 121 | } |
122 | 122 | ||
123 | static u8 hour2bcd(bool hr12, int hour) | 123 | static u8 hour2bcd(bool hr12, int hour) |
@@ -125,11 +125,11 @@ static u8 hour2bcd(bool hr12, int hour) | |||
125 | if (hr12) { | 125 | if (hr12) { |
126 | hour++; | 126 | hour++; |
127 | if (hour <= 12) | 127 | if (hour <= 12) |
128 | return DS1305_HR_12 | BIN2BCD(hour); | 128 | return DS1305_HR_12 | bin2bcd(hour); |
129 | hour -= 12; | 129 | hour -= 12; |
130 | return DS1305_HR_12 | DS1305_HR_PM | BIN2BCD(hour); | 130 | return DS1305_HR_12 | DS1305_HR_PM | bin2bcd(hour); |
131 | } | 131 | } |
132 | return BIN2BCD(hour); | 132 | return bin2bcd(hour); |
133 | } | 133 | } |
134 | 134 | ||
135 | /*----------------------------------------------------------------------*/ | 135 | /*----------------------------------------------------------------------*/ |
@@ -206,13 +206,13 @@ static int ds1305_get_time(struct device *dev, struct rtc_time *time) | |||
206 | buf[4], buf[5], buf[6]); | 206 | buf[4], buf[5], buf[6]); |
207 | 207 | ||
208 | /* Decode the registers */ | 208 | /* Decode the registers */ |
209 | time->tm_sec = BCD2BIN(buf[DS1305_SEC]); | 209 | time->tm_sec = bcd2bin(buf[DS1305_SEC]); |
210 | time->tm_min = BCD2BIN(buf[DS1305_MIN]); | 210 | time->tm_min = bcd2bin(buf[DS1305_MIN]); |
211 | time->tm_hour = bcd2hour(buf[DS1305_HOUR]); | 211 | time->tm_hour = bcd2hour(buf[DS1305_HOUR]); |
212 | time->tm_wday = buf[DS1305_WDAY] - 1; | 212 | time->tm_wday = buf[DS1305_WDAY] - 1; |
213 | time->tm_mday = BCD2BIN(buf[DS1305_MDAY]); | 213 | time->tm_mday = bcd2bin(buf[DS1305_MDAY]); |
214 | time->tm_mon = BCD2BIN(buf[DS1305_MON]) - 1; | 214 | time->tm_mon = bcd2bin(buf[DS1305_MON]) - 1; |
215 | time->tm_year = BCD2BIN(buf[DS1305_YEAR]) + 100; | 215 | time->tm_year = bcd2bin(buf[DS1305_YEAR]) + 100; |
216 | 216 | ||
217 | dev_vdbg(dev, "%s secs=%d, mins=%d, " | 217 | dev_vdbg(dev, "%s secs=%d, mins=%d, " |
218 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | 218 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", |
@@ -239,13 +239,13 @@ static int ds1305_set_time(struct device *dev, struct rtc_time *time) | |||
239 | /* Write registers starting at the first time/date address. */ | 239 | /* Write registers starting at the first time/date address. */ |
240 | *bp++ = DS1305_WRITE | DS1305_SEC; | 240 | *bp++ = DS1305_WRITE | DS1305_SEC; |
241 | 241 | ||
242 | *bp++ = BIN2BCD(time->tm_sec); | 242 | *bp++ = bin2bcd(time->tm_sec); |
243 | *bp++ = BIN2BCD(time->tm_min); | 243 | *bp++ = bin2bcd(time->tm_min); |
244 | *bp++ = hour2bcd(ds1305->hr12, time->tm_hour); | 244 | *bp++ = hour2bcd(ds1305->hr12, time->tm_hour); |
245 | *bp++ = (time->tm_wday < 7) ? (time->tm_wday + 1) : 1; | 245 | *bp++ = (time->tm_wday < 7) ? (time->tm_wday + 1) : 1; |
246 | *bp++ = BIN2BCD(time->tm_mday); | 246 | *bp++ = bin2bcd(time->tm_mday); |
247 | *bp++ = BIN2BCD(time->tm_mon + 1); | 247 | *bp++ = bin2bcd(time->tm_mon + 1); |
248 | *bp++ = BIN2BCD(time->tm_year - 100); | 248 | *bp++ = bin2bcd(time->tm_year - 100); |
249 | 249 | ||
250 | dev_dbg(dev, "%s: %02x %02x %02x, %02x %02x %02x %02x\n", | 250 | dev_dbg(dev, "%s: %02x %02x %02x, %02x %02x %02x %02x\n", |
251 | "write", buf[1], buf[2], buf[3], | 251 | "write", buf[1], buf[2], buf[3], |
@@ -329,8 +329,8 @@ static int ds1305_get_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
329 | * fill in the rest ... and also handle rollover to tomorrow when | 329 | * fill in the rest ... and also handle rollover to tomorrow when |
330 | * that's needed. | 330 | * that's needed. |
331 | */ | 331 | */ |
332 | alm->time.tm_sec = BCD2BIN(buf[DS1305_SEC]); | 332 | alm->time.tm_sec = bcd2bin(buf[DS1305_SEC]); |
333 | alm->time.tm_min = BCD2BIN(buf[DS1305_MIN]); | 333 | alm->time.tm_min = bcd2bin(buf[DS1305_MIN]); |
334 | alm->time.tm_hour = bcd2hour(buf[DS1305_HOUR]); | 334 | alm->time.tm_hour = bcd2hour(buf[DS1305_HOUR]); |
335 | alm->time.tm_mday = -1; | 335 | alm->time.tm_mday = -1; |
336 | alm->time.tm_mon = -1; | 336 | alm->time.tm_mon = -1; |
@@ -387,8 +387,8 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
387 | 387 | ||
388 | /* write alarm */ | 388 | /* write alarm */ |
389 | buf[0] = DS1305_WRITE | DS1305_ALM0(DS1305_SEC); | 389 | buf[0] = DS1305_WRITE | DS1305_ALM0(DS1305_SEC); |
390 | buf[1 + DS1305_SEC] = BIN2BCD(alm->time.tm_sec); | 390 | buf[1 + DS1305_SEC] = bin2bcd(alm->time.tm_sec); |
391 | buf[1 + DS1305_MIN] = BIN2BCD(alm->time.tm_min); | 391 | buf[1 + DS1305_MIN] = bin2bcd(alm->time.tm_min); |
392 | buf[1 + DS1305_HOUR] = hour2bcd(ds1305->hr12, alm->time.tm_hour); | 392 | buf[1 + DS1305_HOUR] = hour2bcd(ds1305->hr12, alm->time.tm_hour); |
393 | buf[1 + DS1305_WDAY] = DS1305_ALM_DISABLE; | 393 | buf[1 + DS1305_WDAY] = DS1305_ALM_DISABLE; |
394 | 394 | ||
@@ -606,7 +606,6 @@ ds1305_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | |||
606 | static struct bin_attribute nvram = { | 606 | static struct bin_attribute nvram = { |
607 | .attr.name = "nvram", | 607 | .attr.name = "nvram", |
608 | .attr.mode = S_IRUGO | S_IWUSR, | 608 | .attr.mode = S_IRUGO | S_IWUSR, |
609 | .attr.owner = THIS_MODULE, | ||
610 | .read = ds1305_nvram_read, | 609 | .read = ds1305_nvram_read, |
611 | .write = ds1305_nvram_write, | 610 | .write = ds1305_nvram_write, |
612 | .size = DS1305_NVRAM_LEN, | 611 | .size = DS1305_NVRAM_LEN, |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 4fcf0734a6ef..162330b9d1dc 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -222,17 +222,17 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) | |||
222 | ds1307->regs[4], ds1307->regs[5], | 222 | ds1307->regs[4], ds1307->regs[5], |
223 | ds1307->regs[6]); | 223 | ds1307->regs[6]); |
224 | 224 | ||
225 | t->tm_sec = BCD2BIN(ds1307->regs[DS1307_REG_SECS] & 0x7f); | 225 | t->tm_sec = bcd2bin(ds1307->regs[DS1307_REG_SECS] & 0x7f); |
226 | t->tm_min = BCD2BIN(ds1307->regs[DS1307_REG_MIN] & 0x7f); | 226 | t->tm_min = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); |
227 | tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; | 227 | tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; |
228 | t->tm_hour = BCD2BIN(tmp); | 228 | t->tm_hour = bcd2bin(tmp); |
229 | t->tm_wday = BCD2BIN(ds1307->regs[DS1307_REG_WDAY] & 0x07) - 1; | 229 | t->tm_wday = bcd2bin(ds1307->regs[DS1307_REG_WDAY] & 0x07) - 1; |
230 | t->tm_mday = BCD2BIN(ds1307->regs[DS1307_REG_MDAY] & 0x3f); | 230 | t->tm_mday = bcd2bin(ds1307->regs[DS1307_REG_MDAY] & 0x3f); |
231 | tmp = ds1307->regs[DS1307_REG_MONTH] & 0x1f; | 231 | tmp = ds1307->regs[DS1307_REG_MONTH] & 0x1f; |
232 | t->tm_mon = BCD2BIN(tmp) - 1; | 232 | t->tm_mon = bcd2bin(tmp) - 1; |
233 | 233 | ||
234 | /* assume 20YY not 19YY, and ignore DS1337_BIT_CENTURY */ | 234 | /* assume 20YY not 19YY, and ignore DS1337_BIT_CENTURY */ |
235 | t->tm_year = BCD2BIN(ds1307->regs[DS1307_REG_YEAR]) + 100; | 235 | t->tm_year = bcd2bin(ds1307->regs[DS1307_REG_YEAR]) + 100; |
236 | 236 | ||
237 | dev_dbg(dev, "%s secs=%d, mins=%d, " | 237 | dev_dbg(dev, "%s secs=%d, mins=%d, " |
238 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | 238 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", |
@@ -258,16 +258,16 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) | |||
258 | t->tm_mon, t->tm_year, t->tm_wday); | 258 | t->tm_mon, t->tm_year, t->tm_wday); |
259 | 259 | ||
260 | *buf++ = 0; /* first register addr */ | 260 | *buf++ = 0; /* first register addr */ |
261 | buf[DS1307_REG_SECS] = BIN2BCD(t->tm_sec); | 261 | buf[DS1307_REG_SECS] = bin2bcd(t->tm_sec); |
262 | buf[DS1307_REG_MIN] = BIN2BCD(t->tm_min); | 262 | buf[DS1307_REG_MIN] = bin2bcd(t->tm_min); |
263 | buf[DS1307_REG_HOUR] = BIN2BCD(t->tm_hour); | 263 | buf[DS1307_REG_HOUR] = bin2bcd(t->tm_hour); |
264 | buf[DS1307_REG_WDAY] = BIN2BCD(t->tm_wday + 1); | 264 | buf[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1); |
265 | buf[DS1307_REG_MDAY] = BIN2BCD(t->tm_mday); | 265 | buf[DS1307_REG_MDAY] = bin2bcd(t->tm_mday); |
266 | buf[DS1307_REG_MONTH] = BIN2BCD(t->tm_mon + 1); | 266 | buf[DS1307_REG_MONTH] = bin2bcd(t->tm_mon + 1); |
267 | 267 | ||
268 | /* assume 20YY not 19YY */ | 268 | /* assume 20YY not 19YY */ |
269 | tmp = t->tm_year - 100; | 269 | tmp = t->tm_year - 100; |
270 | buf[DS1307_REG_YEAR] = BIN2BCD(tmp); | 270 | buf[DS1307_REG_YEAR] = bin2bcd(tmp); |
271 | 271 | ||
272 | switch (ds1307->type) { | 272 | switch (ds1307->type) { |
273 | case ds_1337: | 273 | case ds_1337: |
@@ -551,7 +551,6 @@ static struct bin_attribute nvram = { | |||
551 | .attr = { | 551 | .attr = { |
552 | .name = "nvram", | 552 | .name = "nvram", |
553 | .mode = S_IRUGO | S_IWUSR, | 553 | .mode = S_IRUGO | S_IWUSR, |
554 | .owner = THIS_MODULE, | ||
555 | }, | 554 | }, |
556 | 555 | ||
557 | .read = ds1307_nvram_read, | 556 | .read = ds1307_nvram_read, |
@@ -709,18 +708,18 @@ read_rtc: | |||
709 | } | 708 | } |
710 | 709 | ||
711 | tmp = ds1307->regs[DS1307_REG_SECS]; | 710 | tmp = ds1307->regs[DS1307_REG_SECS]; |
712 | tmp = BCD2BIN(tmp & 0x7f); | 711 | tmp = bcd2bin(tmp & 0x7f); |
713 | if (tmp > 60) | 712 | if (tmp > 60) |
714 | goto exit_bad; | 713 | goto exit_bad; |
715 | tmp = BCD2BIN(ds1307->regs[DS1307_REG_MIN] & 0x7f); | 714 | tmp = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); |
716 | if (tmp > 60) | 715 | if (tmp > 60) |
717 | goto exit_bad; | 716 | goto exit_bad; |
718 | 717 | ||
719 | tmp = BCD2BIN(ds1307->regs[DS1307_REG_MDAY] & 0x3f); | 718 | tmp = bcd2bin(ds1307->regs[DS1307_REG_MDAY] & 0x3f); |
720 | if (tmp == 0 || tmp > 31) | 719 | if (tmp == 0 || tmp > 31) |
721 | goto exit_bad; | 720 | goto exit_bad; |
722 | 721 | ||
723 | tmp = BCD2BIN(ds1307->regs[DS1307_REG_MONTH] & 0x1f); | 722 | tmp = bcd2bin(ds1307->regs[DS1307_REG_MONTH] & 0x1f); |
724 | if (tmp == 0 || tmp > 12) | 723 | if (tmp == 0 || tmp > 12) |
725 | goto exit_bad; | 724 | goto exit_bad; |
726 | 725 | ||
@@ -739,14 +738,14 @@ read_rtc: | |||
739 | /* Be sure we're in 24 hour mode. Multi-master systems | 738 | /* Be sure we're in 24 hour mode. Multi-master systems |
740 | * take note... | 739 | * take note... |
741 | */ | 740 | */ |
742 | tmp = BCD2BIN(tmp & 0x1f); | 741 | tmp = bcd2bin(tmp & 0x1f); |
743 | if (tmp == 12) | 742 | if (tmp == 12) |
744 | tmp = 0; | 743 | tmp = 0; |
745 | if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) | 744 | if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) |
746 | tmp += 12; | 745 | tmp += 12; |
747 | i2c_smbus_write_byte_data(client, | 746 | i2c_smbus_write_byte_data(client, |
748 | DS1307_REG_HOUR, | 747 | DS1307_REG_HOUR, |
749 | BIN2BCD(tmp)); | 748 | bin2bcd(tmp)); |
750 | } | 749 | } |
751 | 750 | ||
752 | ds1307->rtc = rtc_device_register(client->name, &client->dev, | 751 | ds1307->rtc = rtc_device_register(client->name, &client->dev, |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 86981d34fbb6..25caada78398 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -153,8 +153,8 @@ ds1511_wdog_set(unsigned long deciseconds) | |||
153 | /* | 153 | /* |
154 | * set the wdog values in the wdog registers | 154 | * set the wdog values in the wdog registers |
155 | */ | 155 | */ |
156 | rtc_write(BIN2BCD(deciseconds % 100), DS1511_WD_MSEC); | 156 | rtc_write(bin2bcd(deciseconds % 100), DS1511_WD_MSEC); |
157 | rtc_write(BIN2BCD(deciseconds / 100), DS1511_WD_SEC); | 157 | rtc_write(bin2bcd(deciseconds / 100), DS1511_WD_SEC); |
158 | /* | 158 | /* |
159 | * set wdog enable and wdog 'steering' bit to issue a reset | 159 | * set wdog enable and wdog 'steering' bit to issue a reset |
160 | */ | 160 | */ |
@@ -220,13 +220,13 @@ static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) | |||
220 | /* | 220 | /* |
221 | * each register is a different number of valid bits | 221 | * each register is a different number of valid bits |
222 | */ | 222 | */ |
223 | sec = BIN2BCD(sec) & 0x7f; | 223 | sec = bin2bcd(sec) & 0x7f; |
224 | min = BIN2BCD(min) & 0x7f; | 224 | min = bin2bcd(min) & 0x7f; |
225 | hrs = BIN2BCD(hrs) & 0x3f; | 225 | hrs = bin2bcd(hrs) & 0x3f; |
226 | day = BIN2BCD(day) & 0x3f; | 226 | day = bin2bcd(day) & 0x3f; |
227 | mon = BIN2BCD(mon) & 0x1f; | 227 | mon = bin2bcd(mon) & 0x1f; |
228 | yrs = BIN2BCD(yrs) & 0xff; | 228 | yrs = bin2bcd(yrs) & 0xff; |
229 | cen = BIN2BCD(cen) & 0xff; | 229 | cen = bin2bcd(cen) & 0xff; |
230 | 230 | ||
231 | spin_lock_irqsave(&ds1511_lock, flags); | 231 | spin_lock_irqsave(&ds1511_lock, flags); |
232 | rtc_disable_update(); | 232 | rtc_disable_update(); |
@@ -264,14 +264,14 @@ static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) | |||
264 | rtc_enable_update(); | 264 | rtc_enable_update(); |
265 | spin_unlock_irqrestore(&ds1511_lock, flags); | 265 | spin_unlock_irqrestore(&ds1511_lock, flags); |
266 | 266 | ||
267 | rtc_tm->tm_sec = BCD2BIN(rtc_tm->tm_sec); | 267 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); |
268 | rtc_tm->tm_min = BCD2BIN(rtc_tm->tm_min); | 268 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); |
269 | rtc_tm->tm_hour = BCD2BIN(rtc_tm->tm_hour); | 269 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); |
270 | rtc_tm->tm_mday = BCD2BIN(rtc_tm->tm_mday); | 270 | rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); |
271 | rtc_tm->tm_wday = BCD2BIN(rtc_tm->tm_wday); | 271 | rtc_tm->tm_wday = bcd2bin(rtc_tm->tm_wday); |
272 | rtc_tm->tm_mon = BCD2BIN(rtc_tm->tm_mon); | 272 | rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); |
273 | rtc_tm->tm_year = BCD2BIN(rtc_tm->tm_year); | 273 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); |
274 | century = BCD2BIN(century) * 100; | 274 | century = bcd2bin(century) * 100; |
275 | 275 | ||
276 | /* | 276 | /* |
277 | * Account for differences between how the RTC uses the values | 277 | * Account for differences between how the RTC uses the values |
@@ -304,16 +304,16 @@ ds1511_rtc_update_alarm(struct rtc_plat_data *pdata) | |||
304 | 304 | ||
305 | spin_lock_irqsave(&pdata->rtc->irq_lock, flags); | 305 | spin_lock_irqsave(&pdata->rtc->irq_lock, flags); |
306 | rtc_write(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? | 306 | rtc_write(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? |
307 | 0x80 : BIN2BCD(pdata->alrm_mday) & 0x3f, | 307 | 0x80 : bin2bcd(pdata->alrm_mday) & 0x3f, |
308 | RTC_ALARM_DATE); | 308 | RTC_ALARM_DATE); |
309 | rtc_write(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? | 309 | rtc_write(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? |
310 | 0x80 : BIN2BCD(pdata->alrm_hour) & 0x3f, | 310 | 0x80 : bin2bcd(pdata->alrm_hour) & 0x3f, |
311 | RTC_ALARM_HOUR); | 311 | RTC_ALARM_HOUR); |
312 | rtc_write(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? | 312 | rtc_write(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? |
313 | 0x80 : BIN2BCD(pdata->alrm_min) & 0x7f, | 313 | 0x80 : bin2bcd(pdata->alrm_min) & 0x7f, |
314 | RTC_ALARM_MIN); | 314 | RTC_ALARM_MIN); |
315 | rtc_write(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? | 315 | rtc_write(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? |
316 | 0x80 : BIN2BCD(pdata->alrm_sec) & 0x7f, | 316 | 0x80 : bin2bcd(pdata->alrm_sec) & 0x7f, |
317 | RTC_ALARM_SEC); | 317 | RTC_ALARM_SEC); |
318 | rtc_write(rtc_read(RTC_CMD) | (pdata->irqen ? RTC_TIE : 0), RTC_CMD); | 318 | rtc_write(rtc_read(RTC_CMD) | (pdata->irqen ? RTC_TIE : 0), RTC_CMD); |
319 | rtc_read(RTC_CMD1); /* clear interrupts */ | 319 | rtc_read(RTC_CMD1); /* clear interrupts */ |
@@ -481,7 +481,6 @@ static struct bin_attribute ds1511_nvram_attr = { | |||
481 | .attr = { | 481 | .attr = { |
482 | .name = "nvram", | 482 | .name = "nvram", |
483 | .mode = S_IRUGO | S_IWUGO, | 483 | .mode = S_IRUGO | S_IWUGO, |
484 | .owner = THIS_MODULE, | ||
485 | }, | 484 | }, |
486 | .size = DS1511_RAM_MAX, | 485 | .size = DS1511_RAM_MAX, |
487 | .read = ds1511_nvram_read, | 486 | .read = ds1511_nvram_read, |
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 4ef59285b489..b9475cd20210 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -78,17 +78,17 @@ static int ds1553_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
78 | void __iomem *ioaddr = pdata->ioaddr; | 78 | void __iomem *ioaddr = pdata->ioaddr; |
79 | u8 century; | 79 | u8 century; |
80 | 80 | ||
81 | century = BIN2BCD((tm->tm_year + 1900) / 100); | 81 | century = bin2bcd((tm->tm_year + 1900) / 100); |
82 | 82 | ||
83 | writeb(RTC_WRITE, pdata->ioaddr + RTC_CONTROL); | 83 | writeb(RTC_WRITE, pdata->ioaddr + RTC_CONTROL); |
84 | 84 | ||
85 | writeb(BIN2BCD(tm->tm_year % 100), ioaddr + RTC_YEAR); | 85 | writeb(bin2bcd(tm->tm_year % 100), ioaddr + RTC_YEAR); |
86 | writeb(BIN2BCD(tm->tm_mon + 1), ioaddr + RTC_MONTH); | 86 | writeb(bin2bcd(tm->tm_mon + 1), ioaddr + RTC_MONTH); |
87 | writeb(BIN2BCD(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY); | 87 | writeb(bin2bcd(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY); |
88 | writeb(BIN2BCD(tm->tm_mday), ioaddr + RTC_DATE); | 88 | writeb(bin2bcd(tm->tm_mday), ioaddr + RTC_DATE); |
89 | writeb(BIN2BCD(tm->tm_hour), ioaddr + RTC_HOURS); | 89 | writeb(bin2bcd(tm->tm_hour), ioaddr + RTC_HOURS); |
90 | writeb(BIN2BCD(tm->tm_min), ioaddr + RTC_MINUTES); | 90 | writeb(bin2bcd(tm->tm_min), ioaddr + RTC_MINUTES); |
91 | writeb(BIN2BCD(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS); | 91 | writeb(bin2bcd(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS); |
92 | 92 | ||
93 | /* RTC_CENTURY and RTC_CONTROL share same register */ | 93 | /* RTC_CENTURY and RTC_CONTROL share same register */ |
94 | writeb(RTC_WRITE | (century & RTC_CENTURY_MASK), ioaddr + RTC_CENTURY); | 94 | writeb(RTC_WRITE | (century & RTC_CENTURY_MASK), ioaddr + RTC_CENTURY); |
@@ -118,14 +118,14 @@ static int ds1553_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
118 | year = readb(ioaddr + RTC_YEAR); | 118 | year = readb(ioaddr + RTC_YEAR); |
119 | century = readb(ioaddr + RTC_CENTURY) & RTC_CENTURY_MASK; | 119 | century = readb(ioaddr + RTC_CENTURY) & RTC_CENTURY_MASK; |
120 | writeb(0, ioaddr + RTC_CONTROL); | 120 | writeb(0, ioaddr + RTC_CONTROL); |
121 | tm->tm_sec = BCD2BIN(second); | 121 | tm->tm_sec = bcd2bin(second); |
122 | tm->tm_min = BCD2BIN(minute); | 122 | tm->tm_min = bcd2bin(minute); |
123 | tm->tm_hour = BCD2BIN(hour); | 123 | tm->tm_hour = bcd2bin(hour); |
124 | tm->tm_mday = BCD2BIN(day); | 124 | tm->tm_mday = bcd2bin(day); |
125 | tm->tm_wday = BCD2BIN(week); | 125 | tm->tm_wday = bcd2bin(week); |
126 | tm->tm_mon = BCD2BIN(month) - 1; | 126 | tm->tm_mon = bcd2bin(month) - 1; |
127 | /* year is 1900 + tm->tm_year */ | 127 | /* year is 1900 + tm->tm_year */ |
128 | tm->tm_year = BCD2BIN(year) + BCD2BIN(century) * 100 - 1900; | 128 | tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900; |
129 | 129 | ||
130 | if (rtc_valid_tm(tm) < 0) { | 130 | if (rtc_valid_tm(tm) < 0) { |
131 | dev_err(dev, "retrieved date/time is not valid.\n"); | 131 | dev_err(dev, "retrieved date/time is not valid.\n"); |
@@ -141,16 +141,16 @@ static void ds1553_rtc_update_alarm(struct rtc_plat_data *pdata) | |||
141 | 141 | ||
142 | spin_lock_irqsave(&pdata->rtc->irq_lock, flags); | 142 | spin_lock_irqsave(&pdata->rtc->irq_lock, flags); |
143 | writeb(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? | 143 | writeb(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? |
144 | 0x80 : BIN2BCD(pdata->alrm_mday), | 144 | 0x80 : bin2bcd(pdata->alrm_mday), |
145 | ioaddr + RTC_DATE_ALARM); | 145 | ioaddr + RTC_DATE_ALARM); |
146 | writeb(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? | 146 | writeb(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? |
147 | 0x80 : BIN2BCD(pdata->alrm_hour), | 147 | 0x80 : bin2bcd(pdata->alrm_hour), |
148 | ioaddr + RTC_HOURS_ALARM); | 148 | ioaddr + RTC_HOURS_ALARM); |
149 | writeb(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? | 149 | writeb(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? |
150 | 0x80 : BIN2BCD(pdata->alrm_min), | 150 | 0x80 : bin2bcd(pdata->alrm_min), |
151 | ioaddr + RTC_MINUTES_ALARM); | 151 | ioaddr + RTC_MINUTES_ALARM); |
152 | writeb(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? | 152 | writeb(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? |
153 | 0x80 : BIN2BCD(pdata->alrm_sec), | 153 | 0x80 : bin2bcd(pdata->alrm_sec), |
154 | ioaddr + RTC_SECONDS_ALARM); | 154 | ioaddr + RTC_SECONDS_ALARM); |
155 | writeb(pdata->irqen ? RTC_INTS_AE : 0, ioaddr + RTC_INTERRUPTS); | 155 | writeb(pdata->irqen ? RTC_INTS_AE : 0, ioaddr + RTC_INTERRUPTS); |
156 | readb(ioaddr + RTC_FLAGS); /* clear interrupts */ | 156 | readb(ioaddr + RTC_FLAGS); /* clear interrupts */ |
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index 24d35ede2dbf..8bc8501bffc8 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -66,17 +66,17 @@ static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
66 | void __iomem *ioaddr = pdata->ioaddr_rtc; | 66 | void __iomem *ioaddr = pdata->ioaddr_rtc; |
67 | u8 century; | 67 | u8 century; |
68 | 68 | ||
69 | century = BIN2BCD((tm->tm_year + 1900) / 100); | 69 | century = bin2bcd((tm->tm_year + 1900) / 100); |
70 | 70 | ||
71 | writeb(RTC_WRITE, ioaddr + RTC_CONTROL); | 71 | writeb(RTC_WRITE, ioaddr + RTC_CONTROL); |
72 | 72 | ||
73 | writeb(BIN2BCD(tm->tm_year % 100), ioaddr + RTC_YEAR); | 73 | writeb(bin2bcd(tm->tm_year % 100), ioaddr + RTC_YEAR); |
74 | writeb(BIN2BCD(tm->tm_mon + 1), ioaddr + RTC_MONTH); | 74 | writeb(bin2bcd(tm->tm_mon + 1), ioaddr + RTC_MONTH); |
75 | writeb(BIN2BCD(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY); | 75 | writeb(bin2bcd(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY); |
76 | writeb(BIN2BCD(tm->tm_mday), ioaddr + RTC_DATE); | 76 | writeb(bin2bcd(tm->tm_mday), ioaddr + RTC_DATE); |
77 | writeb(BIN2BCD(tm->tm_hour), ioaddr + RTC_HOURS); | 77 | writeb(bin2bcd(tm->tm_hour), ioaddr + RTC_HOURS); |
78 | writeb(BIN2BCD(tm->tm_min), ioaddr + RTC_MINUTES); | 78 | writeb(bin2bcd(tm->tm_min), ioaddr + RTC_MINUTES); |
79 | writeb(BIN2BCD(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS); | 79 | writeb(bin2bcd(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS); |
80 | 80 | ||
81 | /* RTC_CENTURY and RTC_CONTROL share same register */ | 81 | /* RTC_CENTURY and RTC_CONTROL share same register */ |
82 | writeb(RTC_WRITE | (century & RTC_CENTURY_MASK), ioaddr + RTC_CENTURY); | 82 | writeb(RTC_WRITE | (century & RTC_CENTURY_MASK), ioaddr + RTC_CENTURY); |
@@ -106,14 +106,14 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
106 | year = readb(ioaddr + RTC_YEAR); | 106 | year = readb(ioaddr + RTC_YEAR); |
107 | century = readb(ioaddr + RTC_CENTURY) & RTC_CENTURY_MASK; | 107 | century = readb(ioaddr + RTC_CENTURY) & RTC_CENTURY_MASK; |
108 | writeb(0, ioaddr + RTC_CONTROL); | 108 | writeb(0, ioaddr + RTC_CONTROL); |
109 | tm->tm_sec = BCD2BIN(second); | 109 | tm->tm_sec = bcd2bin(second); |
110 | tm->tm_min = BCD2BIN(minute); | 110 | tm->tm_min = bcd2bin(minute); |
111 | tm->tm_hour = BCD2BIN(hour); | 111 | tm->tm_hour = bcd2bin(hour); |
112 | tm->tm_mday = BCD2BIN(day); | 112 | tm->tm_mday = bcd2bin(day); |
113 | tm->tm_wday = BCD2BIN(week); | 113 | tm->tm_wday = bcd2bin(week); |
114 | tm->tm_mon = BCD2BIN(month) - 1; | 114 | tm->tm_mon = bcd2bin(month) - 1; |
115 | /* year is 1900 + tm->tm_year */ | 115 | /* year is 1900 + tm->tm_year */ |
116 | tm->tm_year = BCD2BIN(year) + BCD2BIN(century) * 100 - 1900; | 116 | tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900; |
117 | 117 | ||
118 | if (rtc_valid_tm(tm) < 0) { | 118 | if (rtc_valid_tm(tm) < 0) { |
119 | dev_err(dev, "retrieved date/time is not valid.\n"); | 119 | dev_err(dev, "retrieved date/time is not valid.\n"); |
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index abfdfcbaa059..3a7be11cc6b9 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c | |||
@@ -131,17 +131,17 @@ static int fm3130_get_time(struct device *dev, struct rtc_time *t) | |||
131 | fm3130->regs[0xc], fm3130->regs[0xd], | 131 | fm3130->regs[0xc], fm3130->regs[0xd], |
132 | fm3130->regs[0xe]); | 132 | fm3130->regs[0xe]); |
133 | 133 | ||
134 | t->tm_sec = BCD2BIN(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f); | 134 | t->tm_sec = bcd2bin(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f); |
135 | t->tm_min = BCD2BIN(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); | 135 | t->tm_min = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); |
136 | tmp = fm3130->regs[FM3130_RTC_HOURS] & 0x3f; | 136 | tmp = fm3130->regs[FM3130_RTC_HOURS] & 0x3f; |
137 | t->tm_hour = BCD2BIN(tmp); | 137 | t->tm_hour = bcd2bin(tmp); |
138 | t->tm_wday = BCD2BIN(fm3130->regs[FM3130_RTC_DAY] & 0x07) - 1; | 138 | t->tm_wday = bcd2bin(fm3130->regs[FM3130_RTC_DAY] & 0x07) - 1; |
139 | t->tm_mday = BCD2BIN(fm3130->regs[FM3130_RTC_DATE] & 0x3f); | 139 | t->tm_mday = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f); |
140 | tmp = fm3130->regs[FM3130_RTC_MONTHS] & 0x1f; | 140 | tmp = fm3130->regs[FM3130_RTC_MONTHS] & 0x1f; |
141 | t->tm_mon = BCD2BIN(tmp) - 1; | 141 | t->tm_mon = bcd2bin(tmp) - 1; |
142 | 142 | ||
143 | /* assume 20YY not 19YY, and ignore CF bit */ | 143 | /* assume 20YY not 19YY, and ignore CF bit */ |
144 | t->tm_year = BCD2BIN(fm3130->regs[FM3130_RTC_YEARS]) + 100; | 144 | t->tm_year = bcd2bin(fm3130->regs[FM3130_RTC_YEARS]) + 100; |
145 | 145 | ||
146 | dev_dbg(dev, "%s secs=%d, mins=%d, " | 146 | dev_dbg(dev, "%s secs=%d, mins=%d, " |
147 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | 147 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", |
@@ -167,16 +167,16 @@ static int fm3130_set_time(struct device *dev, struct rtc_time *t) | |||
167 | t->tm_mon, t->tm_year, t->tm_wday); | 167 | t->tm_mon, t->tm_year, t->tm_wday); |
168 | 168 | ||
169 | /* first register addr */ | 169 | /* first register addr */ |
170 | buf[FM3130_RTC_SECONDS] = BIN2BCD(t->tm_sec); | 170 | buf[FM3130_RTC_SECONDS] = bin2bcd(t->tm_sec); |
171 | buf[FM3130_RTC_MINUTES] = BIN2BCD(t->tm_min); | 171 | buf[FM3130_RTC_MINUTES] = bin2bcd(t->tm_min); |
172 | buf[FM3130_RTC_HOURS] = BIN2BCD(t->tm_hour); | 172 | buf[FM3130_RTC_HOURS] = bin2bcd(t->tm_hour); |
173 | buf[FM3130_RTC_DAY] = BIN2BCD(t->tm_wday + 1); | 173 | buf[FM3130_RTC_DAY] = bin2bcd(t->tm_wday + 1); |
174 | buf[FM3130_RTC_DATE] = BIN2BCD(t->tm_mday); | 174 | buf[FM3130_RTC_DATE] = bin2bcd(t->tm_mday); |
175 | buf[FM3130_RTC_MONTHS] = BIN2BCD(t->tm_mon + 1); | 175 | buf[FM3130_RTC_MONTHS] = bin2bcd(t->tm_mon + 1); |
176 | 176 | ||
177 | /* assume 20YY not 19YY */ | 177 | /* assume 20YY not 19YY */ |
178 | tmp = t->tm_year - 100; | 178 | tmp = t->tm_year - 100; |
179 | buf[FM3130_RTC_YEARS] = BIN2BCD(tmp); | 179 | buf[FM3130_RTC_YEARS] = bin2bcd(tmp); |
180 | 180 | ||
181 | dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x" | 181 | dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x" |
182 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | 182 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", |
@@ -222,11 +222,11 @@ static int fm3130_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
222 | fm3130->regs[FM3130_ALARM_MONTHS]); | 222 | fm3130->regs[FM3130_ALARM_MONTHS]); |
223 | 223 | ||
224 | 224 | ||
225 | tm->tm_sec = BCD2BIN(fm3130->regs[FM3130_ALARM_SECONDS] & 0x7F); | 225 | tm->tm_sec = bcd2bin(fm3130->regs[FM3130_ALARM_SECONDS] & 0x7F); |
226 | tm->tm_min = BCD2BIN(fm3130->regs[FM3130_ALARM_MINUTES] & 0x7F); | 226 | tm->tm_min = bcd2bin(fm3130->regs[FM3130_ALARM_MINUTES] & 0x7F); |
227 | tm->tm_hour = BCD2BIN(fm3130->regs[FM3130_ALARM_HOURS] & 0x3F); | 227 | tm->tm_hour = bcd2bin(fm3130->regs[FM3130_ALARM_HOURS] & 0x3F); |
228 | tm->tm_mday = BCD2BIN(fm3130->regs[FM3130_ALARM_DATE] & 0x3F); | 228 | tm->tm_mday = bcd2bin(fm3130->regs[FM3130_ALARM_DATE] & 0x3F); |
229 | tm->tm_mon = BCD2BIN(fm3130->regs[FM3130_ALARM_MONTHS] & 0x1F); | 229 | tm->tm_mon = bcd2bin(fm3130->regs[FM3130_ALARM_MONTHS] & 0x1F); |
230 | if (tm->tm_mon > 0) | 230 | if (tm->tm_mon > 0) |
231 | tm->tm_mon -= 1; /* RTC is 1-12, tm_mon is 0-11 */ | 231 | tm->tm_mon -= 1; /* RTC is 1-12, tm_mon is 0-11 */ |
232 | dev_dbg(dev, "%s secs=%d, mins=%d, " | 232 | dev_dbg(dev, "%s secs=%d, mins=%d, " |
@@ -252,23 +252,23 @@ static int fm3130_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
252 | 252 | ||
253 | if (tm->tm_sec != -1) | 253 | if (tm->tm_sec != -1) |
254 | fm3130->regs[FM3130_ALARM_SECONDS] = | 254 | fm3130->regs[FM3130_ALARM_SECONDS] = |
255 | BIN2BCD(tm->tm_sec) | 0x80; | 255 | bin2bcd(tm->tm_sec) | 0x80; |
256 | 256 | ||
257 | if (tm->tm_min != -1) | 257 | if (tm->tm_min != -1) |
258 | fm3130->regs[FM3130_ALARM_MINUTES] = | 258 | fm3130->regs[FM3130_ALARM_MINUTES] = |
259 | BIN2BCD(tm->tm_min) | 0x80; | 259 | bin2bcd(tm->tm_min) | 0x80; |
260 | 260 | ||
261 | if (tm->tm_hour != -1) | 261 | if (tm->tm_hour != -1) |
262 | fm3130->regs[FM3130_ALARM_HOURS] = | 262 | fm3130->regs[FM3130_ALARM_HOURS] = |
263 | BIN2BCD(tm->tm_hour) | 0x80; | 263 | bin2bcd(tm->tm_hour) | 0x80; |
264 | 264 | ||
265 | if (tm->tm_mday != -1) | 265 | if (tm->tm_mday != -1) |
266 | fm3130->regs[FM3130_ALARM_DATE] = | 266 | fm3130->regs[FM3130_ALARM_DATE] = |
267 | BIN2BCD(tm->tm_mday) | 0x80; | 267 | bin2bcd(tm->tm_mday) | 0x80; |
268 | 268 | ||
269 | if (tm->tm_mon != -1) | 269 | if (tm->tm_mon != -1) |
270 | fm3130->regs[FM3130_ALARM_MONTHS] = | 270 | fm3130->regs[FM3130_ALARM_MONTHS] = |
271 | BIN2BCD(tm->tm_mon + 1) | 0x80; | 271 | bin2bcd(tm->tm_mon + 1) | 0x80; |
272 | 272 | ||
273 | dev_dbg(dev, "alarm write %02x %02x %02x %02x %02x\n", | 273 | dev_dbg(dev, "alarm write %02x %02x %02x %02x %02x\n", |
274 | fm3130->regs[FM3130_ALARM_SECONDS], | 274 | fm3130->regs[FM3130_ALARM_SECONDS], |
@@ -414,18 +414,18 @@ static int __devinit fm3130_probe(struct i2c_client *client, | |||
414 | /* TODO */ | 414 | /* TODO */ |
415 | /* TODO need to sanity check alarm */ | 415 | /* TODO need to sanity check alarm */ |
416 | tmp = fm3130->regs[FM3130_RTC_SECONDS]; | 416 | tmp = fm3130->regs[FM3130_RTC_SECONDS]; |
417 | tmp = BCD2BIN(tmp & 0x7f); | 417 | tmp = bcd2bin(tmp & 0x7f); |
418 | if (tmp > 60) | 418 | if (tmp > 60) |
419 | goto exit_bad; | 419 | goto exit_bad; |
420 | tmp = BCD2BIN(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); | 420 | tmp = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); |
421 | if (tmp > 60) | 421 | if (tmp > 60) |
422 | goto exit_bad; | 422 | goto exit_bad; |
423 | 423 | ||
424 | tmp = BCD2BIN(fm3130->regs[FM3130_RTC_DATE] & 0x3f); | 424 | tmp = bcd2bin(fm3130->regs[FM3130_RTC_DATE] & 0x3f); |
425 | if (tmp == 0 || tmp > 31) | 425 | if (tmp == 0 || tmp > 31) |
426 | goto exit_bad; | 426 | goto exit_bad; |
427 | 427 | ||
428 | tmp = BCD2BIN(fm3130->regs[FM3130_RTC_MONTHS] & 0x1f); | 428 | tmp = bcd2bin(fm3130->regs[FM3130_RTC_MONTHS] & 0x1f); |
429 | if (tmp == 0 || tmp > 12) | 429 | if (tmp == 0 || tmp > 12) |
430 | goto exit_bad; | 430 | goto exit_bad; |
431 | 431 | ||
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index a81adab6e515..2cd77ab8fc66 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c | |||
@@ -259,26 +259,26 @@ isl1208_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) | |||
259 | return sr; | 259 | return sr; |
260 | } | 260 | } |
261 | 261 | ||
262 | tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SC]); | 262 | tm->tm_sec = bcd2bin(regs[ISL1208_REG_SC]); |
263 | tm->tm_min = BCD2BIN(regs[ISL1208_REG_MN]); | 263 | tm->tm_min = bcd2bin(regs[ISL1208_REG_MN]); |
264 | 264 | ||
265 | /* HR field has a more complex interpretation */ | 265 | /* HR field has a more complex interpretation */ |
266 | { | 266 | { |
267 | const u8 _hr = regs[ISL1208_REG_HR]; | 267 | const u8 _hr = regs[ISL1208_REG_HR]; |
268 | if (_hr & ISL1208_REG_HR_MIL) /* 24h format */ | 268 | if (_hr & ISL1208_REG_HR_MIL) /* 24h format */ |
269 | tm->tm_hour = BCD2BIN(_hr & 0x3f); | 269 | tm->tm_hour = bcd2bin(_hr & 0x3f); |
270 | else { | 270 | else { |
271 | /* 12h format */ | 271 | /* 12h format */ |
272 | tm->tm_hour = BCD2BIN(_hr & 0x1f); | 272 | tm->tm_hour = bcd2bin(_hr & 0x1f); |
273 | if (_hr & ISL1208_REG_HR_PM) /* PM flag set */ | 273 | if (_hr & ISL1208_REG_HR_PM) /* PM flag set */ |
274 | tm->tm_hour += 12; | 274 | tm->tm_hour += 12; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DT]); | 278 | tm->tm_mday = bcd2bin(regs[ISL1208_REG_DT]); |
279 | tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */ | 279 | tm->tm_mon = bcd2bin(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */ |
280 | tm->tm_year = BCD2BIN(regs[ISL1208_REG_YR]) + 100; | 280 | tm->tm_year = bcd2bin(regs[ISL1208_REG_YR]) + 100; |
281 | tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DW]); | 281 | tm->tm_wday = bcd2bin(regs[ISL1208_REG_DW]); |
282 | 282 | ||
283 | return 0; | 283 | return 0; |
284 | } | 284 | } |
@@ -305,13 +305,13 @@ isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm) | |||
305 | } | 305 | } |
306 | 306 | ||
307 | /* MSB of each alarm register is an enable bit */ | 307 | /* MSB of each alarm register is an enable bit */ |
308 | tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f); | 308 | tm->tm_sec = bcd2bin(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f); |
309 | tm->tm_min = BCD2BIN(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f); | 309 | tm->tm_min = bcd2bin(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f); |
310 | tm->tm_hour = BCD2BIN(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f); | 310 | tm->tm_hour = bcd2bin(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f); |
311 | tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f); | 311 | tm->tm_mday = bcd2bin(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f); |
312 | tm->tm_mon = | 312 | tm->tm_mon = |
313 | BCD2BIN(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1; | 313 | bcd2bin(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1; |
314 | tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03); | 314 | tm->tm_wday = bcd2bin(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03); |
315 | 315 | ||
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
@@ -328,15 +328,15 @@ isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) | |||
328 | int sr; | 328 | int sr; |
329 | u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; | 329 | u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; |
330 | 330 | ||
331 | regs[ISL1208_REG_SC] = BIN2BCD(tm->tm_sec); | 331 | regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec); |
332 | regs[ISL1208_REG_MN] = BIN2BCD(tm->tm_min); | 332 | regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min); |
333 | regs[ISL1208_REG_HR] = BIN2BCD(tm->tm_hour) | ISL1208_REG_HR_MIL; | 333 | regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL; |
334 | 334 | ||
335 | regs[ISL1208_REG_DT] = BIN2BCD(tm->tm_mday); | 335 | regs[ISL1208_REG_DT] = bin2bcd(tm->tm_mday); |
336 | regs[ISL1208_REG_MO] = BIN2BCD(tm->tm_mon + 1); | 336 | regs[ISL1208_REG_MO] = bin2bcd(tm->tm_mon + 1); |
337 | regs[ISL1208_REG_YR] = BIN2BCD(tm->tm_year - 100); | 337 | regs[ISL1208_REG_YR] = bin2bcd(tm->tm_year - 100); |
338 | 338 | ||
339 | regs[ISL1208_REG_DW] = BIN2BCD(tm->tm_wday & 7); | 339 | regs[ISL1208_REG_DW] = bin2bcd(tm->tm_wday & 7); |
340 | 340 | ||
341 | sr = isl1208_i2c_get_sr(client); | 341 | sr = isl1208_i2c_get_sr(client); |
342 | if (sr < 0) { | 342 | if (sr < 0) { |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 470fb2d29545..893f7dece239 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -110,15 +110,15 @@ static int m41t80_get_datetime(struct i2c_client *client, | |||
110 | return -EIO; | 110 | return -EIO; |
111 | } | 111 | } |
112 | 112 | ||
113 | tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f); | 113 | tm->tm_sec = bcd2bin(buf[M41T80_REG_SEC] & 0x7f); |
114 | tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f); | 114 | tm->tm_min = bcd2bin(buf[M41T80_REG_MIN] & 0x7f); |
115 | tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f); | 115 | tm->tm_hour = bcd2bin(buf[M41T80_REG_HOUR] & 0x3f); |
116 | tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f); | 116 | tm->tm_mday = bcd2bin(buf[M41T80_REG_DAY] & 0x3f); |
117 | tm->tm_wday = buf[M41T80_REG_WDAY] & 0x07; | 117 | tm->tm_wday = buf[M41T80_REG_WDAY] & 0x07; |
118 | tm->tm_mon = BCD2BIN(buf[M41T80_REG_MON] & 0x1f) - 1; | 118 | tm->tm_mon = bcd2bin(buf[M41T80_REG_MON] & 0x1f) - 1; |
119 | 119 | ||
120 | /* assume 20YY not 19YY, and ignore the Century Bit */ | 120 | /* assume 20YY not 19YY, and ignore the Century Bit */ |
121 | tm->tm_year = BCD2BIN(buf[M41T80_REG_YEAR]) + 100; | 121 | tm->tm_year = bcd2bin(buf[M41T80_REG_YEAR]) + 100; |
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
@@ -161,19 +161,19 @@ static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
161 | /* Merge time-data and register flags into buf[0..7] */ | 161 | /* Merge time-data and register flags into buf[0..7] */ |
162 | buf[M41T80_REG_SSEC] = 0; | 162 | buf[M41T80_REG_SSEC] = 0; |
163 | buf[M41T80_REG_SEC] = | 163 | buf[M41T80_REG_SEC] = |
164 | BIN2BCD(tm->tm_sec) | (buf[M41T80_REG_SEC] & ~0x7f); | 164 | bin2bcd(tm->tm_sec) | (buf[M41T80_REG_SEC] & ~0x7f); |
165 | buf[M41T80_REG_MIN] = | 165 | buf[M41T80_REG_MIN] = |
166 | BIN2BCD(tm->tm_min) | (buf[M41T80_REG_MIN] & ~0x7f); | 166 | bin2bcd(tm->tm_min) | (buf[M41T80_REG_MIN] & ~0x7f); |
167 | buf[M41T80_REG_HOUR] = | 167 | buf[M41T80_REG_HOUR] = |
168 | BIN2BCD(tm->tm_hour) | (buf[M41T80_REG_HOUR] & ~0x3f) ; | 168 | bin2bcd(tm->tm_hour) | (buf[M41T80_REG_HOUR] & ~0x3f) ; |
169 | buf[M41T80_REG_WDAY] = | 169 | buf[M41T80_REG_WDAY] = |
170 | (tm->tm_wday & 0x07) | (buf[M41T80_REG_WDAY] & ~0x07); | 170 | (tm->tm_wday & 0x07) | (buf[M41T80_REG_WDAY] & ~0x07); |
171 | buf[M41T80_REG_DAY] = | 171 | buf[M41T80_REG_DAY] = |
172 | BIN2BCD(tm->tm_mday) | (buf[M41T80_REG_DAY] & ~0x3f); | 172 | bin2bcd(tm->tm_mday) | (buf[M41T80_REG_DAY] & ~0x3f); |
173 | buf[M41T80_REG_MON] = | 173 | buf[M41T80_REG_MON] = |
174 | BIN2BCD(tm->tm_mon + 1) | (buf[M41T80_REG_MON] & ~0x1f); | 174 | bin2bcd(tm->tm_mon + 1) | (buf[M41T80_REG_MON] & ~0x1f); |
175 | /* assume 20YY not 19YY */ | 175 | /* assume 20YY not 19YY */ |
176 | buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100); | 176 | buf[M41T80_REG_YEAR] = bin2bcd(tm->tm_year % 100); |
177 | 177 | ||
178 | if (i2c_transfer(client->adapter, msgs, 1) != 1) { | 178 | if (i2c_transfer(client->adapter, msgs, 1) != 1) { |
179 | dev_err(&client->dev, "write error\n"); | 179 | dev_err(&client->dev, "write error\n"); |
@@ -288,15 +288,15 @@ static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
288 | 288 | ||
289 | wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */ | 289 | wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */ |
290 | reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ? | 290 | reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ? |
291 | BIN2BCD(t->time.tm_sec) : 0x80; | 291 | bin2bcd(t->time.tm_sec) : 0x80; |
292 | reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ? | 292 | reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ? |
293 | BIN2BCD(t->time.tm_min) : 0x80; | 293 | bin2bcd(t->time.tm_min) : 0x80; |
294 | reg[M41T80_REG_ALARM_HOUR] |= t->time.tm_hour >= 0 ? | 294 | reg[M41T80_REG_ALARM_HOUR] |= t->time.tm_hour >= 0 ? |
295 | BIN2BCD(t->time.tm_hour) : 0x80; | 295 | bin2bcd(t->time.tm_hour) : 0x80; |
296 | reg[M41T80_REG_ALARM_DAY] |= t->time.tm_mday >= 0 ? | 296 | reg[M41T80_REG_ALARM_DAY] |= t->time.tm_mday >= 0 ? |
297 | BIN2BCD(t->time.tm_mday) : 0x80; | 297 | bin2bcd(t->time.tm_mday) : 0x80; |
298 | if (t->time.tm_mon >= 0) | 298 | if (t->time.tm_mon >= 0) |
299 | reg[M41T80_REG_ALARM_MON] |= BIN2BCD(t->time.tm_mon + 1); | 299 | reg[M41T80_REG_ALARM_MON] |= bin2bcd(t->time.tm_mon + 1); |
300 | else | 300 | else |
301 | reg[M41T80_REG_ALARM_DAY] |= 0x40; | 301 | reg[M41T80_REG_ALARM_DAY] |= 0x40; |
302 | 302 | ||
@@ -347,15 +347,15 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
347 | t->time.tm_mday = -1; | 347 | t->time.tm_mday = -1; |
348 | t->time.tm_mon = -1; | 348 | t->time.tm_mon = -1; |
349 | if (!(reg[M41T80_REG_ALARM_SEC] & 0x80)) | 349 | if (!(reg[M41T80_REG_ALARM_SEC] & 0x80)) |
350 | t->time.tm_sec = BCD2BIN(reg[M41T80_REG_ALARM_SEC] & 0x7f); | 350 | t->time.tm_sec = bcd2bin(reg[M41T80_REG_ALARM_SEC] & 0x7f); |
351 | if (!(reg[M41T80_REG_ALARM_MIN] & 0x80)) | 351 | if (!(reg[M41T80_REG_ALARM_MIN] & 0x80)) |
352 | t->time.tm_min = BCD2BIN(reg[M41T80_REG_ALARM_MIN] & 0x7f); | 352 | t->time.tm_min = bcd2bin(reg[M41T80_REG_ALARM_MIN] & 0x7f); |
353 | if (!(reg[M41T80_REG_ALARM_HOUR] & 0x80)) | 353 | if (!(reg[M41T80_REG_ALARM_HOUR] & 0x80)) |
354 | t->time.tm_hour = BCD2BIN(reg[M41T80_REG_ALARM_HOUR] & 0x3f); | 354 | t->time.tm_hour = bcd2bin(reg[M41T80_REG_ALARM_HOUR] & 0x3f); |
355 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x80)) | 355 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x80)) |
356 | t->time.tm_mday = BCD2BIN(reg[M41T80_REG_ALARM_DAY] & 0x3f); | 356 | t->time.tm_mday = bcd2bin(reg[M41T80_REG_ALARM_DAY] & 0x3f); |
357 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x40)) | 357 | if (!(reg[M41T80_REG_ALARM_DAY] & 0x40)) |
358 | t->time.tm_mon = BCD2BIN(reg[M41T80_REG_ALARM_MON] & 0x1f) - 1; | 358 | t->time.tm_mon = bcd2bin(reg[M41T80_REG_ALARM_MON] & 0x1f) - 1; |
359 | t->time.tm_year = -1; | 359 | t->time.tm_year = -1; |
360 | t->time.tm_wday = -1; | 360 | t->time.tm_wday = -1; |
361 | t->time.tm_yday = -1; | 361 | t->time.tm_yday = -1; |
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c index 9b19499c829e..c3a18c58daf6 100644 --- a/drivers/rtc/rtc-m41t94.c +++ b/drivers/rtc/rtc-m41t94.c | |||
@@ -41,17 +41,17 @@ static int m41t94_set_time(struct device *dev, struct rtc_time *tm) | |||
41 | tm->tm_mon, tm->tm_year, tm->tm_wday); | 41 | tm->tm_mon, tm->tm_year, tm->tm_wday); |
42 | 42 | ||
43 | buf[0] = 0x80 | M41T94_REG_SECONDS; /* write time + date */ | 43 | buf[0] = 0x80 | M41T94_REG_SECONDS; /* write time + date */ |
44 | buf[M41T94_REG_SECONDS] = BIN2BCD(tm->tm_sec); | 44 | buf[M41T94_REG_SECONDS] = bin2bcd(tm->tm_sec); |
45 | buf[M41T94_REG_MINUTES] = BIN2BCD(tm->tm_min); | 45 | buf[M41T94_REG_MINUTES] = bin2bcd(tm->tm_min); |
46 | buf[M41T94_REG_HOURS] = BIN2BCD(tm->tm_hour); | 46 | buf[M41T94_REG_HOURS] = bin2bcd(tm->tm_hour); |
47 | buf[M41T94_REG_WDAY] = BIN2BCD(tm->tm_wday + 1); | 47 | buf[M41T94_REG_WDAY] = bin2bcd(tm->tm_wday + 1); |
48 | buf[M41T94_REG_DAY] = BIN2BCD(tm->tm_mday); | 48 | buf[M41T94_REG_DAY] = bin2bcd(tm->tm_mday); |
49 | buf[M41T94_REG_MONTH] = BIN2BCD(tm->tm_mon + 1); | 49 | buf[M41T94_REG_MONTH] = bin2bcd(tm->tm_mon + 1); |
50 | 50 | ||
51 | buf[M41T94_REG_HOURS] |= M41T94_BIT_CEB; | 51 | buf[M41T94_REG_HOURS] |= M41T94_BIT_CEB; |
52 | if (tm->tm_year >= 100) | 52 | if (tm->tm_year >= 100) |
53 | buf[M41T94_REG_HOURS] |= M41T94_BIT_CB; | 53 | buf[M41T94_REG_HOURS] |= M41T94_BIT_CB; |
54 | buf[M41T94_REG_YEAR] = BIN2BCD(tm->tm_year % 100); | 54 | buf[M41T94_REG_YEAR] = bin2bcd(tm->tm_year % 100); |
55 | 55 | ||
56 | return spi_write(spi, buf, 8); | 56 | return spi_write(spi, buf, 8); |
57 | } | 57 | } |
@@ -82,14 +82,14 @@ static int m41t94_read_time(struct device *dev, struct rtc_time *tm) | |||
82 | spi_write(spi, buf, 2); | 82 | spi_write(spi, buf, 2); |
83 | } | 83 | } |
84 | 84 | ||
85 | tm->tm_sec = BCD2BIN(spi_w8r8(spi, M41T94_REG_SECONDS)); | 85 | tm->tm_sec = bcd2bin(spi_w8r8(spi, M41T94_REG_SECONDS)); |
86 | tm->tm_min = BCD2BIN(spi_w8r8(spi, M41T94_REG_MINUTES)); | 86 | tm->tm_min = bcd2bin(spi_w8r8(spi, M41T94_REG_MINUTES)); |
87 | hour = spi_w8r8(spi, M41T94_REG_HOURS); | 87 | hour = spi_w8r8(spi, M41T94_REG_HOURS); |
88 | tm->tm_hour = BCD2BIN(hour & 0x3f); | 88 | tm->tm_hour = bcd2bin(hour & 0x3f); |
89 | tm->tm_wday = BCD2BIN(spi_w8r8(spi, M41T94_REG_WDAY)) - 1; | 89 | tm->tm_wday = bcd2bin(spi_w8r8(spi, M41T94_REG_WDAY)) - 1; |
90 | tm->tm_mday = BCD2BIN(spi_w8r8(spi, M41T94_REG_DAY)); | 90 | tm->tm_mday = bcd2bin(spi_w8r8(spi, M41T94_REG_DAY)); |
91 | tm->tm_mon = BCD2BIN(spi_w8r8(spi, M41T94_REG_MONTH)) - 1; | 91 | tm->tm_mon = bcd2bin(spi_w8r8(spi, M41T94_REG_MONTH)) - 1; |
92 | tm->tm_year = BCD2BIN(spi_w8r8(spi, M41T94_REG_YEAR)); | 92 | tm->tm_year = bcd2bin(spi_w8r8(spi, M41T94_REG_YEAR)); |
93 | if ((hour & M41T94_BIT_CB) || !(hour & M41T94_BIT_CEB)) | 93 | if ((hour & M41T94_BIT_CB) || !(hour & M41T94_BIT_CEB)) |
94 | tm->tm_year += 100; | 94 | tm->tm_year += 100; |
95 | 95 | ||
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index ce4eff6a8d51..04b63dab6932 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c | |||
@@ -76,10 +76,10 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
76 | /* Issue the READ command */ | 76 | /* Issue the READ command */ |
77 | M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); | 77 | M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); |
78 | 78 | ||
79 | tm->tm_year = BCD2BIN(M48T59_READ(M48T59_YEAR)); | 79 | tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); |
80 | /* tm_mon is 0-11 */ | 80 | /* tm_mon is 0-11 */ |
81 | tm->tm_mon = BCD2BIN(M48T59_READ(M48T59_MONTH)) - 1; | 81 | tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; |
82 | tm->tm_mday = BCD2BIN(M48T59_READ(M48T59_MDAY)); | 82 | tm->tm_mday = bcd2bin(M48T59_READ(M48T59_MDAY)); |
83 | 83 | ||
84 | val = M48T59_READ(M48T59_WDAY); | 84 | val = M48T59_READ(M48T59_WDAY); |
85 | if ((pdata->type == M48T59RTC_TYPE_M48T59) && | 85 | if ((pdata->type == M48T59RTC_TYPE_M48T59) && |
@@ -88,10 +88,10 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
88 | tm->tm_year += 100; /* one century */ | 88 | tm->tm_year += 100; /* one century */ |
89 | } | 89 | } |
90 | 90 | ||
91 | tm->tm_wday = BCD2BIN(val & 0x07); | 91 | tm->tm_wday = bcd2bin(val & 0x07); |
92 | tm->tm_hour = BCD2BIN(M48T59_READ(M48T59_HOUR) & 0x3F); | 92 | tm->tm_hour = bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F); |
93 | tm->tm_min = BCD2BIN(M48T59_READ(M48T59_MIN) & 0x7F); | 93 | tm->tm_min = bcd2bin(M48T59_READ(M48T59_MIN) & 0x7F); |
94 | tm->tm_sec = BCD2BIN(M48T59_READ(M48T59_SEC) & 0x7F); | 94 | tm->tm_sec = bcd2bin(M48T59_READ(M48T59_SEC) & 0x7F); |
95 | 95 | ||
96 | /* Clear the READ bit */ | 96 | /* Clear the READ bit */ |
97 | M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); | 97 | M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); |
@@ -119,17 +119,17 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
119 | /* Issue the WRITE command */ | 119 | /* Issue the WRITE command */ |
120 | M48T59_SET_BITS(M48T59_CNTL_WRITE, M48T59_CNTL); | 120 | M48T59_SET_BITS(M48T59_CNTL_WRITE, M48T59_CNTL); |
121 | 121 | ||
122 | M48T59_WRITE((BIN2BCD(tm->tm_sec) & 0x7F), M48T59_SEC); | 122 | M48T59_WRITE((bin2bcd(tm->tm_sec) & 0x7F), M48T59_SEC); |
123 | M48T59_WRITE((BIN2BCD(tm->tm_min) & 0x7F), M48T59_MIN); | 123 | M48T59_WRITE((bin2bcd(tm->tm_min) & 0x7F), M48T59_MIN); |
124 | M48T59_WRITE((BIN2BCD(tm->tm_hour) & 0x3F), M48T59_HOUR); | 124 | M48T59_WRITE((bin2bcd(tm->tm_hour) & 0x3F), M48T59_HOUR); |
125 | M48T59_WRITE((BIN2BCD(tm->tm_mday) & 0x3F), M48T59_MDAY); | 125 | M48T59_WRITE((bin2bcd(tm->tm_mday) & 0x3F), M48T59_MDAY); |
126 | /* tm_mon is 0-11 */ | 126 | /* tm_mon is 0-11 */ |
127 | M48T59_WRITE((BIN2BCD(tm->tm_mon + 1) & 0x1F), M48T59_MONTH); | 127 | M48T59_WRITE((bin2bcd(tm->tm_mon + 1) & 0x1F), M48T59_MONTH); |
128 | M48T59_WRITE(BIN2BCD(tm->tm_year % 100), M48T59_YEAR); | 128 | M48T59_WRITE(bin2bcd(tm->tm_year % 100), M48T59_YEAR); |
129 | 129 | ||
130 | if (pdata->type == M48T59RTC_TYPE_M48T59 && (tm->tm_year / 100)) | 130 | if (pdata->type == M48T59RTC_TYPE_M48T59 && (tm->tm_year / 100)) |
131 | val = (M48T59_WDAY_CEB | M48T59_WDAY_CB); | 131 | val = (M48T59_WDAY_CEB | M48T59_WDAY_CB); |
132 | val |= (BIN2BCD(tm->tm_wday) & 0x07); | 132 | val |= (bin2bcd(tm->tm_wday) & 0x07); |
133 | M48T59_WRITE(val, M48T59_WDAY); | 133 | M48T59_WRITE(val, M48T59_WDAY); |
134 | 134 | ||
135 | /* Clear the WRITE bit */ | 135 | /* Clear the WRITE bit */ |
@@ -158,18 +158,18 @@ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
158 | /* Issue the READ command */ | 158 | /* Issue the READ command */ |
159 | M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); | 159 | M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); |
160 | 160 | ||
161 | tm->tm_year = BCD2BIN(M48T59_READ(M48T59_YEAR)); | 161 | tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); |
162 | /* tm_mon is 0-11 */ | 162 | /* tm_mon is 0-11 */ |
163 | tm->tm_mon = BCD2BIN(M48T59_READ(M48T59_MONTH)) - 1; | 163 | tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; |
164 | 164 | ||
165 | val = M48T59_READ(M48T59_WDAY); | 165 | val = M48T59_READ(M48T59_WDAY); |
166 | if ((val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) | 166 | if ((val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) |
167 | tm->tm_year += 100; /* one century */ | 167 | tm->tm_year += 100; /* one century */ |
168 | 168 | ||
169 | tm->tm_mday = BCD2BIN(M48T59_READ(M48T59_ALARM_DATE)); | 169 | tm->tm_mday = bcd2bin(M48T59_READ(M48T59_ALARM_DATE)); |
170 | tm->tm_hour = BCD2BIN(M48T59_READ(M48T59_ALARM_HOUR)); | 170 | tm->tm_hour = bcd2bin(M48T59_READ(M48T59_ALARM_HOUR)); |
171 | tm->tm_min = BCD2BIN(M48T59_READ(M48T59_ALARM_MIN)); | 171 | tm->tm_min = bcd2bin(M48T59_READ(M48T59_ALARM_MIN)); |
172 | tm->tm_sec = BCD2BIN(M48T59_READ(M48T59_ALARM_SEC)); | 172 | tm->tm_sec = bcd2bin(M48T59_READ(M48T59_ALARM_SEC)); |
173 | 173 | ||
174 | /* Clear the READ bit */ | 174 | /* Clear the READ bit */ |
175 | M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); | 175 | M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); |
@@ -201,18 +201,18 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
201 | * 0xff means "always match" | 201 | * 0xff means "always match" |
202 | */ | 202 | */ |
203 | mday = tm->tm_mday; | 203 | mday = tm->tm_mday; |
204 | mday = (mday >= 1 && mday <= 31) ? BIN2BCD(mday) : 0xff; | 204 | mday = (mday >= 1 && mday <= 31) ? bin2bcd(mday) : 0xff; |
205 | if (mday == 0xff) | 205 | if (mday == 0xff) |
206 | mday = M48T59_READ(M48T59_MDAY); | 206 | mday = M48T59_READ(M48T59_MDAY); |
207 | 207 | ||
208 | hour = tm->tm_hour; | 208 | hour = tm->tm_hour; |
209 | hour = (hour < 24) ? BIN2BCD(hour) : 0x00; | 209 | hour = (hour < 24) ? bin2bcd(hour) : 0x00; |
210 | 210 | ||
211 | min = tm->tm_min; | 211 | min = tm->tm_min; |
212 | min = (min < 60) ? BIN2BCD(min) : 0x00; | 212 | min = (min < 60) ? bin2bcd(min) : 0x00; |
213 | 213 | ||
214 | sec = tm->tm_sec; | 214 | sec = tm->tm_sec; |
215 | sec = (sec < 60) ? BIN2BCD(sec) : 0x00; | 215 | sec = (sec < 60) ? bin2bcd(sec) : 0x00; |
216 | 216 | ||
217 | spin_lock_irqsave(&m48t59->lock, flags); | 217 | spin_lock_irqsave(&m48t59->lock, flags); |
218 | /* Issue the WRITE command */ | 218 | /* Issue the WRITE command */ |
@@ -360,7 +360,6 @@ static struct bin_attribute m48t59_nvram_attr = { | |||
360 | .attr = { | 360 | .attr = { |
361 | .name = "nvram", | 361 | .name = "nvram", |
362 | .mode = S_IRUGO | S_IWUSR, | 362 | .mode = S_IRUGO | S_IWUSR, |
363 | .owner = THIS_MODULE, | ||
364 | }, | 363 | }, |
365 | .read = m48t59_nvram_read, | 364 | .read = m48t59_nvram_read, |
366 | .write = m48t59_nvram_write, | 365 | .write = m48t59_nvram_write, |
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c index 3f7f99a5d96a..7c045cffa9ff 100644 --- a/drivers/rtc/rtc-m48t86.c +++ b/drivers/rtc/rtc-m48t86.c | |||
@@ -62,14 +62,14 @@ static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
62 | tm->tm_wday = ops->readbyte(M48T86_REG_DOW); | 62 | tm->tm_wday = ops->readbyte(M48T86_REG_DOW); |
63 | } else { | 63 | } else { |
64 | /* bcd mode */ | 64 | /* bcd mode */ |
65 | tm->tm_sec = BCD2BIN(ops->readbyte(M48T86_REG_SEC)); | 65 | tm->tm_sec = bcd2bin(ops->readbyte(M48T86_REG_SEC)); |
66 | tm->tm_min = BCD2BIN(ops->readbyte(M48T86_REG_MIN)); | 66 | tm->tm_min = bcd2bin(ops->readbyte(M48T86_REG_MIN)); |
67 | tm->tm_hour = BCD2BIN(ops->readbyte(M48T86_REG_HOUR) & 0x3F); | 67 | tm->tm_hour = bcd2bin(ops->readbyte(M48T86_REG_HOUR) & 0x3F); |
68 | tm->tm_mday = BCD2BIN(ops->readbyte(M48T86_REG_DOM)); | 68 | tm->tm_mday = bcd2bin(ops->readbyte(M48T86_REG_DOM)); |
69 | /* tm_mon is 0-11 */ | 69 | /* tm_mon is 0-11 */ |
70 | tm->tm_mon = BCD2BIN(ops->readbyte(M48T86_REG_MONTH)) - 1; | 70 | tm->tm_mon = bcd2bin(ops->readbyte(M48T86_REG_MONTH)) - 1; |
71 | tm->tm_year = BCD2BIN(ops->readbyte(M48T86_REG_YEAR)) + 100; | 71 | tm->tm_year = bcd2bin(ops->readbyte(M48T86_REG_YEAR)) + 100; |
72 | tm->tm_wday = BCD2BIN(ops->readbyte(M48T86_REG_DOW)); | 72 | tm->tm_wday = bcd2bin(ops->readbyte(M48T86_REG_DOW)); |
73 | } | 73 | } |
74 | 74 | ||
75 | /* correct the hour if the clock is in 12h mode */ | 75 | /* correct the hour if the clock is in 12h mode */ |
@@ -103,13 +103,13 @@ static int m48t86_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
103 | ops->writebyte(tm->tm_wday, M48T86_REG_DOW); | 103 | ops->writebyte(tm->tm_wday, M48T86_REG_DOW); |
104 | } else { | 104 | } else { |
105 | /* bcd mode */ | 105 | /* bcd mode */ |
106 | ops->writebyte(BIN2BCD(tm->tm_sec), M48T86_REG_SEC); | 106 | ops->writebyte(bin2bcd(tm->tm_sec), M48T86_REG_SEC); |
107 | ops->writebyte(BIN2BCD(tm->tm_min), M48T86_REG_MIN); | 107 | ops->writebyte(bin2bcd(tm->tm_min), M48T86_REG_MIN); |
108 | ops->writebyte(BIN2BCD(tm->tm_hour), M48T86_REG_HOUR); | 108 | ops->writebyte(bin2bcd(tm->tm_hour), M48T86_REG_HOUR); |
109 | ops->writebyte(BIN2BCD(tm->tm_mday), M48T86_REG_DOM); | 109 | ops->writebyte(bin2bcd(tm->tm_mday), M48T86_REG_DOM); |
110 | ops->writebyte(BIN2BCD(tm->tm_mon + 1), M48T86_REG_MONTH); | 110 | ops->writebyte(bin2bcd(tm->tm_mon + 1), M48T86_REG_MONTH); |
111 | ops->writebyte(BIN2BCD(tm->tm_year % 100), M48T86_REG_YEAR); | 111 | ops->writebyte(bin2bcd(tm->tm_year % 100), M48T86_REG_YEAR); |
112 | ops->writebyte(BIN2BCD(tm->tm_wday), M48T86_REG_DOW); | 112 | ops->writebyte(bin2bcd(tm->tm_wday), M48T86_REG_DOW); |
113 | } | 113 | } |
114 | 114 | ||
115 | /* update ended */ | 115 | /* update ended */ |
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index 12c9cd25cad8..80782798763f 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c | |||
@@ -150,14 +150,14 @@ static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) | |||
150 | if (rc < 0) | 150 | if (rc < 0) |
151 | return rc; | 151 | return rc; |
152 | 152 | ||
153 | tm->tm_sec = BCD2BIN(regs[MAX6900_REG_SC]); | 153 | tm->tm_sec = bcd2bin(regs[MAX6900_REG_SC]); |
154 | tm->tm_min = BCD2BIN(regs[MAX6900_REG_MN]); | 154 | tm->tm_min = bcd2bin(regs[MAX6900_REG_MN]); |
155 | tm->tm_hour = BCD2BIN(regs[MAX6900_REG_HR] & 0x3f); | 155 | tm->tm_hour = bcd2bin(regs[MAX6900_REG_HR] & 0x3f); |
156 | tm->tm_mday = BCD2BIN(regs[MAX6900_REG_DT]); | 156 | tm->tm_mday = bcd2bin(regs[MAX6900_REG_DT]); |
157 | tm->tm_mon = BCD2BIN(regs[MAX6900_REG_MO]) - 1; | 157 | tm->tm_mon = bcd2bin(regs[MAX6900_REG_MO]) - 1; |
158 | tm->tm_year = BCD2BIN(regs[MAX6900_REG_YR]) + | 158 | tm->tm_year = bcd2bin(regs[MAX6900_REG_YR]) + |
159 | BCD2BIN(regs[MAX6900_REG_CENTURY]) * 100 - 1900; | 159 | bcd2bin(regs[MAX6900_REG_CENTURY]) * 100 - 1900; |
160 | tm->tm_wday = BCD2BIN(regs[MAX6900_REG_DW]); | 160 | tm->tm_wday = bcd2bin(regs[MAX6900_REG_DW]); |
161 | 161 | ||
162 | return 0; | 162 | return 0; |
163 | } | 163 | } |
@@ -184,14 +184,14 @@ max6900_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) | |||
184 | if (rc < 0) | 184 | if (rc < 0) |
185 | return rc; | 185 | return rc; |
186 | 186 | ||
187 | regs[MAX6900_REG_SC] = BIN2BCD(tm->tm_sec); | 187 | regs[MAX6900_REG_SC] = bin2bcd(tm->tm_sec); |
188 | regs[MAX6900_REG_MN] = BIN2BCD(tm->tm_min); | 188 | regs[MAX6900_REG_MN] = bin2bcd(tm->tm_min); |
189 | regs[MAX6900_REG_HR] = BIN2BCD(tm->tm_hour); | 189 | regs[MAX6900_REG_HR] = bin2bcd(tm->tm_hour); |
190 | regs[MAX6900_REG_DT] = BIN2BCD(tm->tm_mday); | 190 | regs[MAX6900_REG_DT] = bin2bcd(tm->tm_mday); |
191 | regs[MAX6900_REG_MO] = BIN2BCD(tm->tm_mon + 1); | 191 | regs[MAX6900_REG_MO] = bin2bcd(tm->tm_mon + 1); |
192 | regs[MAX6900_REG_DW] = BIN2BCD(tm->tm_wday); | 192 | regs[MAX6900_REG_DW] = bin2bcd(tm->tm_wday); |
193 | regs[MAX6900_REG_YR] = BIN2BCD(tm->tm_year % 100); | 193 | regs[MAX6900_REG_YR] = bin2bcd(tm->tm_year % 100); |
194 | regs[MAX6900_REG_CENTURY] = BIN2BCD((tm->tm_year + 1900) / 100); | 194 | regs[MAX6900_REG_CENTURY] = bin2bcd((tm->tm_year + 1900) / 100); |
195 | /* set write protect */ | 195 | /* set write protect */ |
196 | regs[MAX6900_REG_CT] = MAX6900_REG_CT_WP; | 196 | regs[MAX6900_REG_CT] = MAX6900_REG_CT_WP; |
197 | 197 | ||
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index 78b2551fb19d..2f6507df7b49 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c | |||
@@ -124,15 +124,15 @@ static int max6902_get_datetime(struct device *dev, struct rtc_time *dt) | |||
124 | 124 | ||
125 | /* The chip sends data in this order: | 125 | /* The chip sends data in this order: |
126 | * Seconds, Minutes, Hours, Date, Month, Day, Year */ | 126 | * Seconds, Minutes, Hours, Date, Month, Day, Year */ |
127 | dt->tm_sec = BCD2BIN(chip->buf[1]); | 127 | dt->tm_sec = bcd2bin(chip->buf[1]); |
128 | dt->tm_min = BCD2BIN(chip->buf[2]); | 128 | dt->tm_min = bcd2bin(chip->buf[2]); |
129 | dt->tm_hour = BCD2BIN(chip->buf[3]); | 129 | dt->tm_hour = bcd2bin(chip->buf[3]); |
130 | dt->tm_mday = BCD2BIN(chip->buf[4]); | 130 | dt->tm_mday = bcd2bin(chip->buf[4]); |
131 | dt->tm_mon = BCD2BIN(chip->buf[5]) - 1; | 131 | dt->tm_mon = bcd2bin(chip->buf[5]) - 1; |
132 | dt->tm_wday = BCD2BIN(chip->buf[6]); | 132 | dt->tm_wday = bcd2bin(chip->buf[6]); |
133 | dt->tm_year = BCD2BIN(chip->buf[7]); | 133 | dt->tm_year = bcd2bin(chip->buf[7]); |
134 | 134 | ||
135 | century = BCD2BIN(tmp) * 100; | 135 | century = bcd2bin(tmp) * 100; |
136 | 136 | ||
137 | dt->tm_year += century; | 137 | dt->tm_year += century; |
138 | dt->tm_year -= 1900; | 138 | dt->tm_year -= 1900; |
@@ -168,15 +168,15 @@ static int max6902_set_datetime(struct device *dev, struct rtc_time *dt) | |||
168 | /* Remove write protection */ | 168 | /* Remove write protection */ |
169 | max6902_set_reg(dev, 0xF, 0); | 169 | max6902_set_reg(dev, 0xF, 0); |
170 | 170 | ||
171 | max6902_set_reg(dev, 0x01, BIN2BCD(dt->tm_sec)); | 171 | max6902_set_reg(dev, 0x01, bin2bcd(dt->tm_sec)); |
172 | max6902_set_reg(dev, 0x03, BIN2BCD(dt->tm_min)); | 172 | max6902_set_reg(dev, 0x03, bin2bcd(dt->tm_min)); |
173 | max6902_set_reg(dev, 0x05, BIN2BCD(dt->tm_hour)); | 173 | max6902_set_reg(dev, 0x05, bin2bcd(dt->tm_hour)); |
174 | 174 | ||
175 | max6902_set_reg(dev, 0x07, BIN2BCD(dt->tm_mday)); | 175 | max6902_set_reg(dev, 0x07, bin2bcd(dt->tm_mday)); |
176 | max6902_set_reg(dev, 0x09, BIN2BCD(dt->tm_mon+1)); | 176 | max6902_set_reg(dev, 0x09, bin2bcd(dt->tm_mon+1)); |
177 | max6902_set_reg(dev, 0x0B, BIN2BCD(dt->tm_wday)); | 177 | max6902_set_reg(dev, 0x0B, bin2bcd(dt->tm_wday)); |
178 | max6902_set_reg(dev, 0x0D, BIN2BCD(dt->tm_year%100)); | 178 | max6902_set_reg(dev, 0x0D, bin2bcd(dt->tm_year%100)); |
179 | max6902_set_reg(dev, 0x13, BIN2BCD(dt->tm_year/100)); | 179 | max6902_set_reg(dev, 0x13, bin2bcd(dt->tm_year/100)); |
180 | 180 | ||
181 | /* Compulab used a delay here. However, the datasheet | 181 | /* Compulab used a delay here. However, the datasheet |
182 | * does not mention a delay being required anywhere... */ | 182 | * does not mention a delay being required anywhere... */ |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 8876605d4d4b..2cbeb0794f14 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -186,30 +186,30 @@ static int tm2bcd(struct rtc_time *tm) | |||
186 | if (rtc_valid_tm(tm) != 0) | 186 | if (rtc_valid_tm(tm) != 0) |
187 | return -EINVAL; | 187 | return -EINVAL; |
188 | 188 | ||
189 | tm->tm_sec = BIN2BCD(tm->tm_sec); | 189 | tm->tm_sec = bin2bcd(tm->tm_sec); |
190 | tm->tm_min = BIN2BCD(tm->tm_min); | 190 | tm->tm_min = bin2bcd(tm->tm_min); |
191 | tm->tm_hour = BIN2BCD(tm->tm_hour); | 191 | tm->tm_hour = bin2bcd(tm->tm_hour); |
192 | tm->tm_mday = BIN2BCD(tm->tm_mday); | 192 | tm->tm_mday = bin2bcd(tm->tm_mday); |
193 | 193 | ||
194 | tm->tm_mon = BIN2BCD(tm->tm_mon + 1); | 194 | tm->tm_mon = bin2bcd(tm->tm_mon + 1); |
195 | 195 | ||
196 | /* epoch == 1900 */ | 196 | /* epoch == 1900 */ |
197 | if (tm->tm_year < 100 || tm->tm_year > 199) | 197 | if (tm->tm_year < 100 || tm->tm_year > 199) |
198 | return -EINVAL; | 198 | return -EINVAL; |
199 | tm->tm_year = BIN2BCD(tm->tm_year - 100); | 199 | tm->tm_year = bin2bcd(tm->tm_year - 100); |
200 | 200 | ||
201 | return 0; | 201 | return 0; |
202 | } | 202 | } |
203 | 203 | ||
204 | static void bcd2tm(struct rtc_time *tm) | 204 | static void bcd2tm(struct rtc_time *tm) |
205 | { | 205 | { |
206 | tm->tm_sec = BCD2BIN(tm->tm_sec); | 206 | tm->tm_sec = bcd2bin(tm->tm_sec); |
207 | tm->tm_min = BCD2BIN(tm->tm_min); | 207 | tm->tm_min = bcd2bin(tm->tm_min); |
208 | tm->tm_hour = BCD2BIN(tm->tm_hour); | 208 | tm->tm_hour = bcd2bin(tm->tm_hour); |
209 | tm->tm_mday = BCD2BIN(tm->tm_mday); | 209 | tm->tm_mday = bcd2bin(tm->tm_mday); |
210 | tm->tm_mon = BCD2BIN(tm->tm_mon) - 1; | 210 | tm->tm_mon = bcd2bin(tm->tm_mon) - 1; |
211 | /* epoch == 1900 */ | 211 | /* epoch == 1900 */ |
212 | tm->tm_year = BCD2BIN(tm->tm_year) + 100; | 212 | tm->tm_year = bcd2bin(tm->tm_year) + 100; |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
diff --git a/drivers/rtc/rtc-parisc.c b/drivers/rtc/rtc-parisc.c new file mode 100644 index 000000000000..346d633655e7 --- /dev/null +++ b/drivers/rtc/rtc-parisc.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* rtc-parisc: RTC for HP PA-RISC firmware | ||
2 | * | ||
3 | * Copyright (C) 2008 Kyle McMartin <kyle@mcmartin.ca> | ||
4 | */ | ||
5 | |||
6 | #include <linux/kernel.h> | ||
7 | #include <linux/module.h> | ||
8 | #include <linux/time.h> | ||
9 | #include <linux/platform_device.h> | ||
10 | |||
11 | #include <asm/rtc.h> | ||
12 | |||
13 | /* as simple as can be, and no simpler. */ | ||
14 | struct parisc_rtc { | ||
15 | struct rtc_device *rtc; | ||
16 | spinlock_t lock; | ||
17 | }; | ||
18 | |||
19 | static int parisc_get_time(struct device *dev, struct rtc_time *tm) | ||
20 | { | ||
21 | struct parisc_rtc *p = dev_get_drvdata(dev); | ||
22 | unsigned long flags, ret; | ||
23 | |||
24 | spin_lock_irqsave(&p->lock, flags); | ||
25 | ret = get_rtc_time(tm); | ||
26 | spin_unlock_irqrestore(&p->lock, flags); | ||
27 | |||
28 | if (ret & RTC_BATT_BAD) | ||
29 | return -EOPNOTSUPP; | ||
30 | |||
31 | return 0; | ||
32 | } | ||
33 | |||
34 | static int parisc_set_time(struct device *dev, struct rtc_time *tm) | ||
35 | { | ||
36 | struct parisc_rtc *p = dev_get_drvdata(dev); | ||
37 | unsigned long flags, ret; | ||
38 | |||
39 | spin_lock_irqsave(&p->lock, flags); | ||
40 | ret = set_rtc_time(tm); | ||
41 | spin_unlock_irqrestore(&p->lock, flags); | ||
42 | |||
43 | if (ret < 0) | ||
44 | return -EOPNOTSUPP; | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static const struct rtc_class_ops parisc_rtc_ops = { | ||
50 | .read_time = parisc_get_time, | ||
51 | .set_time = parisc_set_time, | ||
52 | }; | ||
53 | |||
54 | static int __devinit parisc_rtc_probe(struct platform_device *dev) | ||
55 | { | ||
56 | struct parisc_rtc *p; | ||
57 | |||
58 | p = kzalloc(sizeof (*p), GFP_KERNEL); | ||
59 | if (!p) | ||
60 | return -ENOMEM; | ||
61 | |||
62 | spin_lock_init(&p->lock); | ||
63 | |||
64 | p->rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops, | ||
65 | THIS_MODULE); | ||
66 | if (IS_ERR(p->rtc)) { | ||
67 | int err = PTR_ERR(p->rtc); | ||
68 | kfree(p); | ||
69 | return err; | ||
70 | } | ||
71 | |||
72 | platform_set_drvdata(dev, p); | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static int __devexit parisc_rtc_remove(struct platform_device *dev) | ||
78 | { | ||
79 | struct parisc_rtc *p = platform_get_drvdata(dev); | ||
80 | |||
81 | rtc_device_unregister(p->rtc); | ||
82 | kfree(p); | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static struct platform_driver parisc_rtc_driver = { | ||
88 | .driver = { | ||
89 | .name = "rtc-parisc", | ||
90 | .owner = THIS_MODULE, | ||
91 | }, | ||
92 | .probe = parisc_rtc_probe, | ||
93 | .remove = __devexit_p(parisc_rtc_remove), | ||
94 | }; | ||
95 | |||
96 | static int __init parisc_rtc_init(void) | ||
97 | { | ||
98 | return platform_driver_register(&parisc_rtc_driver); | ||
99 | } | ||
100 | |||
101 | static void __exit parisc_rtc_fini(void) | ||
102 | { | ||
103 | platform_driver_unregister(&parisc_rtc_driver); | ||
104 | } | ||
105 | |||
106 | module_init(parisc_rtc_init); | ||
107 | module_exit(parisc_rtc_fini); | ||
108 | |||
109 | MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>"); | ||
110 | MODULE_LICENSE("GPL"); | ||
111 | MODULE_DESCRIPTION("HP PA-RISC RTC driver"); | ||
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index a829f20ad6d6..b725913ccbe8 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -97,13 +97,13 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
97 | buf[8]); | 97 | buf[8]); |
98 | 98 | ||
99 | 99 | ||
100 | tm->tm_sec = BCD2BIN(buf[PCF8563_REG_SC] & 0x7F); | 100 | tm->tm_sec = bcd2bin(buf[PCF8563_REG_SC] & 0x7F); |
101 | tm->tm_min = BCD2BIN(buf[PCF8563_REG_MN] & 0x7F); | 101 | tm->tm_min = bcd2bin(buf[PCF8563_REG_MN] & 0x7F); |
102 | tm->tm_hour = BCD2BIN(buf[PCF8563_REG_HR] & 0x3F); /* rtc hr 0-23 */ | 102 | tm->tm_hour = bcd2bin(buf[PCF8563_REG_HR] & 0x3F); /* rtc hr 0-23 */ |
103 | tm->tm_mday = BCD2BIN(buf[PCF8563_REG_DM] & 0x3F); | 103 | tm->tm_mday = bcd2bin(buf[PCF8563_REG_DM] & 0x3F); |
104 | tm->tm_wday = buf[PCF8563_REG_DW] & 0x07; | 104 | tm->tm_wday = buf[PCF8563_REG_DW] & 0x07; |
105 | tm->tm_mon = BCD2BIN(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ | 105 | tm->tm_mon = bcd2bin(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ |
106 | tm->tm_year = BCD2BIN(buf[PCF8563_REG_YR]); | 106 | tm->tm_year = bcd2bin(buf[PCF8563_REG_YR]); |
107 | if (tm->tm_year < 70) | 107 | if (tm->tm_year < 70) |
108 | tm->tm_year += 100; /* assume we are in 1970...2069 */ | 108 | tm->tm_year += 100; /* assume we are in 1970...2069 */ |
109 | /* detect the polarity heuristically. see note above. */ | 109 | /* detect the polarity heuristically. see note above. */ |
@@ -138,17 +138,17 @@ static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
138 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | 138 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); |
139 | 139 | ||
140 | /* hours, minutes and seconds */ | 140 | /* hours, minutes and seconds */ |
141 | buf[PCF8563_REG_SC] = BIN2BCD(tm->tm_sec); | 141 | buf[PCF8563_REG_SC] = bin2bcd(tm->tm_sec); |
142 | buf[PCF8563_REG_MN] = BIN2BCD(tm->tm_min); | 142 | buf[PCF8563_REG_MN] = bin2bcd(tm->tm_min); |
143 | buf[PCF8563_REG_HR] = BIN2BCD(tm->tm_hour); | 143 | buf[PCF8563_REG_HR] = bin2bcd(tm->tm_hour); |
144 | 144 | ||
145 | buf[PCF8563_REG_DM] = BIN2BCD(tm->tm_mday); | 145 | buf[PCF8563_REG_DM] = bin2bcd(tm->tm_mday); |
146 | 146 | ||
147 | /* month, 1 - 12 */ | 147 | /* month, 1 - 12 */ |
148 | buf[PCF8563_REG_MO] = BIN2BCD(tm->tm_mon + 1); | 148 | buf[PCF8563_REG_MO] = bin2bcd(tm->tm_mon + 1); |
149 | 149 | ||
150 | /* year and century */ | 150 | /* year and century */ |
151 | buf[PCF8563_REG_YR] = BIN2BCD(tm->tm_year % 100); | 151 | buf[PCF8563_REG_YR] = bin2bcd(tm->tm_year % 100); |
152 | if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100)) | 152 | if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100)) |
153 | buf[PCF8563_REG_MO] |= PCF8563_MO_C; | 153 | buf[PCF8563_REG_MO] |= PCF8563_MO_C; |
154 | 154 | ||
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index d388c662bf4b..7d33cda3f8f6 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -76,11 +76,11 @@ static int pcf8583_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
76 | buf[4] &= 0x3f; | 76 | buf[4] &= 0x3f; |
77 | buf[5] &= 0x1f; | 77 | buf[5] &= 0x1f; |
78 | 78 | ||
79 | dt->tm_sec = BCD2BIN(buf[1]); | 79 | dt->tm_sec = bcd2bin(buf[1]); |
80 | dt->tm_min = BCD2BIN(buf[2]); | 80 | dt->tm_min = bcd2bin(buf[2]); |
81 | dt->tm_hour = BCD2BIN(buf[3]); | 81 | dt->tm_hour = bcd2bin(buf[3]); |
82 | dt->tm_mday = BCD2BIN(buf[4]); | 82 | dt->tm_mday = bcd2bin(buf[4]); |
83 | dt->tm_mon = BCD2BIN(buf[5]) - 1; | 83 | dt->tm_mon = bcd2bin(buf[5]) - 1; |
84 | } | 84 | } |
85 | 85 | ||
86 | return ret == 2 ? 0 : -EIO; | 86 | return ret == 2 ? 0 : -EIO; |
@@ -94,14 +94,14 @@ static int pcf8583_set_datetime(struct i2c_client *client, struct rtc_time *dt, | |||
94 | buf[0] = 0; | 94 | buf[0] = 0; |
95 | buf[1] = get_ctrl(client) | 0x80; | 95 | buf[1] = get_ctrl(client) | 0x80; |
96 | buf[2] = 0; | 96 | buf[2] = 0; |
97 | buf[3] = BIN2BCD(dt->tm_sec); | 97 | buf[3] = bin2bcd(dt->tm_sec); |
98 | buf[4] = BIN2BCD(dt->tm_min); | 98 | buf[4] = bin2bcd(dt->tm_min); |
99 | buf[5] = BIN2BCD(dt->tm_hour); | 99 | buf[5] = bin2bcd(dt->tm_hour); |
100 | 100 | ||
101 | if (datetoo) { | 101 | if (datetoo) { |
102 | len = 8; | 102 | len = 8; |
103 | buf[6] = BIN2BCD(dt->tm_mday) | (dt->tm_year << 6); | 103 | buf[6] = bin2bcd(dt->tm_mday) | (dt->tm_year << 6); |
104 | buf[7] = BIN2BCD(dt->tm_mon + 1) | (dt->tm_wday << 5); | 104 | buf[7] = bin2bcd(dt->tm_mon + 1) | (dt->tm_wday << 5); |
105 | } | 105 | } |
106 | 106 | ||
107 | ret = i2c_master_send(client, (char *)buf, len); | 107 | ret = i2c_master_send(client, (char *)buf, len); |
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index 395985b339c9..42028f233bef 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c | |||
@@ -80,13 +80,13 @@ static int r9701_get_datetime(struct device *dev, struct rtc_time *dt) | |||
80 | 80 | ||
81 | memset(dt, 0, sizeof(*dt)); | 81 | memset(dt, 0, sizeof(*dt)); |
82 | 82 | ||
83 | dt->tm_sec = BCD2BIN(buf[0]); /* RSECCNT */ | 83 | dt->tm_sec = bcd2bin(buf[0]); /* RSECCNT */ |
84 | dt->tm_min = BCD2BIN(buf[1]); /* RMINCNT */ | 84 | dt->tm_min = bcd2bin(buf[1]); /* RMINCNT */ |
85 | dt->tm_hour = BCD2BIN(buf[2]); /* RHRCNT */ | 85 | dt->tm_hour = bcd2bin(buf[2]); /* RHRCNT */ |
86 | 86 | ||
87 | dt->tm_mday = BCD2BIN(buf[3]); /* RDAYCNT */ | 87 | dt->tm_mday = bcd2bin(buf[3]); /* RDAYCNT */ |
88 | dt->tm_mon = BCD2BIN(buf[4]) - 1; /* RMONCNT */ | 88 | dt->tm_mon = bcd2bin(buf[4]) - 1; /* RMONCNT */ |
89 | dt->tm_year = BCD2BIN(buf[5]) + 100; /* RYRCNT */ | 89 | dt->tm_year = bcd2bin(buf[5]) + 100; /* RYRCNT */ |
90 | 90 | ||
91 | /* the rtc device may contain illegal values on power up | 91 | /* the rtc device may contain illegal values on power up |
92 | * according to the data sheet. make sure they are valid. | 92 | * according to the data sheet. make sure they are valid. |
@@ -103,12 +103,12 @@ static int r9701_set_datetime(struct device *dev, struct rtc_time *dt) | |||
103 | if (year >= 2100 || year < 2000) | 103 | if (year >= 2100 || year < 2000) |
104 | return -EINVAL; | 104 | return -EINVAL; |
105 | 105 | ||
106 | ret = write_reg(dev, RHRCNT, BIN2BCD(dt->tm_hour)); | 106 | ret = write_reg(dev, RHRCNT, bin2bcd(dt->tm_hour)); |
107 | ret = ret ? ret : write_reg(dev, RMINCNT, BIN2BCD(dt->tm_min)); | 107 | ret = ret ? ret : write_reg(dev, RMINCNT, bin2bcd(dt->tm_min)); |
108 | ret = ret ? ret : write_reg(dev, RSECCNT, BIN2BCD(dt->tm_sec)); | 108 | ret = ret ? ret : write_reg(dev, RSECCNT, bin2bcd(dt->tm_sec)); |
109 | ret = ret ? ret : write_reg(dev, RDAYCNT, BIN2BCD(dt->tm_mday)); | 109 | ret = ret ? ret : write_reg(dev, RDAYCNT, bin2bcd(dt->tm_mday)); |
110 | ret = ret ? ret : write_reg(dev, RMONCNT, BIN2BCD(dt->tm_mon + 1)); | 110 | ret = ret ? ret : write_reg(dev, RMONCNT, bin2bcd(dt->tm_mon + 1)); |
111 | ret = ret ? ret : write_reg(dev, RYRCNT, BIN2BCD(dt->tm_year - 100)); | 111 | ret = ret ? ret : write_reg(dev, RYRCNT, bin2bcd(dt->tm_year - 100)); |
112 | ret = ret ? ret : write_reg(dev, RWKCNT, 1 << dt->tm_wday); | 112 | ret = ret ? ret : write_reg(dev, RWKCNT, 1 << dt->tm_wday); |
113 | 113 | ||
114 | return ret; | 114 | return ret; |
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 1c14d4497c4d..e6ea3f5ee1eb 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c | |||
@@ -235,33 +235,33 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
235 | 235 | ||
236 | data = rs5c313_read_reg(RS5C313_ADDR_SEC); | 236 | data = rs5c313_read_reg(RS5C313_ADDR_SEC); |
237 | data |= (rs5c313_read_reg(RS5C313_ADDR_SEC10) << 4); | 237 | data |= (rs5c313_read_reg(RS5C313_ADDR_SEC10) << 4); |
238 | tm->tm_sec = BCD2BIN(data); | 238 | tm->tm_sec = bcd2bin(data); |
239 | 239 | ||
240 | data = rs5c313_read_reg(RS5C313_ADDR_MIN); | 240 | data = rs5c313_read_reg(RS5C313_ADDR_MIN); |
241 | data |= (rs5c313_read_reg(RS5C313_ADDR_MIN10) << 4); | 241 | data |= (rs5c313_read_reg(RS5C313_ADDR_MIN10) << 4); |
242 | tm->tm_min = BCD2BIN(data); | 242 | tm->tm_min = bcd2bin(data); |
243 | 243 | ||
244 | data = rs5c313_read_reg(RS5C313_ADDR_HOUR); | 244 | data = rs5c313_read_reg(RS5C313_ADDR_HOUR); |
245 | data |= (rs5c313_read_reg(RS5C313_ADDR_HOUR10) << 4); | 245 | data |= (rs5c313_read_reg(RS5C313_ADDR_HOUR10) << 4); |
246 | tm->tm_hour = BCD2BIN(data); | 246 | tm->tm_hour = bcd2bin(data); |
247 | 247 | ||
248 | data = rs5c313_read_reg(RS5C313_ADDR_DAY); | 248 | data = rs5c313_read_reg(RS5C313_ADDR_DAY); |
249 | data |= (rs5c313_read_reg(RS5C313_ADDR_DAY10) << 4); | 249 | data |= (rs5c313_read_reg(RS5C313_ADDR_DAY10) << 4); |
250 | tm->tm_mday = BCD2BIN(data); | 250 | tm->tm_mday = bcd2bin(data); |
251 | 251 | ||
252 | data = rs5c313_read_reg(RS5C313_ADDR_MON); | 252 | data = rs5c313_read_reg(RS5C313_ADDR_MON); |
253 | data |= (rs5c313_read_reg(RS5C313_ADDR_MON10) << 4); | 253 | data |= (rs5c313_read_reg(RS5C313_ADDR_MON10) << 4); |
254 | tm->tm_mon = BCD2BIN(data) - 1; | 254 | tm->tm_mon = bcd2bin(data) - 1; |
255 | 255 | ||
256 | data = rs5c313_read_reg(RS5C313_ADDR_YEAR); | 256 | data = rs5c313_read_reg(RS5C313_ADDR_YEAR); |
257 | data |= (rs5c313_read_reg(RS5C313_ADDR_YEAR10) << 4); | 257 | data |= (rs5c313_read_reg(RS5C313_ADDR_YEAR10) << 4); |
258 | tm->tm_year = BCD2BIN(data); | 258 | tm->tm_year = bcd2bin(data); |
259 | 259 | ||
260 | if (tm->tm_year < 70) | 260 | if (tm->tm_year < 70) |
261 | tm->tm_year += 100; | 261 | tm->tm_year += 100; |
262 | 262 | ||
263 | data = rs5c313_read_reg(RS5C313_ADDR_WEEK); | 263 | data = rs5c313_read_reg(RS5C313_ADDR_WEEK); |
264 | tm->tm_wday = BCD2BIN(data); | 264 | tm->tm_wday = bcd2bin(data); |
265 | 265 | ||
266 | RS5C313_CEDISABLE; | 266 | RS5C313_CEDISABLE; |
267 | ndelay(700); /* CE:L */ | 267 | ndelay(700); /* CE:L */ |
@@ -294,31 +294,31 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | data = BIN2BCD(tm->tm_sec); | 297 | data = bin2bcd(tm->tm_sec); |
298 | rs5c313_write_reg(RS5C313_ADDR_SEC, data); | 298 | rs5c313_write_reg(RS5C313_ADDR_SEC, data); |
299 | rs5c313_write_reg(RS5C313_ADDR_SEC10, (data >> 4)); | 299 | rs5c313_write_reg(RS5C313_ADDR_SEC10, (data >> 4)); |
300 | 300 | ||
301 | data = BIN2BCD(tm->tm_min); | 301 | data = bin2bcd(tm->tm_min); |
302 | rs5c313_write_reg(RS5C313_ADDR_MIN, data ); | 302 | rs5c313_write_reg(RS5C313_ADDR_MIN, data ); |
303 | rs5c313_write_reg(RS5C313_ADDR_MIN10, (data >> 4)); | 303 | rs5c313_write_reg(RS5C313_ADDR_MIN10, (data >> 4)); |
304 | 304 | ||
305 | data = BIN2BCD(tm->tm_hour); | 305 | data = bin2bcd(tm->tm_hour); |
306 | rs5c313_write_reg(RS5C313_ADDR_HOUR, data); | 306 | rs5c313_write_reg(RS5C313_ADDR_HOUR, data); |
307 | rs5c313_write_reg(RS5C313_ADDR_HOUR10, (data >> 4)); | 307 | rs5c313_write_reg(RS5C313_ADDR_HOUR10, (data >> 4)); |
308 | 308 | ||
309 | data = BIN2BCD(tm->tm_mday); | 309 | data = bin2bcd(tm->tm_mday); |
310 | rs5c313_write_reg(RS5C313_ADDR_DAY, data); | 310 | rs5c313_write_reg(RS5C313_ADDR_DAY, data); |
311 | rs5c313_write_reg(RS5C313_ADDR_DAY10, (data>> 4)); | 311 | rs5c313_write_reg(RS5C313_ADDR_DAY10, (data>> 4)); |
312 | 312 | ||
313 | data = BIN2BCD(tm->tm_mon + 1); | 313 | data = bin2bcd(tm->tm_mon + 1); |
314 | rs5c313_write_reg(RS5C313_ADDR_MON, data); | 314 | rs5c313_write_reg(RS5C313_ADDR_MON, data); |
315 | rs5c313_write_reg(RS5C313_ADDR_MON10, (data >> 4)); | 315 | rs5c313_write_reg(RS5C313_ADDR_MON10, (data >> 4)); |
316 | 316 | ||
317 | data = BIN2BCD(tm->tm_year % 100); | 317 | data = bin2bcd(tm->tm_year % 100); |
318 | rs5c313_write_reg(RS5C313_ADDR_YEAR, data); | 318 | rs5c313_write_reg(RS5C313_ADDR_YEAR, data); |
319 | rs5c313_write_reg(RS5C313_ADDR_YEAR10, (data >> 4)); | 319 | rs5c313_write_reg(RS5C313_ADDR_YEAR10, (data >> 4)); |
320 | 320 | ||
321 | data = BIN2BCD(tm->tm_wday); | 321 | data = bin2bcd(tm->tm_wday); |
322 | rs5c313_write_reg(RS5C313_ADDR_WEEK, data); | 322 | rs5c313_write_reg(RS5C313_ADDR_WEEK, data); |
323 | 323 | ||
324 | RS5C313_CEDISABLE; /* CE:H */ | 324 | RS5C313_CEDISABLE; /* CE:H */ |
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 839462659afa..dd1e2bc7a472 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -74,20 +74,20 @@ rs5c348_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
74 | txbuf[3] = 0; /* dummy */ | 74 | txbuf[3] = 0; /* dummy */ |
75 | txbuf[4] = RS5C348_CMD_MW(RS5C348_REG_SECS); /* cmd, sec, ... */ | 75 | txbuf[4] = RS5C348_CMD_MW(RS5C348_REG_SECS); /* cmd, sec, ... */ |
76 | txp = &txbuf[5]; | 76 | txp = &txbuf[5]; |
77 | txp[RS5C348_REG_SECS] = BIN2BCD(tm->tm_sec); | 77 | txp[RS5C348_REG_SECS] = bin2bcd(tm->tm_sec); |
78 | txp[RS5C348_REG_MINS] = BIN2BCD(tm->tm_min); | 78 | txp[RS5C348_REG_MINS] = bin2bcd(tm->tm_min); |
79 | if (pdata->rtc_24h) { | 79 | if (pdata->rtc_24h) { |
80 | txp[RS5C348_REG_HOURS] = BIN2BCD(tm->tm_hour); | 80 | txp[RS5C348_REG_HOURS] = bin2bcd(tm->tm_hour); |
81 | } else { | 81 | } else { |
82 | /* hour 0 is AM12, noon is PM12 */ | 82 | /* hour 0 is AM12, noon is PM12 */ |
83 | txp[RS5C348_REG_HOURS] = BIN2BCD((tm->tm_hour + 11) % 12 + 1) | | 83 | txp[RS5C348_REG_HOURS] = bin2bcd((tm->tm_hour + 11) % 12 + 1) | |
84 | (tm->tm_hour >= 12 ? RS5C348_BIT_PM : 0); | 84 | (tm->tm_hour >= 12 ? RS5C348_BIT_PM : 0); |
85 | } | 85 | } |
86 | txp[RS5C348_REG_WDAY] = BIN2BCD(tm->tm_wday); | 86 | txp[RS5C348_REG_WDAY] = bin2bcd(tm->tm_wday); |
87 | txp[RS5C348_REG_DAY] = BIN2BCD(tm->tm_mday); | 87 | txp[RS5C348_REG_DAY] = bin2bcd(tm->tm_mday); |
88 | txp[RS5C348_REG_MONTH] = BIN2BCD(tm->tm_mon + 1) | | 88 | txp[RS5C348_REG_MONTH] = bin2bcd(tm->tm_mon + 1) | |
89 | (tm->tm_year >= 100 ? RS5C348_BIT_Y2K : 0); | 89 | (tm->tm_year >= 100 ? RS5C348_BIT_Y2K : 0); |
90 | txp[RS5C348_REG_YEAR] = BIN2BCD(tm->tm_year % 100); | 90 | txp[RS5C348_REG_YEAR] = bin2bcd(tm->tm_year % 100); |
91 | /* write in one transfer to avoid data inconsistency */ | 91 | /* write in one transfer to avoid data inconsistency */ |
92 | ret = spi_write_then_read(spi, txbuf, sizeof(txbuf), NULL, 0); | 92 | ret = spi_write_then_read(spi, txbuf, sizeof(txbuf), NULL, 0); |
93 | udelay(62); /* Tcsr 62us */ | 93 | udelay(62); /* Tcsr 62us */ |
@@ -116,20 +116,20 @@ rs5c348_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
116 | if (ret < 0) | 116 | if (ret < 0) |
117 | return ret; | 117 | return ret; |
118 | 118 | ||
119 | tm->tm_sec = BCD2BIN(rxbuf[RS5C348_REG_SECS] & RS5C348_SECS_MASK); | 119 | tm->tm_sec = bcd2bin(rxbuf[RS5C348_REG_SECS] & RS5C348_SECS_MASK); |
120 | tm->tm_min = BCD2BIN(rxbuf[RS5C348_REG_MINS] & RS5C348_MINS_MASK); | 120 | tm->tm_min = bcd2bin(rxbuf[RS5C348_REG_MINS] & RS5C348_MINS_MASK); |
121 | tm->tm_hour = BCD2BIN(rxbuf[RS5C348_REG_HOURS] & RS5C348_HOURS_MASK); | 121 | tm->tm_hour = bcd2bin(rxbuf[RS5C348_REG_HOURS] & RS5C348_HOURS_MASK); |
122 | if (!pdata->rtc_24h) { | 122 | if (!pdata->rtc_24h) { |
123 | tm->tm_hour %= 12; | 123 | tm->tm_hour %= 12; |
124 | if (rxbuf[RS5C348_REG_HOURS] & RS5C348_BIT_PM) | 124 | if (rxbuf[RS5C348_REG_HOURS] & RS5C348_BIT_PM) |
125 | tm->tm_hour += 12; | 125 | tm->tm_hour += 12; |
126 | } | 126 | } |
127 | tm->tm_wday = BCD2BIN(rxbuf[RS5C348_REG_WDAY] & RS5C348_WDAY_MASK); | 127 | tm->tm_wday = bcd2bin(rxbuf[RS5C348_REG_WDAY] & RS5C348_WDAY_MASK); |
128 | tm->tm_mday = BCD2BIN(rxbuf[RS5C348_REG_DAY] & RS5C348_DAY_MASK); | 128 | tm->tm_mday = bcd2bin(rxbuf[RS5C348_REG_DAY] & RS5C348_DAY_MASK); |
129 | tm->tm_mon = | 129 | tm->tm_mon = |
130 | BCD2BIN(rxbuf[RS5C348_REG_MONTH] & RS5C348_MONTH_MASK) - 1; | 130 | bcd2bin(rxbuf[RS5C348_REG_MONTH] & RS5C348_MONTH_MASK) - 1; |
131 | /* year is 1900 + tm->tm_year */ | 131 | /* year is 1900 + tm->tm_year */ |
132 | tm->tm_year = BCD2BIN(rxbuf[RS5C348_REG_YEAR]) + | 132 | tm->tm_year = bcd2bin(rxbuf[RS5C348_REG_YEAR]) + |
133 | ((rxbuf[RS5C348_REG_MONTH] & RS5C348_BIT_Y2K) ? 100 : 0); | 133 | ((rxbuf[RS5C348_REG_MONTH] & RS5C348_BIT_Y2K) ? 100 : 0); |
134 | 134 | ||
135 | if (rtc_valid_tm(tm) < 0) { | 135 | if (rtc_valid_tm(tm) < 0) { |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 8b561958fb1e..2f2c68d476da 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -148,9 +148,9 @@ static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg) | |||
148 | unsigned hour; | 148 | unsigned hour; |
149 | 149 | ||
150 | if (rs5c->time24) | 150 | if (rs5c->time24) |
151 | return BCD2BIN(reg & 0x3f); | 151 | return bcd2bin(reg & 0x3f); |
152 | 152 | ||
153 | hour = BCD2BIN(reg & 0x1f); | 153 | hour = bcd2bin(reg & 0x1f); |
154 | if (hour == 12) | 154 | if (hour == 12) |
155 | hour = 0; | 155 | hour = 0; |
156 | if (reg & 0x20) | 156 | if (reg & 0x20) |
@@ -161,15 +161,15 @@ static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg) | |||
161 | static unsigned rs5c_hr2reg(struct rs5c372 *rs5c, unsigned hour) | 161 | static unsigned rs5c_hr2reg(struct rs5c372 *rs5c, unsigned hour) |
162 | { | 162 | { |
163 | if (rs5c->time24) | 163 | if (rs5c->time24) |
164 | return BIN2BCD(hour); | 164 | return bin2bcd(hour); |
165 | 165 | ||
166 | if (hour > 12) | 166 | if (hour > 12) |
167 | return 0x20 | BIN2BCD(hour - 12); | 167 | return 0x20 | bin2bcd(hour - 12); |
168 | if (hour == 12) | 168 | if (hour == 12) |
169 | return 0x20 | BIN2BCD(12); | 169 | return 0x20 | bin2bcd(12); |
170 | if (hour == 0) | 170 | if (hour == 0) |
171 | return BIN2BCD(12); | 171 | return bin2bcd(12); |
172 | return BIN2BCD(hour); | 172 | return bin2bcd(hour); |
173 | } | 173 | } |
174 | 174 | ||
175 | static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) | 175 | static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) |
@@ -180,18 +180,18 @@ static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
180 | if (status < 0) | 180 | if (status < 0) |
181 | return status; | 181 | return status; |
182 | 182 | ||
183 | tm->tm_sec = BCD2BIN(rs5c->regs[RS5C372_REG_SECS] & 0x7f); | 183 | tm->tm_sec = bcd2bin(rs5c->regs[RS5C372_REG_SECS] & 0x7f); |
184 | tm->tm_min = BCD2BIN(rs5c->regs[RS5C372_REG_MINS] & 0x7f); | 184 | tm->tm_min = bcd2bin(rs5c->regs[RS5C372_REG_MINS] & 0x7f); |
185 | tm->tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C372_REG_HOURS]); | 185 | tm->tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C372_REG_HOURS]); |
186 | 186 | ||
187 | tm->tm_wday = BCD2BIN(rs5c->regs[RS5C372_REG_WDAY] & 0x07); | 187 | tm->tm_wday = bcd2bin(rs5c->regs[RS5C372_REG_WDAY] & 0x07); |
188 | tm->tm_mday = BCD2BIN(rs5c->regs[RS5C372_REG_DAY] & 0x3f); | 188 | tm->tm_mday = bcd2bin(rs5c->regs[RS5C372_REG_DAY] & 0x3f); |
189 | 189 | ||
190 | /* tm->tm_mon is zero-based */ | 190 | /* tm->tm_mon is zero-based */ |
191 | tm->tm_mon = BCD2BIN(rs5c->regs[RS5C372_REG_MONTH] & 0x1f) - 1; | 191 | tm->tm_mon = bcd2bin(rs5c->regs[RS5C372_REG_MONTH] & 0x1f) - 1; |
192 | 192 | ||
193 | /* year is 1900 + tm->tm_year */ | 193 | /* year is 1900 + tm->tm_year */ |
194 | tm->tm_year = BCD2BIN(rs5c->regs[RS5C372_REG_YEAR]) + 100; | 194 | tm->tm_year = bcd2bin(rs5c->regs[RS5C372_REG_YEAR]) + 100; |
195 | 195 | ||
196 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | 196 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " |
197 | "mday=%d, mon=%d, year=%d, wday=%d\n", | 197 | "mday=%d, mon=%d, year=%d, wday=%d\n", |
@@ -216,13 +216,13 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
216 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | 216 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); |
217 | 217 | ||
218 | addr = RS5C_ADDR(RS5C372_REG_SECS); | 218 | addr = RS5C_ADDR(RS5C372_REG_SECS); |
219 | buf[0] = BIN2BCD(tm->tm_sec); | 219 | buf[0] = bin2bcd(tm->tm_sec); |
220 | buf[1] = BIN2BCD(tm->tm_min); | 220 | buf[1] = bin2bcd(tm->tm_min); |
221 | buf[2] = rs5c_hr2reg(rs5c, tm->tm_hour); | 221 | buf[2] = rs5c_hr2reg(rs5c, tm->tm_hour); |
222 | buf[3] = BIN2BCD(tm->tm_wday); | 222 | buf[3] = bin2bcd(tm->tm_wday); |
223 | buf[4] = BIN2BCD(tm->tm_mday); | 223 | buf[4] = bin2bcd(tm->tm_mday); |
224 | buf[5] = BIN2BCD(tm->tm_mon + 1); | 224 | buf[5] = bin2bcd(tm->tm_mon + 1); |
225 | buf[6] = BIN2BCD(tm->tm_year - 100); | 225 | buf[6] = bin2bcd(tm->tm_year - 100); |
226 | 226 | ||
227 | if (i2c_smbus_write_i2c_block_data(client, addr, sizeof(buf), buf) < 0) { | 227 | if (i2c_smbus_write_i2c_block_data(client, addr, sizeof(buf), buf) < 0) { |
228 | dev_err(&client->dev, "%s: write error\n", __func__); | 228 | dev_err(&client->dev, "%s: write error\n", __func__); |
@@ -367,7 +367,7 @@ static int rs5c_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
367 | 367 | ||
368 | /* report alarm time */ | 368 | /* report alarm time */ |
369 | t->time.tm_sec = 0; | 369 | t->time.tm_sec = 0; |
370 | t->time.tm_min = BCD2BIN(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f); | 370 | t->time.tm_min = bcd2bin(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f); |
371 | t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]); | 371 | t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]); |
372 | t->time.tm_mday = -1; | 372 | t->time.tm_mday = -1; |
373 | t->time.tm_mon = -1; | 373 | t->time.tm_mon = -1; |
@@ -413,7 +413,7 @@ static int rs5c_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
413 | } | 413 | } |
414 | 414 | ||
415 | /* set alarm */ | 415 | /* set alarm */ |
416 | buf[0] = BIN2BCD(t->time.tm_min); | 416 | buf[0] = bin2bcd(t->time.tm_min); |
417 | buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour); | 417 | buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour); |
418 | buf[2] = 0x7f; /* any/all days */ | 418 | buf[2] = 0x7f; /* any/all days */ |
419 | 419 | ||
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index a6fa1f2f2ca6..def4d396d0b0 100644 --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c | |||
@@ -104,12 +104,12 @@ static int s35390a_disable_test_mode(struct s35390a *s35390a) | |||
104 | static char s35390a_hr2reg(struct s35390a *s35390a, int hour) | 104 | static char s35390a_hr2reg(struct s35390a *s35390a, int hour) |
105 | { | 105 | { |
106 | if (s35390a->twentyfourhour) | 106 | if (s35390a->twentyfourhour) |
107 | return BIN2BCD(hour); | 107 | return bin2bcd(hour); |
108 | 108 | ||
109 | if (hour < 12) | 109 | if (hour < 12) |
110 | return BIN2BCD(hour); | 110 | return bin2bcd(hour); |
111 | 111 | ||
112 | return 0x40 | BIN2BCD(hour - 12); | 112 | return 0x40 | bin2bcd(hour - 12); |
113 | } | 113 | } |
114 | 114 | ||
115 | static int s35390a_reg2hr(struct s35390a *s35390a, char reg) | 115 | static int s35390a_reg2hr(struct s35390a *s35390a, char reg) |
@@ -117,9 +117,9 @@ static int s35390a_reg2hr(struct s35390a *s35390a, char reg) | |||
117 | unsigned hour; | 117 | unsigned hour; |
118 | 118 | ||
119 | if (s35390a->twentyfourhour) | 119 | if (s35390a->twentyfourhour) |
120 | return BCD2BIN(reg & 0x3f); | 120 | return bcd2bin(reg & 0x3f); |
121 | 121 | ||
122 | hour = BCD2BIN(reg & 0x3f); | 122 | hour = bcd2bin(reg & 0x3f); |
123 | if (reg & 0x40) | 123 | if (reg & 0x40) |
124 | hour += 12; | 124 | hour += 12; |
125 | 125 | ||
@@ -137,13 +137,13 @@ static int s35390a_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
137 | tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, | 137 | tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, |
138 | tm->tm_wday); | 138 | tm->tm_wday); |
139 | 139 | ||
140 | buf[S35390A_BYTE_YEAR] = BIN2BCD(tm->tm_year - 100); | 140 | buf[S35390A_BYTE_YEAR] = bin2bcd(tm->tm_year - 100); |
141 | buf[S35390A_BYTE_MONTH] = BIN2BCD(tm->tm_mon + 1); | 141 | buf[S35390A_BYTE_MONTH] = bin2bcd(tm->tm_mon + 1); |
142 | buf[S35390A_BYTE_DAY] = BIN2BCD(tm->tm_mday); | 142 | buf[S35390A_BYTE_DAY] = bin2bcd(tm->tm_mday); |
143 | buf[S35390A_BYTE_WDAY] = BIN2BCD(tm->tm_wday); | 143 | buf[S35390A_BYTE_WDAY] = bin2bcd(tm->tm_wday); |
144 | buf[S35390A_BYTE_HOURS] = s35390a_hr2reg(s35390a, tm->tm_hour); | 144 | buf[S35390A_BYTE_HOURS] = s35390a_hr2reg(s35390a, tm->tm_hour); |
145 | buf[S35390A_BYTE_MINS] = BIN2BCD(tm->tm_min); | 145 | buf[S35390A_BYTE_MINS] = bin2bcd(tm->tm_min); |
146 | buf[S35390A_BYTE_SECS] = BIN2BCD(tm->tm_sec); | 146 | buf[S35390A_BYTE_SECS] = bin2bcd(tm->tm_sec); |
147 | 147 | ||
148 | /* This chip expects the bits of each byte to be in reverse order */ | 148 | /* This chip expects the bits of each byte to be in reverse order */ |
149 | for (i = 0; i < 7; ++i) | 149 | for (i = 0; i < 7; ++i) |
@@ -168,13 +168,13 @@ static int s35390a_get_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
168 | for (i = 0; i < 7; ++i) | 168 | for (i = 0; i < 7; ++i) |
169 | buf[i] = bitrev8(buf[i]); | 169 | buf[i] = bitrev8(buf[i]); |
170 | 170 | ||
171 | tm->tm_sec = BCD2BIN(buf[S35390A_BYTE_SECS]); | 171 | tm->tm_sec = bcd2bin(buf[S35390A_BYTE_SECS]); |
172 | tm->tm_min = BCD2BIN(buf[S35390A_BYTE_MINS]); | 172 | tm->tm_min = bcd2bin(buf[S35390A_BYTE_MINS]); |
173 | tm->tm_hour = s35390a_reg2hr(s35390a, buf[S35390A_BYTE_HOURS]); | 173 | tm->tm_hour = s35390a_reg2hr(s35390a, buf[S35390A_BYTE_HOURS]); |
174 | tm->tm_wday = BCD2BIN(buf[S35390A_BYTE_WDAY]); | 174 | tm->tm_wday = bcd2bin(buf[S35390A_BYTE_WDAY]); |
175 | tm->tm_mday = BCD2BIN(buf[S35390A_BYTE_DAY]); | 175 | tm->tm_mday = bcd2bin(buf[S35390A_BYTE_DAY]); |
176 | tm->tm_mon = BCD2BIN(buf[S35390A_BYTE_MONTH]) - 1; | 176 | tm->tm_mon = bcd2bin(buf[S35390A_BYTE_MONTH]) - 1; |
177 | tm->tm_year = BCD2BIN(buf[S35390A_BYTE_YEAR]) + 100; | 177 | tm->tm_year = bcd2bin(buf[S35390A_BYTE_YEAR]) + 100; |
178 | 178 | ||
179 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, mday=%d, " | 179 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, mday=%d, " |
180 | "mon=%d, year=%d, wday=%d\n", __func__, tm->tm_sec, | 180 | "mon=%d, year=%d, wday=%d\n", __func__, tm->tm_sec, |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index e7d19b6c265a..910bc704939c 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -134,12 +134,12 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
134 | rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, | 134 | rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, |
135 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); | 135 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); |
136 | 136 | ||
137 | BCD_TO_BIN(rtc_tm->tm_sec); | 137 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); |
138 | BCD_TO_BIN(rtc_tm->tm_min); | 138 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); |
139 | BCD_TO_BIN(rtc_tm->tm_hour); | 139 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); |
140 | BCD_TO_BIN(rtc_tm->tm_mday); | 140 | rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); |
141 | BCD_TO_BIN(rtc_tm->tm_mon); | 141 | rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); |
142 | BCD_TO_BIN(rtc_tm->tm_year); | 142 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); |
143 | 143 | ||
144 | rtc_tm->tm_year += 100; | 144 | rtc_tm->tm_year += 100; |
145 | rtc_tm->tm_mon -= 1; | 145 | rtc_tm->tm_mon -= 1; |
@@ -163,12 +163,12 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
163 | return -EINVAL; | 163 | return -EINVAL; |
164 | } | 164 | } |
165 | 165 | ||
166 | writeb(BIN2BCD(tm->tm_sec), base + S3C2410_RTCSEC); | 166 | writeb(bin2bcd(tm->tm_sec), base + S3C2410_RTCSEC); |
167 | writeb(BIN2BCD(tm->tm_min), base + S3C2410_RTCMIN); | 167 | writeb(bin2bcd(tm->tm_min), base + S3C2410_RTCMIN); |
168 | writeb(BIN2BCD(tm->tm_hour), base + S3C2410_RTCHOUR); | 168 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_RTCHOUR); |
169 | writeb(BIN2BCD(tm->tm_mday), base + S3C2410_RTCDATE); | 169 | writeb(bin2bcd(tm->tm_mday), base + S3C2410_RTCDATE); |
170 | writeb(BIN2BCD(tm->tm_mon + 1), base + S3C2410_RTCMON); | 170 | writeb(bin2bcd(tm->tm_mon + 1), base + S3C2410_RTCMON); |
171 | writeb(BIN2BCD(year), base + S3C2410_RTCYEAR); | 171 | writeb(bin2bcd(year), base + S3C2410_RTCYEAR); |
172 | 172 | ||
173 | return 0; | 173 | return 0; |
174 | } | 174 | } |
@@ -199,34 +199,34 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
199 | /* decode the alarm enable field */ | 199 | /* decode the alarm enable field */ |
200 | 200 | ||
201 | if (alm_en & S3C2410_RTCALM_SECEN) | 201 | if (alm_en & S3C2410_RTCALM_SECEN) |
202 | BCD_TO_BIN(alm_tm->tm_sec); | 202 | alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec); |
203 | else | 203 | else |
204 | alm_tm->tm_sec = 0xff; | 204 | alm_tm->tm_sec = 0xff; |
205 | 205 | ||
206 | if (alm_en & S3C2410_RTCALM_MINEN) | 206 | if (alm_en & S3C2410_RTCALM_MINEN) |
207 | BCD_TO_BIN(alm_tm->tm_min); | 207 | alm_tm->tm_min = bcd2bin(alm_tm->tm_min); |
208 | else | 208 | else |
209 | alm_tm->tm_min = 0xff; | 209 | alm_tm->tm_min = 0xff; |
210 | 210 | ||
211 | if (alm_en & S3C2410_RTCALM_HOUREN) | 211 | if (alm_en & S3C2410_RTCALM_HOUREN) |
212 | BCD_TO_BIN(alm_tm->tm_hour); | 212 | alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour); |
213 | else | 213 | else |
214 | alm_tm->tm_hour = 0xff; | 214 | alm_tm->tm_hour = 0xff; |
215 | 215 | ||
216 | if (alm_en & S3C2410_RTCALM_DAYEN) | 216 | if (alm_en & S3C2410_RTCALM_DAYEN) |
217 | BCD_TO_BIN(alm_tm->tm_mday); | 217 | alm_tm->tm_mday = bcd2bin(alm_tm->tm_mday); |
218 | else | 218 | else |
219 | alm_tm->tm_mday = 0xff; | 219 | alm_tm->tm_mday = 0xff; |
220 | 220 | ||
221 | if (alm_en & S3C2410_RTCALM_MONEN) { | 221 | if (alm_en & S3C2410_RTCALM_MONEN) { |
222 | BCD_TO_BIN(alm_tm->tm_mon); | 222 | alm_tm->tm_mon = bcd2bin(alm_tm->tm_mon); |
223 | alm_tm->tm_mon -= 1; | 223 | alm_tm->tm_mon -= 1; |
224 | } else { | 224 | } else { |
225 | alm_tm->tm_mon = 0xff; | 225 | alm_tm->tm_mon = 0xff; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (alm_en & S3C2410_RTCALM_YEAREN) | 228 | if (alm_en & S3C2410_RTCALM_YEAREN) |
229 | BCD_TO_BIN(alm_tm->tm_year); | 229 | alm_tm->tm_year = bcd2bin(alm_tm->tm_year); |
230 | else | 230 | else |
231 | alm_tm->tm_year = 0xffff; | 231 | alm_tm->tm_year = 0xffff; |
232 | 232 | ||
@@ -250,17 +250,17 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
250 | 250 | ||
251 | if (tm->tm_sec < 60 && tm->tm_sec >= 0) { | 251 | if (tm->tm_sec < 60 && tm->tm_sec >= 0) { |
252 | alrm_en |= S3C2410_RTCALM_SECEN; | 252 | alrm_en |= S3C2410_RTCALM_SECEN; |
253 | writeb(BIN2BCD(tm->tm_sec), base + S3C2410_ALMSEC); | 253 | writeb(bin2bcd(tm->tm_sec), base + S3C2410_ALMSEC); |
254 | } | 254 | } |
255 | 255 | ||
256 | if (tm->tm_min < 60 && tm->tm_min >= 0) { | 256 | if (tm->tm_min < 60 && tm->tm_min >= 0) { |
257 | alrm_en |= S3C2410_RTCALM_MINEN; | 257 | alrm_en |= S3C2410_RTCALM_MINEN; |
258 | writeb(BIN2BCD(tm->tm_min), base + S3C2410_ALMMIN); | 258 | writeb(bin2bcd(tm->tm_min), base + S3C2410_ALMMIN); |
259 | } | 259 | } |
260 | 260 | ||
261 | if (tm->tm_hour < 24 && tm->tm_hour >= 0) { | 261 | if (tm->tm_hour < 24 && tm->tm_hour >= 0) { |
262 | alrm_en |= S3C2410_RTCALM_HOUREN; | 262 | alrm_en |= S3C2410_RTCALM_HOUREN; |
263 | writeb(BIN2BCD(tm->tm_hour), base + S3C2410_ALMHOUR); | 263 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_ALMHOUR); |
264 | } | 264 | } |
265 | 265 | ||
266 | pr_debug("setting S3C2410_RTCALM to %08x\n", alrm_en); | 266 | pr_debug("setting S3C2410_RTCALM to %08x\n", alrm_en); |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index fcead4c4cd1f..aaf9d6a337cc 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -324,23 +324,23 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
324 | 324 | ||
325 | sec128 = readb(rtc->regbase + R64CNT); | 325 | sec128 = readb(rtc->regbase + R64CNT); |
326 | 326 | ||
327 | tm->tm_sec = BCD2BIN(readb(rtc->regbase + RSECCNT)); | 327 | tm->tm_sec = bcd2bin(readb(rtc->regbase + RSECCNT)); |
328 | tm->tm_min = BCD2BIN(readb(rtc->regbase + RMINCNT)); | 328 | tm->tm_min = bcd2bin(readb(rtc->regbase + RMINCNT)); |
329 | tm->tm_hour = BCD2BIN(readb(rtc->regbase + RHRCNT)); | 329 | tm->tm_hour = bcd2bin(readb(rtc->regbase + RHRCNT)); |
330 | tm->tm_wday = BCD2BIN(readb(rtc->regbase + RWKCNT)); | 330 | tm->tm_wday = bcd2bin(readb(rtc->regbase + RWKCNT)); |
331 | tm->tm_mday = BCD2BIN(readb(rtc->regbase + RDAYCNT)); | 331 | tm->tm_mday = bcd2bin(readb(rtc->regbase + RDAYCNT)); |
332 | tm->tm_mon = BCD2BIN(readb(rtc->regbase + RMONCNT)) - 1; | 332 | tm->tm_mon = bcd2bin(readb(rtc->regbase + RMONCNT)) - 1; |
333 | 333 | ||
334 | if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) { | 334 | if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) { |
335 | yr = readw(rtc->regbase + RYRCNT); | 335 | yr = readw(rtc->regbase + RYRCNT); |
336 | yr100 = BCD2BIN(yr >> 8); | 336 | yr100 = bcd2bin(yr >> 8); |
337 | yr &= 0xff; | 337 | yr &= 0xff; |
338 | } else { | 338 | } else { |
339 | yr = readb(rtc->regbase + RYRCNT); | 339 | yr = readb(rtc->regbase + RYRCNT); |
340 | yr100 = BCD2BIN((yr == 0x99) ? 0x19 : 0x20); | 340 | yr100 = bcd2bin((yr == 0x99) ? 0x19 : 0x20); |
341 | } | 341 | } |
342 | 342 | ||
343 | tm->tm_year = (yr100 * 100 + BCD2BIN(yr)) - 1900; | 343 | tm->tm_year = (yr100 * 100 + bcd2bin(yr)) - 1900; |
344 | 344 | ||
345 | sec2 = readb(rtc->regbase + R64CNT); | 345 | sec2 = readb(rtc->regbase + R64CNT); |
346 | cf_bit = readb(rtc->regbase + RCR1) & RCR1_CF; | 346 | cf_bit = readb(rtc->regbase + RCR1) & RCR1_CF; |
@@ -382,20 +382,20 @@ static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
382 | tmp &= ~RCR2_START; | 382 | tmp &= ~RCR2_START; |
383 | writeb(tmp, rtc->regbase + RCR2); | 383 | writeb(tmp, rtc->regbase + RCR2); |
384 | 384 | ||
385 | writeb(BIN2BCD(tm->tm_sec), rtc->regbase + RSECCNT); | 385 | writeb(bin2bcd(tm->tm_sec), rtc->regbase + RSECCNT); |
386 | writeb(BIN2BCD(tm->tm_min), rtc->regbase + RMINCNT); | 386 | writeb(bin2bcd(tm->tm_min), rtc->regbase + RMINCNT); |
387 | writeb(BIN2BCD(tm->tm_hour), rtc->regbase + RHRCNT); | 387 | writeb(bin2bcd(tm->tm_hour), rtc->regbase + RHRCNT); |
388 | writeb(BIN2BCD(tm->tm_wday), rtc->regbase + RWKCNT); | 388 | writeb(bin2bcd(tm->tm_wday), rtc->regbase + RWKCNT); |
389 | writeb(BIN2BCD(tm->tm_mday), rtc->regbase + RDAYCNT); | 389 | writeb(bin2bcd(tm->tm_mday), rtc->regbase + RDAYCNT); |
390 | writeb(BIN2BCD(tm->tm_mon + 1), rtc->regbase + RMONCNT); | 390 | writeb(bin2bcd(tm->tm_mon + 1), rtc->regbase + RMONCNT); |
391 | 391 | ||
392 | if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) { | 392 | if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) { |
393 | year = (BIN2BCD((tm->tm_year + 1900) / 100) << 8) | | 393 | year = (bin2bcd((tm->tm_year + 1900) / 100) << 8) | |
394 | BIN2BCD(tm->tm_year % 100); | 394 | bin2bcd(tm->tm_year % 100); |
395 | writew(year, rtc->regbase + RYRCNT); | 395 | writew(year, rtc->regbase + RYRCNT); |
396 | } else { | 396 | } else { |
397 | year = tm->tm_year % 100; | 397 | year = tm->tm_year % 100; |
398 | writeb(BIN2BCD(year), rtc->regbase + RYRCNT); | 398 | writeb(bin2bcd(year), rtc->regbase + RYRCNT); |
399 | } | 399 | } |
400 | 400 | ||
401 | /* Start RTC */ | 401 | /* Start RTC */ |
@@ -417,7 +417,7 @@ static inline int sh_rtc_read_alarm_value(struct sh_rtc *rtc, int reg_off) | |||
417 | byte = readb(rtc->regbase + reg_off); | 417 | byte = readb(rtc->regbase + reg_off); |
418 | if (byte & AR_ENB) { | 418 | if (byte & AR_ENB) { |
419 | byte &= ~AR_ENB; /* strip the enable bit */ | 419 | byte &= ~AR_ENB; /* strip the enable bit */ |
420 | value = BCD2BIN(byte); | 420 | value = bcd2bin(byte); |
421 | } | 421 | } |
422 | 422 | ||
423 | return value; | 423 | return value; |
@@ -455,7 +455,7 @@ static inline void sh_rtc_write_alarm_value(struct sh_rtc *rtc, | |||
455 | if (value < 0) | 455 | if (value < 0) |
456 | writeb(0, rtc->regbase + reg_off); | 456 | writeb(0, rtc->regbase + reg_off); |
457 | else | 457 | else |
458 | writeb(BIN2BCD(value) | AR_ENB, rtc->regbase + reg_off); | 458 | writeb(bin2bcd(value) | AR_ENB, rtc->regbase + reg_off); |
459 | } | 459 | } |
460 | 460 | ||
461 | static int sh_rtc_check_alarm(struct rtc_time *tm) | 461 | static int sh_rtc_check_alarm(struct rtc_time *tm) |
@@ -568,7 +568,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev) | |||
568 | struct sh_rtc *rtc; | 568 | struct sh_rtc *rtc; |
569 | struct resource *res; | 569 | struct resource *res; |
570 | unsigned int tmp; | 570 | unsigned int tmp; |
571 | int ret = -ENOENT; | 571 | int ret; |
572 | 572 | ||
573 | rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); | 573 | rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); |
574 | if (unlikely(!rtc)) | 574 | if (unlikely(!rtc)) |
@@ -577,26 +577,33 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev) | |||
577 | spin_lock_init(&rtc->lock); | 577 | spin_lock_init(&rtc->lock); |
578 | 578 | ||
579 | /* get periodic/carry/alarm irqs */ | 579 | /* get periodic/carry/alarm irqs */ |
580 | rtc->periodic_irq = platform_get_irq(pdev, 0); | 580 | ret = platform_get_irq(pdev, 0); |
581 | if (unlikely(rtc->periodic_irq < 0)) { | 581 | if (unlikely(ret < 0)) { |
582 | ret = -ENOENT; | ||
582 | dev_err(&pdev->dev, "No IRQ for period\n"); | 583 | dev_err(&pdev->dev, "No IRQ for period\n"); |
583 | goto err_badres; | 584 | goto err_badres; |
584 | } | 585 | } |
586 | rtc->periodic_irq = ret; | ||
585 | 587 | ||
586 | rtc->carry_irq = platform_get_irq(pdev, 1); | 588 | ret = platform_get_irq(pdev, 1); |
587 | if (unlikely(rtc->carry_irq < 0)) { | 589 | if (unlikely(ret < 0)) { |
590 | ret = -ENOENT; | ||
588 | dev_err(&pdev->dev, "No IRQ for carry\n"); | 591 | dev_err(&pdev->dev, "No IRQ for carry\n"); |
589 | goto err_badres; | 592 | goto err_badres; |
590 | } | 593 | } |
594 | rtc->carry_irq = ret; | ||
591 | 595 | ||
592 | rtc->alarm_irq = platform_get_irq(pdev, 2); | 596 | ret = platform_get_irq(pdev, 2); |
593 | if (unlikely(rtc->alarm_irq < 0)) { | 597 | if (unlikely(ret < 0)) { |
598 | ret = -ENOENT; | ||
594 | dev_err(&pdev->dev, "No IRQ for alarm\n"); | 599 | dev_err(&pdev->dev, "No IRQ for alarm\n"); |
595 | goto err_badres; | 600 | goto err_badres; |
596 | } | 601 | } |
602 | rtc->alarm_irq = ret; | ||
597 | 603 | ||
598 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 604 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
599 | if (unlikely(res == NULL)) { | 605 | if (unlikely(res == NULL)) { |
606 | ret = -ENOENT; | ||
600 | dev_err(&pdev->dev, "No IO resource\n"); | 607 | dev_err(&pdev->dev, "No IO resource\n"); |
601 | goto err_badres; | 608 | goto err_badres; |
602 | } | 609 | } |
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index 9a7e920315fa..f4cd46e15af9 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c | |||
@@ -82,14 +82,14 @@ static int stk17ta8_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
82 | flags = readb(pdata->ioaddr + RTC_FLAGS); | 82 | flags = readb(pdata->ioaddr + RTC_FLAGS); |
83 | writeb(flags | RTC_WRITE, pdata->ioaddr + RTC_FLAGS); | 83 | writeb(flags | RTC_WRITE, pdata->ioaddr + RTC_FLAGS); |
84 | 84 | ||
85 | writeb(BIN2BCD(tm->tm_year % 100), ioaddr + RTC_YEAR); | 85 | writeb(bin2bcd(tm->tm_year % 100), ioaddr + RTC_YEAR); |
86 | writeb(BIN2BCD(tm->tm_mon + 1), ioaddr + RTC_MONTH); | 86 | writeb(bin2bcd(tm->tm_mon + 1), ioaddr + RTC_MONTH); |
87 | writeb(BIN2BCD(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY); | 87 | writeb(bin2bcd(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY); |
88 | writeb(BIN2BCD(tm->tm_mday), ioaddr + RTC_DATE); | 88 | writeb(bin2bcd(tm->tm_mday), ioaddr + RTC_DATE); |
89 | writeb(BIN2BCD(tm->tm_hour), ioaddr + RTC_HOURS); | 89 | writeb(bin2bcd(tm->tm_hour), ioaddr + RTC_HOURS); |
90 | writeb(BIN2BCD(tm->tm_min), ioaddr + RTC_MINUTES); | 90 | writeb(bin2bcd(tm->tm_min), ioaddr + RTC_MINUTES); |
91 | writeb(BIN2BCD(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS); | 91 | writeb(bin2bcd(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS); |
92 | writeb(BIN2BCD((tm->tm_year + 1900) / 100), ioaddr + RTC_CENTURY); | 92 | writeb(bin2bcd((tm->tm_year + 1900) / 100), ioaddr + RTC_CENTURY); |
93 | 93 | ||
94 | writeb(flags & ~RTC_WRITE, pdata->ioaddr + RTC_FLAGS); | 94 | writeb(flags & ~RTC_WRITE, pdata->ioaddr + RTC_FLAGS); |
95 | return 0; | 95 | return 0; |
@@ -120,14 +120,14 @@ static int stk17ta8_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
120 | year = readb(ioaddr + RTC_YEAR); | 120 | year = readb(ioaddr + RTC_YEAR); |
121 | century = readb(ioaddr + RTC_CENTURY); | 121 | century = readb(ioaddr + RTC_CENTURY); |
122 | writeb(flags & ~RTC_READ, ioaddr + RTC_FLAGS); | 122 | writeb(flags & ~RTC_READ, ioaddr + RTC_FLAGS); |
123 | tm->tm_sec = BCD2BIN(second); | 123 | tm->tm_sec = bcd2bin(second); |
124 | tm->tm_min = BCD2BIN(minute); | 124 | tm->tm_min = bcd2bin(minute); |
125 | tm->tm_hour = BCD2BIN(hour); | 125 | tm->tm_hour = bcd2bin(hour); |
126 | tm->tm_mday = BCD2BIN(day); | 126 | tm->tm_mday = bcd2bin(day); |
127 | tm->tm_wday = BCD2BIN(week); | 127 | tm->tm_wday = bcd2bin(week); |
128 | tm->tm_mon = BCD2BIN(month) - 1; | 128 | tm->tm_mon = bcd2bin(month) - 1; |
129 | /* year is 1900 + tm->tm_year */ | 129 | /* year is 1900 + tm->tm_year */ |
130 | tm->tm_year = BCD2BIN(year) + BCD2BIN(century) * 100 - 1900; | 130 | tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900; |
131 | 131 | ||
132 | if (rtc_valid_tm(tm) < 0) { | 132 | if (rtc_valid_tm(tm) < 0) { |
133 | dev_err(dev, "retrieved date/time is not valid.\n"); | 133 | dev_err(dev, "retrieved date/time is not valid.\n"); |
@@ -148,16 +148,16 @@ static void stk17ta8_rtc_update_alarm(struct rtc_plat_data *pdata) | |||
148 | writeb(flags | RTC_WRITE, ioaddr + RTC_FLAGS); | 148 | writeb(flags | RTC_WRITE, ioaddr + RTC_FLAGS); |
149 | 149 | ||
150 | writeb(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? | 150 | writeb(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? |
151 | 0x80 : BIN2BCD(pdata->alrm_mday), | 151 | 0x80 : bin2bcd(pdata->alrm_mday), |
152 | ioaddr + RTC_DATE_ALARM); | 152 | ioaddr + RTC_DATE_ALARM); |
153 | writeb(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? | 153 | writeb(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? |
154 | 0x80 : BIN2BCD(pdata->alrm_hour), | 154 | 0x80 : bin2bcd(pdata->alrm_hour), |
155 | ioaddr + RTC_HOURS_ALARM); | 155 | ioaddr + RTC_HOURS_ALARM); |
156 | writeb(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? | 156 | writeb(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? |
157 | 0x80 : BIN2BCD(pdata->alrm_min), | 157 | 0x80 : bin2bcd(pdata->alrm_min), |
158 | ioaddr + RTC_MINUTES_ALARM); | 158 | ioaddr + RTC_MINUTES_ALARM); |
159 | writeb(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? | 159 | writeb(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? |
160 | 0x80 : BIN2BCD(pdata->alrm_sec), | 160 | 0x80 : bin2bcd(pdata->alrm_sec), |
161 | ioaddr + RTC_SECONDS_ALARM); | 161 | ioaddr + RTC_SECONDS_ALARM); |
162 | writeb(pdata->irqen ? RTC_INTS_AIE : 0, ioaddr + RTC_INTERRUPTS); | 162 | writeb(pdata->irqen ? RTC_INTS_AIE : 0, ioaddr + RTC_INTERRUPTS); |
163 | readb(ioaddr + RTC_FLAGS); /* clear interrupts */ | 163 | readb(ioaddr + RTC_FLAGS); /* clear interrupts */ |
@@ -280,7 +280,6 @@ static struct bin_attribute stk17ta8_nvram_attr = { | |||
280 | .attr = { | 280 | .attr = { |
281 | .name = "nvram", | 281 | .name = "nvram", |
282 | .mode = S_IRUGO | S_IWUSR, | 282 | .mode = S_IRUGO | S_IWUSR, |
283 | .owner = THIS_MODULE, | ||
284 | }, | 283 | }, |
285 | .size = RTC_OFFSET, | 284 | .size = RTC_OFFSET, |
286 | .read = stk17ta8_nvram_read, | 285 | .read = stk17ta8_nvram_read, |
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index 10025d840268..14d4f036a768 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c | |||
@@ -92,19 +92,19 @@ static int v3020_read_time(struct device *dev, struct rtc_time *dt) | |||
92 | 92 | ||
93 | /* ...and then read constant values. */ | 93 | /* ...and then read constant values. */ |
94 | tmp = v3020_get_reg(chip, V3020_SECONDS); | 94 | tmp = v3020_get_reg(chip, V3020_SECONDS); |
95 | dt->tm_sec = BCD2BIN(tmp); | 95 | dt->tm_sec = bcd2bin(tmp); |
96 | tmp = v3020_get_reg(chip, V3020_MINUTES); | 96 | tmp = v3020_get_reg(chip, V3020_MINUTES); |
97 | dt->tm_min = BCD2BIN(tmp); | 97 | dt->tm_min = bcd2bin(tmp); |
98 | tmp = v3020_get_reg(chip, V3020_HOURS); | 98 | tmp = v3020_get_reg(chip, V3020_HOURS); |
99 | dt->tm_hour = BCD2BIN(tmp); | 99 | dt->tm_hour = bcd2bin(tmp); |
100 | tmp = v3020_get_reg(chip, V3020_MONTH_DAY); | 100 | tmp = v3020_get_reg(chip, V3020_MONTH_DAY); |
101 | dt->tm_mday = BCD2BIN(tmp); | 101 | dt->tm_mday = bcd2bin(tmp); |
102 | tmp = v3020_get_reg(chip, V3020_MONTH); | 102 | tmp = v3020_get_reg(chip, V3020_MONTH); |
103 | dt->tm_mon = BCD2BIN(tmp) - 1; | 103 | dt->tm_mon = bcd2bin(tmp) - 1; |
104 | tmp = v3020_get_reg(chip, V3020_WEEK_DAY); | 104 | tmp = v3020_get_reg(chip, V3020_WEEK_DAY); |
105 | dt->tm_wday = BCD2BIN(tmp); | 105 | dt->tm_wday = bcd2bin(tmp); |
106 | tmp = v3020_get_reg(chip, V3020_YEAR); | 106 | tmp = v3020_get_reg(chip, V3020_YEAR); |
107 | dt->tm_year = BCD2BIN(tmp)+100; | 107 | dt->tm_year = bcd2bin(tmp)+100; |
108 | 108 | ||
109 | #ifdef DEBUG | 109 | #ifdef DEBUG |
110 | printk("\n%s : Read RTC values\n",__func__); | 110 | printk("\n%s : Read RTC values\n",__func__); |
@@ -136,13 +136,13 @@ static int v3020_set_time(struct device *dev, struct rtc_time *dt) | |||
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | /* Write all the values to ram... */ | 138 | /* Write all the values to ram... */ |
139 | v3020_set_reg(chip, V3020_SECONDS, BIN2BCD(dt->tm_sec)); | 139 | v3020_set_reg(chip, V3020_SECONDS, bin2bcd(dt->tm_sec)); |
140 | v3020_set_reg(chip, V3020_MINUTES, BIN2BCD(dt->tm_min)); | 140 | v3020_set_reg(chip, V3020_MINUTES, bin2bcd(dt->tm_min)); |
141 | v3020_set_reg(chip, V3020_HOURS, BIN2BCD(dt->tm_hour)); | 141 | v3020_set_reg(chip, V3020_HOURS, bin2bcd(dt->tm_hour)); |
142 | v3020_set_reg(chip, V3020_MONTH_DAY, BIN2BCD(dt->tm_mday)); | 142 | v3020_set_reg(chip, V3020_MONTH_DAY, bin2bcd(dt->tm_mday)); |
143 | v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon + 1)); | 143 | v3020_set_reg(chip, V3020_MONTH, bin2bcd(dt->tm_mon + 1)); |
144 | v3020_set_reg(chip, V3020_WEEK_DAY, BIN2BCD(dt->tm_wday)); | 144 | v3020_set_reg(chip, V3020_WEEK_DAY, bin2bcd(dt->tm_wday)); |
145 | v3020_set_reg(chip, V3020_YEAR, BIN2BCD(dt->tm_year % 100)); | 145 | v3020_set_reg(chip, V3020_YEAR, bin2bcd(dt->tm_year % 100)); |
146 | 146 | ||
147 | /* ...and set the clock. */ | 147 | /* ...and set the clock. */ |
148 | v3020_set_reg(chip, V3020_CMD_RAM2CLOCK, 0); | 148 | v3020_set_reg(chip, V3020_CMD_RAM2CLOCK, 0); |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 884b635f028b..834dcc6d785f 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -360,7 +360,7 @@ static int __devinit rtc_probe(struct platform_device *pdev) | |||
360 | spin_unlock_irq(&rtc_lock); | 360 | spin_unlock_irq(&rtc_lock); |
361 | 361 | ||
362 | aie_irq = platform_get_irq(pdev, 0); | 362 | aie_irq = platform_get_irq(pdev, 0); |
363 | if (aie_irq < 0 || aie_irq >= NR_IRQS) { | 363 | if (aie_irq < 0 || aie_irq >= nr_irqs) { |
364 | retval = -EBUSY; | 364 | retval = -EBUSY; |
365 | goto err_device_unregister; | 365 | goto err_device_unregister; |
366 | } | 366 | } |
@@ -371,7 +371,7 @@ static int __devinit rtc_probe(struct platform_device *pdev) | |||
371 | goto err_device_unregister; | 371 | goto err_device_unregister; |
372 | 372 | ||
373 | pie_irq = platform_get_irq(pdev, 1); | 373 | pie_irq = platform_get_irq(pdev, 1); |
374 | if (pie_irq < 0 || pie_irq >= NR_IRQS) | 374 | if (pie_irq < 0 || pie_irq >= nr_irqs) |
375 | goto err_free_irq; | 375 | goto err_free_irq; |
376 | 376 | ||
377 | retval = request_irq(pie_irq, rtclong1_interrupt, IRQF_DISABLED, | 377 | retval = request_irq(pie_irq, rtclong1_interrupt, IRQF_DISABLED, |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index 7dcfba1bbfe1..310c10795e9a 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -118,13 +118,13 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
118 | for (i = 0; i <= 4; i++) | 118 | for (i = 0; i <= 4; i++) |
119 | buf[i] &= 0x7F; | 119 | buf[i] &= 0x7F; |
120 | 120 | ||
121 | tm->tm_sec = BCD2BIN(buf[CCR_SEC]); | 121 | tm->tm_sec = bcd2bin(buf[CCR_SEC]); |
122 | tm->tm_min = BCD2BIN(buf[CCR_MIN]); | 122 | tm->tm_min = bcd2bin(buf[CCR_MIN]); |
123 | tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ | 123 | tm->tm_hour = bcd2bin(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ |
124 | tm->tm_mday = BCD2BIN(buf[CCR_MDAY]); | 124 | tm->tm_mday = bcd2bin(buf[CCR_MDAY]); |
125 | tm->tm_mon = BCD2BIN(buf[CCR_MONTH]) - 1; /* mon is 0-11 */ | 125 | tm->tm_mon = bcd2bin(buf[CCR_MONTH]) - 1; /* mon is 0-11 */ |
126 | tm->tm_year = BCD2BIN(buf[CCR_YEAR]) | 126 | tm->tm_year = bcd2bin(buf[CCR_YEAR]) |
127 | + (BCD2BIN(buf[CCR_Y2K]) * 100) - 1900; | 127 | + (bcd2bin(buf[CCR_Y2K]) * 100) - 1900; |
128 | tm->tm_wday = buf[CCR_WDAY]; | 128 | tm->tm_wday = buf[CCR_WDAY]; |
129 | 129 | ||
130 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | 130 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " |
@@ -174,11 +174,11 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
174 | __func__, | 174 | __func__, |
175 | tm->tm_sec, tm->tm_min, tm->tm_hour); | 175 | tm->tm_sec, tm->tm_min, tm->tm_hour); |
176 | 176 | ||
177 | buf[CCR_SEC] = BIN2BCD(tm->tm_sec); | 177 | buf[CCR_SEC] = bin2bcd(tm->tm_sec); |
178 | buf[CCR_MIN] = BIN2BCD(tm->tm_min); | 178 | buf[CCR_MIN] = bin2bcd(tm->tm_min); |
179 | 179 | ||
180 | /* set hour and 24hr bit */ | 180 | /* set hour and 24hr bit */ |
181 | buf[CCR_HOUR] = BIN2BCD(tm->tm_hour) | X1205_HR_MIL; | 181 | buf[CCR_HOUR] = bin2bcd(tm->tm_hour) | X1205_HR_MIL; |
182 | 182 | ||
183 | /* should we also set the date? */ | 183 | /* should we also set the date? */ |
184 | if (datetoo) { | 184 | if (datetoo) { |
@@ -187,15 +187,15 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
187 | __func__, | 187 | __func__, |
188 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | 188 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); |
189 | 189 | ||
190 | buf[CCR_MDAY] = BIN2BCD(tm->tm_mday); | 190 | buf[CCR_MDAY] = bin2bcd(tm->tm_mday); |
191 | 191 | ||
192 | /* month, 1 - 12 */ | 192 | /* month, 1 - 12 */ |
193 | buf[CCR_MONTH] = BIN2BCD(tm->tm_mon + 1); | 193 | buf[CCR_MONTH] = bin2bcd(tm->tm_mon + 1); |
194 | 194 | ||
195 | /* year, since the rtc epoch*/ | 195 | /* year, since the rtc epoch*/ |
196 | buf[CCR_YEAR] = BIN2BCD(tm->tm_year % 100); | 196 | buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100); |
197 | buf[CCR_WDAY] = tm->tm_wday & 0x07; | 197 | buf[CCR_WDAY] = tm->tm_wday & 0x07; |
198 | buf[CCR_Y2K] = BIN2BCD(tm->tm_year / 100); | 198 | buf[CCR_Y2K] = bin2bcd(tm->tm_year / 100); |
199 | } | 199 | } |
200 | 200 | ||
201 | /* If writing alarm registers, set compare bits on registers 0-4 */ | 201 | /* If writing alarm registers, set compare bits on registers 0-4 */ |
@@ -437,7 +437,7 @@ static int x1205_validate_client(struct i2c_client *client) | |||
437 | return -EIO; | 437 | return -EIO; |
438 | } | 438 | } |
439 | 439 | ||
440 | value = BCD2BIN(reg & probe_limits_pattern[i].mask); | 440 | value = bcd2bin(reg & probe_limits_pattern[i].mask); |
441 | 441 | ||
442 | if (value > probe_limits_pattern[i].max || | 442 | if (value > probe_limits_pattern[i].max || |
443 | value < probe_limits_pattern[i].min) { | 443 | value < probe_limits_pattern[i].min) { |