Skip to content

Commit cda370e

Browse files
kishonbjorn-helgaas
authored andcommitted
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 <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 0b91516 commit cda370e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/misc/pci_endpoint_test.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ struct pci_endpoint_test_data {
100100
bool no_msi;
101101
};
102102

103-
static int bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 };
104-
105103
static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
106104
u32 offset)
107105
{
@@ -149,11 +147,12 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
149147
int j;
150148
u32 val;
151149
int size;
150+
struct pci_dev *pdev = test->pdev;
152151

153152
if (!test->bar[barno])
154153
return false;
155154

156-
size = bar_size[barno];
155+
size = pci_resource_len(pdev, barno);
157156

158157
if (barno == test->test_reg_bar)
159158
size = 0x4;

0 commit comments

Comments
 (0)