summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2016-03-11 22:25:13 +0100
committerBjorn Helgaas <bhelgaas@google.com>2016-03-11 22:48:16 +0100
commitd51b371087d7198c733d2ef3c4db8165aee4de4e (patch)
treee2373aa3244e803008d92705f287ca90bbc78953
parentPCI: generic: Move structure definitions to separate header file (diff)
downloadlinux-d51b371087d7198c733d2ef3c4db8165aee4de4e.tar.xz
linux-d51b371087d7198c733d2ef3c4db8165aee4de4e.zip
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>
-rw-r--r--drivers/pci/host/pci-host-generic.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
index 89e25b2a0bf9..d392b1e42912 100644
--- a/drivers/pci/host/pci-host-generic.c
+++ b/drivers/pci/host/pci-host-generic.c
@@ -182,19 +182,15 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
return 0;
}
-static int gen_pci_probe(struct platform_device *pdev)
+static int pci_host_common_probe(struct platform_device *pdev,
+ struct gen_pci *pci)
{
int err;
const char *type;
- const struct of_device_id *of_id;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
- struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
struct pci_bus *bus, *child;
- if (!pci)
- return -ENOMEM;
-
type = of_get_property(np, "device_type", NULL);
if (!type || strcmp(type, "pci")) {
dev_err(dev, "invalid \"device_type\" %s\n", type);
@@ -203,8 +199,6 @@ static int gen_pci_probe(struct platform_device *pdev)
of_pci_check_probe_only();
- of_id = of_match_node(gen_pci_of_match, np);
- pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data;
pci->host.dev.parent = dev;
INIT_LIST_HEAD(&pci->host.windows);
INIT_LIST_HEAD(&pci->resources);
@@ -247,6 +241,21 @@ static int gen_pci_probe(struct platform_device *pdev)
return 0;
}
+static int gen_pci_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ const struct of_device_id *of_id;
+ struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
+
+ if (!pci)
+ return -ENOMEM;
+
+ of_id = of_match_node(gen_pci_of_match, dev->of_node);
+ pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data;
+
+ return pci_host_common_probe(pdev, pci);
+}
+
static struct platform_driver gen_pci_driver = {
.driver = {
.name = "pci-host-generic",