2020-10-05 09:18:00

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH dwc-next 0/3] PCI: dwc: remove useless dw_pcie_ops

Some designware based device driver especially host only driver may
work well with the default read_dbi/write_dbi/link_up implementation
in pcie-designware.c, thus remove the assumption to simplify those
drivers.

Jisheng Zhang (3):
PCI: dwc: Don't assume the ops in dw_pcie always exists
PCI: dwc: al: Remove useless dw_pcie_ops
PCI: dwc: imx6: Remove useless dw_pcie_ops

drivers/pci/controller/dwc/pci-imx6.c | 5 -----
drivers/pci/controller/dwc/pcie-al.c | 4 ----
drivers/pci/controller/dwc/pcie-designware-ep.c | 8 +++-----
drivers/pci/controller/dwc/pcie-designware.c | 14 +++++++-------
4 files changed, 10 insertions(+), 21 deletions(-)

--
2.28.0


2020-10-05 09:18:32

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH dwc-next 2/3] PCI: dwc: al: Remove useless dw_pcie_ops

We have removed the dw_pcie_ops always exists assumption in dwc
core driver, we can remove the useless dw_pcie_ops now.

Signed-off-by: Jisheng Zhang <[email protected]>
---
drivers/pci/controller/dwc/pcie-al.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c
index f973fbca90cf..a1fe1b847ef1 100644
--- a/drivers/pci/controller/dwc/pcie-al.c
+++ b/drivers/pci/controller/dwc/pcie-al.c
@@ -339,9 +339,6 @@ static int al_add_pcie_port(struct pcie_port *pp,
return 0;
}

-static const struct dw_pcie_ops dw_pcie_ops = {
-};
-
static int al_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -360,7 +357,6 @@ static int al_pcie_probe(struct platform_device *pdev)
return -ENOMEM;

pci->dev = dev;
- pci->ops = &dw_pcie_ops;

al_pcie->pci = pci;
al_pcie->dev = dev;
--
2.28.0

2020-10-05 09:20:14

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH dwc-next 1/3] PCI: dwc: Don't assume the ops in dw_pcie always exists

Some designware based device driver especially host only driver may
work well with the default read_dbi/write_dbi/link_up implementation
in pcie-designware.c, thus remove the assumption to simplify those
drivers.

Signed-off-by: Jisheng Zhang <[email protected]>
---
drivers/pci/controller/dwc/pcie-designware-ep.c | 8 +++-----
drivers/pci/controller/dwc/pcie-designware.c | 14 +++++++-------
2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index ad7da4ea43a5..411b7624331d 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -432,10 +432,8 @@ static void dw_pcie_ep_stop(struct pci_epc *epc)
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);

- if (!pci->ops->stop_link)
- return;
-
- pci->ops->stop_link(pci);
+ if (pci->ops && pci->ops->stop_link)
+ pci->ops->stop_link(pci);
}

static int dw_pcie_ep_start(struct pci_epc *epc)
@@ -443,7 +441,7 @@ static int dw_pcie_ep_start(struct pci_epc *epc)
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);

- if (!pci->ops->start_link)
+ if (!pci->ops || !pci->ops->start_link)
return -EINVAL;

return pci->ops->start_link(pci);
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 3c1f17c78241..2a6109109029 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -140,7 +140,7 @@ u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size)
int ret;
u32 val;

- if (pci->ops->read_dbi)
+ if (pci->ops && pci->ops->read_dbi)
return pci->ops->read_dbi(pci, pci->dbi_base, reg, size);

ret = dw_pcie_read(pci->dbi_base + reg, size, &val);
@@ -155,7 +155,7 @@ void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
{
int ret;

- if (pci->ops->write_dbi) {
+ if (pci->ops && pci->ops->write_dbi) {
pci->ops->write_dbi(pci, pci->dbi_base, reg, size, val);
return;
}
@@ -170,7 +170,7 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
{
int ret;

- if (pci->ops->write_dbi2) {
+ if (pci->ops && pci->ops->write_dbi2) {
pci->ops->write_dbi2(pci, pci->dbi_base2, reg, size, val);
return;
}
@@ -185,7 +185,7 @@ static u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg)
int ret;
u32 val;

- if (pci->ops->read_dbi)
+ if (pci->ops && pci->ops->read_dbi)
return pci->ops->read_dbi(pci, pci->atu_base, reg, 4);

ret = dw_pcie_read(pci->atu_base + reg, 4, &val);
@@ -199,7 +199,7 @@ static void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val)
{
int ret;

- if (pci->ops->write_dbi) {
+ if (pci->ops && pci->ops->write_dbi) {
pci->ops->write_dbi(pci, pci->atu_base, reg, 4, val);
return;
}
@@ -270,7 +270,7 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,
{
u32 retries, val;

- if (pci->ops->cpu_addr_fixup)
+ if (pci->ops && pci->ops->cpu_addr_fixup)
cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr);

if (pci->iatu_unroll_enabled) {
@@ -478,7 +478,7 @@ int dw_pcie_link_up(struct dw_pcie *pci)
{
u32 val;

- if (pci->ops->link_up)
+ if (pci->ops && pci->ops->link_up)
return pci->ops->link_up(pci);

val = readl(pci->dbi_base + PCIE_PORT_DEBUG1);
--
2.28.0

2020-10-05 09:20:41

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH dwc-next 3/3] PCI: dwc: imx6: Remove useless dw_pcie_ops

We have removed the dw_pcie_ops always exists assumption in dwc
core driver, we can remove the useless dw_pcie_ops now.

Signed-off-by: Jisheng Zhang <[email protected]>
---
drivers/pci/controller/dwc/pci-imx6.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 337c74cbdfdb..72f8bc7d878c 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -870,10 +870,6 @@ static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie,
return 0;
}

-static const struct dw_pcie_ops dw_pcie_ops = {
- /* No special ops needed, but pcie-designware still expects this struct */
-};
-
#ifdef CONFIG_PM_SLEEP
static void imx6_pcie_ltssm_disable(struct device *dev)
{
@@ -1013,7 +1009,6 @@ static int imx6_pcie_probe(struct platform_device *pdev)
return -ENOMEM;

pci->dev = dev;
- pci->ops = &dw_pcie_ops;

imx6_pcie->pci = pci;
imx6_pcie->drvdata = of_device_get_match_data(dev);
--
2.28.0