From: Guenter Roeck Date: Mon, 23 Apr 2012 03:58:51 +0000 (-0700) Subject: hwmon: (ntc_thermistor) Optimize and fix build warning X-Git-Tag: v3.5-rc1~115^2~5 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbe43a62762d2a6430cf6ed65d3459ce1e8ed46c;p=pandora-kernel.git hwmon: (ntc_thermistor) Optimize and fix build warning The following build warning is seen in some configurations: drivers/hwmon/ntc_thermistor.c: In function 'ntc_show_temp': drivers/hwmon/ntc_thermistor.c:293: warning: 'temp' may be used uninitialized in this function Fix the problem by re-arranging the code to overload return values with error codes, and by avoiding error returns whenever possible. Specifically, Simplify lookup_comp() to not return an error. Instead, return i_low == i_high if there is an exact match, or if the ohm value is outside the lookup table range. Modify get_temp_mC() to not return an error. Since it only returns an error after lookup_comp() returned an error, this is quite straightforward after above change. Separate ntc_thermistor_read() into a function to read the resistor value (which can return an error), and the call to get_temp_mC() which doesn't. Call the functions directly from ntc_show_temp(). Code was tested using a test program, comparing the result of the old and new versions of get_temp_mC() for resistor values between 0 and 2,000,000 ohm. As a side effect, this patch reduces code size by approximately 400 bytes on x86_64. Signed-off-by: Guenter Roeck Cc: Donggeun Kim Reviewed-by: Robert Coulson --- Reading git-diff-tree failed