mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
eth: intel: use vmalloc_array() to simplify code
Remove array_size() calls and replace vmalloc() with vmalloc_array() to simplify the code and maintain consistency with existing kmalloc_array() usage. vmalloc_array() is also optimized better, resulting in less instructions being used. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Link: https://patch.msgid.link/20250816090659.117699-2-rongqianfeng@vivo.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
ab4ee77ed9
commit
4490d075c2
|
|
@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
|
|||
|
||||
/* allocate temporary buffer to store rings in */
|
||||
i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
|
||||
temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
|
||||
temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
|
||||
|
||||
if (!temp_ring) {
|
||||
err = -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device *netdev,
|
|||
}
|
||||
|
||||
if (adapter->num_tx_queues > adapter->num_rx_queues)
|
||||
temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
|
||||
adapter->num_tx_queues));
|
||||
temp_ring = vmalloc_array(adapter->num_tx_queues,
|
||||
sizeof(struct igb_ring));
|
||||
else
|
||||
temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
|
||||
adapter->num_rx_queues));
|
||||
temp_ring = vmalloc_array(adapter->num_rx_queues,
|
||||
sizeof(struct igb_ring));
|
||||
|
||||
if (!temp_ring) {
|
||||
err = -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device *netdev,
|
|||
}
|
||||
|
||||
if (adapter->num_tx_queues > adapter->num_rx_queues)
|
||||
temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
|
||||
adapter->num_tx_queues));
|
||||
temp_ring = vmalloc_array(adapter->num_tx_queues,
|
||||
sizeof(struct igc_ring));
|
||||
else
|
||||
temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
|
||||
adapter->num_rx_queues));
|
||||
temp_ring = vmalloc_array(adapter->num_rx_queues,
|
||||
sizeof(struct igc_ring));
|
||||
|
||||
if (!temp_ring) {
|
||||
err = -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
|
|||
/* allocate temporary buffer to store rings in */
|
||||
i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
|
||||
adapter->num_rx_queues);
|
||||
temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
|
||||
temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
|
||||
|
||||
if (!temp_ring) {
|
||||
err = -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
|
|||
}
|
||||
|
||||
if (new_tx_count != adapter->tx_ring_count) {
|
||||
tx_ring = vmalloc(array_size(sizeof(*tx_ring),
|
||||
adapter->num_tx_queues +
|
||||
adapter->num_xdp_queues));
|
||||
tx_ring = vmalloc_array(adapter->num_tx_queues +
|
||||
adapter->num_xdp_queues,
|
||||
sizeof(*tx_ring));
|
||||
if (!tx_ring) {
|
||||
err = -ENOMEM;
|
||||
goto clear_reset;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user