Skip to content

Commit 8217a7a

Browse files
ndreysShawn Guo
authored andcommitted
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>
1 parent 9e98c67 commit 8217a7a

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

‎drivers/soc/imx/gpcv2.c‎

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
136136
GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ;
137137
const bool enable_power_control = !on;
138138
const bool has_regulator = !IS_ERR(domain->regulator);
139-
unsigned long deadline;
140139
int i, ret = 0;
140+
u32 pxx_req;
141141

142142
regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
143143
domain->bits.map, domain->bits.map);
@@ -169,30 +169,19 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
169169
* As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait
170170
* for PUP_REQ/PDN_REQ bit to be cleared
171171
*/
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;
196185
}
197186

198187
if (enable_power_control)

0 commit comments

Comments
 (0)