Skip to contentSkip to conversation

hwmon: (emc1403) Relax hysteresis limit write checks

PATCH In review Guenter Roeck 2 participants 2 messages May 12, 2014 – May 18, 2014 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 6/9 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.

---
 drivers/hwmon/emc1403.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/hwmon/emc1403.c +1 -6
index 877144c..13cac04 100644
@@ -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;
Signature · 7 lines
1.9.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v1 6/9
#1 lore raw
Quoted 17 lines · Guenter Roeck

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.

---
 drivers/hwmon/emc1403.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/hwmon/emc1403.c +0 -0
index 877144c..13cac04 100644
@@ -147,12 +147,7 @@ static ssize_t store_hyst(struct device *dev,
 		goto fail;
 
 	hyst = limit * 1000 - val;

drivers/hwmon/emc1403.c static ssize_t store_hyst(struct device *dev, · line 153

Quoted 10 lines
drivers/hwmon/emc1403.c +1 -6
-	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;
Signature · 7 lines
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors