]> git.itanic.dy.fi Git - linux-stable/commitdiff
PCI: altera: Rework config accessors for use without a struct pci_bus
authorLey Foon Tan <lftan@altera.com>
Fri, 26 Aug 2016 01:47:24 +0000 (09:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jan 2019 21:16:11 +0000 (22:16 +0100)
commit 31fc0ad47e2e0b8417616aa0f1ddcc67edf1e109 upstream.

Rework configs accessors so a future patch can use them in _probe() with
struct altera_pcie instead of struct pci_bus.

Signed-off-by: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Claudius Heine <claudius.heine.ext@siemens.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/host/pcie-altera.c

index e0be9ac5701a8826fa97ebd45d80e7e1e5ceb582..a95c9c4e03c7a8f42359ceaa545b094dabd72805 100644 (file)
@@ -330,22 +330,14 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn,
        return PCIBIOS_SUCCESSFUL;
 }
 
-static int altera_pcie_cfg_read(struct pci_bus *bus, unsigned int devfn,
-                               int where, int size, u32 *value)
+static int _altera_pcie_cfg_read(struct altera_pcie *pcie, u8 busno,
+                                unsigned int devfn, int where, int size,
+                                u32 *value)
 {
-       struct altera_pcie *pcie = bus->sysdata;
        int ret;
        u32 data;
        u8 byte_en;
 
-       if (altera_pcie_hide_rc_bar(bus, devfn, where))
-               return PCIBIOS_BAD_REGISTER_NUMBER;
-
-       if (!altera_pcie_valid_config(pcie, bus, PCI_SLOT(devfn))) {
-               *value = 0xffffffff;
-               return PCIBIOS_DEVICE_NOT_FOUND;
-       }
-
        switch (size) {
        case 1:
                byte_en = 1 << (where & 3);
@@ -358,7 +350,7 @@ static int altera_pcie_cfg_read(struct pci_bus *bus, unsigned int devfn,
                break;
        }
 
-       ret = tlp_cfg_dword_read(pcie, bus->number, devfn,
+       ret = tlp_cfg_dword_read(pcie, busno, devfn,
                                 (where & ~DWORD_MASK), byte_en, &data);
        if (ret != PCIBIOS_SUCCESSFUL)
                return ret;
@@ -378,20 +370,14 @@ static int altera_pcie_cfg_read(struct pci_bus *bus, unsigned int devfn,
        return PCIBIOS_SUCCESSFUL;
 }
 
-static int altera_pcie_cfg_write(struct pci_bus *bus, unsigned int devfn,
-                                int where, int size, u32 value)
+static int _altera_pcie_cfg_write(struct altera_pcie *pcie, u8 busno,
+                                 unsigned int devfn, int where, int size,
+                                 u32 value)
 {
-       struct altera_pcie *pcie = bus->sysdata;
        u32 data32;
        u32 shift = 8 * (where & 3);
        u8 byte_en;
 
-       if (altera_pcie_hide_rc_bar(bus, devfn, where))
-               return PCIBIOS_BAD_REGISTER_NUMBER;
-
-       if (!altera_pcie_valid_config(pcie, bus, PCI_SLOT(devfn)))
-               return PCIBIOS_DEVICE_NOT_FOUND;
-
        switch (size) {
        case 1:
                data32 = (value & 0xff) << shift;
@@ -407,8 +393,40 @@ static int altera_pcie_cfg_write(struct pci_bus *bus, unsigned int devfn,
                break;
        }
 
-       return tlp_cfg_dword_write(pcie, bus->number, devfn,
-               (where & ~DWORD_MASK), byte_en, data32);
+       return tlp_cfg_dword_write(pcie, busno, devfn, (where & ~DWORD_MASK),
+                                  byte_en, data32);
+}
+
+static int altera_pcie_cfg_read(struct pci_bus *bus, unsigned int devfn,
+                               int where, int size, u32 *value)
+{
+       struct altera_pcie *pcie = bus->sysdata;
+
+       if (altera_pcie_hide_rc_bar(bus, devfn, where))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+
+       if (!altera_pcie_valid_config(pcie, bus, PCI_SLOT(devfn))) {
+               *value = 0xffffffff;
+               return PCIBIOS_DEVICE_NOT_FOUND;
+       }
+
+       return _altera_pcie_cfg_read(pcie, bus->number, devfn, where, size,
+                                    value);
+}
+
+static int altera_pcie_cfg_write(struct pci_bus *bus, unsigned int devfn,
+                                int where, int size, u32 value)
+{
+       struct altera_pcie *pcie = bus->sysdata;
+
+       if (altera_pcie_hide_rc_bar(bus, devfn, where))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+
+       if (!altera_pcie_valid_config(pcie, bus, PCI_SLOT(devfn)))
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       return _altera_pcie_cfg_write(pcie, bus->number, devfn, where, size,
+                                    value);
 }
 
 static struct pci_ops altera_pcie_ops = {