Skip to content

Commit 11e9797

Browse files
robherringLorenzo Pieralisi
authored andcommitted
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/[email protected] Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Cc: Thomas Petazzoni <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Bjorn Helgaas <[email protected]>
1 parent d3bb94d commit 11e9797

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/pci/controller/pci-aardvark.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ struct advk_pcie {
195195
DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);
196196
struct mutex msi_used_lock;
197197
u16 msi_msg;
198-
int root_bus_nr;
199198
int link_gen;
200199
struct pci_bridge_emul bridge;
201200
struct gpio_desc *reset_gpio;
@@ -641,7 +640,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
641640
static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
642641
int devfn)
643642
{
644-
if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
643+
if (pci_is_root_bus(bus) && PCI_SLOT(devfn) != 0)
645644
return false;
646645

647646
return true;
@@ -659,7 +658,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
659658
return PCIBIOS_DEVICE_NOT_FOUND;
660659
}
661660

662-
if (bus->number == pcie->root_bus_nr)
661+
if (pci_is_root_bus(bus))
663662
return pci_bridge_emul_conf_read(&pcie->bridge, where,
664663
size, val);
665664

@@ -670,7 +669,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
670669
/* Program the control register */
671670
reg = advk_readl(pcie, PIO_CTRL);
672671
reg &= ~PIO_CTRL_TYPE_MASK;
673-
if (bus->primary == pcie->root_bus_nr)
672+
if (pci_is_root_bus(bus->parent))
674673
reg |= PCIE_CONFIG_RD_TYPE0;
675674
else
676675
reg |= PCIE_CONFIG_RD_TYPE1;
@@ -715,7 +714,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
715714
if (!advk_pcie_valid_device(pcie, bus, devfn))
716715
return PCIBIOS_DEVICE_NOT_FOUND;
717716

718-
if (bus->number == pcie->root_bus_nr)
717+
if (pci_is_root_bus(bus))
719718
return pci_bridge_emul_conf_write(&pcie->bridge, where,
720719
size, val);
721720

@@ -729,7 +728,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
729728
/* Program the control register */
730729
reg = advk_readl(pcie, PIO_CTRL);
731730
reg &= ~PIO_CTRL_TYPE_MASK;
732-
if (bus->primary == pcie->root_bus_nr)
731+
if (pci_is_root_bus(bus->parent))
733732
reg |= PCIE_CONFIG_WR_TYPE0;
734733
else
735734
reg |= PCIE_CONFIG_WR_TYPE1;
@@ -1138,7 +1137,7 @@ static int advk_pcie_probe(struct platform_device *pdev)
11381137
dev_err(dev, "Failed to parse resources\n");
11391138
return ret;
11401139
}
1141-
pcie->root_bus_nr = bus->start;
1140+
bridge->busnr = bus->start;
11421141

11431142
pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
11441143
"reset-gpios", 0,

0 commit comments

Comments
 (0)