Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[sfrench/cifs-2.6.git] / drivers / i2c / chips / pcf8591.c
index 80f1df9a4500f7582c757b815eb1efc7d8f101fd..925a6b371fd248651238cad2f92bb89b67dfc1c7 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
@@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode,
 
 struct pcf8591_data {
        struct i2c_client client;
-       struct semaphore update_lock;
+       struct mutex update_lock;
 
        u8 control;
        u8 aout;
@@ -88,10 +89,10 @@ static int pcf8591_read_channel(struct device *dev, int channel);
 
 /* This is the driver that will be inserted */
 static struct i2c_driver pcf8591_driver = {
-       .owner          = THIS_MODULE,
-       .name           = "pcf8591",
+       .driver = {
+               .name   = "pcf8591",
+       },
        .id             = I2C_DRIVERID_PCF8591,
-       .flags          = I2C_DF_NOTIFY,
        .attach_adapter = pcf8591_attach_adapter,
        .detach_client  = pcf8591_detach_client,
 };
@@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
        struct pcf8591_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        if (val)
                data->control |= PCF8591_CONTROL_AOEF;
        else
                data->control &= ~PCF8591_CONTROL_AOEF;
        i2c_smbus_write_byte(client, data->control);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -166,7 +167,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
 }
 
 /* This function is called by i2c_probe */
-int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
+static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
        struct pcf8591_data *data;
@@ -178,11 +179,10 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 
        /* OK. For now, we presume we have a valid client. We now create the
           client structure, even though we cannot fill it completely yet. */
-       if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
-       memset(data, 0, sizeof(struct pcf8591_data));
        
        new_client = &data->client;
        i2c_set_clientdata(new_client, data);
@@ -201,7 +201,7 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Fill in the remaining client fields and put it into the global 
           list */
        strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE);
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -266,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
        struct i2c_client *client = to_i2c_client(dev);
        struct pcf8591_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) {
                data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
@@ -279,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
        }
        value = i2c_smbus_read_byte(client);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        if ((channel == 2 && input_mode == 2) ||
            (channel != 3 && (input_mode == 1 || input_mode == 3)))