Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: pci_endpoint_test: Avoid using hard-coded BAR sizes

BAR sizes are hard-coded in pci_endpoint_test driver corresponding to the
sizes used in pci-epf-test function driver. This might break if the sizes
in pci-epf-test function driver are modified (and the corresponding change
is not done in pci_endpoint_test PCI driver).

To avoid hard coding BAR sizes, use pci_resource_len() API.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Kishon Vijay Abraham I and committed by
Bjorn Helgaas
cda370ec 0b91516a

+2 -3
+2 -3
drivers/misc/pci_endpoint_test.c
··· 100 100 bool no_msi; 101 101 }; 102 102 103 - static int bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 }; 104 - 105 103 static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test, 106 104 u32 offset) 107 105 { ··· 147 149 int j; 148 150 u32 val; 149 151 int size; 152 + struct pci_dev *pdev = test->pdev; 150 153 151 154 if (!test->bar[barno]) 152 155 return false; 153 156 154 - size = bar_size[barno]; 157 + size = pci_resource_len(pdev, barno); 155 158 156 159 if (barno == test->test_reg_bar) 157 160 size = 0x4;