diff options
author | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2017-06-28 16:14:00 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2017-07-02 17:14:26 -0400 |
commit | ae13cb9b1926e821ab8b5f00995f829f10d9fa20 (patch) | |
tree | 7005f61fe522f6d542c1b75b61ce28ec1b2cd584 | |
parent | 4246a86472ddcf6f33a74ede8ad1bfbcda66c5df (diff) |
PCI: rockchip: Convert PCI scan API to pci_scan_root_bus_bridge()
The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.
Convert PCI rockchip host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Wenrui Li <wenrui.li@rock-chips.com>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
-rw-r--r-- | drivers/pci/host/pcie-rockchip.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c index 0e020b6e0943..cae5a6dec8b0 100644 --- a/drivers/pci/host/pcie-rockchip.c +++ b/drivers/pci/host/pcie-rockchip.c | |||
@@ -1284,6 +1284,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev) | |||
1284 | struct rockchip_pcie *rockchip; | 1284 | struct rockchip_pcie *rockchip; |
1285 | struct device *dev = &pdev->dev; | 1285 | struct device *dev = &pdev->dev; |
1286 | struct pci_bus *bus, *child; | 1286 | struct pci_bus *bus, *child; |
1287 | struct pci_host_bridge *bridge; | ||
1287 | struct resource_entry *win; | 1288 | struct resource_entry *win; |
1288 | resource_size_t io_base; | 1289 | resource_size_t io_base; |
1289 | struct resource *mem; | 1290 | struct resource *mem; |
@@ -1295,10 +1296,12 @@ static int rockchip_pcie_probe(struct platform_device *pdev) | |||
1295 | if (!dev->of_node) | 1296 | if (!dev->of_node) |
1296 | return -ENODEV; | 1297 | return -ENODEV; |
1297 | 1298 | ||
1298 | rockchip = devm_kzalloc(dev, sizeof(*rockchip), GFP_KERNEL); | 1299 | bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rockchip)); |
1299 | if (!rockchip) | 1300 | if (!bridge) |
1300 | return -ENOMEM; | 1301 | return -ENOMEM; |
1301 | 1302 | ||
1303 | rockchip = pci_host_bridge_priv(bridge); | ||
1304 | |||
1302 | platform_set_drvdata(pdev, rockchip); | 1305 | platform_set_drvdata(pdev, rockchip); |
1303 | rockchip->dev = dev; | 1306 | rockchip->dev = dev; |
1304 | 1307 | ||
@@ -1396,11 +1399,18 @@ static int rockchip_pcie_probe(struct platform_device *pdev) | |||
1396 | goto err_free_res; | 1399 | goto err_free_res; |
1397 | } | 1400 | } |
1398 | 1401 | ||
1399 | bus = pci_scan_root_bus(&pdev->dev, 0, &rockchip_pcie_ops, rockchip, &res); | 1402 | list_splice_init(&res, &bridge->windows); |
1400 | if (!bus) { | 1403 | bridge->dev.parent = &pdev->dev; |
1401 | err = -ENOMEM; | 1404 | bridge->sysdata = rockchip; |
1405 | bridge->busnr = 0; | ||
1406 | bridge->ops = &rockchip_pcie_ops; | ||
1407 | |||
1408 | err = pci_scan_root_bus_bridge(bridge); | ||
1409 | if (!err) | ||
1402 | goto err_free_res; | 1410 | goto err_free_res; |
1403 | } | 1411 | |
1412 | bus = bridge->bus; | ||
1413 | |||
1404 | rockchip->root_bus = bus; | 1414 | rockchip->root_bus = bus; |
1405 | 1415 | ||
1406 | pci_bus_size_bridges(bus); | 1416 | pci_bus_size_bridges(bus); |