Merge branch 'master'
[powerpc.git] / drivers / i2c / chips / ds1337.c
index 74ece8a..01b0370 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/string.h>
 #include <linux/rtc.h>         /* get the user-level API */
 #include <linux/bcd.h>
@@ -39,9 +38,8 @@
  * Functions declaration
  */
 static unsigned short normal_i2c[] = { 0x68, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
-SENSORS_INSMOD_1(ds1337);
+I2C_CLIENT_INSMOD_1(ds1337);
 
 static int ds1337_attach_adapter(struct i2c_adapter *adapter);
 static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind);
@@ -165,7 +163,7 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
        buf[0] = 0;             /* reg offset */
        buf[1] = BIN2BCD(dt->tm_sec);
        buf[2] = BIN2BCD(dt->tm_min);
-       buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6);
+       buf[3] = BIN2BCD(dt->tm_hour);
        buf[4] = BIN2BCD(dt->tm_wday) + 1;
        buf[5] = BIN2BCD(dt->tm_mday);
        buf[6] = BIN2BCD(dt->tm_mon) + 1;
@@ -227,7 +225,7 @@ int ds1337_do_command(int bus, int cmd, void *arg)
 
 static int ds1337_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, ds1337_detect);
+       return i2c_probe(adapter, &addr_data, ds1337_detect);
 }
 
 /*
@@ -245,11 +243,10 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind)
                                     I2C_FUNC_I2C))
                goto exit;
 
-       if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct ds1337_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
-       memset(data, 0, sizeof(struct ds1337_data));
        INIT_LIST_HEAD(&data->list);
 
        /* The common I2C client data is placed right before the
@@ -344,9 +341,9 @@ static void ds1337_init_client(struct i2c_client *client)
 
        /* Ensure that device is set in 24-hour mode */
        val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR);
-       if ((val >= 0) && (val & (1 << 6)) == 0)
+       if ((val >= 0) && (val & (1 << 6)))
                i2c_smbus_write_byte_data(client, DS1337_REG_HOUR,
-                                         val | (1 << 6));
+                                         val & 0x3f);
 }
 
 static int ds1337_detach_client(struct i2c_client *client)
@@ -354,11 +351,8 @@ static int ds1337_detach_client(struct i2c_client *client)
        int err;
        struct ds1337_data *data = i2c_get_clientdata(client);
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        list_del(&data->list);
        kfree(data);