History

PCI: host-generic: Eliminate pci_host_common_probe wrappers

Most ECAM host drivers are just different pci_ecam_ops which can be DT match table data. That's already the case in some cases, but let's do that for all the ECAM drivers. Then we can use of_device_get_match_data() in pci_host_common_probe() and eliminate the probe wrapper functions and use pci_host_common_probe() directly for probe.

Rob Herring committed 6 years ago

Commit b2f75a41 parent 0c59c067 files · +25 −44Browse files

Unified · Split

7 files
  1. drivers/pci/controller/dwc/pcie-hisi.c +1 −10
  2. drivers/pci/controller/pci-host-common.c +7 −2
  3. drivers/pci/controller/pci-host-generic.c +1 −14
  4. drivers/pci/controller/pci-thunder-ecam.c +5 −7
  5. drivers/pci/controller/pci-thunder-pem.c +5 −7
  6. drivers/pci/controller/pcie-tango.c +5 −2
  7. include/linux/pci-ecam.h +1 −2
drivers/pci/controller/dwc/pcie-hisi.c+1−10
@@ -332,15 +332,6 @@ static struct platform_driver hisi_pcie_driver = { · 331 unmodified lines
332332 };
333333 builtin_platform_driver(hisi_pcie_driver);
334334
335−static int hisi_pcie_almost_ecam_probe(struct platform_device *pdev)
336−{
337− struct device *dev = &pdev->dev;
338− struct pci_ecam_ops *ops;
339−
340− ops = (struct pci_ecam_ops *)of_device_get_match_data(dev);
341− return pci_host_common_probe(pdev, ops);
342−}
343−
344335 static int hisi_pcie_platform_init(struct pci_config_window *cfg)
345336 {
346337 struct device *dev = cfg->parent;
@@ -385,7 +376,7 @@ static const struct of_device_id hisi_pcie_almost_ecam_of_match[] = { · 38 unmodified lines
385376 };
386377
387378 static struct platform_driver hisi_pcie_almost_ecam_driver = {
388− .probe = hisi_pcie_almost_ecam_probe,
379+ .probe = pci_host_common_probe,
389380 .driver = {
390381 .name = "hisi-pcie-almost-ecam",
391382 .of_match_table = hisi_pcie_almost_ecam_of_match,
drivers/pci/controller/pci-host-common.c+7−2
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <linux/kernel.h>
1111 #include <linux/module.h>
1212 #include <linux/of_address.h>
13+#include <linux/of_device.h>
1314 #include <linux/of_pci.h>
1415 #include <linux/pci-ecam.h>
1516 #include <linux/platform_device.h>
@@ -55,15 +56,19 @@ err_out: · 39 unmodified lines
5556 return ERR_PTR(err);
5657 }
5758
58−int pci_host_common_probe(struct platform_device *pdev,
59− const struct pci_ecam_ops *ops)
59+int pci_host_common_probe(struct platform_device *pdev)
6060 {
6161 struct device *dev = &pdev->dev;
6262 struct pci_host_bridge *bridge;
6363 struct pci_config_window *cfg;
6464 struct list_head resources;
65+ const struct pci_ecam_ops *ops;
6566 int ret;
6667
68+ ops = of_device_get_match_data(&pdev->dev);
69+ if (!ops)
70+ return -ENODEV;
71+
6772 bridge = devm_pci_alloc_host_bridge(dev, 0);
6873 if (!bridge)
6974 return -ENOMEM;
drivers/pci/controller/pci-host-generic.c+1−14
@@ -11,8 +11,6 @@ · 10 unmodified lines
1111 #include <linux/kernel.h>
1212 #include <linux/init.h>
1313 #include <linux/module.h>
14−#include <linux/of_address.h>
15−#include <linux/of_pci.h>
1614 #include <linux/pci-ecam.h>
1715 #include <linux/platform_device.h>
1816
@@ -79,23 +77,12 @@ static const struct of_device_id gen_pci_of_match[] = { · 60 unmodified lines
7977 };
8078 MODULE_DEVICE_TABLE(of, gen_pci_of_match);
8179
82−static int gen_pci_probe(struct platform_device *pdev)
83−{
84− const struct of_device_id *of_id;
85− struct pci_ecam_ops *ops;
86−
87− of_id = of_match_node(gen_pci_of_match, pdev->dev.of_node);
88− ops = (struct pci_ecam_ops *)of_id->data;
89−
90− return pci_host_common_probe(pdev, ops);
91−}
92−
9380 static struct platform_driver gen_pci_driver = {
9481 .driver = {
9582 .name = "pci-host-generic",
9683 .of_match_table = gen_pci_of_match,
9784 },
98− .probe = gen_pci_probe,
85+ .probe = pci_host_common_probe,
9986 .remove = pci_host_common_remove,
10087 };
10188 module_platform_driver(gen_pci_driver);
drivers/pci/controller/pci-thunder-ecam.c+5−7
@@ -357,22 +357,20 @@ const struct pci_ecam_ops pci_thunder_ecam_ops = { · 356 unmodified lines
357357 #ifdef CONFIG_PCI_HOST_THUNDER_ECAM
358358
359359 static const struct of_device_id thunder_ecam_of_match[] = {
360− { .compatible = "cavium,pci-host-thunder-ecam" },
360+ {
361+ .compatible = "cavium,pci-host-thunder-ecam",
362+ .data = &pci_thunder_ecam_ops,
363+ },
361364 { },
362365 };
363366
364−static int thunder_ecam_probe(struct platform_device *pdev)
365−{
366− return pci_host_common_probe(pdev, &pci_thunder_ecam_ops);
367−}
368−
369367 static struct platform_driver thunder_ecam_driver = {
370368 .driver = {
371369 .name = KBUILD_MODNAME,
372370 .of_match_table = thunder_ecam_of_match,
373371 .suppress_bind_attrs = true,
374372 },
375− .probe = thunder_ecam_probe,
373+ .probe = pci_host_common_probe,
376374 };
377375 builtin_platform_driver(thunder_ecam_driver);
378376
drivers/pci/controller/pci-thunder-pem.c+5−7
@@ -451,22 +451,20 @@ static const struct pci_ecam_ops pci_thunder_pem_ops = { · 450 unmodified lines
451451 };
452452
453453 static const struct of_device_id thunder_pem_of_match[] = {
454− { .compatible = "cavium,pci-host-thunder-pem" },
454+ {
455+ .compatible = "cavium,pci-host-thunder-pem",
456+ .data = &pci_thunder_pem_ops,
457+ },
455458 { },
456459 };
457460
458−static int thunder_pem_probe(struct platform_device *pdev)
459−{
460− return pci_host_common_probe(pdev, &pci_thunder_pem_ops);
461−}
462−
463461 static struct platform_driver thunder_pem_driver = {
464462 .driver = {
465463 .name = KBUILD_MODNAME,
466464 .of_match_table = thunder_pem_of_match,
467465 .suppress_bind_attrs = true,
468466 },
469− .probe = thunder_pem_probe,
467+ .probe = pci_host_common_probe,
470468 };
471469 builtin_platform_driver(thunder_pem_driver);
472470
drivers/pci/controller/pcie-tango.c+5−2
@@ -295,11 +295,14 @@ static int tango_pcie_probe(struct platform_device *pdev) · 294 unmodified lines
295295 spin_lock_init(&pcie->used_msi_lock);
296296 irq_set_chained_handler_and_data(virq, tango_msi_isr, pcie);
297297
298− return pci_host_common_probe(pdev, &smp8759_ecam_ops);
298+ return pci_host_common_probe(pdev);
299299 }
300300
301301 static const struct of_device_id tango_pcie_ids[] = {
302− { .compatible = "sigma,smp8759-pcie" },
302+ {
303+ .compatible = "sigma,smp8759-pcie",
304+ .data = &smp8759_ecam_ops,
305+ },
303306 { },
304307 };
305308
include/linux/pci-ecam.h+1−2
@@ -61,8 +61,7 @@ extern const struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */ · 60 unmodified lines
6161
6262 #if IS_ENABLED(CONFIG_PCI_HOST_COMMON)
6363 /* for DT-based PCI controllers that support ECAM */
64−int pci_host_common_probe(struct platform_device *pdev,
65− const struct pci_ecam_ops *ops);
64+int pci_host_common_probe(struct platform_device *pdev);
6665 int pci_host_common_remove(struct platform_device *pdev);
6766 #endif
6867 #endif