linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / i2c / chips / pcf8591.c
index 925a6b3..36cff09 100644 (file)
@@ -24,7 +24,6 @@
 #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,
@@ -75,7 +74,7 @@ MODULE_PARM_DESC(input_mode,
 
 struct pcf8591_data {
        struct i2c_client client;
-       struct mutex update_lock;
+       struct semaphore update_lock;
 
        u8 control;
        u8 aout;
@@ -145,13 +144,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);
 
-       mutex_lock(&data->update_lock);
+       down(&data->update_lock);
        if (val)
                data->control |= PCF8591_CONTROL_AOEF;
        else
                data->control &= ~PCF8591_CONTROL_AOEF;
        i2c_smbus_write_byte(client, data->control);
-       mutex_unlock(&data->update_lock);
+       up(&data->update_lock);
        return count;
 }
 
@@ -201,7 +200,7 @@ static 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);
-       mutex_init(&data->update_lock);
+       init_MUTEX(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -266,7 +265,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);
 
-       mutex_lock(&data->update_lock);
+       down(&data->update_lock);
 
        if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) {
                data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
@@ -279,7 +278,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
        }
        value = i2c_smbus_read_byte(client);
 
-       mutex_unlock(&data->update_lock);
+       up(&data->update_lock);
 
        if ((channel == 2 && input_mode == 2) ||
            (channel != 3 && (input_mode == 1 || input_mode == 3)))