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]
Message-ID: <20220520145551.b2sqheaizkegna3n@notapiano>
Date:   Fri, 20 May 2022 10:55:51 -0400
From:   NĂ­colas F. R. A. Prado 
        <nfraprado@...labora.com>
To:     Rex-BC Chen <rex-bc.chen@...iatek.com>
Cc:     mturquette@...libre.com, sboyd@...nel.org, matthias.bgg@...il.com,
        robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
        p.zabel@...gutronix.de, angelogioacchino.delregno@...labora.com,
        chun-jie.chen@...iatek.com, wenst@...omium.org,
        runyang.chen@...iatek.com, linux-kernel@...r.kernel.org,
        devicetree@...r.kernel.org, linux-clk@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org,
        Project_Global_Chrome_Upstream_Group@...iatek.com
Subject: Re: [PATCH v7 04/19] clk: mediatek: reset: Extract common drivers to
 update function

On Thu, May 19, 2022 at 08:55:12PM +0800, Rex-BC Chen wrote:
> To make drivers more clear and readable, we extract common code
> within assert and deassert to mtk_reset_update_set_clr() and
> mtk_reset_update().
> 
> Signed-off-by: Rex-BC Chen <rex-bc.chen@...iatek.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
> ---
>  drivers/clk/mediatek/reset.c | 38 +++++++++++++++++++++---------------
>  1 file changed, 22 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
> index 5cbbcc22a4fc..22fa9f09752c 100644
> --- a/drivers/clk/mediatek/reset.c
> +++ b/drivers/clk/mediatek/reset.c
> @@ -12,24 +12,27 @@
>  
>  #include "reset.h"
>  
> -static int mtk_reset_assert(struct reset_controller_dev *rcdev,
> -			    unsigned long id)
> +static int mtk_reset_update(struct reset_controller_dev *rcdev,
> +			    unsigned long id, bool deassert)

I'd have called the bool 'assert', and then passed true on assert and false on
deassert, as I think that's slightly more intuitive, but that's just personal
preference. It's fine like this as well.

Thanks,
NĂ­colas

>  {
>  	struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
> +	unsigned int val = deassert ? 0 : ~0;
>  
>  	return regmap_update_bits(data->regmap,
>  				  data->regofs + ((id / 32) << 2),
> -				  BIT(id % 32), ~0);
> +				  BIT(id % 32), val);
> +}
> +
> +static int mtk_reset_assert(struct reset_controller_dev *rcdev,
> +			    unsigned long id)
> +{
> +	return mtk_reset_update(rcdev, id, false);
>  }
>  
>  static int mtk_reset_deassert(struct reset_controller_dev *rcdev,
>  			      unsigned long id)
>  {
> -	struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
> -
> -	return regmap_update_bits(data->regmap,
> -				  data->regofs + ((id / 32) << 2),
> -				  BIT(id % 32), 0);
> +	return mtk_reset_update(rcdev, id, true);
>  }
>  
>  static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id)
> @@ -43,24 +46,27 @@ static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id)
>  	return mtk_reset_deassert(rcdev, id);
>  }
>  
> -static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
> -				    unsigned long id)
> +static int mtk_reset_update_set_clr(struct reset_controller_dev *rcdev,
> +				    unsigned long id, bool deassert)
>  {
>  	struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
> +	unsigned int deassert_ofs = deassert ? 0x4 : 0;
>  
>  	return regmap_write(data->regmap,
> -			    data->regofs + ((id / 32) << 4),
> +			    data->regofs + ((id / 32) << 4) + deassert_ofs,
>  			    BIT(id % 32));
>  }
>  
> +static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
> +				    unsigned long id)
> +{
> +	return mtk_reset_update_set_clr(rcdev, id, false);
> +}
> +
>  static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
>  				      unsigned long id)
>  {
> -	struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
> -
> -	return regmap_write(data->regmap,
> -			    data->regofs + ((id / 32) << 4) + 0x4,
> -			    BIT(id % 32));
> +	return mtk_reset_update_set_clr(rcdev, id, true);
>  }
>  
>  static int mtk_reset_set_clr(struct reset_controller_dev *rcdev,
> -- 
> 2.18.0
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ