* [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:19 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:19 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, linux-arm-kernel,
bcm-kernel-feedback-list, Mingkai Hu, Roy Zang, Shailendra Verma
This turned into much ado about nothing, but Shailendra's hisi patch
prompted similar cleanups in other drivers. It's a minor simplification,
but I think worth doing consistently across drivers.
Basically this is Geert's observation that when the driver probe function
is called only as a result of matching something in <match_table>, a
subsequent of_match_device(<match_table>, dev) call should never fail.
Therefore, instead of this:
struct of_device_id *match;
match = of_match_device(<match_table>, dev);
... = match->data;
we can do this:
... = of_device_get_match_data(dev);
---
Bjorn Helgaas (3):
PCI: iproc: Use of_device_get_match_data() to simplify probe
PCI: layerscape: Use of_device_get_match_data() to simplify probe
PCI: rcar: Use of_device_get_match_data() to simplify probe
Shailendra Verma (1):
PCI: hisi: Use of_device_get_match_data() to simplify probe
drivers/pci/host/pci-layerscape.c | 7 +------
drivers/pci/host/pcie-hisi.c | 8 +++-----
drivers/pci/host/pcie-iproc-platform.c | 7 +------
drivers/pci/host/pcie-rcar.c | 7 +------
4 files changed, 6 insertions(+), 23 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:19 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:19 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui, Roy Zang,
linux-renesas-soc, Minghuan Lian, Zhou Wang, Simon Horman,
Geert Uytterhoeven, Shailendra Verma, bcm-kernel-feedback-list,
Mingkai Hu, linuxppc-dev, linux-arm-kernel
This turned into much ado about nothing, but Shailendra's hisi patch
prompted similar cleanups in other drivers. It's a minor simplification,
but I think worth doing consistently across drivers.
Basically this is Geert's observation that when the driver probe function
is called only as a result of matching something in <match_table>, a
subsequent of_match_device(<match_table>, dev) call should never fail.
Therefore, instead of this:
struct of_device_id *match;
match = of_match_device(<match_table>, dev);
... = match->data;
we can do this:
... = of_device_get_match_data(dev);
---
Bjorn Helgaas (3):
PCI: iproc: Use of_device_get_match_data() to simplify probe
PCI: layerscape: Use of_device_get_match_data() to simplify probe
PCI: rcar: Use of_device_get_match_data() to simplify probe
Shailendra Verma (1):
PCI: hisi: Use of_device_get_match_data() to simplify probe
drivers/pci/host/pci-layerscape.c | 7 +------
drivers/pci/host/pcie-hisi.c | 8 +++-----
drivers/pci/host/pcie-iproc-platform.c | 7 +------
drivers/pci/host/pcie-rcar.c | 7 +------
4 files changed, 6 insertions(+), 23 deletions(-)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:19 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:19 UTC (permalink / raw)
To: linux-arm-kernel
This turned into much ado about nothing, but Shailendra's hisi patch
prompted similar cleanups in other drivers. It's a minor simplification,
but I think worth doing consistently across drivers.
Basically this is Geert's observation that when the driver probe function
is called only as a result of matching something in <match_table>, a
subsequent of_match_device(<match_table>, dev) call should never fail.
Therefore, instead of this:
struct of_device_id *match;
match = of_match_device(<match_table>, dev);
... = match->data;
we can do this:
... = of_device_get_match_data(dev);
---
Bjorn Helgaas (3):
PCI: iproc: Use of_device_get_match_data() to simplify probe
PCI: layerscape: Use of_device_get_match_data() to simplify probe
PCI: rcar: Use of_device_get_match_data() to simplify probe
Shailendra Verma (1):
PCI: hisi: Use of_device_get_match_data() to simplify probe
drivers/pci/host/pci-layerscape.c | 7 +------
drivers/pci/host/pcie-hisi.c | 8 +++-----
drivers/pci/host/pcie-iproc-platform.c | 7 +------
drivers/pci/host/pcie-rcar.c | 7 +------
4 files changed, 6 insertions(+), 23 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1 1/4] PCI: hisi: Use of_device_get_match_data() to simplify probe
2017-01-31 20:19 ` Bjorn Helgaas
@ 2017-01-31 20:19 ` Bjorn Helgaas
-1 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:19 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, linux-arm-kernel,
bcm-kernel-feedback-list, Mingkai Hu, Roy Zang, Shailendra Verma
From: Shailendra Verma <shailendra.v@samsung.com>
The only way to call hisi_pcie_probe() is to match an entry in
hisi_pcie_of_match[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the soc_ops pointer. No
functional change intended.
[bhelgaas: use of_device_get_match_data(), changelog]
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-hisi.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/host/pcie-hisi.c b/drivers/pci/host/pcie-hisi.c
index a301a7187b30..33c201afdbf1 100644
--- a/drivers/pci/host/pcie-hisi.c
+++ b/drivers/pci/host/pcie-hisi.c
@@ -139,7 +139,7 @@ struct hisi_pcie {
struct pcie_port pp; /* pp.dbi_base is DT rc_dbi */
struct regmap *subctrl;
u32 port_id;
- struct pcie_soc_ops *soc_ops;
+ const struct pcie_soc_ops *soc_ops;
};
/* HipXX PCIe host only supports 32-bit config access */
@@ -259,7 +259,6 @@ static int hisi_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct hisi_pcie *hisi_pcie;
struct pcie_port *pp;
- const struct of_device_id *match;
struct resource *reg;
struct device_driver *driver;
int ret;
@@ -272,11 +271,10 @@ static int hisi_pcie_probe(struct platform_device *pdev)
pp->dev = dev;
driver = dev->driver;
- match = of_match_device(driver->of_match_table, dev);
- hisi_pcie->soc_ops = (struct pcie_soc_ops *) match->data;
+ hisi_pcie->soc_ops = of_device_get_match_data(dev);
hisi_pcie->subctrl =
- syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl");
+ syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl");
if (IS_ERR(hisi_pcie->subctrl)) {
dev_err(dev, "cannot get subctrl base\n");
return PTR_ERR(hisi_pcie->subctrl);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 1/4] PCI: hisi: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:19 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:19 UTC (permalink / raw)
To: linux-arm-kernel
From: Shailendra Verma <shailendra.v@samsung.com>
The only way to call hisi_pcie_probe() is to match an entry in
hisi_pcie_of_match[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the soc_ops pointer. No
functional change intended.
[bhelgaas: use of_device_get_match_data(), changelog]
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-hisi.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/host/pcie-hisi.c b/drivers/pci/host/pcie-hisi.c
index a301a7187b30..33c201afdbf1 100644
--- a/drivers/pci/host/pcie-hisi.c
+++ b/drivers/pci/host/pcie-hisi.c
@@ -139,7 +139,7 @@ struct hisi_pcie {
struct pcie_port pp; /* pp.dbi_base is DT rc_dbi */
struct regmap *subctrl;
u32 port_id;
- struct pcie_soc_ops *soc_ops;
+ const struct pcie_soc_ops *soc_ops;
};
/* HipXX PCIe host only supports 32-bit config access */
@@ -259,7 +259,6 @@ static int hisi_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct hisi_pcie *hisi_pcie;
struct pcie_port *pp;
- const struct of_device_id *match;
struct resource *reg;
struct device_driver *driver;
int ret;
@@ -272,11 +271,10 @@ static int hisi_pcie_probe(struct platform_device *pdev)
pp->dev = dev;
driver = dev->driver;
- match = of_match_device(driver->of_match_table, dev);
- hisi_pcie->soc_ops = (struct pcie_soc_ops *) match->data;
+ hisi_pcie->soc_ops = of_device_get_match_data(dev);
hisi_pcie->subctrl =
- syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl");
+ syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl");
if (IS_ERR(hisi_pcie->subctrl)) {
dev_err(dev, "cannot get subctrl base\n");
return PTR_ERR(hisi_pcie->subctrl);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 2/4] PCI: iproc: Use of_device_get_match_data() to simplify probe
2017-01-31 20:19 ` Bjorn Helgaas
(?)
@ 2017-01-31 20:20 ` Bjorn Helgaas
-1 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, linux-arm-kernel,
bcm-kernel-feedback-list, Mingkai Hu, Roy Zang, Shailendra Verma
The only way to call iproc_pcie_pltfm_probe() is to match an entry in
iproc_pcie_of_match_table[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the pcie->type. No functional
change intended.
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-iproc-platform.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c
index 22d814a78a78..f4909bb0b2ad 100644
--- a/drivers/pci/host/pcie-iproc-platform.c
+++ b/drivers/pci/host/pcie-iproc-platform.c
@@ -47,7 +47,6 @@ MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table);
static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- const struct of_device_id *of_id;
struct iproc_pcie *pcie;
struct device_node *np = dev->of_node;
struct resource reg;
@@ -55,16 +54,12 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
LIST_HEAD(res);
int ret;
- of_id = of_match_device(iproc_pcie_of_match_table, dev);
- if (!of_id)
- return -EINVAL;
-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
pcie->dev = dev;
- pcie->type = (enum iproc_pcie_type)of_id->data;
+ pcie->type = (enum iproc_pcie_type) of_device_get_match_data(dev);
ret = of_address_to_resource(np, 0, ®);
if (ret < 0) {
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 2/4] PCI: iproc: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:20 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui, Roy Zang,
linux-renesas-soc, Minghuan Lian, Zhou Wang, Simon Horman,
Geert Uytterhoeven, Shailendra Verma, bcm-kernel-feedback-list,
Mingkai Hu, linuxppc-dev, linux-arm-kernel
The only way to call iproc_pcie_pltfm_probe() is to match an entry in
iproc_pcie_of_match_table[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the pcie->type. No functional
change intended.
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-iproc-platform.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c
index 22d814a78a78..f4909bb0b2ad 100644
--- a/drivers/pci/host/pcie-iproc-platform.c
+++ b/drivers/pci/host/pcie-iproc-platform.c
@@ -47,7 +47,6 @@ MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table);
static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- const struct of_device_id *of_id;
struct iproc_pcie *pcie;
struct device_node *np = dev->of_node;
struct resource reg;
@@ -55,16 +54,12 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
LIST_HEAD(res);
int ret;
- of_id = of_match_device(iproc_pcie_of_match_table, dev);
- if (!of_id)
- return -EINVAL;
-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
pcie->dev = dev;
- pcie->type = (enum iproc_pcie_type)of_id->data;
+ pcie->type = (enum iproc_pcie_type) of_device_get_match_data(dev);
ret = of_address_to_resource(np, 0, ®);
if (ret < 0) {
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 2/4] PCI: iproc: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:20 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-arm-kernel
The only way to call iproc_pcie_pltfm_probe() is to match an entry in
iproc_pcie_of_match_table[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the pcie->type. No functional
change intended.
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-iproc-platform.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c
index 22d814a78a78..f4909bb0b2ad 100644
--- a/drivers/pci/host/pcie-iproc-platform.c
+++ b/drivers/pci/host/pcie-iproc-platform.c
@@ -47,7 +47,6 @@ MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table);
static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- const struct of_device_id *of_id;
struct iproc_pcie *pcie;
struct device_node *np = dev->of_node;
struct resource reg;
@@ -55,16 +54,12 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
LIST_HEAD(res);
int ret;
- of_id = of_match_device(iproc_pcie_of_match_table, dev);
- if (!of_id)
- return -EINVAL;
-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
pcie->dev = dev;
- pcie->type = (enum iproc_pcie_type)of_id->data;
+ pcie->type = (enum iproc_pcie_type) of_device_get_match_data(dev);
ret = of_address_to_resource(np, 0, ®);
if (ret < 0) {
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 3/4] PCI: layerscape: Use of_device_get_match_data() to simplify probe
2017-01-31 20:19 ` Bjorn Helgaas
@ 2017-01-31 20:20 ` Bjorn Helgaas
-1 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, linux-arm-kernel,
bcm-kernel-feedback-list, Mingkai Hu, Roy Zang, Shailendra Verma
The only way to call ls_pcie_probe() is to match an entry in
ls_pcie_of_match[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the drvdata pointer. No
functional change intended.
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index ea789138531b..c1f06f8f05fd 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -239,23 +239,18 @@ static int __init ls_add_pcie_port(struct ls_pcie *pcie)
static int __init ls_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- const struct of_device_id *match;
struct ls_pcie *pcie;
struct pcie_port *pp;
struct resource *dbi_base;
int ret;
- match = of_match_device(ls_pcie_of_match, dev);
- if (!match)
- return -ENODEV;
-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
pp = &pcie->pp;
pp->dev = dev;
- pcie->drvdata = match->data;
+ pcie->drvdata = of_device_get_match_data(dev);
pp->ops = pcie->drvdata->ops;
dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 3/4] PCI: layerscape: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:20 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-arm-kernel
The only way to call ls_pcie_probe() is to match an entry in
ls_pcie_of_match[], so match cannot be NULL.
Use of_device_get_match_data() to retrieve the drvdata pointer. No
functional change intended.
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index ea789138531b..c1f06f8f05fd 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -239,23 +239,18 @@ static int __init ls_add_pcie_port(struct ls_pcie *pcie)
static int __init ls_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- const struct of_device_id *match;
struct ls_pcie *pcie;
struct pcie_port *pp;
struct resource *dbi_base;
int ret;
- match = of_match_device(ls_pcie_of_match, dev);
- if (!match)
- return -ENODEV;
-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
pp = &pcie->pp;
pp->dev = dev;
- pcie->drvdata = match->data;
+ pcie->drvdata = of_device_get_match_data(dev);
pp->ops = pcie->drvdata->ops;
dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 4/4] PCI: rcar: Use of_device_get_match_data() to simplify probe
2017-01-31 20:19 ` Bjorn Helgaas
@ 2017-01-31 20:20 ` Bjorn Helgaas
-1 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-pci
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, linux-arm-kernel,
bcm-kernel-feedback-list, Mingkai Hu, Roy Zang, Shailendra Verma
This is a DT-only driver, so the only way to call rcar_pcie_probe() is to
match an entry in rcar_pcie_of_match[], so of_id cannot be NULL.
Furthermore, of_id->data can only be NULL if an rcar_pcie_of_match[] entry
has a NULL .data member. That's a driver defect, and we don't want to
return -EINVAL, which is easy to ignore. We'd rather take the NULL pointer
dereference so we notice the problem and fix it.
Use of_device_get_match_data() to retrieve the hw_init_fn pointer. No
functional change intended.
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-rcar.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index aca85be101f8..b3b6d5273347 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -1125,7 +1125,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct rcar_pcie *pcie;
unsigned int data;
- const struct of_device_id *of_id;
int err;
int (*hw_init_fn)(struct rcar_pcie *);
@@ -1149,11 +1148,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
if (err)
return err;
- of_id = of_match_device(rcar_pcie_of_match, dev);
- if (!of_id || !of_id->data)
- return -EINVAL;
- hw_init_fn = of_id->data;
-
pm_runtime_enable(dev);
err = pm_runtime_get_sync(dev);
if (err < 0) {
@@ -1162,6 +1156,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
}
/* Failure to get a link might just be that no cards are inserted */
+ hw_init_fn = of_device_get_match_data(dev);
err = hw_init_fn(pcie);
if (err) {
dev_info(dev, "PCIe link down\n");
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 1 4/4] PCI: rcar: Use of_device_get_match_data() to simplify probe
@ 2017-01-31 20:20 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-01-31 20:20 UTC (permalink / raw)
To: linux-arm-kernel
This is a DT-only driver, so the only way to call rcar_pcie_probe() is to
match an entry in rcar_pcie_of_match[], so of_id cannot be NULL.
Furthermore, of_id->data can only be NULL if an rcar_pcie_of_match[] entry
has a NULL .data member. That's a driver defect, and we don't want to
return -EINVAL, which is easy to ignore. We'd rather take the NULL pointer
dereference so we notice the problem and fix it.
Use of_device_get_match_data() to retrieve the hw_init_fn pointer. No
functional change intended.
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-rcar.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index aca85be101f8..b3b6d5273347 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -1125,7 +1125,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct rcar_pcie *pcie;
unsigned int data;
- const struct of_device_id *of_id;
int err;
int (*hw_init_fn)(struct rcar_pcie *);
@@ -1149,11 +1148,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
if (err)
return err;
- of_id = of_match_device(rcar_pcie_of_match, dev);
- if (!of_id || !of_id->data)
- return -EINVAL;
- hw_init_fn = of_id->data;
-
pm_runtime_enable(dev);
err = pm_runtime_get_sync(dev);
if (err < 0) {
@@ -1162,6 +1156,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
}
/* Failure to get a link might just be that no cards are inserted */
+ hw_init_fn = of_device_get_match_data(dev);
err = hw_init_fn(pcie);
if (err) {
dev_info(dev, "PCIe link down\n");
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 1 4/4] PCI: rcar: Use of_device_get_match_data() to simplify probe
2017-01-31 20:20 ` Bjorn Helgaas
(?)
@ 2017-02-02 9:25 ` Simon Horman
-1 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2017-02-02 9:25 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-pci, Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Geert Uytterhoeven, linux-arm-kernel, bcm-kernel-feedback-list,
Mingkai Hu, Roy Zang, Shailendra Verma
On Tue, Jan 31, 2017 at 02:20:20PM -0600, Bjorn Helgaas wrote:
> This is a DT-only driver, so the only way to call rcar_pcie_probe() is to
> match an entry in rcar_pcie_of_match[], so of_id cannot be NULL.
>
> Furthermore, of_id->data can only be NULL if an rcar_pcie_of_match[] entry
> has a NULL .data member. That's a driver defect, and we don't want to
> return -EINVAL, which is easy to ignore. We'd rather take the NULL pointer
> dereference so we notice the problem and fix it.
>
> Use of_device_get_match_data() to retrieve the hw_init_fn pointer. No
> functional change intended.
>
> Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/pci/host/pcie-rcar.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index aca85be101f8..b3b6d5273347 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -1125,7 +1125,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct rcar_pcie *pcie;
> unsigned int data;
> - const struct of_device_id *of_id;
> int err;
> int (*hw_init_fn)(struct rcar_pcie *);
>
> @@ -1149,11 +1148,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (err)
> return err;
>
> - of_id = of_match_device(rcar_pcie_of_match, dev);
> - if (!of_id || !of_id->data)
> - return -EINVAL;
> - hw_init_fn = of_id->data;
> -
> pm_runtime_enable(dev);
> err = pm_runtime_get_sync(dev);
> if (err < 0) {
> @@ -1162,6 +1156,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> }
>
> /* Failure to get a link might just be that no cards are inserted */
> + hw_init_fn = of_device_get_match_data(dev);
> err = hw_init_fn(pcie);
> if (err) {
> dev_info(dev, "PCIe link down\n");
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1 4/4] PCI: rcar: Use of_device_get_match_data() to simplify probe
@ 2017-02-02 9:25 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2017-02-02 9:25 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, linux-pci, Roy Zang,
linux-renesas-soc, Minghuan Lian, Zhou Wang, Geert Uytterhoeven,
Shailendra Verma, Ray Jui, bcm-kernel-feedback-list, Mingkai Hu,
linuxppc-dev, linux-arm-kernel
On Tue, Jan 31, 2017 at 02:20:20PM -0600, Bjorn Helgaas wrote:
> This is a DT-only driver, so the only way to call rcar_pcie_probe() is to
> match an entry in rcar_pcie_of_match[], so of_id cannot be NULL.
>
> Furthermore, of_id->data can only be NULL if an rcar_pcie_of_match[] entry
> has a NULL .data member. That's a driver defect, and we don't want to
> return -EINVAL, which is easy to ignore. We'd rather take the NULL pointer
> dereference so we notice the problem and fix it.
>
> Use of_device_get_match_data() to retrieve the hw_init_fn pointer. No
> functional change intended.
>
> Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/pci/host/pcie-rcar.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index aca85be101f8..b3b6d5273347 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -1125,7 +1125,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct rcar_pcie *pcie;
> unsigned int data;
> - const struct of_device_id *of_id;
> int err;
> int (*hw_init_fn)(struct rcar_pcie *);
>
> @@ -1149,11 +1148,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (err)
> return err;
>
> - of_id = of_match_device(rcar_pcie_of_match, dev);
> - if (!of_id || !of_id->data)
> - return -EINVAL;
> - hw_init_fn = of_id->data;
> -
> pm_runtime_enable(dev);
> err = pm_runtime_get_sync(dev);
> if (err < 0) {
> @@ -1162,6 +1156,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> }
>
> /* Failure to get a link might just be that no cards are inserted */
> + hw_init_fn = of_device_get_match_data(dev);
> err = hw_init_fn(pcie);
> if (err) {
> dev_info(dev, "PCIe link down\n");
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1 4/4] PCI: rcar: Use of_device_get_match_data() to simplify probe
@ 2017-02-02 9:25 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2017-02-02 9:25 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jan 31, 2017 at 02:20:20PM -0600, Bjorn Helgaas wrote:
> This is a DT-only driver, so the only way to call rcar_pcie_probe() is to
> match an entry in rcar_pcie_of_match[], so of_id cannot be NULL.
>
> Furthermore, of_id->data can only be NULL if an rcar_pcie_of_match[] entry
> has a NULL .data member. That's a driver defect, and we don't want to
> return -EINVAL, which is easy to ignore. We'd rather take the NULL pointer
> dereference so we notice the problem and fix it.
>
> Use of_device_get_match_data() to retrieve the hw_init_fn pointer. No
> functional change intended.
>
> Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/pci/host/pcie-rcar.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index aca85be101f8..b3b6d5273347 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -1125,7 +1125,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct rcar_pcie *pcie;
> unsigned int data;
> - const struct of_device_id *of_id;
> int err;
> int (*hw_init_fn)(struct rcar_pcie *);
>
> @@ -1149,11 +1148,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (err)
> return err;
>
> - of_id = of_match_device(rcar_pcie_of_match, dev);
> - if (!of_id || !of_id->data)
> - return -EINVAL;
> - hw_init_fn = of_id->data;
> -
> pm_runtime_enable(dev);
> err = pm_runtime_get_sync(dev);
> if (err < 0) {
> @@ -1162,6 +1156,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> }
>
> /* Failure to get a link might just be that no cards are inserted */
> + hw_init_fn = of_device_get_match_data(dev);
> err = hw_init_fn(pcie);
> if (err) {
> dev_info(dev, "PCIe link down\n");
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe
2017-01-31 20:19 ` Bjorn Helgaas
(?)
@ 2017-02-03 21:07 ` Bjorn Helgaas
-1 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-02-03 21:07 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-pci, Scott Branden, Gabriele Paoloni, Jon Mason, Ray Jui,
Roy Zang, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, Shailendra Verma,
bcm-kernel-feedback-list, Mingkai Hu, linuxppc-dev,
linux-arm-kernel
On Tue, Jan 31, 2017 at 02:19:51PM -0600, Bjorn Helgaas wrote:
> This turned into much ado about nothing, but Shailendra's hisi patch
> prompted similar cleanups in other drivers. It's a minor simplification,
> but I think worth doing consistently across drivers.
>
> Basically this is Geert's observation that when the driver probe function
> is called only as a result of matching something in <match_table>, a
> subsequent of_match_device(<match_table>, dev) call should never fail.
>
> Therefore, instead of this:
>
> struct of_device_id *match;
>
> match = of_match_device(<match_table>, dev);
> ... = match->data;
>
> we can do this:
>
> ... = of_device_get_match_data(dev);
>
> ---
>
> Bjorn Helgaas (3):
> PCI: iproc: Use of_device_get_match_data() to simplify probe
> PCI: layerscape: Use of_device_get_match_data() to simplify probe
> PCI: rcar: Use of_device_get_match_data() to simplify probe
>
> Shailendra Verma (1):
> PCI: hisi: Use of_device_get_match_data() to simplify probe
>
>
> drivers/pci/host/pci-layerscape.c | 7 +------
> drivers/pci/host/pcie-hisi.c | 8 +++-----
> drivers/pci/host/pcie-iproc-platform.c | 7 +------
> drivers/pci/host/pcie-rcar.c | 7 +------
> 4 files changed, 6 insertions(+), 23 deletions(-)
I applied these to pci/host-layerscape, pci/host-hisi, pci/host-iproc,
pci/host-rcar for v4.11.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe
@ 2017-02-03 21:07 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-02-03 21:07 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Scott Branden, Gabriele Paoloni, Jon Mason, linux-pci,
linuxppc-dev, linux-renesas-soc, Minghuan Lian, Zhou Wang,
Simon Horman, Geert Uytterhoeven, linux-arm-kernel, Ray Jui,
bcm-kernel-feedback-list, Mingkai Hu, Roy Zang, Shailendra Verma
On Tue, Jan 31, 2017 at 02:19:51PM -0600, Bjorn Helgaas wrote:
> This turned into much ado about nothing, but Shailendra's hisi patch
> prompted similar cleanups in other drivers. It's a minor simplification,
> but I think worth doing consistently across drivers.
>
> Basically this is Geert's observation that when the driver probe function
> is called only as a result of matching something in <match_table>, a
> subsequent of_match_device(<match_table>, dev) call should never fail.
>
> Therefore, instead of this:
>
> struct of_device_id *match;
>
> match = of_match_device(<match_table>, dev);
> ... = match->data;
>
> we can do this:
>
> ... = of_device_get_match_data(dev);
>
> ---
>
> Bjorn Helgaas (3):
> PCI: iproc: Use of_device_get_match_data() to simplify probe
> PCI: layerscape: Use of_device_get_match_data() to simplify probe
> PCI: rcar: Use of_device_get_match_data() to simplify probe
>
> Shailendra Verma (1):
> PCI: hisi: Use of_device_get_match_data() to simplify probe
>
>
> drivers/pci/host/pci-layerscape.c | 7 +------
> drivers/pci/host/pcie-hisi.c | 8 +++-----
> drivers/pci/host/pcie-iproc-platform.c | 7 +------
> drivers/pci/host/pcie-rcar.c | 7 +------
> 4 files changed, 6 insertions(+), 23 deletions(-)
I applied these to pci/host-layerscape, pci/host-hisi, pci/host-iproc,
pci/host-rcar for v4.11.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe
@ 2017-02-03 21:07 ` Bjorn Helgaas
0 siblings, 0 replies; 18+ messages in thread
From: Bjorn Helgaas @ 2017-02-03 21:07 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jan 31, 2017 at 02:19:51PM -0600, Bjorn Helgaas wrote:
> This turned into much ado about nothing, but Shailendra's hisi patch
> prompted similar cleanups in other drivers. It's a minor simplification,
> but I think worth doing consistently across drivers.
>
> Basically this is Geert's observation that when the driver probe function
> is called only as a result of matching something in <match_table>, a
> subsequent of_match_device(<match_table>, dev) call should never fail.
>
> Therefore, instead of this:
>
> struct of_device_id *match;
>
> match = of_match_device(<match_table>, dev);
> ... = match->data;
>
> we can do this:
>
> ... = of_device_get_match_data(dev);
>
> ---
>
> Bjorn Helgaas (3):
> PCI: iproc: Use of_device_get_match_data() to simplify probe
> PCI: layerscape: Use of_device_get_match_data() to simplify probe
> PCI: rcar: Use of_device_get_match_data() to simplify probe
>
> Shailendra Verma (1):
> PCI: hisi: Use of_device_get_match_data() to simplify probe
>
>
> drivers/pci/host/pci-layerscape.c | 7 +------
> drivers/pci/host/pcie-hisi.c | 8 +++-----
> drivers/pci/host/pcie-iproc-platform.c | 7 +------
> drivers/pci/host/pcie-rcar.c | 7 +------
> 4 files changed, 6 insertions(+), 23 deletions(-)
I applied these to pci/host-layerscape, pci/host-hisi, pci/host-iproc,
pci/host-rcar for v4.11.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2017-02-03 21:07 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-31 20:19 [PATCH 1 0/4] PCI: Use of_device_get_match_data() to simplify probe Bjorn Helgaas
2017-01-31 20:19 ` Bjorn Helgaas
2017-01-31 20:19 ` Bjorn Helgaas
2017-01-31 20:19 ` [PATCH 1 1/4] PCI: hisi: " Bjorn Helgaas
2017-01-31 20:19 ` Bjorn Helgaas
2017-01-31 20:20 ` [PATCH 1 2/4] PCI: iproc: " Bjorn Helgaas
2017-01-31 20:20 ` Bjorn Helgaas
2017-01-31 20:20 ` Bjorn Helgaas
2017-01-31 20:20 ` [PATCH 1 3/4] PCI: layerscape: " Bjorn Helgaas
2017-01-31 20:20 ` Bjorn Helgaas
2017-01-31 20:20 ` [PATCH 1 4/4] PCI: rcar: " Bjorn Helgaas
2017-01-31 20:20 ` Bjorn Helgaas
2017-02-02 9:25 ` Simon Horman
2017-02-02 9:25 ` Simon Horman
2017-02-02 9:25 ` Simon Horman
2017-02-03 21:07 ` [PATCH 1 0/4] PCI: " Bjorn Helgaas
2017-02-03 21:07 ` Bjorn Helgaas
2017-02-03 21:07 ` Bjorn Helgaas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.