summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddartha Mohanadoss <smohanad@codeaurora.org>2017-06-12 13:01:48 -0700
committerSiddartha Mohanadoss <smohanad@codeaurora.org>2017-06-12 14:34:05 -0700
commitbe4c84ffe8d1ccfe205edfaae0e4f00e7749f5e8 (patch)
tree914407bc20d214146e7a61fc463212c6fecdf921
parentc1a2472056c800ff46e0ac21a4b67c179a570ad0 (diff)
iio: rradc: Update thermistor scaling
Scale the result with scaling coefficient before performing an integer division to retain the resolution. Change-Id: I11480099996e16e90736c667691ff0f057c02261 Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
-rw-r--r--drivers/iio/adc/qcom-rradc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/adc/qcom-rradc.c b/drivers/iio/adc/qcom-rradc.c
index 537cca877f66..5c20970ccbbb 100644
--- a/drivers/iio/adc/qcom-rradc.c
+++ b/drivers/iio/adc/qcom-rradc.c
@@ -331,8 +331,8 @@ static int rradc_post_process_therm(struct rradc_chip *chip,
int64_t temp;
/* K = code/4 */
- temp = div64_s64(adc_code, FG_ADC_RR_BATT_THERM_LSB_K);
- temp *= FG_ADC_SCALE_MILLI_FACTOR;
+ temp = ((int64_t)adc_code * FG_ADC_SCALE_MILLI_FACTOR);
+ temp = div64_s64(temp, FG_ADC_RR_BATT_THERM_LSB_K);
*result_millidegc = temp - FG_ADC_KELVINMIL_CELSIUSMIL;
return 0;