Skip to content

Commit 5525493

Browse files
robherringLorenzo Pieralisi
authored andcommitted
PCI: designware: 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: Richard Zhu <[email protected]> Cc: Lucas Stach <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Pengutronix Kernel Team <[email protected]> Cc: Fabio Estevam <[email protected]> Cc: NXP Linux Team <[email protected]> Cc: Murali Karicheri <[email protected]> Cc: Jingoo Han <[email protected]> Cc: Gustavo Pimentel <[email protected]>
1 parent 11e9797 commit 5525493

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ static void imx6_pcie_quirk(struct pci_dev *dev)
12691269
if (bus->dev.parent->parent->driver != &imx6_pcie_driver.driver)
12701270
return;
12711271

1272-
if (bus->number == pp->root_bus_nr) {
1272+
if (pci_is_root_bus(bus)) {
12731273
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
12741274
struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci);
12751275

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static int ks_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
440440

441441
reg = CFG_BUS(bus->number) | CFG_DEVICE(PCI_SLOT(devfn)) |
442442
CFG_FUNC(PCI_FUNC(devfn));
443-
if (bus->parent->number != pp->root_bus_nr)
443+
if (!pci_is_root_bus(bus->parent))
444444
reg |= CFG_TYPE1;
445445
ks_pcie_app_writel(ks_pcie, CFG_SETUP, reg);
446446

@@ -457,7 +457,7 @@ static int ks_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
457457

458458
reg = CFG_BUS(bus->number) | CFG_DEVICE(PCI_SLOT(devfn)) |
459459
CFG_FUNC(PCI_FUNC(devfn));
460-
if (bus->parent->number != pp->root_bus_nr)
460+
if (!pci_is_root_bus(bus->parent))
461461
reg |= CFG_TYPE1;
462462
ks_pcie_app_writel(ks_pcie, CFG_SETUP, reg);
463463

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
473473
goto err_free_msi;
474474
}
475475

476-
pp->root_bus_nr = pp->busn->start;
477-
478476
bridge->sysdata = pp;
479-
bridge->busnr = pp->root_bus_nr;
477+
bridge->busnr = pp->busn->start;
480478
bridge->ops = &dw_pcie_ops;
481479
bridge->map_irq = of_irq_parse_and_map_pci;
482480
bridge->swizzle_irq = pci_common_swizzle;
@@ -528,7 +526,7 @@ static int dw_pcie_access_other_conf(struct pcie_port *pp, struct pci_bus *bus,
528526
busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
529527
PCIE_ATU_FUNC(PCI_FUNC(devfn));
530528

531-
if (bus->parent->number == pp->root_bus_nr) {
529+
if (pci_is_root_bus(bus->parent)) {
532530
type = PCIE_ATU_TYPE_CFG0;
533531
cpu_addr = pp->cfg0_base;
534532
cfg_size = pp->cfg0_size;
@@ -584,13 +582,11 @@ static int dw_pcie_valid_device(struct pcie_port *pp, struct pci_bus *bus,
584582
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
585583

586584
/* If there is no link, then there is no device */
587-
if (bus->number != pp->root_bus_nr) {
585+
if (!pci_is_root_bus(bus)) {
588586
if (!dw_pcie_link_up(pci))
589587
return 0;
590-
}
591-
592-
/* Access only one slot on each root port */
593-
if (bus->number == pp->root_bus_nr && dev > 0)
588+
} else if (dev > 0)
589+
/* Access only one slot on each root port */
594590
return 0;
595591

596592
return 1;
@@ -606,7 +602,7 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
606602
return PCIBIOS_DEVICE_NOT_FOUND;
607603
}
608604

609-
if (bus->number == pp->root_bus_nr)
605+
if (pci_is_root_bus(bus))
610606
return dw_pcie_rd_own_conf(pp, where, size, val);
611607

612608
return dw_pcie_rd_other_conf(pp, bus, devfn, where, size, val);
@@ -620,7 +616,7 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
620616
if (!dw_pcie_valid_device(pp, bus, PCI_SLOT(devfn)))
621617
return PCIBIOS_DEVICE_NOT_FOUND;
622618

623-
if (bus->number == pp->root_bus_nr)
619+
if (pci_is_root_bus(bus))
624620
return dw_pcie_wr_own_conf(pp, where, size, val);
625621

626622
return dw_pcie_wr_other_conf(pp, bus, devfn, where, size, val);

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ struct dw_pcie_host_ops {
173173
};
174174

175175
struct pcie_port {
176-
u8 root_bus_nr;
177176
u64 cfg0_base;
178177
void __iomem *va_cfg0_base;
179178
u32 cfg0_size;

0 commit comments

Comments
 (0)