Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: xilinx-nwl: 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 xilinx-nwl 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: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>

authored by

Lorenzo Pieralisi and committed by
Bjorn Helgaas
123db533 ae13cb9b

+18 -10
+18 -10
drivers/pci/host/pcie-xilinx-nwl.c
··· 791 791 struct nwl_pcie *pcie; 792 792 struct pci_bus *bus; 793 793 struct pci_bus *child; 794 + struct pci_host_bridge *bridge; 794 795 int err; 795 796 resource_size_t iobase = 0; 796 797 LIST_HEAD(res); 797 798 798 - pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 799 - if (!pcie) 800 - return -ENOMEM; 799 + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); 800 + if (!bridge) 801 + return -ENODEV; 802 + 803 + pcie = pci_host_bridge_priv(bridge); 801 804 802 805 pcie->dev = dev; 803 806 pcie->ecam_value = NWL_ECAM_VALUE_DEFAULT; ··· 833 830 goto error; 834 831 } 835 832 836 - bus = pci_create_root_bus(dev, pcie->root_busno, 837 - &nwl_pcie_ops, pcie, &res); 838 - if (!bus) { 839 - err = -ENOMEM; 840 - goto error; 841 - } 833 + list_splice_init(&res, &bridge->windows); 834 + bridge->dev.parent = dev; 835 + bridge->sysdata = pcie; 836 + bridge->busnr = pcie->root_busno; 837 + bridge->ops = &nwl_pcie_ops; 842 838 843 839 if (IS_ENABLED(CONFIG_PCI_MSI)) { 844 840 err = nwl_pcie_enable_msi(pcie); ··· 846 844 goto error; 847 845 } 848 846 } 849 - pci_scan_child_bus(bus); 847 + 848 + err = pci_scan_root_bus_bridge(bridge); 849 + if (err) 850 + goto error; 851 + 852 + bus = bridge->bus; 853 + 850 854 pci_assign_unassigned_bus_resources(bus); 851 855 list_for_each_entry(child, &bus->children, node) 852 856 pcie_bus_configure_settings(child);