Skip to content

Commit 92c71aa

Browse files
kseerpsre
authored andcommitted
power: supply: ltc4162l: Use GENMASK macro in bitmask operation
Replace the bitmask operation BIT(6) - 1 with GENMASK(5, 0) to make the code clearer and readable. Reviewed-by: Nuno Sa <[email protected]> Signed-off-by: Kim Seer Paller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 260d7c5 commit 92c71aa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/power/supply/ltc4162-l-charger.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static int ltc4162l_get_icharge(struct ltc4162l_info *info,
410410
if (ret)
411411
return ret;
412412

413-
regval &= BIT(6) - 1; /* Only the lower 5 bits */
413+
regval &= GENMASK(5, 0);
414414

415415
/* The charge current servo level: (icharge_dac + 1) × 1mV/RSNSB */
416416
++regval;
@@ -449,7 +449,7 @@ static int ltc4162l_get_vcharge(struct ltc4162l_info *info,
449449
if (ret)
450450
return ret;
451451

452-
regval &= BIT(6) - 1; /* Only the lower 5 bits */
452+
regval &= GENMASK(5, 0);
453453

454454
/*
455455
* charge voltage setting can be computed from
@@ -500,7 +500,7 @@ static int ltc4015_get_vcharge(struct ltc4162l_info *info,
500500
if (ret)
501501
return ret;
502502

503-
regval &= BIT(6) - 1; /* Only the lower 5 bits */
503+
regval &= GENMASK(5, 0);
504504

505505
/*
506506
* charge voltage setting can be computed from:
@@ -636,7 +636,7 @@ static int ltc4162l_get_iin_limit_dac(struct ltc4162l_info *info,
636636
if (ret)
637637
return ret;
638638

639-
regval &= BIT(6) - 1; /* Only 6 bits */
639+
regval &= GENMASK(5, 0);
640640

641641
/* (iin_limit_dac + 1) × 500μV / RSNSI */
642642
++regval;

0 commit comments

Comments
 (0)