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

Commit 2f364fe0 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-bms: always release output locks in bms driver



If a SPMI read error occurs, there can be a situation where the
BMS_HOLD_OREG bit is not set and the bms param lock is never released.
This can cause deadlocks and battery SoC to never move. Fix this by
releasing the locks after handling an error.

Change-Id: I880b8e1ed2ff1ec3ce701f1e9922c9aac353766a
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent bf850d5a
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1007,14 +1007,14 @@ static int read_soc_params_raw(struct qpnp_bms_chip *chip,
			chip->base + BMS1_OCV_FOR_SOC_DATA0, 2);
	if (rc) {
		pr_err("Error reading ocv: rc = %d\n", rc);
		return -ENXIO;
		goto param_err;
	}

	rc = read_cc_raw(chip, &raw->cc, CC);
	rc = read_cc_raw(chip, &raw->shdw_cc, SHDW_CC);
	if (rc) {
		pr_err("Failed to read raw cc data, rc = %d\n", rc);
		return rc;
		goto param_err;
	}

	unlock_output_data(chip);
@@ -1072,6 +1072,11 @@ static int read_soc_params_raw(struct qpnp_bms_chip *chip,
			raw->last_good_ocv_raw, raw->last_good_ocv_uv);
	pr_debug("cc_raw= 0x%llx\n", raw->cc);
	return 0;

param_err:
	unlock_output_data(chip);
	mutex_unlock(&chip->bms_output_lock);
	return rc;
}

static int calculate_pc(struct qpnp_bms_chip *chip, int ocv_uv,