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

soc: imx: gpcv2: Make use of regmap_read_poll_timeout()

Replace explicit polling loop with a call to
regmap_read_poll_timeout() to avoid code repetition. Also fix
misspelled "failed" while at it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Chris Healy <cphealy@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>

authored by

Andrey Smirnov and committed by
Shawn Guo
8217a7a2 9e98c678

+14 -25
+14 -25
drivers/soc/imx/gpcv2.c
··· 136 136 GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ; 137 137 const bool enable_power_control = !on; 138 138 const bool has_regulator = !IS_ERR(domain->regulator); 139 - unsigned long deadline; 140 139 int i, ret = 0; 140 + u32 pxx_req; 141 141 142 142 regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING, 143 143 domain->bits.map, domain->bits.map); ··· 169 169 * As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait 170 170 * for PUP_REQ/PDN_REQ bit to be cleared 171 171 */ 172 - deadline = jiffies + msecs_to_jiffies(1); 173 - while (true) { 174 - u32 pxx_req; 175 - 176 - regmap_read(domain->regmap, offset, &pxx_req); 177 - 178 - if (!(pxx_req & domain->bits.pxx)) 179 - break; 180 - 181 - if (time_after(jiffies, deadline)) { 182 - dev_err(domain->dev, "falied to command PGC\n"); 183 - ret = -ETIMEDOUT; 184 - /* 185 - * If we were in a process of enabling a 186 - * domain and failed we might as well disable 187 - * the regulator we just enabled. And if it 188 - * was the opposite situation and we failed to 189 - * power down -- keep the regulator on 190 - */ 191 - on = !on; 192 - break; 193 - } 194 - 195 - cpu_relax(); 172 + ret = regmap_read_poll_timeout(domain->regmap, offset, pxx_req, 173 + !(pxx_req & domain->bits.pxx), 174 + 0, USEC_PER_MSEC); 175 + if (ret) { 176 + dev_err(domain->dev, "failed to command PGC\n"); 177 + /* 178 + * If we were in a process of enabling a 179 + * domain and failed we might as well disable 180 + * the regulator we just enabled. And if it 181 + * was the opposite situation and we failed to 182 + * power down -- keep the regulator on 183 + */ 184 + on = !on; 196 185 } 197 186 198 187 if (enable_power_control)