From: Axel Lin Date: Tue, 5 Aug 2014 02:08:31 +0000 (+0800) Subject: hwmon: (lm92) Prevent overflow problem when writing large limits X-Git-Tag: omap-for-v3.17/fixes-against-rc2~68^2~14 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b963089161b8fb244889c972edf553b9d737545;p=pandora-kernel.git hwmon: (lm92) Prevent overflow problem when writing large limits On platforms with sizeof(int) < sizeof(long), writing a temperature limit larger than MAXINT will result in unpredictable limit values written to the chip. Avoid auto-conversion from long to int to fix the problem. The hysteresis temperature range depends on the value of data->temp[attr->index], since val is subtracted from it. Use a wider clamp, [-120000, 220000] should do to cover the possible range. Also add missing TEMP_TO_REG() on writes into cached hysteresis value. Also uses clamp_val to simplify the code a bit. Signed-off-by: Axel Lin [Guenter Roeck: Fixed double TEMP_TO_REG on hysteresis updates] Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck --- Reading git-diff-tree failed