]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
misc: pci_endpoint_test: Avoid using hard-coded BAR sizes
authorKishon Vijay Abraham I <kishon@ti.com>
Fri, 18 Aug 2017 14:58:08 +0000 (20:28 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 29 Aug 2017 21:00:40 +0000 (16:00 -0500)
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>
drivers/misc/pci_endpoint_test.c

index 5cbb25cf276c914fff7863754f97e5e2c46b116c..1f37ad39b16929cec0fe7aa9e082de5bf12b6931 100644 (file)
@@ -100,8 +100,6 @@ struct pci_endpoint_test_data {
        bool no_msi;
 };
 
-static int bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 };
-
 static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
                                          u32 offset)
 {
@@ -149,11 +147,12 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
        int j;
        u32 val;
        int size;
+       struct pci_dev *pdev = test->pdev;
 
        if (!test->bar[barno])
                return false;
 
-       size = bar_size[barno];
+       size = pci_resource_len(pdev, barno);
 
        if (barno == test->test_reg_bar)
                size = 0x4;