PCI: aardvark: Introduce an advk_pcie_valid_device() helper
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 24 Nov 2021 22:49:18 +0000 (23:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Dec 2021 07:46:50 +0000 (08:46 +0100)
commit 248d4e59616c632f37f04c233eec6d5008384926 upstream.

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>
Signed-off-by: Marek BehĂșn <kabel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/host/pci-aardvark.c

index ae67e5c3fe70530e0a35b4e8edf62b7cc9ab4a90..9426715316b2c843412d423e3ae71bf79944e992 100644 (file)
@@ -592,6 +592,15 @@ static bool advk_pcie_pio_is_running(struct advk_pcie *pcie)
        return false;
 }
 
+static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
+                                 int devfn)
+{
+       if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
+               return false;
+
+       return true;
+}
+
 static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
                             int where, int size, u32 *val)
 {
@@ -599,7 +608,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
        u32 reg;
        int ret;
 
-       if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
+       if (!advk_pcie_valid_device(pcie, bus, devfn)) {
                *val = 0xffffffff;
                return PCIBIOS_DEVICE_NOT_FOUND;
        }
@@ -660,7 +669,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
        int offset;
        int ret;
 
-       if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
+       if (!advk_pcie_valid_device(pcie, bus, devfn))
                return PCIBIOS_DEVICE_NOT_FOUND;
 
        if (where % size)