Received: by 10.192.165.156 with SMTP id m28csp535559imm; Thu, 19 Apr 2018 03:25:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zbnHKHHQSxOEXslEOdgOkmQr7ypcbfV7EDwXwnWip08UiOsqyz/Gkvw9F6YcGvy5QH99W X-Received: by 2002:a17:902:bd41:: with SMTP id b1-v6mr5469518plx.302.1524133504070; Thu, 19 Apr 2018 03:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133504; cv=none; d=google.com; s=arc-20160816; b=ueNc/gRlcZ43l2lFh1Hkf+IcfdHshjDwXddY+x8gu/7I79Qn6lCHbl0FCWiQg5sTnG t+XBFKr6j/MA1/C9o79UWm/LT55TqiEggt/WBxdk4ez7sLbOkjsj/PWNnJYKzZKw9Czc THexLSxJkyWt/zJxcU2nZ3zCXctwc+nqz/QCyH7sVDMPgeKWC9jZHgu3aL8XMxsMfAOS uIkBNCJnqLkeM3PNF7lNbcYGH6q4YMjW8193rTrMdY5068gBiaJdDDhEAjpa14ml2VuS V1AM1msPbDekcc+57wMh1Ofb/owdXAm9G1kyHvIzvS5gPywYsn5hWWzre+IzdXfEg81t WaRw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=5Bty71wn993fA76/zXZ84POkhQ1jg2pjK1dvsAboWSI=; b=XmJoK/pSQuTLKeZxaAdDxzkudLdUPp5GkzZlfzJqUJQPSBb/S6x0wkKevAdldY0q+T ejNT7VB6mjCb1x1VDKlXZE9OXI5b9auEvVJjWsO3aWgUJdJW4Uxvb1zmjXD5RC/nkscp LvOh2W+M6B5gb9qdpzYUolOvey9mm01bT9HrkkDGtepAzzTdGh7lHRHmW42zgVHVhcra XR/JitiVEeBZEt8jC2EdGl5kQpYqtpsyUaf9KqoUZBtyVXJJ4lce8Pp0gt9COMREOoyo NRMImlCxHfMe95rFSqtBIhJlgiS743LwN6gZ2/irjNgsZJGm8WOjf+fVc2oKb3OJuJLU 9oNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R+uXsCpd; 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 i12si2835602pgq.35.2018.04.19.03.24.50; Thu, 19 Apr 2018 03:25:04 -0700 (PDT) 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=R+uXsCpd; 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 S1751876AbeDSKXm (ORCPT + 99 others); Thu, 19 Apr 2018 06:23:42 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40104 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeDSKXi (ORCPT ); Thu, 19 Apr 2018 06:23:38 -0400 Received: by mail-pf0-f195.google.com with SMTP id y66so2418871pfi.7; Thu, 19 Apr 2018 03:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5Bty71wn993fA76/zXZ84POkhQ1jg2pjK1dvsAboWSI=; b=R+uXsCpdZ7XtqV7RgvPmvxYE0dJ66smF76LTbjfNs0e9Ss5T2VKL/Dl/+n11ke7qvB rlc42Z24a/ek6V9yT/wx297J5LkelCGGWD1WNeHxO//GbVcpFfM/UZKB5LV+lxfWprLs 0WC4R3edEt24cxXLjdSHb5KD3CEq7xXgAoRVXZv30K5UV6b1DBSeJFJE0kr/PJpHlTfh PQ/424aSGYeaz665wWBR5Kc1iA3F1DYIctDcu6uNHPlvuDkW4R8SUtDcFBWHRWH9Hg1x oCZvs9RaDI1wg9blat2DRRSYknNLolGgu4esgzxfArVz2CMxkw3itFXTe87i+JmU81SD MoZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5Bty71wn993fA76/zXZ84POkhQ1jg2pjK1dvsAboWSI=; b=fb+6BBcaIPqE8UOvX6MmYa48PYSyLUVxEJ2TEypuFtc2e8RcpJUZjx6dJyC2o+ePEW nrucsDubeNTRFHlzF+yoVKi+5lOyZvBpnRa33je5q7JkGaRvJ4oAl3z6eHHurfecTqqP qVvYr7S0oxR02xxz9je5SMrGLELteHDeSVgiQIsZyjg1y3z97PB86iV3N6ETxCdClmQF BHwBtbN7Tbfju2mCRxBaW4wChG1PGZ64qDwuYvtlNNqJadBDAUGKg0ltrwJfYKed7u8N eHYjGqmOG/RyVD9+Ylv+lr54KDWPamQbL+o88cZdo8Jv9ZsXtC7PAuByetb7bJDiEvyR 5Rcg== X-Gm-Message-State: ALQs6tCi9JhhwlUD6j6sg/23C5yT84TCXHnZw+ENtWTZb6qynEInVz3L JN2BiZ2EzNsKrEEuBjTIrhE= X-Received: by 10.99.121.194 with SMTP id u185mr4613353pgc.409.1524133417946; Thu, 19 Apr 2018 03:23:37 -0700 (PDT) Received: from ziggy.stardust ([37.223.140.222]) by smtp.gmail.com with ESMTPSA id p13sm7799977pgn.18.2018.04.19.03.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 03:23:36 -0700 (PDT) Subject: Re: [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout helpers To: sean.wang@mediatek.com, robh+dt@kernel.org, mark.rutland@arm.com, marcel@holtmann.org, johan.hedberg@gmail.com Cc: devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson , Weiyi Lu References: <2f84f7695ea3223b8626a8369aa4ae5e0d03fdce.1522736996.git.sean.wang@mediatek.com> From: Matthias Brugger Openpgp: preference=signencrypt Autocrypt: addr=matthias.bgg@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFP1zgUBEAC21D6hk7//0kOmsUrE3eZ55kjc9DmFPKIz6l4NggqwQjBNRHIMh04BbCMY fL3eT7ZsYV5nur7zctmJ+vbszoOASXUpfq8M+S5hU2w7sBaVk5rpH9yW8CUWz2+ZpQXPJcFa OhLZuSKB1F5JcvLbETRjNzNU7B3TdS2+zkgQQdEyt7Ij2HXGLJ2w+yG2GuR9/iyCJRf10Okq gTh//XESJZ8S6KlOWbLXRE+yfkKDXQx2Jr1XuVvM3zPqH5FMg8reRVFsQ+vI0b+OlyekT/Xe 0Hwvqkev95GG6x7yseJwI+2ydDH6M5O7fPKFW5mzAdDE2g/K9B4e2tYK6/rA7Fq4cqiAw1+u EgO44+eFgv082xtBez5WNkGn18vtw0LW3ESmKh19u6kEGoi0WZwslCNaGFrS4M7OH+aOJeqK fx5dIv2CEbxc6xnHY7dwkcHikTA4QdbdFeUSuj4YhIZ+0QlDVtS1QEXyvZbZky7ur9rHkZvP ZqlUsLJ2nOqsmahMTIQ8Mgx9SLEShWqD4kOF4zNfPJsgEMB49KbS2o9jxbGB+JKupjNddfxZ HlH1KF8QwC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ctRA0gssE 3GRKuEIuXx1SDnchsfHg18gCCrEtYZ9czwNjVoV1Tv2lpzTTk+6HEJaQpMnPeAKbOeehq3gY KcvmDL+bRCTjmXg8WrBZdUuj0BCDYqneaUgVnp+wQogA3mHGVs281v1XZmjlsVmM9Y8VPE61 4zSiZQBL5CinBTTI8ssYlV/aIKYi0dxRcj6vYnAfUImOsdZ5AQja5xIqw1rwWWUOYb99 Message-ID: <6fd85b96-f076-36c7-8ff4-8e8ed252edb2@gmail.com> Date: Thu, 19 Apr 2018 12:23:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <2f84f7695ea3223b8626a8369aa4ae5e0d03fdce.1522736996.git.sean.wang@mediatek.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/03/2018 09:15 AM, sean.wang@mediatek.com wrote: > From: Sean Wang > > Reuse the common helpers regmap_read_poll_timeout provided by Linux core > instead of an open-coded handling. > > Signed-off-by: Sean Wang > Cc: Matthias Brugger > Cc: Ulf Hansson > Cc: Weiyi Lu > --- > drivers/soc/mediatek/mtk-infracfg.c | 45 +++++++++---------------------------- > 1 file changed, 10 insertions(+), 35 deletions(-) > > diff --git a/drivers/soc/mediatek/mtk-infracfg.c b/drivers/soc/mediatek/mtk-infracfg.c > index 8c310de..b849aa5 100644 > --- a/drivers/soc/mediatek/mtk-infracfg.c > +++ b/drivers/soc/mediatek/mtk-infracfg.c > @@ -12,6 +12,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -37,7 +38,6 @@ > int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, > bool reg_update) > { > - unsigned long expired; > u32 val; > int ret; > > @@ -47,22 +47,11 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, > else > regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask); > > - expired = jiffies + HZ; > + ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1, > + val, (val & mask) == mask, 10, > + jiffies_to_usecs(HZ)); To align with the changes in scpsys, please define MTK_POLL_DELAY_US and MTK_POLL_TIMEOUT. I'm not really fan of passing macros as function arguments. Other then that, the patch looks good. Thanks a lot, Matthias > > - while (1) { > - ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val); > - if (ret) > - return ret; > - > - if ((val & mask) == mask) > - break; > - > - cpu_relax(); > - if (time_after(jiffies, expired)) > - return -EIO; > - } > - > - return 0; > + return ret; > } > > /** > @@ -80,30 +69,16 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, > int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask, > bool reg_update) > { > - unsigned long expired; > int ret; > + u32 val; > > if (reg_update) > regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0); > else > regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask); > > - expired = jiffies + HZ; > - > - while (1) { > - u32 val; > - > - ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val); > - if (ret) > - return ret; > - > - if (!(val & mask)) > - break; > - > - cpu_relax(); > - if (time_after(jiffies, expired)) > - return -EIO; > - } > - > - return 0; > + ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1, > + val, !(val & mask), 10, > + jiffies_to_usecs(HZ)); > + return ret; > } >