]> www.infradead.org Git - users/hch/misc.git/commitdiff
PCI: Clean up early_dump_pci_device()
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 10 Jun 2025 10:58:19 +0000 (13:58 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 11 Aug 2025 20:00:51 +0000 (15:00 -0500)
Convert 256 to PCI_CFG_SPACE_SIZE and 4 to sizeof(u32) and avoid i / 4
construct by changing the iteration.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/20250610105820.7126-2-ilpo.jarvinen@linux.intel.com
drivers/pci/probe.c

index 505e9a6021187ee2b413b8811d91875eb388eec4..b06f0d19f9a746b0b87fad21ca82525395a0c126 100644 (file)
@@ -3,6 +3,7 @@
  * PCI detection and setup code
  */
 
+#include <linux/array_size.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -1912,16 +1913,16 @@ static int pci_intx_mask_broken(struct pci_dev *dev)
 
 static void early_dump_pci_device(struct pci_dev *pdev)
 {
-       u32 value[256 / 4];
+       u32 value[PCI_CFG_SPACE_SIZE / sizeof(u32)];
        int i;
 
        pci_info(pdev, "config space:\n");
 
-       for (i = 0; i < 256; i += 4)
-               pci_read_config_dword(pdev, i, &value[i / 4]);
+       for (i = 0; i < ARRAY_SIZE(value); i++)
+               pci_read_config_dword(pdev, i * sizeof(u32), &value[i]);
 
        print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1,
-                      value, 256, false);
+                      value, ARRAY_SIZE(value) * sizeof(u32), false);
 }
 
 static const char *pci_type_str(struct pci_dev *dev)