diff mbox series

power: supply: ltc4162l: Use GENMASK macro in bitmask operation

Message ID 20250114011318.5784-1-kimseer.paller@analog.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power: supply: ltc4162l: Use GENMASK macro in bitmask operation | expand

Commit Message

Kim Seer Paller Jan. 14, 2025, 1:13 a.m. UTC
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@analog.com>
---
 drivers/power/supply/ltc4162-l-charger.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


base-commit: a3a8799165ff83bb764fd800c6559c3cba0ddac3

Comments

Nuno Sá Jan. 15, 2025, 9:15 a.m. UTC | #1
On Tue, 2025-01-14 at 09:13 +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@analog.com>
> ---

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

>  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
diff mbox series

Patch

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;