mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 23:24:22 -04:00
drivers: thermal: tsens: Common get_temp() learns to do ADC conversion
get_temp() learns to return temperature regardless of whether it is returned as ADC code or direct temperature. Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
This commit is contained in:
parent
c8b6169093
commit
14bbe98811
1 changed files with 9 additions and 4 deletions
|
|
@ -129,10 +129,15 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
mask = GENMASK(priv->fields[LAST_TEMP_0].msb,
|
||||
priv->fields[LAST_TEMP_0].lsb);
|
||||
/* Convert temperature from deciCelsius to milliCelsius */
|
||||
*temp = sign_extend32(last_temp, fls(mask) - 1) * 100;
|
||||
if (priv->feat->adc) {
|
||||
/* Convert temperature from ADC code to milliCelsius */
|
||||
*temp = code_to_degc(last_temp, s) * 1000;
|
||||
} else {
|
||||
mask = GENMASK(priv->fields[LAST_TEMP_0].msb,
|
||||
priv->fields[LAST_TEMP_0].lsb);
|
||||
/* Convert temperature from deciCelsius to milliCelsius */
|
||||
*temp = sign_extend32(last_temp, fls(mask) - 1) * 100;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue