Skip to content

Commit aa84931

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Clean up early_dump_pci_device()
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
1 parent 24b2d3c commit aa84931

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/pci/probe.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* PCI detection and setup code
44
*/
55

6+
#include <linux/array_size.h>
67
#include <linux/kernel.h>
78
#include <linux/delay.h>
89
#include <linux/init.h>
@@ -1912,16 +1913,16 @@ static int pci_intx_mask_broken(struct pci_dev *dev)
19121913

19131914
static void early_dump_pci_device(struct pci_dev *pdev)
19141915
{
1915-
u32 value[256 / 4];
1916+
u32 value[PCI_CFG_SPACE_SIZE / sizeof(u32)];
19161917
int i;
19171918

19181919
pci_info(pdev, "config space:\n");
19191920

1920-
for (i = 0; i < 256; i += 4)
1921-
pci_read_config_dword(pdev, i, &value[i / 4]);
1921+
for (i = 0; i < ARRAY_SIZE(value); i++)
1922+
pci_read_config_dword(pdev, i * sizeof(u32), &value[i]);
19221923

19231924
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1,
1924-
value, 256, false);
1925+
value, ARRAY_SIZE(value) * sizeof(u32), false);
19251926
}
19261927

19271928
static const char *pci_type_str(struct pci_dev *dev)

0 commit comments

Comments
 (0)