Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933134Ab2BAV6R (ORCPT ); Wed, 1 Feb 2012 16:58:17 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33253 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755826Ab2BAVHr (ORCPT ); Wed, 1 Feb 2012 16:07:47 -0500 X-Sasl-enc: 3G2JY/R/lVaxu/IerRDBWRpYE6V6tH8GIdNIpOw5nJ1g 1328130466 X-Mailbox-Line: From gregkh@clark.kroah.org Wed Feb 1 12:15:32 2012 Message-Id: <20120201201532.470753596@clark.kroah.org> User-Agent: quilt/0.51-14.1 Date: Wed, 01 Feb 2012 12:14:19 -0800 From: Greg KH To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Jean Delvare , Guenter Roeck Subject: [17/20] hwmon: (f71805f) Fix clamping of temperature limits In-Reply-To: <20120201210055.GA25374@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1352 Lines: 47 2.6.32-longterm review patch. If anyone has any objections, please let me know. ------------------ From: Jean Delvare commit 86b2bbfdbd1fcc4a3aa62ccd3f245c40c5ad5b85 upstream. 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 Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/f71805f.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c @@ -281,11 +281,11 @@ 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; - return ((val + 500) / 1000); + if (val <= 0) + return 0; + if (val >= 1000 * 0xff) + return 0xff; + return (val + 500) / 1000; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/