linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / i2c / chips / tps65010.c
index 179b1e0..1af3dfb 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/suspend.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
-#include <linux/mutex.h>
 
 #include <asm/irq.h>
 #include <asm/mach-types.h>
@@ -82,7 +81,7 @@ enum tps_model {
 
 struct tps65010 {
        struct i2c_client       client;
-       struct mutex            lock;
+       struct semaphore        lock;
        int                     irq;
        struct work_struct      work;
        struct dentry           *file;
@@ -219,7 +218,7 @@ static int dbg_show(struct seq_file *s, void *_)
        seq_printf(s, "driver  %s\nversion %s\nchip    %s\n\n",
                        DRIVER_NAME, DRIVER_VERSION, chip);
 
-       mutex_lock(&tps->lock);
+       down(&tps->lock);
 
        /* FIXME how can we tell whether a battery is present?
         * likely involves a charge gauging chip (like BQ26501).
@@ -301,7 +300,7 @@ static int dbg_show(struct seq_file *s, void *_)
                                (v2 & (1 << (4 + i))) ? "rising" : "falling");
        }
 
-       mutex_unlock(&tps->lock);
+       up(&tps->lock);
        return 0;
 }
 
@@ -417,7 +416,7 @@ static void tps65010_work(void *_tps)
 {
        struct tps65010         *tps = _tps;
 
-       mutex_lock(&tps->lock);
+       down(&tps->lock);
 
        tps65010_interrupt(tps);
 
@@ -445,7 +444,7 @@ static void tps65010_work(void *_tps)
        if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))
                enable_irq(tps->irq);
 
-       mutex_unlock(&tps->lock);
+       up(&tps->lock);
 }
 
 static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs)
@@ -506,7 +505,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
        if (!tps)
                return 0;
 
-       mutex_init(&tps->lock);
+       init_MUTEX(&tps->lock);
        INIT_WORK(&tps->work, tps65010_work, tps);
        tps->irq = -1;
        tps->client.addr = address;
@@ -696,7 +695,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
        if ((gpio < GPIO1) || (gpio > GPIO4))
                return -EINVAL;
 
-       mutex_lock(&the_tps->lock);
+       down(&the_tps->lock);
 
        defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO);
 
@@ -721,7 +720,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
                gpio, value ? "high" : "low",
                i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO));
 
-       mutex_unlock(&the_tps->lock);
+       up(&the_tps->lock);
        return status;
 }
 EXPORT_SYMBOL(tps65010_set_gpio_out_value);
@@ -746,7 +745,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
                led = LED2;
        }
 
-       mutex_lock(&the_tps->lock);
+       down(&the_tps->lock);
 
        pr_debug("%s: led%i_on   0x%02x\n", DRIVER_NAME, led,
                i2c_smbus_read_byte_data(&the_tps->client,
@@ -772,7 +771,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
        default:
                printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
                       DRIVER_NAME);
-               mutex_unlock(&the_tps->lock);
+               up(&the_tps->lock);
                return -EINVAL;
        }
 
@@ -782,7 +781,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
        if (status != 0) {
                printk(KERN_ERR "%s: Failed to write led%i_on register\n",
                       DRIVER_NAME, led);
-               mutex_unlock(&the_tps->lock);
+               up(&the_tps->lock);
                return status;
        }
 
@@ -795,7 +794,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
        if (status != 0) {
                printk(KERN_ERR "%s: Failed to write led%i_per register\n",
                       DRIVER_NAME, led);
-               mutex_unlock(&the_tps->lock);
+               up(&the_tps->lock);
                return status;
        }
 
@@ -803,7 +802,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
                i2c_smbus_read_byte_data(&the_tps->client,
                                TPS_LED1_PER + offs));
 
-       mutex_unlock(&the_tps->lock);
+       up(&the_tps->lock);
 
        return status;
 }
@@ -821,7 +820,7 @@ int tps65010_set_vib(unsigned value)
        if (!the_tps)
                return -ENODEV;
 
-       mutex_lock(&the_tps->lock);
+       down(&the_tps->lock);
 
        vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2);
        vdcdc2 &= ~(1 << 1);
@@ -832,7 +831,7 @@ int tps65010_set_vib(unsigned value)
 
        pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
 
-       mutex_unlock(&the_tps->lock);
+       up(&the_tps->lock);
        return status;
 }
 EXPORT_SYMBOL(tps65010_set_vib);
@@ -849,7 +848,7 @@ int tps65010_set_low_pwr(unsigned mode)
        if (!the_tps)
                return -ENODEV;
 
-       mutex_lock(&the_tps->lock);
+       down(&the_tps->lock);
 
        pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
                mode ? "enable" : "disable",
@@ -877,7 +876,7 @@ int tps65010_set_low_pwr(unsigned mode)
                pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
                        i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
 
-       mutex_unlock(&the_tps->lock);
+       up(&the_tps->lock);
 
        return status;
 }
@@ -895,7 +894,7 @@ int tps65010_config_vregs1(unsigned value)
        if (!the_tps)
                return -ENODEV;
 
-       mutex_lock(&the_tps->lock);
+       down(&the_tps->lock);
 
        pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
                        i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
@@ -910,7 +909,7 @@ int tps65010_config_vregs1(unsigned value)
                pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
                        i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
 
-       mutex_unlock(&the_tps->lock);
+       up(&the_tps->lock);
 
        return status;
 }
@@ -932,7 +931,7 @@ int tps65013_set_low_pwr(unsigned mode)
        if (!the_tps || the_tps->por)
                return -ENODEV;
 
-       mutex_lock(&the_tps->lock);
+       down(&the_tps->lock);
 
        pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
                DRIVER_NAME,
@@ -960,7 +959,7 @@ int tps65013_set_low_pwr(unsigned mode)
        if (status != 0) {
                printk(KERN_ERR "%s: Failed to write chconfig register\n",
         DRIVER_NAME);
-               mutex_unlock(&the_tps->lock);
+               up(&the_tps->lock);
                return status;
        }
 
@@ -978,7 +977,7 @@ int tps65013_set_low_pwr(unsigned mode)
                pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
                        i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
 
-       mutex_unlock(&the_tps->lock);
+       up(&the_tps->lock);
 
        return status;
 }