aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-rs5c348.c
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@kernel.org>2008-10-18 23:28:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-20 11:52:41 -0400
commitfe20ba70abf7d6e5855c3dacc729490b3d0d077f (patch)
tree918619427cc051d22cb38b44e94c7e65f29ee928 /drivers/rtc/rtc-rs5c348.c
parent4110a0d6206bd175419cc5503f80cc296d184cbf (diff)
drivers/rtc/: use bcd2bin/bin2bcd
Change drivers/rtc/ to use the new bcd2bin/bin2bcd functions instead of the obsolete BCD_TO_BIN/BIN_TO_BCD/BCD2BIN/BIN2BCD macros. Signed-off-by: Adrian Bunk <bunk@kernel.org> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-rs5c348.c')
-rw-r--r--drivers/rtc/rtc-rs5c348.c30
1 files changed, 15 insertions, 15 deletions
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) {