diff options
Diffstat (limited to 'drivers/hwmon/sht15.c')
-rw-r--r-- | drivers/hwmon/sht15.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index ebe38b680ee3..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) - 1; 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; |
@@ -332,12 +333,12 @@ static inline int sht15_calc_humid(struct sht15_data *data) | |||
332 | 333 | ||
333 | const int c1 = -4; | 334 | const int c1 = -4; |
334 | const int c2 = 40500; /* x 10 ^ -6 */ | 335 | const int c2 = 40500; /* x 10 ^ -6 */ |
335 | const int c3 = 2800; /* x10 ^ -9 */ | 336 | const int c3 = -2800; /* x10 ^ -9 */ |
336 | 337 | ||
337 | RHlinear = c1*1000 | 338 | RHlinear = c1*1000 |
338 | + c2 * data->val_humid/1000 | 339 | + c2 * data->val_humid/1000 |
339 | + (data->val_humid * data->val_humid * c3)/1000000; | 340 | + (data->val_humid * data->val_humid * c3)/1000000; |
340 | return (temp - 25000) * (10000 + 800 * data->val_humid) | 341 | return (temp - 25000) * (10000 + 80 * data->val_humid) |
341 | / 1000000 + RHlinear; | 342 | / 1000000 + RHlinear; |
342 | } | 343 | } |
343 | 344 | ||
@@ -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 */ |