* [PATCH 2/7] PCI: layerscape: Pass device-specific struct to internal functions
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
@ 2016-10-07 16:42 ` Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 3/7] PCI: layerscape: Remove redundant struct ls_pcie.dbi Bjorn Helgaas
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 16:42 UTC (permalink / raw)
To: Minghuan Lian, Mingkai Hu, Roy Zang; +Cc: linux-pci, linuxppc-dev
Only interfaces used from outside the driver, e.g., those called by the
DesignWare core, need to accept pointers to the generic struct pcie_port.
Internal interfaces can accept pointers to the device-specific struct,
which makes them more straightforward. No functional change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index a1dccb0..85a90f1e 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -212,11 +212,11 @@ static const struct of_device_id ls_pcie_of_match[] = {
{ },
};
-static int __init ls_add_pcie_port(struct pcie_port *pp,
+static int __init ls_add_pcie_port(struct ls_pcie *ls,
struct platform_device *pdev)
{
+ struct pcie_port *pp = &ls->pp;
int ret;
- struct ls_pcie *ls = to_ls_pcie(pp);
pp->dev = &pdev->dev;
pp->dbi_base = ls->dbi;
@@ -259,7 +259,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
if (!ls_pcie_is_bridge(ls))
return -ENODEV;
- ret = ls_add_pcie_port(&ls->pp, pdev);
+ ret = ls_add_pcie_port(ls, pdev);
if (ret < 0)
return ret;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] PCI: layerscape: Remove redundant struct ls_pcie.dbi
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 2/7] PCI: layerscape: Pass device-specific struct to internal functions Bjorn Helgaas
@ 2016-10-07 16:42 ` Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 4/7] PCI: layerscape: Reorder struct ls_pcie Bjorn Helgaas
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 16:42 UTC (permalink / raw)
To: Minghuan Lian, Mingkai Hu, Roy Zang; +Cc: linux-pci, linuxppc-dev
Remove the struct ls_pcie.dbi member, which is a duplicate of the generic
pp.dbi_base member. No functional change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index 85a90f1e..d69614c 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -45,7 +45,6 @@ struct ls_pcie_drvdata {
};
struct ls_pcie {
- void __iomem *dbi;
void __iomem *lut;
struct regmap *scfg;
struct pcie_port pp;
@@ -59,7 +58,7 @@ static bool ls_pcie_is_bridge(struct ls_pcie *ls)
{
u32 header_type;
- header_type = ioread8(ls->dbi + PCI_HEADER_TYPE);
+ header_type = ioread8(ls->pp.dbi_base + PCI_HEADER_TYPE);
header_type &= 0x7f;
return header_type == PCI_HEADER_TYPE_BRIDGE;
@@ -68,13 +67,13 @@ static bool ls_pcie_is_bridge(struct ls_pcie *ls)
/* Clear multi-function bit */
static void ls_pcie_clear_multifunction(struct ls_pcie *ls)
{
- iowrite8(PCI_HEADER_TYPE_BRIDGE, ls->dbi + PCI_HEADER_TYPE);
+ iowrite8(PCI_HEADER_TYPE_BRIDGE, ls->pp.dbi_base + PCI_HEADER_TYPE);
}
/* Fix class value */
static void ls_pcie_fix_class(struct ls_pcie *ls)
{
- iowrite16(PCI_CLASS_BRIDGE_PCI, ls->dbi + PCI_CLASS_DEVICE);
+ iowrite16(PCI_CLASS_BRIDGE_PCI, ls->pp.dbi_base + PCI_CLASS_DEVICE);
}
/* Drop MSG TLP except for Vendor MSG */
@@ -82,9 +81,9 @@ static void ls_pcie_drop_msg_tlp(struct ls_pcie *ls)
{
u32 val;
- val = ioread32(ls->dbi + PCIE_STRFMR1);
+ val = ioread32(ls->pp.dbi_base + PCIE_STRFMR1);
val &= 0xDFFFFFFF;
- iowrite32(val, ls->dbi + PCIE_STRFMR1);
+ iowrite32(val, ls->pp.dbi_base + PCIE_STRFMR1);
}
static int ls1021_pcie_link_up(struct pcie_port *pp)
@@ -148,11 +147,11 @@ static void ls_pcie_host_init(struct pcie_port *pp)
{
struct ls_pcie *ls = to_ls_pcie(pp);
- iowrite32(1, ls->dbi + PCIE_DBI_RO_WR_EN);
+ iowrite32(1, ls->pp.dbi_base + PCIE_DBI_RO_WR_EN);
ls_pcie_fix_class(ls);
ls_pcie_clear_multifunction(ls);
ls_pcie_drop_msg_tlp(ls);
- iowrite32(0, ls->dbi + PCIE_DBI_RO_WR_EN);
+ iowrite32(0, ls->pp.dbi_base + PCIE_DBI_RO_WR_EN);
}
static int ls_pcie_msi_host_init(struct pcie_port *pp,
@@ -219,7 +218,6 @@ static int __init ls_add_pcie_port(struct ls_pcie *ls,
int ret;
pp->dev = &pdev->dev;
- pp->dbi_base = ls->dbi;
pp->ops = ls->drvdata->ops;
ret = dw_pcie_host_init(pp);
@@ -247,14 +245,14 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
return -ENOMEM;
dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
- ls->dbi = devm_ioremap_resource(&pdev->dev, dbi_base);
- if (IS_ERR(ls->dbi)) {
+ ls->pp.dbi_base = devm_ioremap_resource(&pdev->dev, dbi_base);
+ if (IS_ERR(ls->pp.dbi_base)) {
dev_err(&pdev->dev, "missing *regs* space\n");
- return PTR_ERR(ls->dbi);
+ return PTR_ERR(ls->pp.dbi_base);
}
ls->drvdata = match->data;
- ls->lut = ls->dbi + ls->drvdata->lut_offset;
+ ls->lut = ls->pp.dbi_base + ls->drvdata->lut_offset;
if (!ls_pcie_is_bridge(ls))
return -ENODEV;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] PCI: layerscape: Reorder struct ls_pcie
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 2/7] PCI: layerscape: Pass device-specific struct to internal functions Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 3/7] PCI: layerscape: Remove redundant struct ls_pcie.dbi Bjorn Helgaas
@ 2016-10-07 16:42 ` Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 5/7] PCI: layerscape: Add local struct device pointers Bjorn Helgaas
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 16:42 UTC (permalink / raw)
To: Minghuan Lian, Mingkai Hu, Roy Zang; +Cc: linux-pci, linuxppc-dev
Reorder struct ls_pcie to put generic fields first. No functional change
intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index d69614c..8d10665 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -45,9 +45,9 @@ struct ls_pcie_drvdata {
};
struct ls_pcie {
+ struct pcie_port pp; /* pp.dbi_base is DT regs */
void __iomem *lut;
struct regmap *scfg;
- struct pcie_port pp;
const struct ls_pcie_drvdata *drvdata;
int index;
};
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] PCI: layerscape: Add local struct device pointers
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
` (2 preceding siblings ...)
2016-10-07 16:42 ` [PATCH 4/7] PCI: layerscape: Reorder struct ls_pcie Bjorn Helgaas
@ 2016-10-07 16:42 ` Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 6/7] PCI: layerscape: Move struct pcie_port setup to probe function Bjorn Helgaas
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 16:42 UTC (permalink / raw)
To: Minghuan Lian, Mingkai Hu, Roy Zang; +Cc: linux-pci, linuxppc-dev
Use a local "struct device *dev" for brevity and consistency with other
drivers. No functional change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index 8d10665..bf1ce11 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -105,18 +105,19 @@ static int ls1021_pcie_link_up(struct pcie_port *pp)
static void ls1021_pcie_host_init(struct pcie_port *pp)
{
+ struct device *dev = pp->dev;
struct ls_pcie *ls = to_ls_pcie(pp);
u32 index[2];
- ls->scfg = syscon_regmap_lookup_by_phandle(pp->dev->of_node,
+ ls->scfg = syscon_regmap_lookup_by_phandle(dev->of_node,
"fsl,pcie-scfg");
if (IS_ERR(ls->scfg)) {
- dev_err(pp->dev, "No syscfg phandle specified\n");
+ dev_err(dev, "No syscfg phandle specified\n");
ls->scfg = NULL;
return;
}
- if (of_property_read_u32_array(pp->dev->of_node,
+ if (of_property_read_u32_array(dev->of_node,
"fsl,pcie-scfg", index, 2)) {
ls->scfg = NULL;
return;
@@ -231,23 +232,24 @@ static int __init ls_add_pcie_port(struct ls_pcie *ls,
static int __init ls_pcie_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
const struct of_device_id *match;
struct ls_pcie *ls;
struct resource *dbi_base;
int ret;
- match = of_match_device(ls_pcie_of_match, &pdev->dev);
+ match = of_match_device(ls_pcie_of_match, dev);
if (!match)
return -ENODEV;
- ls = devm_kzalloc(&pdev->dev, sizeof(*ls), GFP_KERNEL);
+ ls = devm_kzalloc(dev, sizeof(*ls), GFP_KERNEL);
if (!ls)
return -ENOMEM;
dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
- ls->pp.dbi_base = devm_ioremap_resource(&pdev->dev, dbi_base);
+ ls->pp.dbi_base = devm_ioremap_resource(dev, dbi_base);
if (IS_ERR(ls->pp.dbi_base)) {
- dev_err(&pdev->dev, "missing *regs* space\n");
+ dev_err(dev, "missing *regs* space\n");
return PTR_ERR(ls->pp.dbi_base);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] PCI: layerscape: Move struct pcie_port setup to probe function
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
` (3 preceding siblings ...)
2016-10-07 16:42 ` [PATCH 5/7] PCI: layerscape: Add local struct device pointers Bjorn Helgaas
@ 2016-10-07 16:42 ` Bjorn Helgaas
2016-10-07 16:42 ` [PATCH 7/7] PCI: layerscape: Remove unused ls_add_pcie_port() platform_device arg Bjorn Helgaas
2016-10-07 17:05 ` [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Roy Zang
6 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 16:42 UTC (permalink / raw)
To: Minghuan Lian, Mingkai Hu, Roy Zang; +Cc: linux-pci, linuxppc-dev
Do the basic pcie_port setup in the probe function for consistency with
other drivers. No functional change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index bf1ce11..9b74485 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -218,9 +218,6 @@ static int __init ls_add_pcie_port(struct ls_pcie *ls,
struct pcie_port *pp = &ls->pp;
int ret;
- pp->dev = &pdev->dev;
- pp->ops = ls->drvdata->ops;
-
ret = dw_pcie_host_init(pp);
if (ret) {
dev_err(pp->dev, "failed to initialize host\n");
@@ -235,6 +232,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
const struct of_device_id *match;
struct ls_pcie *ls;
+ struct pcie_port *pp;
struct resource *dbi_base;
int ret;
@@ -246,6 +244,12 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
if (!ls)
return -ENOMEM;
+ ls->drvdata = match->data;
+
+ pp = &ls->pp;
+ pp->dev = dev;
+ pp->ops = ls->drvdata->ops;
+
dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
ls->pp.dbi_base = devm_ioremap_resource(dev, dbi_base);
if (IS_ERR(ls->pp.dbi_base)) {
@@ -253,7 +257,6 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
return PTR_ERR(ls->pp.dbi_base);
}
- ls->drvdata = match->data;
ls->lut = ls->pp.dbi_base + ls->drvdata->lut_offset;
if (!ls_pcie_is_bridge(ls))
@@ -264,7 +267,6 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
return ret;
platform_set_drvdata(pdev, ls);
-
return 0;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] PCI: layerscape: Remove unused ls_add_pcie_port() platform_device arg
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
` (4 preceding siblings ...)
2016-10-07 16:42 ` [PATCH 6/7] PCI: layerscape: Move struct pcie_port setup to probe function Bjorn Helgaas
@ 2016-10-07 16:42 ` Bjorn Helgaas
2016-10-07 17:05 ` [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Roy Zang
6 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 16:42 UTC (permalink / raw)
To: Minghuan Lian, Mingkai Hu, Roy Zang; +Cc: linux-pci, linuxppc-dev
ls_add_pcie_port() doesn't use the platform_device pointer passed to it, so
remove it. No functional change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pci-layerscape.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index 9b74485..1694202 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -212,8 +212,7 @@ static const struct of_device_id ls_pcie_of_match[] = {
{ },
};
-static int __init ls_add_pcie_port(struct ls_pcie *ls,
- struct platform_device *pdev)
+static int __init ls_add_pcie_port(struct ls_pcie *ls)
{
struct pcie_port *pp = &ls->pp;
int ret;
@@ -262,7 +261,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
if (!ls_pcie_is_bridge(ls))
return -ENODEV;
- ret = ls_add_pcie_port(ls, pdev);
+ ret = ls_add_pcie_port(ls);
if (ret < 0)
return ret;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently
2016-10-07 16:41 [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Bjorn Helgaas
` (5 preceding siblings ...)
2016-10-07 16:42 ` [PATCH 7/7] PCI: layerscape: Remove unused ls_add_pcie_port() platform_device arg Bjorn Helgaas
@ 2016-10-07 17:05 ` Roy Zang
2016-10-07 18:21 ` Bjorn Helgaas
6 siblings, 1 reply; 9+ messages in thread
From: Roy Zang @ 2016-10-07 17:05 UTC (permalink / raw)
To: Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang
Cc: linux-pci, linuxppc-dev
On 10/07/2016 11:42 AM, Bjorn Helgaas wrote:=0A=
> Use a device-specific name, "ls", for struct ls_pcie pointers=0A=
> to hint that this is device-specific information. No functional change=
=0A=
> intended.=0A=
how about ls_pcie instead of ls ?=0A=
Roy=0A=
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently
2016-10-07 17:05 ` [PATCH 1/7] PCI: layerscape: Name private struct pointer "ls" consistently Roy Zang
@ 2016-10-07 18:21 ` Bjorn Helgaas
0 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2016-10-07 18:21 UTC (permalink / raw)
To: Roy Zang
Cc: Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang, linux-pci,
linuxppc-dev
On Fri, Oct 07, 2016 at 05:05:05PM +0000, Roy Zang wrote:
> On 10/07/2016 11:42 AM, Bjorn Helgaas wrote:
> > Use a device-specific name, "ls", for struct ls_pcie pointers
> > to hint that this is device-specific information. No functional change
> > intended.
> how about ls_pcie instead of ls ?
Done, and re-pushed the branch, thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread