PCI: keystone: Use device_get_match_data()
Subsystems (2)
PATCH 1/1 PCI: keystone: Use device_get_match_data()
Instead of manipulations with OF APIs, use device_get_match_data().
While at it, drop of_match_ptr() completely and make compiler happy, otherwise it complains:
pci-keystone.c:1069:34: warning: ‘ks_pcie_of_match’ defined but not used [-Wunused-const-variable=]
--- drivers/pci/controller/dwc/pci-keystone.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +3 -4
@@ -24,6 +24,7 @@#include <linux/of_pci.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/resource.h> #include <linux/signal.h>
@@ -1091,7 +1092,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *np = dev->of_node;const struct ks_pcie_of_data *data; -const struct of_device_id *match;enum dw_pcie_device_mode mode;struct dw_pcie *pci;struct keystone_pcie *ks_pcie;
@@ -1108,8 +1108,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)int irq;int i; - match =of_match_device (of_match_ptr (ks_pcie_of_match), dev); - data = (struct ks_pcie_of_data *)match->data; + data =device_get_match_data (dev);if (!data)return -EINVAL ;
@@ -1309,7 +1308,7 @@ static struct platform_driver ks_pcie_driver __refdata = { .remove = __exit_p(ks_pcie_remove), .driver = { .name = "keystone-pcie", - .of_match_table = of_match_ptr(ks_pcie_of_match), + .of_match_table = ks_pcie_of_match, }, };builtin_platform_driver (ks_pcie_driver);
Signature · 1 line
2.30.2
Quoted 6 lines · Andy Shevchenko
Instead of manipulations with OF APIs, use
device_get_match_data().While at it, drop
of_match_ptr()completely and make compiler happy, otherwise it complains:pci-keystone.c:1069:34: warning: ‘ks_pcie_of_match’ defined but not used [-Wunused-const-variable=]
These are two separate things and I'd prefer two separate patches.
I have a to-do item on my list to replace of_match_device(), as you did here. I originally suggested replacing with device_get_match_data(), but I think Rob prefers of_device_get_match_data() because there's really no benefit to the extra indirection of device_get_match_data(). These are not drivers that may potentially be used with either ACPI or OF; they're just OF.
Either way, I'd like to see a patch that does this for all drivers in drivers/pci/controller/ at the same time so they get slightly more consistent.
Same for the .of_match_table update; a good change that I'd like to apply universally. It looks like pcie-spear13xx.c, pcie-armada8k.c, pci-ftpci100.c, pci-v3-semi.c, pci-xgene.c, pcie-iproc-platform.c also have the same issue.
Quoted 47 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/pci/controller/dwc/pci-keystone.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/pci/controller/dwc/pci-keystone.c +3
-4@@ -24,6 +24,7 @@#include <linux/of_pci.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/resource.h> #include <linux/signal.h> @@ -1091,7 +1092,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *np = dev->of_node;const struct ks_pcie_of_data *data; -const struct of_device_id *match;enum dw_pcie_device_mode mode;struct dw_pcie *pci;struct keystone_pcie *ks_pcie;@@ -1108,8 +1108,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)int irq;int i; - match =of_match_device (of_match_ptr (ks_pcie_of_match), dev); - data = (struct ks_pcie_of_data *)match->data; + data =device_get_match_data (dev);if (!data)return -EINVAL ;@@ -1309,7 +1308,7 @@ static struct platform_driver ks_pcie_driver __refdata = { .remove = __exit_p(ks_pcie_remove), .driver = { .name = "keystone-pcie", - .of_match_table = of_match_ptr(ks_pcie_of_match), + .of_match_table = ks_pcie_of_match, }, };builtin_platform_driver (ks_pcie_driver);Signature · 1 line
2.30.2
Quoted 17 lines · Bjorn Helgaas
Quoted 6 lines · Andy Shevchenko
Instead of manipulations with OF APIs, use
device_get_match_data().While at it, drop
of_match_ptr()completely and make compiler happy, otherwise it complains:pci-keystone.c:1069:34: warning: ‘ks_pcie_of_match’ defined but not used [-Wunused-const-variable=]
These are two separate things and I'd prefer two separate patches.
I have a to-do item on my list to replace
of_match_device(), as you did here. I originally suggested replacing withdevice_get_match_data(), but I think Rob prefersof_device_get_match_data()because there's really no benefit to the extra indirection ofdevice_get_match_data(). These are not drivers that may potentially be used with either ACPI or OF; they're just OF.
Quoted 8 lines
Either way, I'd like to see a patch that does this for all drivers in
drivers/pci/controller/at the same time so they get slightly more consistent.Same for the .of_match_table update; a good change that I'd like to apply universally. It looks like
pcie-spear13xx.c,pcie-armada8k.c,pci-ftpci100.c,pci-v3-semi.c,pci-xgene.c,pcie-iproc-platform.calso have the same issue.
Thanks for the review, I will drop this.
Signature · 2 lines
With Best Regards, Andy Shevchenko