Commit ffe82fa6 authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: spear: Pass device-specific struct to internal functions

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: default avatarBjorn Helgaas <bhelgaas@google.com>
parent ca7b941c
...@@ -72,11 +72,11 @@ struct pcie_app_reg { ...@@ -72,11 +72,11 @@ struct pcie_app_reg {
#define to_spear13xx_pcie(x) container_of(x, struct spear13xx_pcie, pp) #define to_spear13xx_pcie(x) container_of(x, struct spear13xx_pcie, pp)
static int spear13xx_pcie_establish_link(struct pcie_port *pp) static int spear13xx_pcie_establish_link(struct spear13xx_pcie *spear13xx_pcie)
{ {
u32 val; struct pcie_port *pp = &spear13xx_pcie->pp;
struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
u32 val;
u32 exp_cap_off = EXP_CAP_ID_OFFSET; u32 exp_cap_off = EXP_CAP_ID_OFFSET;
if (dw_pcie_link_up(pp)) { if (dw_pcie_link_up(pp)) {
...@@ -133,9 +133,9 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp) ...@@ -133,9 +133,9 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp)
static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg) static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg)
{ {
struct pcie_port *pp = arg; struct spear13xx_pcie *spear13xx_pcie = arg;
struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
struct pcie_port *pp = &spear13xx_pcie->pp;
unsigned int status; unsigned int status;
status = readl(&app_reg->int_sts); status = readl(&app_reg->int_sts);
...@@ -150,9 +150,9 @@ static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg) ...@@ -150,9 +150,9 @@ static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static void spear13xx_pcie_enable_interrupts(struct pcie_port *pp) static void spear13xx_pcie_enable_interrupts(struct spear13xx_pcie *spear13xx_pcie)
{ {
struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp); struct pcie_port *pp = &spear13xx_pcie->pp;
struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
/* Enable MSI interrupt */ /* Enable MSI interrupt */
...@@ -176,8 +176,10 @@ static int spear13xx_pcie_link_up(struct pcie_port *pp) ...@@ -176,8 +176,10 @@ static int spear13xx_pcie_link_up(struct pcie_port *pp)
static void spear13xx_pcie_host_init(struct pcie_port *pp) static void spear13xx_pcie_host_init(struct pcie_port *pp)
{ {
spear13xx_pcie_establish_link(pp); struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
spear13xx_pcie_enable_interrupts(pp);
spear13xx_pcie_establish_link(spear13xx_pcie);
spear13xx_pcie_enable_interrupts(spear13xx_pcie);
} }
static struct pcie_host_ops spear13xx_pcie_host_ops = { static struct pcie_host_ops spear13xx_pcie_host_ops = {
...@@ -185,9 +187,10 @@ static struct pcie_host_ops spear13xx_pcie_host_ops = { ...@@ -185,9 +187,10 @@ static struct pcie_host_ops spear13xx_pcie_host_ops = {
.host_init = spear13xx_pcie_host_init, .host_init = spear13xx_pcie_host_init,
}; };
static int spear13xx_add_pcie_port(struct pcie_port *pp, static int spear13xx_add_pcie_port(struct spear13xx_pcie *spear13xx_pcie,
struct platform_device *pdev) struct platform_device *pdev)
{ {
struct pcie_port *pp = &spear13xx_pcie->pp;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; int ret;
...@@ -198,7 +201,7 @@ static int spear13xx_add_pcie_port(struct pcie_port *pp, ...@@ -198,7 +201,7 @@ static int spear13xx_add_pcie_port(struct pcie_port *pp,
} }
ret = devm_request_irq(dev, pp->irq, spear13xx_pcie_irq_handler, ret = devm_request_irq(dev, pp->irq, spear13xx_pcie_irq_handler,
IRQF_SHARED | IRQF_NO_THREAD, IRQF_SHARED | IRQF_NO_THREAD,
"spear1340-pcie", pp); "spear1340-pcie", spear13xx_pcie);
if (ret) { if (ret) {
dev_err(dev, "failed to request irq %d\n", pp->irq); dev_err(dev, "failed to request irq %d\n", pp->irq);
return ret; return ret;
...@@ -268,7 +271,7 @@ static int spear13xx_pcie_probe(struct platform_device *pdev) ...@@ -268,7 +271,7 @@ static int spear13xx_pcie_probe(struct platform_device *pdev)
if (of_property_read_bool(np, "st,pcie-is-gen1")) if (of_property_read_bool(np, "st,pcie-is-gen1"))
spear13xx_pcie->is_gen1 = true; spear13xx_pcie->is_gen1 = true;
ret = spear13xx_add_pcie_port(pp, pdev); ret = spear13xx_add_pcie_port(spear13xx_pcie, pdev);
if (ret < 0) if (ret < 0)
goto fail_clk; goto fail_clk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment