Skip to contentSkip to conversation

drivers/hwmon/emc1403.c: fix inverted set_hyst()

PATCH In review Josef Gajdusek 2 participants 2 messages May 11, 2014 – May 12, 2014 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/hwmon/emc1403.c: fix inverted set_hyst()

Fixes inverted set_hyst() (i. e. writing 76000 actually set it to 74000)

---

drivers/hwmon/emc1403.c +1 -1
index 90ec117..61d89d6 100644
@@ -163,7 +163,7 @@ static ssize_t store_hyst(struct device *dev,
 	if (retval < 0)
 		goto fail;
 
-	hyst = val - retval * 1000;
+	hyst = retval * 1000 - val;
 	hyst = DIV_ROUND_CLOSEST(hyst, 1000);
 	if (hyst < 0 || hyst > 255) {
 		retval = -ERANGE;

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

Reviewed-by on v1 1/1
#1 lore raw

Hi Josef,

Quoted 1 line · Josef Gajdusek

Fixes inverted set_hyst() (i. e. writing 76000 actually set it to 74000)

This is a rather poor description of the symptoms. The typical result from the bug is that you can't actually set the hysteresis value, the driver with fail with "write error: Numerical result out of range". Writing an hysteresis value above the critical limit to get the driver to set it below that limit, is the workaround, not the symptom.

Also, the function is called store_hyst(), not set_hyst().

Quoted 7 lines

---

drivers/hwmon/emc1403.c +0 -0
index 90ec117..61d89d6 100644

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

Quoted 8 lines
drivers/hwmon/emc1403.c +1 -1
@@ -163,7 +163,7 @@ static ssize_t store_hyst(struct device *dev,
 	if (retval < 0)
 		goto fail;
 
-	hyst = val - retval * 1000;
+	hyst = retval * 1000 - val;
 	hyst = DIV_ROUND_CLOSEST(hyst, 1000);
 	if (hyst < 0 || hyst > 255) {
 		retval = -ERANGE;

Anyway, fix is correct, good catch.

This should go to stable trees. Guenter, I'll let you deal with this, thanks.

Signature · 7 lines
Jean Delvare
SUSE L3 Support

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