Skip to content

Commit a99f030

Browse files
tititiou36davem330
authored andcommitted
net: switchdev: Simplify 'mlxsw_sp_mc_write_mdb_entry()'
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> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f79a3bc commit a99f030

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,6 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp,
15691569
{
15701570
long *flood_bitmap;
15711571
int num_of_ports;
1572-
int alloc_size;
15731572
u16 mid_idx;
15741573
int err;
15751574

@@ -1579,18 +1578,17 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp,
15791578
return false;
15801579

15811580
num_of_ports = mlxsw_core_max_ports(mlxsw_sp->core);
1582-
alloc_size = sizeof(long) * BITS_TO_LONGS(num_of_ports);
1583-
flood_bitmap = kzalloc(alloc_size, GFP_KERNEL);
1581+
flood_bitmap = bitmap_alloc(num_of_ports, GFP_KERNEL);
15841582
if (!flood_bitmap)
15851583
return false;
15861584

1587-
bitmap_copy(flood_bitmap, mid->ports_in_mid, num_of_ports);
1585+
bitmap_copy(flood_bitmap, mid->ports_in_mid, num_of_ports);
15881586
mlxsw_sp_mc_get_mrouters_bitmap(flood_bitmap, bridge_device, mlxsw_sp);
15891587

15901588
mid->mid = mid_idx;
15911589
err = mlxsw_sp_port_smid_full_entry(mlxsw_sp, mid_idx, flood_bitmap,
15921590
bridge_device->mrouter);
1593-
kfree(flood_bitmap);
1591+
bitmap_free(flood_bitmap);
15941592
if (err)
15951593
return false;
15961594

0 commit comments

Comments
 (0)