Unverified Commit f64db548 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone



ti_abb_wait_txdone() may return -ETIMEDOUT when ti_abb_check_txdone()
returns true in the latest iteration of the while loop because the timeout
value is abb->settling_time + 1. Similarly, ti_abb_clear_all_txdone() may
return -ETIMEDOUT when ti_abb_check_txdone() returns false in the latest
iteration of the while loop. Fix it.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarNishanth Menon <nm@ti.com>
Link: https://lore.kernel.org/r/20190929095848.21960-1-axel.lin@ingics.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a72865f0
Loading
Loading
Loading
Loading
+8 −18
Original line number Diff line number Diff line
@@ -173,21 +173,16 @@ static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb)
	while (timeout++ <= abb->settling_time) {
		status = ti_abb_check_txdone(abb);
		if (status)
			break;
			return 0;

		udelay(1);
	}

	if (timeout > abb->settling_time) {
		dev_warn_ratelimited(dev,
				     "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
	dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
			     __func__, timeout, readl(abb->int_base));
	return -ETIMEDOUT;
}

	return 0;
}

/**
 * ti_abb_clear_all_txdone() - clears ABB tranxdone event
 * @dev:	device
@@ -205,21 +200,16 @@ static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb)

		status = ti_abb_check_txdone(abb);
		if (!status)
			break;
			return 0;

		udelay(1);
	}

	if (timeout > abb->settling_time) {
		dev_warn_ratelimited(dev,
				     "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
	dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
			     __func__, timeout, readl(abb->int_base));
	return -ETIMEDOUT;
}

	return 0;
}

/**
 * ti_abb_program_ldovbb() - program LDOVBB register for override value
 * @dev:	device