PCI: Prefer of_device_get_match_data() over of_match_device()
Subsystems (8)
cover PCI: Prefer of_device_get_match_data() over of_match_device()
Some drivers use of_match_device() in probe(), which returns a "struct of_device_id *". They need only the of_device_id.data member, so replace of_device_get_match_data() with of_match_device().
Fan Fei (7):
PCI: altera: Prefer of_device_get_match_data() over of_match_device()
PCI: cadence: Prefer of_device_get_match_data() over of_match_device()
PCI: kirin: Prefer of_device_get_match_data() over of_match_device()
PCI: dra7xx: Prefer of_device_get_match_data() over of_match_device()
PCI: keystone: Prefer of_device_get_match_data() over
of_match_device()
PCI: artpec6: Prefer of_device_get_match_data() over of_match_device()
PCI: dwc: Prefer of_device_get_match_data() over of_device_device()
drivers/pci/controller/cadence/pcie-cadence-plat.c | 6 ++---- drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++---- drivers/pci/controller/dwc/pci-keystone.c | 4 +--- drivers/pci/controller/dwc/pcie-artpec6.c | 6 ++---- drivers/pci/controller/dwc/pcie-designware-plat.c | 6 ++---- drivers/pci/controller/dwc/pcie-kirin.c | 6 ++---- drivers/pci/controller/pcie-altera.c | 8 ++++---- 7 files changed, 15 insertions(+), 27 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/7 PCI: altera: Prefer of_device_get_match_data() over of_match_device()
The altera PCI controller driver only needs "struct altera_pcie_data *" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), to get "struct altera_pcie_data *".
--- drivers/pci/controller/pcie-altera.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-altera.c +4 -4
@@ -767,7 +767,7 @@ static int altera_pcie_probe(struct platform_device *pdev)struct altera_pcie *pcie;struct pci_host_bridge *bridge;int ret; -const struct of_device_id *match; +const struct altera_pcie_data *data; bridge =devm_pci_alloc_host_bridge (dev,sizeof (*pcie));if (!bridge)
@@ -777,11 +777,11 @@ static int altera_pcie_probe(struct platform_device *pdev) pcie->pdev = pdev;platform_set_drvdata (pdev, pcie); - match =of_match_device (altera_pcie_of_match, &pdev->dev); -if (!match) + data =of_device_get_match_data (&pdev->dev); +if (!data)return -ENODEV ; - pcie->pcie_data = match->data; + pcie->pcie_data = data; ret =altera_pcie_parse_dt (pcie);if (ret) {
Signature · 1 line
2.25.1
PATCH 2/7 PCI: cadence: Prefer of_device_get_match_data() over of_match_device()
In reply to Fan FeiThe cadence PCI controller driver only needs
"struct cdns_plat_pcie_of_data *" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), to get "struct cdns_plat_pcie_of_data *" directly.
--- drivers/pci/controller/cadence/pcie-cadence-plat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-plat.c +2 -4
@@ -45,7 +45,6 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) {const struct cdns_plat_pcie_of_data *data;struct cdns_plat_pcie *cdns_plat_pcie; -const struct of_device_id *match;struct device *dev = &pdev->dev;struct pci_host_bridge *bridge;struct cdns_pcie_ep *ep;
@@ -54,11 +53,10 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev)bool is_rc;int ret; - match =of_match_device (cdns_plat_pcie_of_match, dev); -if (!match) + data =of_device_get_match_data (dev); +if (!data)return -EINVAL ; - data = (struct cdns_plat_pcie_of_data *)match->data; is_rc = data->is_rc;pr_debug (" Started %s with is_rc: %d\n" , __func__, is_rc);
Signature · 1 line
2.25.1
PATCH 3/7 PCI: kirin: Prefer of_device_get_match_data() over of_match_device()
In reply to Fan FeiThe kirin PCI controller driver only needs "enum pcie_kirin_phy_type" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), and cast to long type, referring "enum pcie_kirin_phy_type".
--- drivers/pci/controller/dwc/pcie-kirin.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-kirin.c +2 -4
@@ -773,7 +773,6 @@ static const struct of_device_id kirin_pcie_match[] = {static int kirin_pcie_probe (struct platform_device *pdev) {enum pcie_kirin_phy_type phy_type; -const struct of_device_id *of_id;struct device *dev = &pdev->dev;struct kirin_pcie *kirin_pcie;struct dw_pcie *pci;
@@ -784,13 +783,12 @@ static int kirin_pcie_probe(struct platform_device *pdev)return -EINVAL ; } - of_id =of_match_device (kirin_pcie_match, dev); -if (!of_id) { + phy_type = (long )of_device_get_match_data (dev); +if (!phy_type) {dev_err (dev,"OF data missing\n" );return -EINVAL ; } - phy_type = (long )of_id->data; kirin_pcie =devm_kzalloc (dev,sizeof (struct kirin_pcie ),GFP_KERNEL );if (!kirin_pcie)
Signature · 1 line
2.25.1
PATCH 4/7 PCI: dra7xx: Prefer of_device_get_match_data() over of_match_device()
In reply to Fan FeiThe dra7xx PCI controller driver only needs "struct dra7xx_pcie_of_data *" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), to get "struct dra7xx_pcie_of_data *" directly.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +2 -4
@@ -697,16 +697,14 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)struct device_node *np = dev->of_node;char name[10 ];struct gpio_desc *reset; -const struct of_device_id *match;const struct dra7xx_pcie_of_data *data;enum dw_pcie_device_mode mode;u32 b1co_mode_sel_mask; - match =of_match_device (of_match_ptr (of_dra7xx_pcie_match), dev); -if (!match) + data =of_device_get_match_data (dev); +if (!data)return -EINVAL ; - data = (struct dra7xx_pcie_of_data *)match->data; mode = (enum dw_pcie_device_mode )data->mode; b1co_mode_sel_mask = data->b1co_mode_sel_mask;
Signature · 1 line
2.25.1
PATCH 5/7 PCI: keystone: Prefer of_device_get_match_data() over of_match_device()
In reply to Fan FeiThe keystone PCI controller driver only needs "struct ks_pcie_of_data *" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), to get "struct ks_pcie_of_data *" directly.
--- drivers/pci/controller/dwc/pci-keystone.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +1 -3
@@ -1087,7 +1087,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;
@@ -1104,8 +1103,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 =of_device_get_match_data (dev);if (!data)return -EINVAL ;
Signature · 1 line
2.25.1
PATCH 6/7 PCI: artpec6: Prefer of_device_get_match_data() over of_match_device()
In reply to Fan FeiThe artpec6 PCI controller driver only needs "struct artpec_pcie_of_data *" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), to get "struct artpec_pcie_of_data *" directly.
--- drivers/pci/controller/dwc/pcie-artpec6.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-artpec6.c +2 -4
@@ -380,17 +380,15 @@ static int artpec6_pcie_probe(struct platform_device *pdev)struct dw_pcie *pci;struct artpec6_pcie *artpec6_pcie;int ret; -const struct of_device_id *match;const struct artpec_pcie_of_data *data;enum artpec_pcie_variants variant;enum dw_pcie_device_mode mode;u32 val; - match =of_match_device (artpec6_pcie_of_match, dev); -if (!match) + data =of_device_get_match_data (dev); +if (!data)return -EINVAL ; - data = (struct artpec_pcie_of_data *)match->data; variant = (enum artpec_pcie_variants )data->variant; mode = (enum dw_pcie_device_mode )data->mode;
Signature · 1 line
2.25.1
PATCH 7/7 PCI: dwc: Prefer of_device_get_match_data() over of_device_device()
In reply to Fan FeiThe dw_plat PCI controller driver only needs
"struct dw_plat_pcie_of_data *" during probe(). Replace of_match_device(), which returns "struct of_device_id *", with of_device_get_match_data(), to get "struct dw_plat_pcie_of_data *" directly.
--- drivers/pci/controller/dwc/pcie-designware-plat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-designware-plat.c +2 -4
@@ -122,15 +122,13 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)struct dw_plat_pcie *dw_plat_pcie;struct dw_pcie *pci;int ret; -const struct of_device_id *match;const struct dw_plat_pcie_of_data *data;enum dw_pcie_device_mode mode; - match =of_match_device (dw_plat_pcie_of_match, dev); -if (!match) + data =of_device_get_match_data (dev); +if (!data)return -EINVAL ; - data = (struct dw_plat_pcie_of_data *)match->data; mode = (enum dw_pcie_device_mode )data->mode; dw_plat_pcie =devm_kzalloc (dev,sizeof (*dw_plat_pcie),GFP_KERNEL );
Signature · 1 line
2.25.1
Bjorn Helgaas
AppliedQuoted 14 lines · Fan Fei
Some drivers use
of_match_device()inprobe(), which returns a "structof_device_id*". They need only the of_device_id.data member, so replaceof_device_get_match_data()withof_match_device().Fan Fei (7):
PCI: altera: Preferof_device_get_match_data()overof_match_device()
PCI: cadence: Preferof_device_get_match_data()overof_match_device()
PCI: kirin: Preferof_device_get_match_data()overof_match_device()
PCI: dra7xx: Preferof_device_get_match_data()overof_match_device()
PCI: keystone: Preferof_device_get_match_data()over
of_match_device()
PCI: artpec6: Preferof_device_get_match_data()overof_match_device()
PCI: dwc: Preferof_device_get_match_data()overof_device_device()
Quoted 8 lines
drivers/pci/controller/cadence/pcie-cadence-plat.c | 6 ++---- drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++---- drivers/pci/controller/dwc/pci-keystone.c | 4 +--- drivers/pci/controller/dwc/pcie-artpec6.c | 6 ++---- drivers/pci/controller/dwc/pcie-designware-plat.c | 6 ++---- drivers/pci/controller/dwc/pcie-kirin.c | 6 ++---- drivers/pci/controller/pcie-altera.c | 8 ++++---- 7 files changed, 15 insertions(+), 27 deletions(-)
Applied to pci/driver-cleanup for v5.17, thank you, Fan!
Quoted 24 lines · Bjorn Helgaas
Quoted 14 lines · Fan Fei
Some drivers use
of_match_device()inprobe(), which returns a "structof_device_id*". They need only the of_device_id.data member, so replaceof_device_get_match_data()withof_match_device().Fan Fei (7):
PCI: altera: Preferof_device_get_match_data()overof_match_device()
PCI: cadence: Preferof_device_get_match_data()overof_match_device()
PCI: kirin: Preferof_device_get_match_data()overof_match_device()
PCI: dra7xx: Preferof_device_get_match_data()overof_match_device()
PCI: keystone: Preferof_device_get_match_data()over
of_match_device()
PCI: artpec6: Preferof_device_get_match_data()overof_match_device()
PCI: dwc: Preferof_device_get_match_data()overof_device_device()Quoted 8 lines
drivers/pci/controller/cadence/pcie-cadence-plat.c | 6 ++---- drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++---- drivers/pci/controller/dwc/pci-keystone.c | 4 +--- drivers/pci/controller/dwc/pcie-artpec6.c | 6 ++---- drivers/pci/controller/dwc/pcie-designware-plat.c | 6 ++---- drivers/pci/controller/dwc/pcie-kirin.c | 6 ++---- drivers/pci/controller/pcie-altera.c | 8 ++++---- 7 files changed, 15 insertions(+), 27 deletions(-)
Quoted 1 line
Applied to pci/driver-cleanup for v5.17, thank you, Fan!
Also applied the following patch since it's closely related.
commit 667c60afad25 ("PCI: j721e: Drop pointless of_device_get_match_data() cast")
Author: Bjorn Helgaas <[email protected]> Date: Wed Dec 8 15:18:20 2021 -0600
PCI: j721e: Drop pointless of_device_get_match_data() cast
of_device_get_match_data() returns "void *", so no cast is needed when assigning the result to a pointer type. Drop the unnecessary cast.
drivers/pci/controller/cadence/pci-j721e.c +1 -1
@@ -367,7 +367,7 @@ static int j721e_pcie_probe(struct platform_device *pdev)int ret;int irq; - data = (struct j721e_pcie_data *)of_device_get_match_data (dev); + data =of_device_get_match_data (dev);if (!data)return -EINVAL ;