Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8236ca2a authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

hwmon: qpnp-adc-common: Fix negative temperature readings



Incorrect readings are seen during negative temperature range
on CHG_TEMP VADC channel. Fix scaling the temperature
using the correct cast type.

Change-Id: I0fb46280354d37969a66ac9ac03856270b8e6ad6
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent ac6766f8
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1589,10 +1589,13 @@ int32_t qpnp_adc_scale_pmi_chg_temp(struct qpnp_vadc_chip *vadc,

	pr_debug("raw_code:%x, v_adc:%lld\n", adc_code,
						adc_chan_result->physical);
	adc_chan_result->physical = ((PMI_CHG_SCALE_1) *
	adc_chan_result->physical = (int64_t) ((PMI_CHG_SCALE_1) *
					(adc_chan_result->physical * 2));
	adc_chan_result->physical += PMI_CHG_SCALE_2;
	do_div(adc_chan_result->physical, 1000000);
	adc_chan_result->physical = (int64_t) (adc_chan_result->physical +
							PMI_CHG_SCALE_2);
	adc_chan_result->physical = (int64_t) adc_chan_result->physical;
	adc_chan_result->physical = div64_s64(adc_chan_result->physical,
								1000000);

	return 0;
}