diff options
Diffstat (limited to 'drivers/hwmon/sht15.c')
-rw-r--r-- | drivers/hwmon/sht15.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index 864a371f6eb9..a610e7880fb3 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/err.h> | 36 | #include <linux/err.h> |
37 | #include <linux/sht15.h> | 37 | #include <linux/sht15.h> |
38 | #include <linux/regulator/consumer.h> | 38 | #include <linux/regulator/consumer.h> |
39 | #include <linux/slab.h> | ||
39 | #include <asm/atomic.h> | 40 | #include <asm/atomic.h> |
40 | 41 | ||
41 | #define SHT15_MEASURE_TEMP 3 | 42 | #define SHT15_MEASURE_TEMP 3 |
@@ -302,13 +303,13 @@ error_ret: | |||
302 | **/ | 303 | **/ |
303 | static inline int sht15_calc_temp(struct sht15_data *data) | 304 | static inline int sht15_calc_temp(struct sht15_data *data) |
304 | { | 305 | { |
305 | int d1 = 0; | 306 | int d1 = temppoints[0].d1; |
306 | int i; | 307 | int i; |
307 | 308 | ||
308 | for (i = 1; i < ARRAY_SIZE(temppoints); i++) | 309 | for (i = ARRAY_SIZE(temppoints) - 1; i > 0; i--) |
309 | /* Find pointer to interpolate */ | 310 | /* Find pointer to interpolate */ |
310 | if (data->supply_uV > temppoints[i - 1].vdd) { | 311 | if (data->supply_uV > temppoints[i - 1].vdd) { |
311 | d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd) | 312 | d1 = (data->supply_uV - temppoints[i - 1].vdd) |
312 | * (temppoints[i].d1 - temppoints[i - 1].d1) | 313 | * (temppoints[i].d1 - temppoints[i - 1].d1) |
313 | / (temppoints[i].vdd - temppoints[i - 1].vdd) | 314 | / (temppoints[i].vdd - temppoints[i - 1].vdd) |
314 | + temppoints[i - 1].d1; | 315 | + temppoints[i - 1].d1; |
@@ -541,7 +542,12 @@ static int __devinit sht15_probe(struct platform_device *pdev) | |||
541 | /* If a regulator is available, query what the supply voltage actually is!*/ | 542 | /* If a regulator is available, query what the supply voltage actually is!*/ |
542 | data->reg = regulator_get(data->dev, "vcc"); | 543 | data->reg = regulator_get(data->dev, "vcc"); |
543 | if (!IS_ERR(data->reg)) { | 544 | if (!IS_ERR(data->reg)) { |
544 | data->supply_uV = regulator_get_voltage(data->reg); | 545 | int voltage; |
546 | |||
547 | voltage = regulator_get_voltage(data->reg); | ||
548 | if (voltage) | ||
549 | data->supply_uV = voltage; | ||
550 | |||
545 | regulator_enable(data->reg); | 551 | regulator_enable(data->reg); |
546 | /* setup a notifier block to update this if another device | 552 | /* setup a notifier block to update this if another device |
547 | * causes the voltage to change */ | 553 | * causes the voltage to change */ |