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

Commit 1dd5d61f authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

soc: qcom: qpnp-pbs: Fix the retry variable check logic



In case of a failure the 'retries' variable becomes
negative thus bypassing the failure check. Fix this.

While at it, also fix the return from the error path.

Change-Id: I40ad767f4faf68b1b83c8b2cd1675af83318d96b
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 7e9bcbf5
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -115,7 +115,7 @@ static int qpnp_pbs_wait_for_ack(struct qpnp_pbs *pbs, u8 bit_pos)
	u16 retries = 2000;
	u16 retries = 2000;
	u8 val;
	u8 val;


	while (retries--) {
	while (retries) {
		rc = qpnp_pbs_read(pbs, pbs->base +
		rc = qpnp_pbs_read(pbs, pbs->base +
					PBS_CLIENT_SCRATCH2, &val, 1);
					PBS_CLIENT_SCRATCH2, &val, 1);
		if (rc < 0) {
		if (rc < 0) {
@@ -144,6 +144,7 @@ static int qpnp_pbs_wait_for_ack(struct qpnp_pbs *pbs, u8 bit_pos)
		}
		}


		usleep_range(QPNP_PBS_RETRY_SLEEP, QPNP_PBS_RETRY_SLEEP + 100);
		usleep_range(QPNP_PBS_RETRY_SLEEP, QPNP_PBS_RETRY_SLEEP + 100);
		retries--;
	}
	}


	if (!retries) {
	if (!retries) {
@@ -282,11 +283,8 @@ int qpnp_pbs_trigger_event(struct device_node *dev_node, u8 bitmap)


error:
error:
	/* Clear all the requested bitmap */
	/* Clear all the requested bitmap */
	rc = qpnp_pbs_masked_write(pbs, pbs->base + PBS_CLIENT_SCRATCH1,
	qpnp_pbs_masked_write(pbs, pbs->base + PBS_CLIENT_SCRATCH1,
						bitmap, 0);
						bitmap, 0);
	if (rc < 0)
		pr_err("Failed to clear %x reg bit rc=%d\n",
					PBS_CLIENT_SCRATCH1, rc);
out:
out:
	mutex_unlock(&pbs->pbs_lock);
	mutex_unlock(&pbs->pbs_lock);