diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-05-12 14:20:24 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-05-21 19:02:24 -0400 |
commit | ceeaa70c0fa7fbf30a0c7a2b07dc895de22583c9 (patch) | |
tree | 02fd9f156adea87cbff20b213ffd567a3260c77a | |
parent | 84899d394e755989a1cc080083080f7695c36467 (diff) |
hwmon: (emc1403) Relax hysteresis limit write checks
Writing the hysteresis limit returned -ERANGE if the written hysteresis
was too high or too low. Relax error check and adjust the hysteresis
value to its valid range.
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/emc1403.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c index 46220b131153..c62bc044a660 100644 --- a/drivers/hwmon/emc1403.c +++ b/drivers/hwmon/emc1403.c | |||
@@ -147,12 +147,7 @@ static ssize_t store_hyst(struct device *dev, | |||
147 | goto fail; | 147 | goto fail; |
148 | 148 | ||
149 | hyst = limit * 1000 - val; | 149 | hyst = limit * 1000 - val; |
150 | hyst = DIV_ROUND_CLOSEST(hyst, 1000); | 150 | hyst = clamp_val(DIV_ROUND_CLOSEST(hyst, 1000), 0, 255); |
151 | if (hyst < 0 || hyst > 255) { | ||
152 | retval = -ERANGE; | ||
153 | goto fail; | ||
154 | } | ||
155 | |||
156 | retval = regmap_write(regmap, 0x21, hyst); | 151 | retval = regmap_write(regmap, 0x21, hyst); |
157 | if (retval == 0) | 152 | if (retval == 0) |
158 | retval = count; | 153 | retval = count; |