lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <00169906c8509779a89dcd611098fbaea14bc7d8.camel@pengutronix.de>
Date:   Wed, 20 Feb 2019 09:22:39 +0100
From:   Lucas Stach <l.stach@...gutronix.de>
To:     Andrey Smirnov <andrew.smirnov@...il.com>,
        Shawn Guo <shawnguo@...nel.org>
Cc:     Chris Healy <cphealy@...il.com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] soc: imx: gpcv2: Make use of regmap_read_poll_timeout()

Am Dienstag, den 19.02.2019, 18:14 -0800 schrieb Andrey Smirnov:
> 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@...il.com>
> Cc: Lucas Stach <l.stach@...gutronix.de>
> Cc: Chris Healy <cphealy@...il.com>
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-kernel@...r.kernel.org

Reviewed-by: Lucas Stach <l.stach@...gutronix.de>

> ---
>  drivers/soc/imx/gpcv2.c | 39 ++++++++++++++-------------------------
>  1 file changed, 14 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
> index 176f473127b6..e06bf12a1e4b 100644
> --- a/drivers/soc/imx/gpcv2.c
> +++ b/drivers/soc/imx/gpcv2.c
> @@ -136,8 +136,8 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
>  		GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ;
>  	const bool enable_power_control = !on;
>  	const bool has_regulator = !IS_ERR(domain->regulator);
> -	unsigned long deadline;
>  	int i, ret = 0;
> +	u32 pxx_req;
>  
>  	regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
>  			   domain->bits.map, domain->bits.map);
> @@ -169,30 +169,19 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
>  	 * As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait
>  	 * for PUP_REQ/PDN_REQ bit to be cleared
>  	 */
> -	deadline = jiffies + msecs_to_jiffies(1);
> -	while (true) {
> -		u32 pxx_req;
> -
> -		regmap_read(domain->regmap, offset, &pxx_req);
> -
> -		if (!(pxx_req & domain->bits.pxx))
> -			break;
> -
> -		if (time_after(jiffies, deadline)) {
> -			dev_err(domain->dev, "falied to command PGC\n");
> -			ret = -ETIMEDOUT;
> -			/*
> -			 * If we were in a process of enabling a
> -			 * domain and failed we might as well disable
> -			 * the regulator we just enabled. And if it
> -			 * was the opposite situation and we failed to
> -			 * power down -- keep the regulator on
> -			 */
> -			on = !on;
> -			break;
> -		}
> -
> -		cpu_relax();
> +	ret = regmap_read_poll_timeout(domain->regmap, offset, pxx_req,
> +				       !(pxx_req & domain->bits.pxx),
> +				       0, USEC_PER_MSEC);
> +	if (ret) {
> +		dev_err(domain->dev, "failed to command PGC\n");
> +		/*
> +		 * If we were in a process of enabling a
> +		 * domain and failed we might as well disable
> +		 * the regulator we just enabled. And if it
> +		 * was the opposite situation and we failed to
> +		 * power down -- keep the regulator on
> +		 */
> +		on = !on;
>  	}
>  
>  	if (enable_power_control)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ