[PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read()

Subsystems: broadcom b53/sf2 ethernet switch driver, networking drivers, networking [dsa], the rest

STALE1630d

Revision v3 of 4 in this series.

2 messages, 2 authors, 2022-01-24 · open the first message on its own page

[PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read()

From: Yury Norov <yury.norov@gmail.com>
Date: 2022-01-23 18:39:56

Don't call bitmap_weight() if the following code can get by
without it.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 3867f3d4545f..9a10d80125d9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1620,12 +1620,8 @@ static int b53_arl_read(struct b53_device *dev, u64 mac,
 		return 0;
 	}
 
-	if (bitmap_weight(free_bins, dev->num_arl_bins) == 0)
-		return -ENOSPC;
-
 	*idx = find_first_bit(free_bins, dev->num_arl_bins);
-
-	return -ENOENT;
+	return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT;
 }
 
 static int b53_arl_op(struct b53_device *dev, int op, int port,
-- 
2.30.2

Re: [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read()

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2022-01-24 03:11:40


On 1/23/2022 10:38 AM, Yury Norov wrote:
Don't call bitmap_weight() if the following code can get by
without it.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help