diff options
Diffstat (limited to 'drivers/rtc/rtc-ds1305.c')
-rw-r--r-- | drivers/rtc/rtc-ds1305.c | 39 |
1 files changed, 19 insertions, 20 deletions
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, |