[PATCH] i2c: convert ds1374 to use a workqueue
[powerpc.git] / drivers / i2c / chips / max6875.c
index 31cee2d..88d2dde 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 /* Do not scan - the MAX6875 access method will write to some EEPROM chips */
 static unsigned short normal_i2c[] = {I2C_CLIENT_END};
@@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875);
 /* Each client has this additional data */
 struct max6875_data {
        struct i2c_client       client;
-       struct semaphore        update_lock;
+       struct mutex            update_lock;
 
        u32                     valid;
        u8                      data[USER_EEPROM_SIZE];
@@ -67,9 +67,9 @@ static int max6875_detach_client(struct i2c_client *client);
 
 /* This is the driver that will be inserted */
 static struct i2c_driver max6875_driver = {
-       .owner          = THIS_MODULE,
-       .name           = "max6875",
-       .flags          = I2C_DF_NOTIFY,
+       .driver = {
+               .name   = "max6875",
+       },
        .attach_adapter = max6875_attach_adapter,
        .detach_client  = max6875_detach_client,
 };
@@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
        if (slice >= USER_EEPROM_SLICES)
                return;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        buf = &data->data[slice << SLICE_BITS];
 
@@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
                data->valid |= (1 << slice);
        }
 exit_up:
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 }
 
 static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off,
@@ -171,11 +171,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
        struct max6875_data *data;
        int err = 0;
 
-       /* Prevent 24rf08 corruption (in case of user error) */
-       if (kind < 0)
-               i2c_smbus_xfer(adapter, address, 0, 0, 0,
-                              I2C_SMBUS_QUICK, NULL);
-
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA
                                     | I2C_FUNC_SMBUS_READ_BYTE))
                return 0;
@@ -184,16 +179,14 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
        if (address & 1)
                return 0;
 
-       if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL)))
+       if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL)))
                return -ENOMEM;
-       memset(data, 0, sizeof(struct max6875_data));
 
        /* A fake client is created on the odd address */
-       if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
+       if (!(fake_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit_kfree1;
        }
-       memset(fake_client, 0, sizeof(struct i2c_client));
 
        /* Init real i2c_client */
        real_client = &data->client;
@@ -203,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
        real_client->driver = &max6875_driver;
        real_client->flags = 0;
        strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Init fake client data */
        /* set the client data to the i2c_client so that it will get freed */