Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp316022imp; Wed, 20 Feb 2019 00:23:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IaymBU+ms0wLUjc8VOKu0or+0oZe/lE8GTMFUoAZIBr1fPSvnXOg/3scNKP8CFslgj4iH4A X-Received: by 2002:a62:6d81:: with SMTP id i123mr20698400pfc.235.1550651022130; Wed, 20 Feb 2019 00:23:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550651022; cv=none; d=google.com; s=arc-20160816; b=cMyxIyRfCnfCApKUL+IB3d/OurQdA7lzca5NlgqEJGSuAkOOemiHNqAiszklTsbJcA gB3TKXlkc//jb5bMtUXscqD4q9tV3/suuVMjzPLCfMnJzvd/1N4iNbWsdLL+bdie50Ik u8IjJKU8CO5oiKAOiB1m1zAkVDI2IBKLkgIEqw+DGJg6CJzM2ddEQUmzmbPU5BDepEvl C0CaakLgeS+QpmaZd7okdPiNux1yNGnKTSBCoYPH2Oc0bcVnt2i+aAX50wuIiRAENtan hhzYyjUORqd/uY+GiINynFIM58nnweSs3Zr+404jxy/1DkpeZkOB1ohp0CLyWU9wLFzd dhoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=NCoF/2VcopYG1aDjNz3oNw6TxnGgP9ocTqXNTPWKu4Y=; b=ok4+KQpewzNrjC+Wff+dH99No7r6yp6JN0YsRAvOovkSMB3k3OG/R2WxfzKtPnWHF0 qfuUJIzyq/b3s54bmxqmaHbONHbbcOMUwlrgXV/U9RkKTQY6iQKn9IpOmvPNVLMCicgG ty5lU5HrvQnTvlI1YRMMiRBLegB46dD62qhghVV0bV75dfW9oBXWuw2YsgB8MAWGCr1N OgIY5jR/r4EdoC4JPjF7F87W6FTOmQSiyutzG6fBXMJH6zagOlPYoYX2IrRcFE1Msbn7 c+OvYnvDSkXA62uSyw8jUm51X0EIuz5fER62UAYjc/lDm3wQXm7zJonS3/HN3aGX5S// jLPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d65si18400866pfc.201.2019.02.20.00.23.26; Wed, 20 Feb 2019 00:23:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbfBTIWq (ORCPT + 99 others); Wed, 20 Feb 2019 03:22:46 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:52441 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfBTIWp (ORCPT ); Wed, 20 Feb 2019 03:22:45 -0500 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=localhost) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gwN9N-00069q-IH; Wed, 20 Feb 2019 09:22:42 +0100 Message-ID: <00169906c8509779a89dcd611098fbaea14bc7d8.camel@pengutronix.de> Subject: Re: [PATCH] soc: imx: gpcv2: Make use of regmap_read_poll_timeout() From: Lucas Stach To: Andrey Smirnov , Shawn Guo Cc: Chris Healy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Wed, 20 Feb 2019 09:22:39 +0100 In-Reply-To: <20190220021429.4910-1-andrew.smirnov@gmail.com> References: <20190220021429.4910-1-andrew.smirnov@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: Lucas Stach > Cc: Chris Healy > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org Reviewed-by: Lucas Stach > --- > 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)