Commit ceeaa70c authored by Guenter Roeck's avatar Guenter Roeck

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: default avatarJean Delvare <jdelvare@suse.de>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 84899d39
...@@ -147,12 +147,7 @@ static ssize_t store_hyst(struct device *dev, ...@@ -147,12 +147,7 @@ static ssize_t store_hyst(struct device *dev,
goto fail; goto fail;
hyst = limit * 1000 - val; hyst = limit * 1000 - val;
hyst = DIV_ROUND_CLOSEST(hyst, 1000); hyst = clamp_val(DIV_ROUND_CLOSEST(hyst, 1000), 0, 255);
if (hyst < 0 || hyst > 255) {
retval = -ERANGE;
goto fail;
}
retval = regmap_write(regmap, 0x21, hyst); retval = regmap_write(regmap, 0x21, hyst);
if (retval == 0) if (retval == 0)
retval = count; retval = count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment