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

Commit 2e3f83ee authored by Rama Krishna Phani A's avatar Rama Krishna Phani A Committed by Gerrit - the friendly Code Review server
Browse files

hwmon: qpnp-adc-voltage: Update calibration logic for VADC



Clients will call adc_tm api to set thresholds for continuous monitoring
of VADC channels. VADC calibration happens at the time of first VADC
read. There is a chance that clients can call adc_tm to set thresholds
even before calibration is done. In that case thresholds are set to
zero which is not expected. Update logic such that calibration happens
either through first VADC read or while clients setting thresholds.

Change-Id: I25c8635c7ec0e140a495e4197b80e3179f60061b
Signed-off-by: default avatarRama Krishna Phani A <rphani@codeaurora.org>
parent 241c08df
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1375,11 +1375,20 @@ int32_t qpnp_get_vadc_gain_and_offset(struct qpnp_vadc_chip *vadc,
				enum qpnp_adc_calib_type calib_type)
{
	int rc = 0;
	struct qpnp_vadc_result result;

	rc = qpnp_vadc_is_valid(vadc);
	if (rc < 0)
		return rc;

	if (!vadc->vadc_init_calib) {
		rc = qpnp_vadc_read(vadc, REF_125V, &result);
		if (rc) {
			pr_debug("vadc read failed with rc = %d\n", rc);
			return rc;
		}
	}

	switch (calib_type) {
	case CALIB_RATIOMETRIC:
	param->dy =