x86/bugs: Drop one "mitigation" from dmesg
[pandora-kernel.git] / drivers / hwmon / lm92.c
index 8fcbd4d..5d091fa 100644 (file)
@@ -73,12 +73,9 @@ static inline int TEMP_FROM_REG(s16 reg)
        return reg / 8 * 625 / 10;
 }
 
-static inline s16 TEMP_TO_REG(int val)
+static inline s16 TEMP_TO_REG(long val)
 {
-       if (val <= -60000)
-               return -60000 * 10 / 625 * 8;
-       if (val >= 160000)
-               return 160000 * 10 / 625 * 8;
+       val = clamp_val(val, -60000, 160000);
        return val * 10 / 625 * 8;
 }
 
@@ -192,10 +189,12 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
        struct lm92_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
+       val = clamp_val(val, -120000, 220000);
        mutex_lock(&data->update_lock);
-       data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
+        data->temp1_hyst =
+               TEMP_TO_REG(TEMP_FROM_REG(data->temp1_crit) - val);
        i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST,
-                                    TEMP_TO_REG(data->temp1_hyst));
+                                    data->temp1_hyst);
        mutex_unlock(&data->update_lock);
        return count;
 }