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