LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: sean.wang@mediatek.com, rjw@rjwysocki.net, khilman@baylibre.com
Cc: ulf.hansson@linaro.org, linux-mediatek@lists.infradead.org,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Weiyi Lu <weiyi.lu@mediatek.com>
Subject: Re: [PATCH v2 2/2] soc: mediatek: reuse regmap_read_poll_timeout helpers
Date: Fri, 27 Apr 2018 11:35:23 +0200	[thread overview]
Message-ID: <4274d8f7-dc1f-b0f9-026f-1a6196dcb730@gmail.com> (raw)
In-Reply-To: <ed866d3345a27b2c87b570562d9ad9132bca6062.1524465345.git.sean.wang@mediatek.com>



On 04/23/2018 08:42 AM, sean.wang@mediatek.com wrote:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> Reuse the common helpers regmap_read_poll_timeout provided by Linux core
> instead of an open-coded handling.
> 
> v1 -> v2:
>  - use macro definitions MTK_POLL_DELAY_US and MTK_POLL_TIMEOUT for
>    arguments sleep_us and timeout_us passing in regmap_read_poll_timeout.
>  - remove unnecessary linux/iopoll.h being included in.
> 
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Weiyi Lu <weiyi.lu@mediatek.com>
> ---
>  drivers/soc/mediatek/mtk-infracfg.c | 46 ++++++++++---------------------------
>  1 file changed, 12 insertions(+), 34 deletions(-)
> 

pushed to v4.17-next/soc

> diff --git a/drivers/soc/mediatek/mtk-infracfg.c b/drivers/soc/mediatek/mtk-infracfg.c
> index 8c310de..958861c 100644
> --- a/drivers/soc/mediatek/mtk-infracfg.c
> +++ b/drivers/soc/mediatek/mtk-infracfg.c
> @@ -17,6 +17,9 @@
>  #include <linux/soc/mediatek/infracfg.h>
>  #include <asm/processor.h>
>  
> +#define MTK_POLL_DELAY_US   10
> +#define MTK_POLL_TIMEOUT    (jiffies_to_usecs(HZ))
> +
>  #define INFRA_TOPAXI_PROTECTEN		0x0220
>  #define INFRA_TOPAXI_PROTECTSTA1	0x0228
>  #define INFRA_TOPAXI_PROTECTEN_SET	0x0260
> @@ -37,7 +40,6 @@
>  int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
>  		bool reg_update)
>  {
> -	unsigned long expired;
>  	u32 val;
>  	int ret;
>  
> @@ -47,22 +49,11 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
>  	else
>  		regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
>  
> -	expired = jiffies + HZ;
> -
> -	while (1) {
> -		ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
> -		if (ret)
> -			return ret;
> -
> -		if ((val & mask) == mask)
> -			break;
> +	ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
> +				       val, (val & mask) == mask,
> +				       MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
>  
> -		cpu_relax();
> -		if (time_after(jiffies, expired))
> -			return -EIO;
> -	}
> -
> -	return 0;
> +	return ret;
>  }
>  
>  /**
> @@ -80,30 +71,17 @@ 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;
> -	}
> +	ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
> +				       val, !(val & mask),
> +				       MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
>  
> -	return 0;
> +	return ret;
>  }
> 

  reply	other threads:[~2018-04-27  9:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23  6:42 [PATCH v2 1/2] regmap: include <linux/ktime.h> from include/linux/regmap.h sean.wang
2018-04-23  6:42 ` [PATCH v2 2/2] soc: mediatek: reuse regmap_read_poll_timeout helpers sean.wang
2018-04-27  9:35   ` Matthias Brugger [this message]
2018-05-11 11:25   ` Matthias Brugger
2018-04-23 10:03 ` [PATCH v2 1/2] regmap: include <linux/ktime.h> from include/linux/regmap.h Mark Brown
2018-04-23 10:11   ` Matthias Brugger
2018-04-23 11:50     ` Mark Brown
2018-04-23 14:07       ` Matthias Brugger
2018-04-24 17:31         ` Mark Brown
2018-04-24 17:46 ` Applied "regmap: include <linux/ktime.h> from include/linux/regmap.h" to the regmap tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4274d8f7-dc1f-b0f9-026f-1a6196dcb730@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sean.wang@mediatek.com \
    --cc=ulf.hansson@linaro.org \
    --cc=weiyi.lu@mediatek.com \
    --subject='Re: [PATCH v2 2/2] soc: mediatek: reuse regmap_read_poll_timeout helpers' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).