aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2005-04-08 09:02:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-22 00:51:51 -0400
commit6069ffde15472da9d041a58df490d388bb175d51 (patch)
tree0e1b536969aafe6bb3a9a567be46a61b8be91886 /drivers/i2c/chips
parent3e9d0ba1305cd7c6efd2ab3a003e58a27da1796b (diff)
[PATCH] I2C: ds1337 2/4
Use correct macros to convert between bdc and bin. See linux/bcd.h Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/chips')
-rw-r--r--drivers/i2c/chips/ds1337.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index e2a6aabdc780..8a9e751d609b 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -127,15 +127,15 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
127 buf[4], buf[5], buf[6]); 127 buf[4], buf[5], buf[6]);
128 128
129 if (result >= 0) { 129 if (result >= 0) {
130 dt->tm_sec = BCD_TO_BIN(buf[0]); 130 dt->tm_sec = BCD2BIN(buf[0]);
131 dt->tm_min = BCD_TO_BIN(buf[1]); 131 dt->tm_min = BCD2BIN(buf[1]);
132 val = buf[2] & 0x3f; 132 val = buf[2] & 0x3f;
133 dt->tm_hour = BCD_TO_BIN(val); 133 dt->tm_hour = BCD2BIN(val);
134 dt->tm_wday = BCD_TO_BIN(buf[3]) - 1; 134 dt->tm_wday = BCD2BIN(buf[3]) - 1;
135 dt->tm_mday = BCD_TO_BIN(buf[4]); 135 dt->tm_mday = BCD2BIN(buf[4]);
136 val = buf[5] & 0x7f; 136 val = buf[5] & 0x7f;
137 dt->tm_mon = BCD_TO_BIN(val); 137 dt->tm_mon = BCD2BIN(val);
138 dt->tm_year = 1900 + BCD_TO_BIN(buf[6]); 138 dt->tm_year = 1900 + BCD2BIN(buf[6]);
139 if (buf[5] & 0x80) 139 if (buf[5] & 0x80)
140 dt->tm_year += 100; 140 dt->tm_year += 100;
141 141
@@ -174,19 +174,19 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
174 dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); 174 dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday);
175 175
176 buf[0] = 0; /* reg offset */ 176 buf[0] = 0; /* reg offset */
177 buf[1] = BIN_TO_BCD(dt->tm_sec); 177 buf[1] = BIN2BCD(dt->tm_sec);
178 buf[2] = BIN_TO_BCD(dt->tm_min); 178 buf[2] = BIN2BCD(dt->tm_min);
179 buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6); 179 buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6);
180 buf[4] = BIN_TO_BCD(dt->tm_wday) + 1; 180 buf[4] = BIN2BCD(dt->tm_wday) + 1;
181 buf[5] = BIN_TO_BCD(dt->tm_mday); 181 buf[5] = BIN2BCD(dt->tm_mday);
182 buf[6] = BIN_TO_BCD(dt->tm_mon); 182 buf[6] = BIN2BCD(dt->tm_mon);
183 if (dt->tm_year >= 2000) { 183 if (dt->tm_year >= 2000) {
184 val = dt->tm_year - 2000; 184 val = dt->tm_year - 2000;
185 buf[6] |= (1 << 7); 185 buf[6] |= (1 << 7);
186 } else { 186 } else {
187 val = dt->tm_year - 1900; 187 val = dt->tm_year - 1900;
188 } 188 }
189 buf[7] = BIN_TO_BCD(val); 189 buf[7] = BIN2BCD(val);
190 190
191 msg[0].addr = client->addr; 191 msg[0].addr = client->addr;
192 msg[0].flags = 0; 192 msg[0].flags = 0;