Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / drivers / w1 / slaves / w1_therm.c
similarity index 94%
rename from drivers/w1/w1_therm.c
rename to drivers/w1/slaves/w1_therm.c
index 4577df3..b022fff 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/sched.h>
 #include <linux/device.h>
 #include <linux/types.h>
 #include <linux/delay.h>
 
-#include "w1.h"
-#include "w1_io.h"
-#include "w1_int.h"
-#include "w1_family.h"
+#include "../w1.h"
+#include "../w1_int.h"
+#include "../w1_family.h"
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
@@ -123,12 +123,12 @@ static inline int w1_DS18S20_convert_temp(u8 rom[9])
 
        if (!rom[7])
                return 0;
-       
+
        if (rom[1] == 0)
                t = ((s32)rom[0] >> 1)*1000;
        else
                t = 1000*(-1*(s32)(0x100-rom[0]) >> 1);
-       
+
        t -= 250;
        h = 1000*((s32)rom[7] - (s32)rom[6]);
        h /= (s32)rom[7];
@@ -166,12 +166,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
        u8 rom[9], crc, verdict;
        int i, max_trying = 10;
 
-       atomic_inc(&sl->refcnt);
-       smp_mb__after_atomic_inc();
-       if (down_interruptible(&sl->master->mutex)) {
-               count = 0;
-               goto out_dec;
-       }
+       mutex_lock(&sl->master->mutex);
 
        if (off > W1_SLAVE_DATA_SIZE) {
                count = 0;
@@ -231,13 +226,10 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
 
        for (i = 0; i < 9; ++i)
                count += sprintf(buf + count, "%02x ", sl->rom[i]);
-       
+
        count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid));
 out:
-       up(&dev->mutex);
-out_dec:
-       smp_mb__before_atomic_inc();
-       atomic_dec(&sl->refcnt);
+       mutex_unlock(&dev->mutex);
 
        return count;
 }