drivers/rtc/: use bcd2bin/bin2bcd
[deliverable/linux.git] / drivers / rtc / rtc-isl1208.c
index fb15e3fb4ce279df7df4cba4fc387b6620d6427c..2cd77ab8fc66b06e43d3b908884a9f4fe8603ca1 100644 (file)
@@ -259,26 +259,26 @@ isl1208_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
                return sr;
        }
 
-       tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SC]);
-       tm->tm_min = BCD2BIN(regs[ISL1208_REG_MN]);
+       tm->tm_sec = bcd2bin(regs[ISL1208_REG_SC]);
+       tm->tm_min = bcd2bin(regs[ISL1208_REG_MN]);
 
        /* HR field has a more complex interpretation */
        {
                const u8 _hr = regs[ISL1208_REG_HR];
                if (_hr & ISL1208_REG_HR_MIL)   /* 24h format */
-                       tm->tm_hour = BCD2BIN(_hr & 0x3f);
+                       tm->tm_hour = bcd2bin(_hr & 0x3f);
                else {
                        /* 12h format */
-                       tm->tm_hour = BCD2BIN(_hr & 0x1f);
+                       tm->tm_hour = bcd2bin(_hr & 0x1f);
                        if (_hr & ISL1208_REG_HR_PM)    /* PM flag set */
                                tm->tm_hour += 12;
                }
        }
 
-       tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DT]);
-       tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */
-       tm->tm_year = BCD2BIN(regs[ISL1208_REG_YR]) + 100;
-       tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DW]);
+       tm->tm_mday = bcd2bin(regs[ISL1208_REG_DT]);
+       tm->tm_mon = bcd2bin(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */
+       tm->tm_year = bcd2bin(regs[ISL1208_REG_YR]) + 100;
+       tm->tm_wday = bcd2bin(regs[ISL1208_REG_DW]);
 
        return 0;
 }
@@ -305,13 +305,13 @@ isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
        }
 
        /* MSB of each alarm register is an enable bit */
-       tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f);
-       tm->tm_min = BCD2BIN(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f);
-       tm->tm_hour = BCD2BIN(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f);
-       tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f);
+       tm->tm_sec = bcd2bin(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f);
+       tm->tm_min = bcd2bin(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f);
+       tm->tm_hour = bcd2bin(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f);
+       tm->tm_mday = bcd2bin(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f);
        tm->tm_mon =
-               BCD2BIN(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1;
-       tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03);
+               bcd2bin(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1;
+       tm->tm_wday = bcd2bin(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03);
 
        return 0;
 }
@@ -328,15 +328,15 @@ isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
        int sr;
        u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
 
-       regs[ISL1208_REG_SC] = BIN2BCD(tm->tm_sec);
-       regs[ISL1208_REG_MN] = BIN2BCD(tm->tm_min);
-       regs[ISL1208_REG_HR] = BIN2BCD(tm->tm_hour) | ISL1208_REG_HR_MIL;
+       regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec);
+       regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min);
+       regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL;
 
-       regs[ISL1208_REG_DT] = BIN2BCD(tm->tm_mday);
-       regs[ISL1208_REG_MO] = BIN2BCD(tm->tm_mon + 1);
-       regs[ISL1208_REG_YR] = BIN2BCD(tm->tm_year - 100);
+       regs[ISL1208_REG_DT] = bin2bcd(tm->tm_mday);
+       regs[ISL1208_REG_MO] = bin2bcd(tm->tm_mon + 1);
+       regs[ISL1208_REG_YR] = bin2bcd(tm->tm_year - 100);
 
-       regs[ISL1208_REG_DW] = BIN2BCD(tm->tm_wday & 7);
+       regs[ISL1208_REG_DW] = bin2bcd(tm->tm_wday & 7);
 
        sr = isl1208_i2c_get_sr(client);
        if (sr < 0) {
@@ -482,7 +482,7 @@ isl1208_sysfs_register(struct device *dev)
 static int
 isl1208_sysfs_unregister(struct device *dev)
 {
-       device_remove_file(dev, &dev_attr_atrim);
+       device_remove_file(dev, &dev_attr_dtrim);
        device_remove_file(dev, &dev_attr_atrim);
        device_remove_file(dev, &dev_attr_usr);
 
@@ -490,7 +490,7 @@ isl1208_sysfs_unregister(struct device *dev)
 }
 
 static int
-isl1208_probe(struct i2c_client *client)
+isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
        int rc = 0;
        struct rtc_device *rtc;
@@ -545,12 +545,19 @@ isl1208_remove(struct i2c_client *client)
        return 0;
 }
 
+static const struct i2c_device_id isl1208_id[] = {
+       { "isl1208", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, isl1208_id);
+
 static struct i2c_driver isl1208_driver = {
        .driver = {
                   .name = "rtc-isl1208",
                   },
        .probe = isl1208_probe,
        .remove = isl1208_remove,
+       .id_table = isl1208_id,
 };
 
 static int __init
This page took 0.026141 seconds and 5 git commands to generate.