aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/lm85.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 4ee9388df983..94a10ecd24df 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -174,20 +174,13 @@ static int RANGE_TO_REG(int range)
174{ 174{
175 int i; 175 int i;
176 176
177 if (range >= lm85_range_map[15])
178 return 15;
179
180 /* Find the closest match */ 177 /* Find the closest match */
181 for (i = 14; i >= 0; --i) { 178 for (i = 0; i < 15; ++i) {
182 if (range >= lm85_range_map[i]) { 179 if (range <= (lm85_range_map[i] + lm85_range_map[i + 1]) / 2)
183 if ((lm85_range_map[i + 1] - range) < 180 break;
184 (range - lm85_range_map[i]))
185 return i + 1;
186 return i;
187 }
188 } 181 }
189 182
190 return 0; 183 return i;
191} 184}
192#define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f] 185#define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f]
193 186