netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()'
@ 2021-07-14  8:32 Christophe JAILLET
  2021-07-14 15:50 ` Ido Schimmel
  2021-07-16 18:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-07-14  8:32 UTC (permalink / raw)
  To: jiri, idosch, davem, kuba
  Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

Use 'bitmap_alloc()/bitmap_free()' instead of hand-writing it.
This makes the code less verbose.

Also, use 'bitmap_alloc()' instead of 'bitmap_zalloc()' because the bitmap
is fully overridden by a 'bitmap_copy()' call just after its allocation.

While at it, remove an extra and unneeded space.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index c5ef9aa64efe..61911fed6aeb 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1569,7 +1569,6 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp,
 {
 	long *flood_bitmap;
 	int num_of_ports;
-	int alloc_size;
 	u16 mid_idx;
 	int err;
 
@@ -1579,18 +1578,17 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp,
 		return false;
 
 	num_of_ports = mlxsw_core_max_ports(mlxsw_sp->core);
-	alloc_size = sizeof(long) * BITS_TO_LONGS(num_of_ports);
-	flood_bitmap = kzalloc(alloc_size, GFP_KERNEL);
+	flood_bitmap = bitmap_alloc(num_of_ports, GFP_KERNEL);
 	if (!flood_bitmap)
 		return false;
 
-	bitmap_copy(flood_bitmap,  mid->ports_in_mid, num_of_ports);
+	bitmap_copy(flood_bitmap, mid->ports_in_mid, num_of_ports);
 	mlxsw_sp_mc_get_mrouters_bitmap(flood_bitmap, bridge_device, mlxsw_sp);
 
 	mid->mid = mid_idx;
 	err = mlxsw_sp_port_smid_full_entry(mlxsw_sp, mid_idx, flood_bitmap,
 					    bridge_device->mrouter);
-	kfree(flood_bitmap);
+	bitmap_free(flood_bitmap);
 	if (err)
 		return false;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()'
  2021-07-14  8:32 [PATCH] net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()' Christophe JAILLET
@ 2021-07-14 15:50 ` Ido Schimmel
  2021-07-16 18:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2021-07-14 15:50 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: jiri, idosch, davem, kuba, netdev, linux-kernel, kernel-janitors

On Wed, Jul 14, 2021 at 10:32:33AM +0200, Christophe JAILLET wrote:
> Use 'bitmap_alloc()/bitmap_free()' instead of hand-writing it.
> This makes the code less verbose.
> 
> Also, use 'bitmap_alloc()' instead of 'bitmap_zalloc()' because the bitmap
> is fully overridden by a 'bitmap_copy()' call just after its allocation.
> 
> While at it, remove an extra and unneeded space.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

For net-next:

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

Note that net-next is closed [1] so you might need to re-submit, if it
does not open soon.

Thanks for the patch.

[1] http://vger.kernel.org/~davem/net-next.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()'
  2021-07-14  8:32 [PATCH] net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()' Christophe JAILLET
  2021-07-14 15:50 ` Ido Schimmel
@ 2021-07-16 18:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-16 18:00 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: jiri, idosch, davem, kuba, netdev, linux-kernel, kernel-janitors

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Wed, 14 Jul 2021 10:32:33 +0200 you wrote:
> Use 'bitmap_alloc()/bitmap_free()' instead of hand-writing it.
> This makes the code less verbose.
> 
> Also, use 'bitmap_alloc()' instead of 'bitmap_zalloc()' because the bitmap
> is fully overridden by a 'bitmap_copy()' call just after its allocation.
> 
> While at it, remove an extra and unneeded space.
> 
> [...]

Here is the summary with links:
  - net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()'
    https://git.kernel.org/netdev/net-next/c/a99f030b2488

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-16 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  8:32 [PATCH] net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()' Christophe JAILLET
2021-07-14 15:50 ` Ido Schimmel
2021-07-16 18:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).