aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorNicolas Kaiser <nikai@nikai.net>2005-11-26 14:15:23 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-06 01:16:21 -0500
commit7e94436942a7517d08c0cd1a8831122a0fea289e (patch)
treef67263807fb5ce39796dc75525323a2c6753c143 /drivers/i2c
parent5b319400f5e2cd31a82b38405856ff2b46a9bb83 (diff)
[PATCH] i2c: Remove duplicate rtc8564 BCD macros
Remove duplicate of BCD macros. Signed-off-by: Nicolas Kaiser <nikai@nikai.net> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/chips/rtc8564.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index 916cdc1af23c..26e498d921da 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -14,6 +14,7 @@
14 */ 14 */
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/bcd.h>
17#include <linux/i2c.h> 18#include <linux/i2c.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
@@ -52,9 +53,6 @@ static inline u8 _rtc8564_ctrl2(struct i2c_client *client)
52#define CTRL1(c) _rtc8564_ctrl1(c) 53#define CTRL1(c) _rtc8564_ctrl1(c)
53#define CTRL2(c) _rtc8564_ctrl2(c) 54#define CTRL2(c) _rtc8564_ctrl2(c)
54 55
55#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
56#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10)
57
58static int debug;; 56static int debug;;
59module_param(debug, int, S_IRUGO | S_IWUSR); 57module_param(debug, int, S_IRUGO | S_IWUSR);
60 58
@@ -224,16 +222,16 @@ static int rtc8564_get_datetime(struct i2c_client *client, struct rtc_tm *dt)
224 return ret; 222 return ret;
225 223
226 /* century stored in minute alarm reg */ 224 /* century stored in minute alarm reg */
227 dt->year = BCD_TO_BIN(buf[RTC8564_REG_YEAR]); 225 dt->year = BCD2BIN(buf[RTC8564_REG_YEAR]);
228 dt->year += 100 * BCD_TO_BIN(buf[RTC8564_REG_AL_MIN] & 0x3f); 226 dt->year += 100 * BCD2BIN(buf[RTC8564_REG_AL_MIN] & 0x3f);
229 dt->mday = BCD_TO_BIN(buf[RTC8564_REG_DAY] & 0x3f); 227 dt->mday = BCD2BIN(buf[RTC8564_REG_DAY] & 0x3f);
230 dt->wday = BCD_TO_BIN(buf[RTC8564_REG_WDAY] & 7); 228 dt->wday = BCD2BIN(buf[RTC8564_REG_WDAY] & 7);
231 dt->mon = BCD_TO_BIN(buf[RTC8564_REG_MON_CENT] & 0x1f); 229 dt->mon = BCD2BIN(buf[RTC8564_REG_MON_CENT] & 0x1f);
232 230
233 dt->secs = BCD_TO_BIN(buf[RTC8564_REG_SEC] & 0x7f); 231 dt->secs = BCD2BIN(buf[RTC8564_REG_SEC] & 0x7f);
234 dt->vl = (buf[RTC8564_REG_SEC] & 0x80) == 0x80; 232 dt->vl = (buf[RTC8564_REG_SEC] & 0x80) == 0x80;
235 dt->mins = BCD_TO_BIN(buf[RTC8564_REG_MIN] & 0x7f); 233 dt->mins = BCD2BIN(buf[RTC8564_REG_MIN] & 0x7f);
236 dt->hours = BCD_TO_BIN(buf[RTC8564_REG_HR] & 0x3f); 234 dt->hours = BCD2BIN(buf[RTC8564_REG_HR] & 0x3f);
237 235
238 _DBGRTCTM(2, *dt); 236 _DBGRTCTM(2, *dt);
239 237
@@ -255,18 +253,18 @@ rtc8564_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo)
255 253
256 buf[RTC8564_REG_CTRL1] = CTRL1(client) | RTC8564_CTRL1_STOP; 254 buf[RTC8564_REG_CTRL1] = CTRL1(client) | RTC8564_CTRL1_STOP;
257 buf[RTC8564_REG_CTRL2] = CTRL2(client); 255 buf[RTC8564_REG_CTRL2] = CTRL2(client);
258 buf[RTC8564_REG_SEC] = BIN_TO_BCD(dt->secs); 256 buf[RTC8564_REG_SEC] = BIN2BCD(dt->secs);
259 buf[RTC8564_REG_MIN] = BIN_TO_BCD(dt->mins); 257 buf[RTC8564_REG_MIN] = BIN2BCD(dt->mins);
260 buf[RTC8564_REG_HR] = BIN_TO_BCD(dt->hours); 258 buf[RTC8564_REG_HR] = BIN2BCD(dt->hours);
261 259
262 if (datetoo) { 260 if (datetoo) {
263 len += 5; 261 len += 5;
264 buf[RTC8564_REG_DAY] = BIN_TO_BCD(dt->mday); 262 buf[RTC8564_REG_DAY] = BIN2BCD(dt->mday);
265 buf[RTC8564_REG_WDAY] = BIN_TO_BCD(dt->wday); 263 buf[RTC8564_REG_WDAY] = BIN2BCD(dt->wday);
266 buf[RTC8564_REG_MON_CENT] = BIN_TO_BCD(dt->mon) & 0x1f; 264 buf[RTC8564_REG_MON_CENT] = BIN2BCD(dt->mon) & 0x1f;
267 /* century stored in minute alarm reg */ 265 /* century stored in minute alarm reg */
268 buf[RTC8564_REG_YEAR] = BIN_TO_BCD(dt->year % 100); 266 buf[RTC8564_REG_YEAR] = BIN2BCD(dt->year % 100);
269 buf[RTC8564_REG_AL_MIN] = BIN_TO_BCD(dt->year / 100); 267 buf[RTC8564_REG_AL_MIN] = BIN2BCD(dt->year / 100);
270 } 268 }
271 269
272 ret = rtc8564_write(client, 0, buf, len); 270 ret = rtc8564_write(client, 0, buf, len);