Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp65843imp; Tue, 19 Feb 2019 18:17:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IYw1QcMbA+FvmMK7qyUWo7BAceTz+A6KgA8ZKiR8BFXkVqmIZyM4y7f2Wl8of7mJOFmTQz6 X-Received: by 2002:a17:902:b089:: with SMTP id p9mr34242288plr.271.1550629039172; Tue, 19 Feb 2019 18:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550629039; cv=none; d=google.com; s=arc-20160816; b=z/s4WDdtiJQCgCFYmH8lwCIu/khuTwpNlmPvL4Jk34ODSyHS2Q29rg0sEMs2ga8zZd kYE6wGYJggdXkyL6TZVjEY6whtLQ0Jvn2DVD3fnTbyH02CX5KJmlB4sOqnB5nMRi0av1 sJ8ZDp0FrirAA+L/21/bH0EvMgUboWZfEdpu9V5+Ou5HaL2p+UK+mIOimt/pl5tjqq0o +8Cs2tG7aGtw64/uwvpUPPLqFLnWcPDo8DW+7nUBsicnlSp7QRd3c6znGl0NLaIPNPqi fLECD5mY+w6toKKPeDxq2L+hFb9imsmmpPz9GjkhOHHtOTgMVxFCDu51II1tx2Dz+itc zWBg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=SqagvOGzM+1NbNVkTuVd8N0ntUQuQbmaSYvM2+e2Zg8=; b=bS2gQIxBOV8AjyRkbf7fmA56lkScboSGv7sb4puSjm04JXJSWV/kU5OdpyWclPAID4 HTGeR7FWtNFnM8gl26hxF2JNn6uf4Zkpn3UlZiRUhwthrflBVe9OJB+Eb7+RWmXMCMI1 GDy2e6tccDxD7tQLEcHSvEYsb4zn4vmFAm8lnHosoNb1TVS2OyGu5XRsdKLKGenDYJMp QZMtemKB0ZTFWi/mIy6kPpN8kGIhgBF5gYDRpKjXxs0jeXNAOPE+YHmGn2SKHdjVGAKp RW4MODzSTIyTFV7YPHRzFPc1FapQnxWWh6Po0bSjSBfrFpR95LH/Zut+5RPD3RNW9NIX BfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OPNU7CdH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si4513282pgd.18.2019.02.19.18.17.04; Tue, 19 Feb 2019 18:17:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OPNU7CdH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730238AbfBTCPC (ORCPT + 99 others); Tue, 19 Feb 2019 21:15:02 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36260 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbfBTCPB (ORCPT ); Tue, 19 Feb 2019 21:15:01 -0500 Received: by mail-pf1-f195.google.com with SMTP id n22so11127891pfa.3 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=ansAvKgHzsw+MZaH4RptH9rHMru/14i71bSq3n57hTYONJww6fUrkmeX6/dWK05/Pd VEPEwP0U+9ZOdp2Cj0mAODFGwoy0Mv9kMY5MsnDOkuv1b7/1wtbHNMh0G2vYW8Ow3Rt6 1bp0lwajv9MeKxRwZ0vmUrGx9RmX0cYoNxIV6zEiz+H1MQOlkw+q3YxfkCDu40Wgt4oW bs1kyQSRgyA+TgoFOK6eMohg6IPVqOUIE6nl0uNQRyd9nobuAYCILMDCD2tyBGMcrm7d 9lZ6l0v7mMOFMwUJtR0/n9eylgKfcZNyPup9lQWq/+ybUD7IurPP1A6mU9rESglxlja3 3QJg== X-Gm-Message-State: AHQUAuZNpvJ2nsJjo0BObjppUMR6OjO6La/sbcNvbiCjcVbRCPUQwZd8 SKQM/tQ34lInh0+GesEfwiM= 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 Cc: Andrey Smirnov , Lucas Stach , Chris Healy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) -- 2.20.1