lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 19 Apr 2018 12:23:32 +0200
From:   Matthias Brugger <matthias.bgg@...il.com>
To:     sean.wang@...iatek.com, robh+dt@...nel.org, mark.rutland@....com,
        marcel@...tmann.org, johan.hedberg@...il.com
Cc:     devicetree@...r.kernel.org, linux-bluetooth@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Weiyi Lu <weiyi.lu@...iatek.com>
Subject: Re: [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout
 helpers



On 04/03/2018 09:15 AM, sean.wang@...iatek.com wrote:
> From: Sean Wang <sean.wang@...iatek.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@...iatek.com>
> Cc: Matthias Brugger <matthias.bgg@...il.com>
> Cc: Ulf Hansson <ulf.hansson@...aro.org>
> Cc: Weiyi Lu <weiyi.lu@...iatek.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.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ