aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/controller/pci-aardvark.c
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>2018-04-06 10:55:35 -0400
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>2018-06-27 13:11:10 -0400
commit248d4e59616c632f37f04c233eec6d5008384926 (patch)
treec0118a41696a66ee3177b28ef8280a91ab077201 /drivers/pci/controller/pci-aardvark.c
parentce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff)
PCI: aardvark: Introduce an advk_pcie_valid_device() helper
In other to mimic other PCIe host controller drivers, introduce an advk_pcie_valid_device() helper, used in the configuration read/write functions. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> [lorenzo.pieralisi@arm.com: updated host->controller dir move] Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Diffstat (limited to 'drivers/pci/controller/pci-aardvark.c')
-rw-r--r--drivers/pci/controller/pci-aardvark.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
index d3172d5d3d35..7b363437d851 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -433,6 +433,15 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie)
433 return -ETIMEDOUT; 433 return -ETIMEDOUT;
434} 434}
435 435
436static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
437 int devfn)
438{
439 if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
440 return false;
441
442 return true;
443}
444
436static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, 445static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
437 int where, int size, u32 *val) 446 int where, int size, u32 *val)
438{ 447{
@@ -440,7 +449,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
440 u32 reg; 449 u32 reg;
441 int ret; 450 int ret;
442 451
443 if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) { 452 if (!advk_pcie_valid_device(pcie, bus, devfn)) {
444 *val = 0xffffffff; 453 *val = 0xffffffff;
445 return PCIBIOS_DEVICE_NOT_FOUND; 454 return PCIBIOS_DEVICE_NOT_FOUND;
446 } 455 }
@@ -494,7 +503,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
494 int offset; 503 int offset;
495 int ret; 504 int ret;
496 505
497 if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) 506 if (!advk_pcie_valid_device(pcie, bus, devfn))
498 return PCIBIOS_DEVICE_NOT_FOUND; 507 return PCIBIOS_DEVICE_NOT_FOUND;
499 508
500 if (where % size) 509 if (where % size)