[PATCH 2/2] wifi: morsemicro: mm81x: use hweight16() to calculate bit index
From: Yury Norov
Date: Fri Sep 25 2026 - 15:59:40 EST
Count the set bits through bit_pos with hweight16() and an inclusive
mask. Preserve the zero fallback and zero-based index.
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
drivers/net/wireless/morsemicro/mm81x/mmrc.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/net/wireless/morsemicro/mm81x/mmrc.c b/drivers/net/wireless/morsemicro/mm81x/mmrc.c
index 4cbc35535e07..6bedcdbcb61f 100644
--- a/drivers/net/wireless/morsemicro/mm81x/mmrc.c
+++ b/drivers/net/wireless/morsemicro/mm81x/mmrc.c
@@ -206,13 +206,7 @@ static const u32 sym_table[10] = { 24, 36, 48, 72, 96, 144, 192, 216, 256, 288 }
*/
static u16 bit_index(u16 in, u32 bit_pos)
{
- u16 i;
- u16 index = 0;
-
- for (i = 0; i != bit_pos + 1; i++) {
- if (((1u << i) & in) != 0)
- index++;
- }
+ u16 index = hweight16(in & GENMASK(bit_pos, 0));
if (index == 0) {
/* Could not match bit pos to caps */
--
2.53.0