Browse Source

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>
Guenter Roeck 11 năm trước cách đây
mục cha
commit
ceeaa70c0f
1 tập tin đã thay đổi với 1 bổ sung6 xóa
  1. 1 6
      drivers/hwmon/emc1403.c

+ 1 - 6
drivers/hwmon/emc1403.c

@@ -147,12 +147,7 @@ static ssize_t store_hyst(struct device *dev,
 		goto fail;
 
 	hyst = limit * 1000 - val;
-	hyst = DIV_ROUND_CLOSEST(hyst, 1000);
-	if (hyst < 0 || hyst > 255) {
-		retval = -ERANGE;
-		goto fail;
-	}
-
+	hyst = clamp_val(DIV_ROUND_CLOSEST(hyst, 1000), 0, 255);
 	retval = regmap_write(regmap, 0x21, hyst);
 	if (retval == 0)
 		retval = count;