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

PCI: generic: Add pci_host_common_probe(), based on gen_pci_probe()

Factor gen_pci_probe(), moving most of it into pci_host_common_probe()
where it can be shared with other drivers that have slightly different
config accessors. No functional change intended.

[bhelgaas: split into separate patch, changelog]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Will Deacon <will.deacon@arm.com>

authored by

David Daney and committed by
Bjorn Helgaas
d51b3710 7149b9fd

+17 -8
+17 -8
drivers/pci/host/pci-host-generic.c
··· 182 182 return 0; 183 183 } 184 184 185 - static int gen_pci_probe(struct platform_device *pdev) 185 + static int pci_host_common_probe(struct platform_device *pdev, 186 + struct gen_pci *pci) 186 187 { 187 188 int err; 188 189 const char *type; 189 - const struct of_device_id *of_id; 190 190 struct device *dev = &pdev->dev; 191 191 struct device_node *np = dev->of_node; 192 - struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); 193 192 struct pci_bus *bus, *child; 194 - 195 - if (!pci) 196 - return -ENOMEM; 197 193 198 194 type = of_get_property(np, "device_type", NULL); 199 195 if (!type || strcmp(type, "pci")) { ··· 199 203 200 204 of_pci_check_probe_only(); 201 205 202 - of_id = of_match_node(gen_pci_of_match, np); 203 - pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data; 204 206 pci->host.dev.parent = dev; 205 207 INIT_LIST_HEAD(&pci->host.windows); 206 208 INIT_LIST_HEAD(&pci->resources); ··· 239 245 240 246 pci_bus_add_devices(bus); 241 247 return 0; 248 + } 249 + 250 + static int gen_pci_probe(struct platform_device *pdev) 251 + { 252 + struct device *dev = &pdev->dev; 253 + const struct of_device_id *of_id; 254 + struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); 255 + 256 + if (!pci) 257 + return -ENOMEM; 258 + 259 + of_id = of_match_node(gen_pci_of_match, dev->of_node); 260 + pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data; 261 + 262 + return pci_host_common_probe(pdev, pci); 242 263 } 243 264 244 265 static struct platform_driver gen_pci_driver = {