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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ie2ihfyhsjkaqzhp7mht2dpskwxwcrdx4cajhp7wq2euiya4t4@tmwzn2aqpvcy>
Date: Wed, 15 Jan 2025 21:40:07 +0100
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Kim Seer Paller <kimseer.paller@...log.com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] power: supply: ltc4162l: Use GENMASK macro in bitmask
 operation

Hi,

On Tue, Jan 14, 2025 at 09:13:18AM +0800, Kim Seer Paller wrote:
> Replace the bitmask operation BIT(6) - 1 with GENMASK(5, 0) to
> make the code clearer and readable.
> 
> Signed-off-by: Kim Seer Paller <kimseer.paller@...log.com>
> ---

Please also get rid of the comments. I expect somebody reading the
code to understand what GENMASK does and the comment makes things
actually worse by sometimes speaking about lower 5 bits and
sometimes about "only 6 bits" :)

Greetings,

-- Sebastian

>  drivers/power/supply/ltc4162-l-charger.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/ltc4162-l-charger.c b/drivers/power/supply/ltc4162-l-charger.c
> index 24b62f000..db1a75c9b 100644
> --- a/drivers/power/supply/ltc4162-l-charger.c
> +++ b/drivers/power/supply/ltc4162-l-charger.c
> @@ -410,7 +410,7 @@ static int ltc4162l_get_icharge(struct ltc4162l_info *info,
>  	if (ret)
>  		return ret;
>  
> -	regval &= BIT(6) - 1; /* Only the lower 5 bits */
> +	regval &= GENMASK(5, 0); /* Only the lower 5 bits */
>  
>  	/* The charge current servo level: (icharge_dac + 1) × 1mV/RSNSB */
>  	++regval;
> @@ -449,7 +449,7 @@ static int ltc4162l_get_vcharge(struct ltc4162l_info *info,
>  	if (ret)
>  		return ret;
>  
> -	regval &= BIT(6) - 1; /* Only the lower 5 bits */
> +	regval &= GENMASK(5, 0); /* Only the lower 5 bits */
>  
>  	/*
>  	 * charge voltage setting can be computed from
> @@ -500,7 +500,7 @@ static int ltc4015_get_vcharge(struct ltc4162l_info *info,
>  	if (ret)
>  		return ret;
>  
> -	regval &= BIT(6) - 1; /* Only the lower 5 bits */
> +	regval &= GENMASK(5, 0); /* Only the lower 5 bits */
>  
>  	/*
>  	 * charge voltage setting can be computed from:
> @@ -636,7 +636,7 @@ static int ltc4162l_get_iin_limit_dac(struct ltc4162l_info *info,
>  	if (ret)
>  		return ret;
>  
> -	regval &= BIT(6) - 1; /* Only 6 bits */
> +	regval &= GENMASK(5, 0); /* Only 6 bits */
>  
>  	/* (iin_limit_dac + 1) × 500μV / RSNSI */
>  	++regval;
> 
> base-commit: a3a8799165ff83bb764fd800c6559c3cba0ddac3
> -- 
> 2.34.1
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ