From patchwork Wed Feb 20 02:14:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10821061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A52CD922 for ; Wed, 20 Feb 2019 02:15:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A7A02DB02 for ; Wed, 20 Feb 2019 02:15:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E7212DB04; Wed, 20 Feb 2019 02:15:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F2952DB02 for ; Wed, 20 Feb 2019 02:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tO3lx7zSpmIbjyolE7jJWpWaqnkQIXyzWezADYJ50F0=; b=gSVPE8BppaRO97 IYgq7cVuMwRit3ztNKjDP8tr/NGuToj9tJEsEjRhDgJ2vh0RsPH8hn/p50CxPFUyEZ+x4GolVlg01 TP5lwyn1h8xreY6104lnNF9vtH3nTbk4aA2ognIsnXiFNbk/gk6MSCLuN5L2D2Z5tR4pmNjSwQLdm w8r3qm9WgqoCgoUunYuifILr/jWrZmUO7A9lbs9lyBwEOBjooPt/oZxl5k8M1Mn+/qOsQyiMDCEDX YNAOcSX8a1xPjAm8PD05mpLDANOksBuHiVlDDcnRJUcYJ7ibtXJwW0Rin7VJ2q18UfLZa01hIIUEJ ybd4p87LPfVTReAEqQuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwHPd-00030m-TQ; Wed, 20 Feb 2019 02:15:05 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwHPZ-0002c9-Ui for linux-arm-kernel@lists.infradead.org; Wed, 20 Feb 2019 02:15:03 +0000 Received: by mail-pg1-x543.google.com with SMTP id u9so7517485pgo.7 for ; Tue, 19 Feb 2019 18:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SqagvOGzM+1NbNVkTuVd8N0ntUQuQbmaSYvM2+e2Zg8=; b=OPNU7CdHUnvsrHQP1WsVmpt3YtGi9dkv6hlltMDg/aWk3Ynbgzi5mV8Pmxbn7vfMhT CV1eKKTuSN2Z9218FzZmc8tbrRRgYUZlzzKoUGFKHnbecRi2M+CwShNKgnvAwEEE27BV Na7oJ0FSQF4Cgg8flRXk2LhZlK+wfwDsqyjq9nPpo/qYYJrRQO3gaXUXXp62a9DSt6IX R+aUI3fmsC+GrRGWerZG0z6F8FFebBPgx270RTT9IZ9+zEj+QPl5FZHsovrUQIgbkRQK soUviez9qgwTNGH38rQXqWLtxzk0Z5FcidyAdNaoVPLiqIoR5CcGhWpSliMw+ID1/Tcg TVeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SqagvOGzM+1NbNVkTuVd8N0ntUQuQbmaSYvM2+e2Zg8=; b=sX/0qtmdyH99NcwgtGwHmBVLDCEkUJ8qkUG0NsVp6ENUFqwj0gexY9Wnij/W4q2QnO 7/uGr7JEBUwHjSoN0SIDaVzmS7hjzsH4OCWOH3E+FUBA5gj0ItYhdJoAHX7L5vSajlsu uuzKwHtAyxQY8UKN7B3FfUjpOVjnPayyuU2EVDbbJUZlzIXTluTliZceEEVvjHVIyACz CVvXZzXRXySoutwVINUbWnMpyloHDJFVYiwhEOgVpQcIO705LefZlT+ek/TZQmRWRFou czZWniSgtl9x2A3wOsAiODs7+MKadtojiExNe06bUWGDn+863DNIAwmdPUwsSgB/VOqi g1cg== X-Gm-Message-State: AHQUAuY5LejyRXs9UYsNzr0mpeD2r0VpWSqNbkM4me4h8m5rRu5o2tLU BDd7KpDAkF8F7PadoE1zy8U= X-Google-Smtp-Source: AHgI3IYwYyP9Qs8ZBGutbuEyX7IMDi/EN/z8BV0g1GY/Knjyz7SMhhVUhgVtIrJiis5U7vwGLKrSbw== X-Received: by 2002:a62:f517:: with SMTP id n23mr32599145pfh.209.1550628900315; Tue, 19 Feb 2019 18:15:00 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id e5sm6130957pfd.73.2019.02.19.18.14.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Feb 2019 18:14:59 -0800 (PST) From: Andrey Smirnov To: Shawn Guo Subject: [PATCH] soc: imx: gpcv2: Make use of regmap_read_poll_timeout() Date: Tue, 19 Feb 2019 18:14:29 -0800 Message-Id: <20190220021429.4910-1-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190219_181502_109626_BFC10A9E X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Smirnov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chris Healy , Lucas Stach Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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)