reiserfs: add locking around error buffer
[safe/jmp/linux-2.6] / drivers / macintosh / windfarm_smu_sat.c
index f449d77..7847e98 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 #include <linux/wait.h>
 #include <linux/i2c.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 #include <asm/prom.h>
 #include <asm/smu.h>
 #include <asm/pmac_low_i2c.h>
@@ -36,7 +36,7 @@
 struct wf_sat {
        int                     nr;
        atomic_t                refcnt;
-       struct semaphore        mutex;
+       struct mutex            mutex;
        unsigned long           last_read; /* jiffies when cache last updated */
        u8                      cache[16];
        struct i2c_client       i2c;
@@ -87,11 +87,12 @@ struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
                return NULL;
        }
 
-       len = i2c_smbus_read_word_data(&sat->i2c, 9);
-       if (len < 0) {
+       err = i2c_smbus_read_word_data(&sat->i2c, 9);
+       if (err < 0) {
                printk(KERN_ERR "smu_sat_get_sdb_part rd len error\n");
                return NULL;
        }
+       len = err;
        if (len == 0) {
                printk(KERN_ERR "smu_sat_get_sdb_part no partition %x\n", id);
                return NULL;
@@ -163,7 +164,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
        if (sat->i2c.adapter == NULL)
                return -ENODEV;
 
-       down(&sat->mutex);
+       mutex_lock(&sat->mutex);
        if (time_after(jiffies, (sat->last_read + MAX_AGE))) {
                err = wf_sat_read_cache(sat);
                if (err)
@@ -182,7 +183,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
        err = 0;
 
  fail:
-       up(&sat->mutex);
+       mutex_unlock(&sat->mutex);
        return err;
 }
 
@@ -233,7 +234,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
        sat->nr = -1;
        sat->node = of_node_get(dev);
        atomic_set(&sat->refcnt, 0);
-       init_MUTEX(&sat->mutex);
+       mutex_init(&sat->mutex);
        sat->i2c.addr = (addr >> 1) & 0x7f;
        sat->i2c.adapter = adapter;
        sat->i2c.driver = &wf_sat_driver;