hwmon: (jc42) Allow negative hysteresis temperatures
authorJean Delvare <jdelvare@suse.de>
Fri, 23 Jan 2015 09:27:03 +0000 (10:27 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 26 Jan 2015 05:24:00 +0000 (21:24 -0800)
The driver supports negative high and critical limits, it can return
negative hysteresis values, so there is no good reason to not let the
user write negative hysteresis values.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/jc42.c

index a46cb65..996bdfd 100644 (file)
@@ -304,15 +304,16 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
                                  const char *buf, size_t count)
 {
        struct jc42_data *data = dev_get_drvdata(dev);
                                  const char *buf, size_t count)
 {
        struct jc42_data *data = dev_get_drvdata(dev);
-       unsigned long val;
+       long val;
        int diff, hyst;
        int err;
        int ret = count;
 
        int diff, hyst;
        int err;
        int ret = count;
 
-       if (kstrtoul(buf, 10, &val) < 0)
+       if (kstrtol(buf, 10, &val) < 0)
                return -EINVAL;
 
                return -EINVAL;
 
-       val = clamp_val(val, 0, JC42_TEMP_MAX);
+       val = clamp_val(val, (data->extended ? JC42_TEMP_MIN_EXTENDED :
+                             JC42_TEMP_MIN) - 6000, JC42_TEMP_MAX);
        diff = jc42_temp_from_reg(data->temp[t_crit]) - val;
 
        hyst = 0;
        diff = jc42_temp_from_reg(data->temp[t_crit]) - val;
 
        hyst = 0;