All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Wang <sean.wang@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: <robh+dt@kernel.org>, <mark.rutland@arm.com>,
	<marcel@holtmann.org>, <johan.hedberg@gmail.com>,
	<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" <ulf.hansson@linaro.org>,
	Weiyi Lu <weiyi.lu@mediatek.com>
Subject: Re: [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout helpers
Date: Fri, 20 Apr 2018 11:42:54 +0800	[thread overview]
Message-ID: <1524195774.26454.1.camel@mtkswgap22> (raw)
In-Reply-To: <6fd85b96-f076-36c7-8ff4-8e8ed252edb2@gmail.com>

On Thu, 2018-04-19 at 12:23 +0200, Matthias Brugger wrote:
> 
> On 04/03/2018 09:15 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.
> > 
> > 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 | 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 <linux/export.h>
> > +#include <linux/iopoll.h>
> >  #include <linux/jiffies.h>
> >  #include <linux/regmap.h>
> >  #include <linux/soc/mediatek/infracfg.h>
> > @@ -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.
> 

Agreed on. will have an improve on it

thanks!

> 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;
> >  }
> > 

WARNING: multiple messages have this Message-ID (diff)
From: Sean Wang <sean.wang@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: robh+dt@kernel.org, mark.rutland@arm.com, marcel@holtmann.org,
	johan.hedberg@gmail.com, 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 <ulf.hansson@linaro.org>,
	Weiyi Lu <weiyi.lu@mediatek.com>
Subject: Re: [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout helpers
Date: Fri, 20 Apr 2018 11:42:54 +0800	[thread overview]
Message-ID: <1524195774.26454.1.camel@mtkswgap22> (raw)
In-Reply-To: <6fd85b96-f076-36c7-8ff4-8e8ed252edb2@gmail.com>

On Thu, 2018-04-19 at 12:23 +0200, Matthias Brugger wrote:
> 
> On 04/03/2018 09:15 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.
> > 
> > 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 | 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 <linux/export.h>
> > +#include <linux/iopoll.h>
> >  #include <linux/jiffies.h>
> >  #include <linux/regmap.h>
> >  #include <linux/soc/mediatek/infracfg.h>
> > @@ -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.
> 

Agreed on. will have an improve on it

thanks!

> 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;
> >  }
> > 

WARNING: multiple messages have this Message-ID (diff)
From: sean.wang@mediatek.com (Sean Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout helpers
Date: Fri, 20 Apr 2018 11:42:54 +0800	[thread overview]
Message-ID: <1524195774.26454.1.camel@mtkswgap22> (raw)
In-Reply-To: <6fd85b96-f076-36c7-8ff4-8e8ed252edb2@gmail.com>

On Thu, 2018-04-19 at 12:23 +0200, Matthias Brugger wrote:
> 
> On 04/03/2018 09:15 AM, sean.wang at 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.
> > 
> > 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 | 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 <linux/export.h>
> > +#include <linux/iopoll.h>
> >  #include <linux/jiffies.h>
> >  #include <linux/regmap.h>
> >  #include <linux/soc/mediatek/infracfg.h>
> > @@ -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.
> 

Agreed on. will have an improve on it

thanks!

> 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;
> >  }
> > 

  reply	other threads:[~2018-04-20  3:42 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03  7:15 [PATCH v1 0/7] add support for Bluetooth on MT7622 SoC sean.wang
2018-04-03  7:15 ` sean.wang at mediatek.com
2018-04-03  7:15 ` sean.wang
2018-04-03  7:15 ` [PATCH v1 1/7] dt-bindings: net: bluetooth: Add mediatek-bluetooth sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang
2018-04-09 21:16   ` Rob Herring
2018-04-09 21:16     ` Rob Herring
2018-04-03  7:15 ` [PATCH v1 2/7] serdev: add dev_pm_domain_attach|detach() sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang
2018-04-03 10:29   ` Marcel Holtmann
2018-04-03 10:29     ` Marcel Holtmann
2018-04-26  5:29     ` Sean Wang
2018-04-26  5:29       ` Sean Wang
2018-04-26  5:29       ` Sean Wang
2018-04-03  7:15 ` [PATCH v1 3/7] soc: mediatek: reuse read[l,x]_poll_timeout helpers sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang
2018-04-18 15:06   ` Matthias Brugger
2018-04-18 15:06     ` Matthias Brugger
2018-04-03  7:15 ` [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout helpers sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang
2018-04-19 10:23   ` Matthias Brugger
2018-04-19 10:23     ` Matthias Brugger
2018-04-20  3:42     ` Sean Wang [this message]
2018-04-20  3:42       ` Sean Wang
2018-04-20  3:42       ` Sean Wang
2018-04-03  7:15 ` [PATCH v1 5/7] soc: mediatek: add a fixed wait for SRAM stable sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang
2018-04-05 16:42   ` Sasha Levin
2018-04-05 16:42     ` Sasha Levin
2018-04-05 16:42     ` Sasha Levin
2018-04-19 10:33   ` Matthias Brugger
2018-04-19 10:33     ` Matthias Brugger
2018-04-20  3:49     ` Sean Wang
2018-04-20  3:49       ` Sean Wang
2018-04-20  3:49       ` Sean Wang
2018-04-23  8:58       ` Sean Wang
2018-04-23  8:58         ` Sean Wang
2018-04-23  8:58         ` Sean Wang
2018-04-03  7:15 ` [PATCH v1 6/7] Bluetooth: hci_mediatek: Add protocol support for MediaTek serial devices sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang
2018-04-03 10:27   ` Marcel Holtmann
2018-04-03 10:27     ` Marcel Holtmann
2018-04-26  7:34     ` Sean Wang
2018-04-26  7:34       ` Sean Wang
2018-04-26  7:34       ` Sean Wang
2018-04-26  9:47       ` Marcel Holtmann
2018-04-26  9:47         ` Marcel Holtmann
2018-04-27  4:13         ` Sean Wang
2018-04-27  4:13           ` Sean Wang
2018-04-27  4:13           ` Sean Wang
2018-04-27  5:25           ` Marcel Holtmann
2018-04-27  5:25             ` Marcel Holtmann
2018-04-27  9:14             ` Sean Wang
2018-04-27  9:14               ` Sean Wang
2018-04-27  9:14               ` Sean Wang
2018-04-27 16:34               ` Marcel Holtmann
2018-04-27 16:34                 ` Marcel Holtmann
2018-05-08  6:48     ` Sean Wang
2018-05-08  6:48       ` Sean Wang
2018-05-08  6:48       ` Sean Wang
2018-05-08  7:27       ` Marcel Holtmann
2018-05-08  7:27         ` Marcel Holtmann
2018-05-08  8:22         ` Sean Wang
2018-05-08  8:22           ` Sean Wang
2018-05-08  8:22           ` Sean Wang
2018-05-08 11:18           ` Marcel Holtmann
2018-05-08 11:18             ` Marcel Holtmann
2018-05-10  6:45             ` Sean Wang
2018-05-10  6:45               ` Sean Wang
2018-05-10  6:45               ` Sean Wang
2018-04-03 12:13   ` kbuild test robot
2018-04-03 12:13     ` kbuild test robot
2018-04-03 12:13     ` kbuild test robot
2018-04-03 12:13   ` [RFC PATCH] Bluetooth: hci_mediatek: mtk_recv_frame() can be static kbuild test robot
2018-04-03 12:13     ` kbuild test robot
2018-04-03 12:13     ` kbuild test robot
2018-04-03  7:15 ` [PATCH v1 7/7] MAINTAINERS: add an entry for MediaTek Bluetooth driver sean.wang
2018-04-03  7:15   ` sean.wang at mediatek.com
2018-04-03  7:15   ` sean.wang

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=1524195774.26454.1.camel@mtkswgap22 \
    --to=sean.wang@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=marcel@holtmann.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=weiyi.lu@mediatek.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.