Commit 11e97973 authored by Rob Herring's avatar Rob Herring Committed by Lorenzo Pieralisi

PCI: aardvark: Use pci_is_root_bus() to check if bus is root bus

Use pci_is_root_bus() rather than tracking the root bus number to
determine if the bus is the root bus or not. This removes storing
duplicated data as well as the need for the host bridge driver to have
to care about the bus numbers in most cases.

Link: https://lore.kernel.org/r/20200722022514.1283916-5-robh@kernel.orgSigned-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
parent d3bb94d0
...@@ -195,7 +195,6 @@ struct advk_pcie { ...@@ -195,7 +195,6 @@ struct advk_pcie {
DECLARE_BITMAP(msi_used, MSI_IRQ_NUM); DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);
struct mutex msi_used_lock; struct mutex msi_used_lock;
u16 msi_msg; u16 msi_msg;
int root_bus_nr;
int link_gen; int link_gen;
struct pci_bridge_emul bridge; struct pci_bridge_emul bridge;
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
...@@ -641,7 +640,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie) ...@@ -641,7 +640,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
int devfn) int devfn)
{ {
if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) if (pci_is_root_bus(bus) && PCI_SLOT(devfn) != 0)
return false; return false;
return true; return true;
...@@ -659,7 +658,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, ...@@ -659,7 +658,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
} }
if (bus->number == pcie->root_bus_nr) if (pci_is_root_bus(bus))
return pci_bridge_emul_conf_read(&pcie->bridge, where, return pci_bridge_emul_conf_read(&pcie->bridge, where,
size, val); size, val);
...@@ -670,7 +669,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, ...@@ -670,7 +669,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
/* Program the control register */ /* Program the control register */
reg = advk_readl(pcie, PIO_CTRL); reg = advk_readl(pcie, PIO_CTRL);
reg &= ~PIO_CTRL_TYPE_MASK; reg &= ~PIO_CTRL_TYPE_MASK;
if (bus->primary == pcie->root_bus_nr) if (pci_is_root_bus(bus->parent))
reg |= PCIE_CONFIG_RD_TYPE0; reg |= PCIE_CONFIG_RD_TYPE0;
else else
reg |= PCIE_CONFIG_RD_TYPE1; reg |= PCIE_CONFIG_RD_TYPE1;
...@@ -715,7 +714,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, ...@@ -715,7 +714,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
if (!advk_pcie_valid_device(pcie, bus, devfn)) if (!advk_pcie_valid_device(pcie, bus, devfn))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
if (bus->number == pcie->root_bus_nr) if (pci_is_root_bus(bus))
return pci_bridge_emul_conf_write(&pcie->bridge, where, return pci_bridge_emul_conf_write(&pcie->bridge, where,
size, val); size, val);
...@@ -729,7 +728,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, ...@@ -729,7 +728,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
/* Program the control register */ /* Program the control register */
reg = advk_readl(pcie, PIO_CTRL); reg = advk_readl(pcie, PIO_CTRL);
reg &= ~PIO_CTRL_TYPE_MASK; reg &= ~PIO_CTRL_TYPE_MASK;
if (bus->primary == pcie->root_bus_nr) if (pci_is_root_bus(bus->parent))
reg |= PCIE_CONFIG_WR_TYPE0; reg |= PCIE_CONFIG_WR_TYPE0;
else else
reg |= PCIE_CONFIG_WR_TYPE1; reg |= PCIE_CONFIG_WR_TYPE1;
...@@ -1138,7 +1137,7 @@ static int advk_pcie_probe(struct platform_device *pdev) ...@@ -1138,7 +1137,7 @@ static int advk_pcie_probe(struct platform_device *pdev)
dev_err(dev, "Failed to parse resources\n"); dev_err(dev, "Failed to parse resources\n");
return ret; return ret;
} }
pcie->root_bus_nr = bus->start; bridge->busnr = bus->start;
pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
"reset-gpios", 0, "reset-gpios", 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment