Skip to content

Commit d84c572

Browse files
robherringLorenzo Pieralisi
authored andcommitted
PCI: rockchip: 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. Also, bridge->busnr is never set so effectively the root bus must be 0. This will be fixed by a subsequent commit. 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: Shawn Lin <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Heiko Stuebner <[email protected]> Cc: [email protected]
1 parent 49169c2 commit d84c572

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

drivers/pci/controller/pcie-rockchip-host.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ static int rockchip_pcie_valid_device(struct rockchip_pcie *rockchip,
7272
struct pci_bus *bus, int dev)
7373
{
7474
/* access only one slot on each root port */
75-
if (bus->number == rockchip->root_bus_nr && dev > 0)
75+
if (pci_is_root_bus(bus) && dev > 0)
7676
return 0;
7777

7878
/*
7979
* do not read more than one device on the bus directly attached
8080
* to RC's downstream side.
8181
*/
82-
if (bus->primary == rockchip->root_bus_nr && dev > 0)
82+
if (pci_is_root_bus(bus->parent) && dev > 0)
8383
return 0;
8484

8585
return 1;
@@ -170,7 +170,7 @@ static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip,
170170
return PCIBIOS_BAD_REGISTER_NUMBER;
171171
}
172172

173-
if (bus->parent->number == rockchip->root_bus_nr)
173+
if (pci_is_root_bus(bus->parent))
174174
rockchip_pcie_cfg_configuration_accesses(rockchip,
175175
AXI_WRAPPER_TYPE0_CFG);
176176
else
@@ -201,7 +201,7 @@ static int rockchip_pcie_wr_other_conf(struct rockchip_pcie *rockchip,
201201
if (!IS_ALIGNED(busdev, size))
202202
return PCIBIOS_BAD_REGISTER_NUMBER;
203203

204-
if (bus->parent->number == rockchip->root_bus_nr)
204+
if (pci_is_root_bus(bus->parent))
205205
rockchip_pcie_cfg_configuration_accesses(rockchip,
206206
AXI_WRAPPER_TYPE0_CFG);
207207
else
@@ -230,7 +230,7 @@ static int rockchip_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
230230
return PCIBIOS_DEVICE_NOT_FOUND;
231231
}
232232

233-
if (bus->number == rockchip->root_bus_nr)
233+
if (pci_is_root_bus(bus))
234234
return rockchip_pcie_rd_own_conf(rockchip, where, size, val);
235235

236236
return rockchip_pcie_rd_other_conf(rockchip, bus, devfn, where, size,
@@ -245,7 +245,7 @@ static int rockchip_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
245245
if (!rockchip_pcie_valid_device(rockchip, bus, PCI_SLOT(devfn)))
246246
return PCIBIOS_DEVICE_NOT_FOUND;
247247

248-
if (bus->number == rockchip->root_bus_nr)
248+
if (pci_is_root_bus(bus))
249249
return rockchip_pcie_wr_own_conf(rockchip, where, size, val);
250250

251251
return rockchip_pcie_wr_other_conf(rockchip, bus, devfn, where, size,
@@ -950,7 +950,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
950950
struct rockchip_pcie *rockchip;
951951
struct device *dev = &pdev->dev;
952952
struct pci_host_bridge *bridge;
953-
struct resource *bus_res;
954953
int err;
955954

956955
if (!dev->of_node)
@@ -991,12 +990,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
991990
goto err_deinit_port;
992991

993992
err = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
994-
&bridge->dma_ranges, &bus_res);
993+
&bridge->dma_ranges, NULL);
995994
if (err)
996995
goto err_remove_irq_domain;
997996

998-
rockchip->root_bus_nr = bus_res->start;
999-
1000997
err = rockchip_pcie_cfg_atu(rockchip);
1001998
if (err)
1002999
goto err_remove_irq_domain;

drivers/pci/controller/pcie-rockchip.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ struct rockchip_pcie {
298298
struct gpio_desc *ep_gpio;
299299
u32 lanes;
300300
u8 lanes_map;
301-
u8 root_bus_nr;
302301
int link_gen;
303302
struct device *dev;
304303
struct irq_domain *irq_domain;

0 commit comments

Comments
 (0)