Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Axel Lin <axel.lin@ingics.com>
Acked-by: Nishanth Menon <nm@ti.com>
Link: https://lore.kernel.org/r/20190929095848.21960-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Axel Lin and committed by
Mark Brown
f64db548 a72865f0

+8 -18
+8 -18
drivers/regulator/ti-abb-regulator.c
··· 173 173 while (timeout++ <= abb->settling_time) { 174 174 status = ti_abb_check_txdone(abb); 175 175 if (status) 176 - break; 176 + return 0; 177 177 178 178 udelay(1); 179 179 } 180 180 181 - if (timeout > abb->settling_time) { 182 - dev_warn_ratelimited(dev, 183 - "%s:TRANXDONE timeout(%duS) int=0x%08x\n", 184 - __func__, timeout, readl(abb->int_base)); 185 - return -ETIMEDOUT; 186 - } 187 - 188 - return 0; 181 + dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n", 182 + __func__, timeout, readl(abb->int_base)); 183 + return -ETIMEDOUT; 189 184 } 190 185 191 186 /** ··· 200 205 201 206 status = ti_abb_check_txdone(abb); 202 207 if (!status) 203 - break; 208 + return 0; 204 209 205 210 udelay(1); 206 211 } 207 212 208 - if (timeout > abb->settling_time) { 209 - dev_warn_ratelimited(dev, 210 - "%s:TRANXDONE timeout(%duS) int=0x%08x\n", 211 - __func__, timeout, readl(abb->int_base)); 212 - return -ETIMEDOUT; 213 - } 214 - 215 - return 0; 213 + dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n", 214 + __func__, timeout, readl(abb->int_base)); 215 + return -ETIMEDOUT; 216 216 } 217 217 218 218 /**