Commit a99f030b authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller
Browse files

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f79a3bcb
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -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,8 +1578,7 @@ 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;

@@ -1590,7 +1588,7 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *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;