aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@gmail.com>2013-09-20 07:51:56 -0400
committerMark Brown <broonie@linaro.org>2013-09-30 06:43:12 -0400
commit5df529d440aa4f0e67be9af3718e7edf05db7d02 (patch)
tree4ea23e91d0a270ba4bcea67882b1c4f331b4bf69
parent043c998f95036e7fc796b240ab5ba49a8de36df3 (diff)
regulator: core: Reduce busy-wait looping
Keep busy-wait looping to a minimum while waiting for a regulator to ramp-up to the target voltage. This follows the guidelines set forth in Documentation/timers/timers-howto.txt and assumes that regulators are never enabled in atomic context. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/core.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ad154247bb90..5075ed1e94a6 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1740,11 +1740,39 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
1740 * together. */ 1740 * together. */
1741 trace_regulator_enable_delay(rdev_get_name(rdev)); 1741 trace_regulator_enable_delay(rdev_get_name(rdev));
1742 1742
1743 if (delay >= 1000) { 1743 /*
1744 mdelay(delay / 1000); 1744 * Delay for the requested amount of time as per the guidelines in:
1745 udelay(delay % 1000); 1745 *
1746 } else if (delay) { 1746 * Documentation/timers/timers-howto.txt
1747 udelay(delay); 1747 *
1748 * The assumption here is that regulators will never be enabled in
1749 * atomic context and therefore sleeping functions can be used.
1750 */
1751 if (delay) {
1752 unsigned int ms = delay / 1000;
1753 unsigned int us = delay % 1000;
1754
1755 if (ms > 0) {
1756 /*
1757 * For small enough values, handle super-millisecond
1758 * delays in the usleep_range() call below.
1759 */
1760 if (ms < 20)
1761 us += ms * 1000;
1762 else
1763 msleep(ms);
1764 }
1765
1766 /*
1767 * Give the scheduler some room to coalesce with any other
1768 * wakeup sources. For delays shorter than 10 us, don't even
1769 * bother setting up high-resolution timers and just busy-
1770 * loop.
1771 */
1772 if (us >= 10)
1773 usleep_range(us, us + 100);
1774 else
1775 udelay(us);
1748 } 1776 }
1749 1777
1750 trace_regulator_enable_complete(rdev_get_name(rdev)); 1778 trace_regulator_enable_complete(rdev_get_name(rdev));