All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: (f71805f) Fix clamping of temperature limits
@ 2012-01-20 15:09 Jean Delvare
  2012-01-20 15:22 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jean Delvare @ 2012-01-20 15:09 UTC (permalink / raw)
  To: lm-sensors

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@linux-fr.org>
Cc: stable@vger.kernel.org
---
 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@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-20 17:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20 15:09 [lm-sensors] [PATCH] hwmon: (f71805f) Fix clamping of temperature limits Jean Delvare
2012-01-20 15:22 ` Guenter Roeck
2012-01-20 16:41 ` Jean Delvare
2012-01-20 17:06 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.