]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
net/mlx4_core: Use ARRAY_SIZE macro
authorThomas Meyer <thomas@m3y3r.de>
Sun, 3 Sep 2017 12:19:31 +0000 (14:19 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Sep 2017 18:49:16 +0000 (11:49 -0700)
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/fw.c
drivers/net/ethernet/mellanox/mlx4/main.c

index d4c7c15cb4adef89d8825ffe812174a83130419e..16c09949afd5b86ebb25d6ea87d3ee49459eef6c 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/mlx4/cmd.h>
 #include <linux/module.h>
 #include <linux/cache.h>
+#include <linux/kernel.h>
 
 #include "fw.h"
 #include "icm.h"
@@ -2455,14 +2456,14 @@ int mlx4_config_dev_retrieval(struct mlx4_dev *dev,
        csum_mask = (config_dev.rx_checksum_val >> CONFIG_DEV_RX_CSUM_MODE_PORT1_BIT_OFFSET) &
                        CONFIG_DEV_RX_CSUM_MODE_MASK;
 
-       if (csum_mask >= sizeof(config_dev_csum_flags)/sizeof(config_dev_csum_flags[0]))
+       if (csum_mask >= ARRAY_SIZE(config_dev_csum_flags))
                return -EINVAL;
        params->rx_csum_flags_port_1 = config_dev_csum_flags[csum_mask];
 
        csum_mask = (config_dev.rx_checksum_val >> CONFIG_DEV_RX_CSUM_MODE_PORT2_BIT_OFFSET) &
                        CONFIG_DEV_RX_CSUM_MODE_MASK;
 
-       if (csum_mask >= sizeof(config_dev_csum_flags)/sizeof(config_dev_csum_flags[0]))
+       if (csum_mask >= ARRAY_SIZE(config_dev_csum_flags))
                return -EINVAL;
        params->rx_csum_flags_port_2 = config_dev_csum_flags[csum_mask];
 
index b3e50f4892c574ae43be82f8779a8201e34b3d61..eccf53705f257f5e93758ddc72d418c741d9939b 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/pci.h>
@@ -3675,7 +3676,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data,
         * per port, we must limit the number of VFs to 63 (since their are
         * 128 MACs)
         */
-       for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]) && i < num_vfs_argc;
+       for (i = 0; i < ARRAY_SIZE(nvfs) && i < num_vfs_argc;
             total_vfs += nvfs[param_map[num_vfs_argc - 1][i]], i++) {
                nvfs[param_map[num_vfs_argc - 1][i]] = num_vfs[i];
                if (nvfs[i] < 0) {
@@ -3684,7 +3685,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data,
                        goto err_disable_pdev;
                }
        }
-       for (i = 0; i < sizeof(prb_vf)/sizeof(prb_vf[0]) && i < probe_vfs_argc;
+       for (i = 0; i < ARRAY_SIZE(prb_vf) && i < probe_vfs_argc;
             i++) {
                prb_vf[param_map[probe_vfs_argc - 1][i]] = probe_vf[i];
                if (prb_vf[i] < 0 || prb_vf[i] > nvfs[i]) {
@@ -3763,11 +3764,11 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data,
                if (total_vfs) {
                        unsigned vfs_offset = 0;
 
-                       for (i = 0; i < sizeof(nvfs)/sizeof(nvfs[0]) &&
+                       for (i = 0; i < ARRAY_SIZE(nvfs) &&
                             vfs_offset + nvfs[i] < extended_func_num(pdev);
                             vfs_offset += nvfs[i], i++)
                                ;
-                       if (i == sizeof(nvfs)/sizeof(nvfs[0])) {
+                       if (i == ARRAY_SIZE(nvfs)) {
                                err = -ENODEV;
                                goto err_release_regions;
                        }