]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
eth: intel: use vmalloc_array() to simplify code
authorQianfeng Rong <rongqianfeng@vivo.com>
Sat, 16 Aug 2025 09:06:52 +0000 (17:06 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 Aug 2025 00:49:51 +0000 (17:49 -0700)
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>
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
drivers/net/ethernet/intel/igb/igb_ethtool.c
drivers/net/ethernet/intel/igc/igc_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbevf/ethtool.c

index 1954a04460d150afe9eb8f04fd182428dd434abb..bf2029144c1dd5ca41140a8a0c719c49756d8aa2 100644 (file)
@@ -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;
index 92ef33459aec788fdea59011399c85c93a4434f4..51d5cb6599ed25d81a5e78b539f2bb979b8d963f 100644 (file)
@@ -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;
index ecb35b693ce559e8be1b38d62c6f12f0f3e18d6a..f3e7218ba6f3d782f9b6a467eff6354d4d441a6d 100644 (file)
@@ -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;
index 25c3a09ad7f1c8d35b1d37145856c0a6b75c854c..2c5d774f1ec17245b79a948c0a371c10b32e521e 100644 (file)
@@ -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;
index 7ac53171b0410ce949fa7105f53b7b3bbd155b28..bebad564188ee6e2f06a6e8d0667505891fcca65 100644 (file)
@@ -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;