[PATCH] hwmon: (f71805f) Fix clamping of temperature limits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Properly clamp temperature limits set by the user. Without this fix,
attempts to write temperature limits above the maximum supported by
the chip (255 degrees Celsius) would arbitrarily and unexpectedly
result in the limit being set to 0 degree Celsius.

Signed-off-by: Jean Delvare <khali@xxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
 drivers/hwmon/f71805f.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- linux-3.3-rc1.orig/drivers/hwmon/f71805f.c	2012-01-20 14:37:27.449912137 +0100
+++ linux-3.3-rc1/drivers/hwmon/f71805f.c	2012-01-20 14:58:33.600930905 +0100
@@ -283,10 +283,10 @@ static inline long temp_from_reg(u8 reg)
 
 static inline u8 temp_to_reg(long val)
 {
-	if (val < 0)
-		val = 0;
-	else if (val > 1000 * 0xff)
-		val = 0xff;
+	if (val <= 0)
+		return 0;
+	if (val >= 1000 * 0xff)
+		return 0xff;
 	return (val + 500) / 1000;
 }
 


-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux