w1_therm_read_bin: don't call flush_signals()
[sfrench/cifs-2.6.git] / drivers / w1 / slaves / w1_therm.c
index 536d16d78de75ce313fa7f4f2b394e2617f4033e..1a6937dc190b777369eac30ace6ea0aa665963bc 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"
 
@@ -141,7 +141,7 @@ static inline int w1_convert_temp(u8 rom[9], u8 fid)
 {
        int i;
 
-       for (i=0; i<sizeof(w1_therm_families)/sizeof(w1_therm_families[0]); ++i)
+       for (i = 0; i < ARRAY_SIZE(w1_therm_families); ++i)
                if (w1_therm_families[i].f->fid == fid)
                        return w1_therm_families[i].convert(rom);
 
@@ -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;
@@ -196,11 +191,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
 
                        w1_write_8(dev, W1_CONVERT_TEMP);
 
-                       while (tm) {
-                               tm = msleep_interruptible(tm);
-                               if (signal_pending(current))
-                                       flush_signals(current);
-                       }
+                       msleep(tm);
 
                        if (!w1_reset_select_slave(sl)) {
 
@@ -234,10 +225,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
 
        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;
 }
@@ -246,7 +234,7 @@ static int __init w1_therm_init(void)
 {
        int err, i;
 
-       for (i=0; i<sizeof(w1_therm_families)/sizeof(w1_therm_families[0]); ++i) {
+       for (i = 0; i < ARRAY_SIZE(w1_therm_families); ++i) {
                err = w1_register_family(w1_therm_families[i].f);
                if (err)
                        w1_therm_families[i].broken = 1;
@@ -259,7 +247,7 @@ static void __exit w1_therm_fini(void)
 {
        int i;
 
-       for (i=0; i<sizeof(w1_therm_families)/sizeof(w1_therm_families[0]); ++i)
+       for (i = 0; i < ARRAY_SIZE(w1_therm_families); ++i)
                if (!w1_therm_families[i].broken)
                        w1_unregister_family(w1_therm_families[i].f);
 }