Commit 7c2c5726 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Jakub Kicinski

hinic: Use the bitmap API when applicable

'vlan_bitmap' is a bitmap and is used as such. So allocate it with
devm_bitmap_zalloc() and its explicit bit size (i.e. VLAN_N_VID).

This avoids the need of the VLAN_BITMAP_SIZE macro which:
   - needlessly has a 'nic_dev' parameter
   - should be "long" (and not byte) aligned, so that the bitmap semantic
     is respected

This is in fact not an issue because VLAN_N_VID is 4096 at the time
being, but devm_bitmap_zalloc() is less verbose and easier to understand.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/6ff7b7d21414240794a77dc2456914412718a145.1656260842.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5ef28832
...@@ -62,8 +62,6 @@ MODULE_PARM_DESC(rx_weight, "Number Rx packets for NAPI budget (default=64)"); ...@@ -62,8 +62,6 @@ MODULE_PARM_DESC(rx_weight, "Number Rx packets for NAPI budget (default=64)");
#define HINIC_LRO_RX_TIMER_DEFAULT 16 #define HINIC_LRO_RX_TIMER_DEFAULT 16
#define VLAN_BITMAP_SIZE(nic_dev) (ALIGN(VLAN_N_VID, 8) / 8)
#define work_to_rx_mode_work(work) \ #define work_to_rx_mode_work(work) \
container_of(work, struct hinic_rx_mode_work, work) container_of(work, struct hinic_rx_mode_work, work)
...@@ -1242,8 +1240,7 @@ static int nic_dev_init(struct pci_dev *pdev) ...@@ -1242,8 +1240,7 @@ static int nic_dev_init(struct pci_dev *pdev)
u64_stats_init(&tx_stats->syncp); u64_stats_init(&tx_stats->syncp);
u64_stats_init(&rx_stats->syncp); u64_stats_init(&rx_stats->syncp);
nic_dev->vlan_bitmap = devm_kzalloc(&pdev->dev, nic_dev->vlan_bitmap = devm_bitmap_zalloc(&pdev->dev, VLAN_N_VID,
VLAN_BITMAP_SIZE(nic_dev),
GFP_KERNEL); GFP_KERNEL);
if (!nic_dev->vlan_bitmap) { if (!nic_dev->vlan_bitmap) {
err = -ENOMEM; err = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment