linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] PCI: dra7xx: Cleanups
@ 2016-10-12 13:32 Bjorn Helgaas
  2016-10-12 13:32 ` [PATCH v2 1/7] PCI: dra7xx: Add local struct device pointers Bjorn Helgaas
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:32 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

  - Add local "dev" pointers to reduce repetition of things like
    "&pdev->dev".

  - Remove redundant struct members.

  - Use generic DesignWare accessors when possible.

  - Pass device-specific struct to internal functions for consistency.

  - Move struct pcie_port setup to probe function for consistency.

Nothing here should change the behavior of the driver.

Changes from v1:
  I dropped the following patches because they were a lot of churn for
  questionable benefit:
    PCI: dra7xx: Rename accessors
    PCI: dra7xx: Name private struct pointer "dra7xx" consistently

---

Bjorn Helgaas (7):
      PCI: dra7xx: Add local struct device pointers
      PCI: dra7xx: Remove redundant struct device pointer from dra7xx_pcie
      PCI: dra7xx: Set drvdata at end of probe function
      PCI: dra7xx: Use generic DesignWare accessors
      PCI: dra7xx: Pass device-specific struct to internal functions
      PCI: dra7xx: Move struct pcie_port setup to probe function
      PCI: dra7xx: Reorder struct dra7xx_pcie


 drivers/pci/host/pci-dra7xx.c |  103 ++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 58 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/7] PCI: dra7xx: Add local struct device pointers
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
@ 2016-10-12 13:32 ` Bjorn Helgaas
  2016-10-12 13:32 ` [PATCH v2 2/7] PCI: dra7xx: Remove redundant struct device pointer from dra7xx_pcie Bjorn Helgaas
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:32 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

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-dra7xx.c |   40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 19223ed..2323679 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -106,10 +106,11 @@ static int dra7xx_pcie_link_up(struct pcie_port *pp)
 static int dra7xx_pcie_establish_link(struct pcie_port *pp)
 {
 	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+	struct device *dev = pp->dev;
 	u32 reg;
 
 	if (dw_pcie_link_up(pp)) {
-		dev_err(pp->dev, "link is already up\n");
+		dev_err(dev, "link is already up\n");
 		return 0;
 	}
 
@@ -223,51 +224,51 @@ static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg)
 static irqreturn_t dra7xx_pcie_irq_handler(int irq, void *arg)
 {
 	struct dra7xx_pcie *dra7xx = arg;
+	struct device *dev = dra7xx->pp.dev;
 	u32 reg;
 
 	reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN);
 
 	if (reg & ERR_SYS)
-		dev_dbg(dra7xx->dev, "System Error\n");
+		dev_dbg(dev, "System Error\n");
 
 	if (reg & ERR_FATAL)
-		dev_dbg(dra7xx->dev, "Fatal Error\n");
+		dev_dbg(dev, "Fatal Error\n");
 
 	if (reg & ERR_NONFATAL)
-		dev_dbg(dra7xx->dev, "Non Fatal Error\n");
+		dev_dbg(dev, "Non Fatal Error\n");
 
 	if (reg & ERR_COR)
-		dev_dbg(dra7xx->dev, "Correctable Error\n");
+		dev_dbg(dev, "Correctable Error\n");
 
 	if (reg & ERR_AXI)
-		dev_dbg(dra7xx->dev, "AXI tag lookup fatal Error\n");
+		dev_dbg(dev, "AXI tag lookup fatal Error\n");
 
 	if (reg & ERR_ECRC)
-		dev_dbg(dra7xx->dev, "ECRC Error\n");
+		dev_dbg(dev, "ECRC Error\n");
 
 	if (reg & PME_TURN_OFF)
-		dev_dbg(dra7xx->dev,
+		dev_dbg(dev,
 			"Power Management Event Turn-Off message received\n");
 
 	if (reg & PME_TO_ACK)
-		dev_dbg(dra7xx->dev,
+		dev_dbg(dev,
 			"Power Management Turn-Off Ack message received\n");
 
 	if (reg & PM_PME)
-		dev_dbg(dra7xx->dev,
-			"PM Power Management Event message received\n");
+		dev_dbg(dev, "PM Power Management Event message received\n");
 
 	if (reg & LINK_REQ_RST)
-		dev_dbg(dra7xx->dev, "Link Request Reset\n");
+		dev_dbg(dev, "Link Request Reset\n");
 
 	if (reg & LINK_UP_EVT)
-		dev_dbg(dra7xx->dev, "Link-up state change\n");
+		dev_dbg(dev, "Link-up state change\n");
 
 	if (reg & CFG_BME_EVT)
-		dev_dbg(dra7xx->dev, "CFG 'Bus Master Enable' change\n");
+		dev_dbg(dev, "CFG 'Bus Master Enable' change\n");
 
 	if (reg & CFG_MSE_EVT)
-		dev_dbg(dra7xx->dev, "CFG 'Memory Space Enable' change\n");
+		dev_dbg(dev, "CFG 'Memory Space Enable' change\n");
 
 	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN, reg);
 
@@ -292,12 +293,11 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
 		return -EINVAL;
 	}
 
-	ret = devm_request_irq(&pdev->dev, pp->irq,
-			       dra7xx_pcie_msi_irq_handler,
+	ret = devm_request_irq(dev, pp->irq, dra7xx_pcie_msi_irq_handler,
 			       IRQF_SHARED | IRQF_NO_THREAD,
 			       "dra7-pcie-msi",	pp);
 	if (ret) {
-		dev_err(&pdev->dev, "failed to request irq\n");
+		dev_err(dev, "failed to request irq\n");
 		return ret;
 	}
 
@@ -314,7 +314,7 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
 
 	ret = dw_pcie_host_init(pp);
 	if (ret) {
-		dev_err(dra7xx->dev, "failed to initialize host\n");
+		dev_err(dev, "failed to initialize host\n");
 		return ret;
 	}
 
@@ -407,7 +407,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 		ret = devm_gpio_request_one(dev, gpio_sel, gpio_flags,
 					    "pcie_reset");
 		if (ret) {
-			dev_err(&pdev->dev, "gpio%d request failed, ret %d\n",
+			dev_err(dev, "gpio%d request failed, ret %d\n",
 				gpio_sel, ret);
 			goto err_gpio;
 		}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/7] PCI: dra7xx: Remove redundant struct device pointer from dra7xx_pcie
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
  2016-10-12 13:32 ` [PATCH v2 1/7] PCI: dra7xx: Add local struct device pointers Bjorn Helgaas
@ 2016-10-12 13:32 ` Bjorn Helgaas
  2016-10-12 13:32 ` [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function Bjorn Helgaas
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:32 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

The DesignWare core already stores the struct device pointer in struct
pcie_port.  Remove the redundant copy from struct dra7xx_pcie.dev.  No
functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-dra7xx.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 2323679..1c24f34 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -67,7 +67,6 @@ struct dra7xx_pcie {
 	void __iomem		*base;
 	struct phy		**phy;
 	int			phy_count;
-	struct device		*dev;
 	struct pcie_port	pp;
 };
 
@@ -390,7 +389,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 
 	dra7xx->base = base;
 	dra7xx->phy = phy;
-	dra7xx->dev = dev;
 	dra7xx->phy_count = phy_count;
 
 	pm_runtime_enable(dev);


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
  2016-10-12 13:32 ` [PATCH v2 1/7] PCI: dra7xx: Add local struct device pointers Bjorn Helgaas
  2016-10-12 13:32 ` [PATCH v2 2/7] PCI: dra7xx: Remove redundant struct device pointer from dra7xx_pcie Bjorn Helgaas
@ 2016-10-12 13:32 ` Bjorn Helgaas
  2016-10-12 19:48   ` Andrew F. Davis
  2016-10-12 13:33 ` [PATCH v2 4/7] PCI: dra7xx: Use generic DesignWare accessors Bjorn Helgaas
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:32 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

Set the drvdata pointer at the end of probe function for consistency with
other drivers.  We don't need the drvdata until after the probe completes,
and we don't need it at all if the probe fails.  No functional change
intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-dra7xx.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 1c24f34..3d184f6 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -418,12 +418,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	reg &= ~LTSSM_EN;
 	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
 
-	platform_set_drvdata(pdev, dra7xx);
-
 	ret = dra7xx_add_pcie_port(dra7xx, pdev);
 	if (ret < 0)
 		goto err_gpio;
 
+	platform_set_drvdata(pdev, dra7xx);
 	return 0;
 
 err_gpio:


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/7] PCI: dra7xx: Use generic DesignWare accessors
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
                   ` (2 preceding siblings ...)
  2016-10-12 13:32 ` [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function Bjorn Helgaas
@ 2016-10-12 13:33 ` Bjorn Helgaas
  2016-10-12 13:33 ` [PATCH v2 5/7] PCI: dra7xx: Pass device-specific struct to internal functions Bjorn Helgaas
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:33 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

The dw_pcie_readl_rc() and dw_pcie_writel_rc() interfaces already add in
pp->dbi_base, so use those instead of doing it ourselves in the dra7xx
driver.  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-dra7xx.c |   19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 3d184f6..66077d0 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -83,17 +83,6 @@ static inline void dra7xx_pcie_writel(struct dra7xx_pcie *pcie, u32 offset,
 	writel(value, pcie->base + offset);
 }
 
-static inline u32 dra7xx_pcie_readl_rc(struct pcie_port *pp, u32 offset)
-{
-	return readl(pp->dbi_base + offset);
-}
-
-static inline void dra7xx_pcie_writel_rc(struct pcie_port *pp, u32 offset,
-					 u32 value)
-{
-	writel(value, pp->dbi_base + offset);
-}
-
 static int dra7xx_pcie_link_up(struct pcie_port *pp)
 {
 	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
@@ -448,9 +437,9 @@ static int dra7xx_pcie_suspend(struct device *dev)
 	u32 val;
 
 	/* clear MSE */
-	val = dra7xx_pcie_readl_rc(pp, PCI_COMMAND);
+	val = dw_pcie_readl_rc(pp, PCI_COMMAND);
 	val &= ~PCI_COMMAND_MEMORY;
-	dra7xx_pcie_writel_rc(pp, PCI_COMMAND, val);
+	dw_pcie_writel_rc(pp, PCI_COMMAND, val);
 
 	return 0;
 }
@@ -462,9 +451,9 @@ static int dra7xx_pcie_resume(struct device *dev)
 	u32 val;
 
 	/* set MSE */
-	val = dra7xx_pcie_readl_rc(pp, PCI_COMMAND);
+	val = dw_pcie_readl_rc(pp, PCI_COMMAND);
 	val |= PCI_COMMAND_MEMORY;
-	dra7xx_pcie_writel_rc(pp, PCI_COMMAND, val);
+	dw_pcie_writel_rc(pp, PCI_COMMAND, val);
 
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 5/7] PCI: dra7xx: Pass device-specific struct to internal functions
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
                   ` (3 preceding siblings ...)
  2016-10-12 13:33 ` [PATCH v2 4/7] PCI: dra7xx: Use generic DesignWare accessors Bjorn Helgaas
@ 2016-10-12 13:33 ` Bjorn Helgaas
  2016-10-12 13:33 ` [PATCH v2 6/7] PCI: dra7xx: Move struct pcie_port setup to probe function Bjorn Helgaas
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:33 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

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-dra7xx.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 66077d0..efb24b8 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -91,9 +91,9 @@ static int dra7xx_pcie_link_up(struct pcie_port *pp)
 	return !!(reg & LINK_UP);
 }
 
-static int dra7xx_pcie_establish_link(struct pcie_port *pp)
+static int dra7xx_pcie_establish_link(struct dra7xx_pcie *dra7xx)
 {
-	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+	struct pcie_port *pp = &dra7xx->pp;
 	struct device *dev = pp->dev;
 	u32 reg;
 
@@ -109,10 +109,8 @@ static int dra7xx_pcie_establish_link(struct pcie_port *pp)
 	return dw_pcie_wait_for_link(pp);
 }
 
-static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
+static void dra7xx_pcie_enable_interrupts(struct dra7xx_pcie *dra7xx)
 {
-	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
-
 	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN,
 			   ~INTERRUPTS);
 	dra7xx_pcie_writel(dra7xx,
@@ -131,6 +129,8 @@ static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
 
 static void dra7xx_pcie_host_init(struct pcie_port *pp)
 {
+	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+
 	pp->io_base &= DRA7XX_CPU_TO_BUS_ADDR;
 	pp->mem_base &= DRA7XX_CPU_TO_BUS_ADDR;
 	pp->cfg0_base &= DRA7XX_CPU_TO_BUS_ADDR;
@@ -138,10 +138,10 @@ static void dra7xx_pcie_host_init(struct pcie_port *pp)
 
 	dw_pcie_setup_rc(pp);
 
-	dra7xx_pcie_establish_link(pp);
+	dra7xx_pcie_establish_link(dra7xx);
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		dw_pcie_msi_init(pp);
-	dra7xx_pcie_enable_interrupts(pp);
+	dra7xx_pcie_enable_interrupts(dra7xx);
 }
 
 static struct pcie_host_ops dra7xx_pcie_host_ops = {
@@ -185,8 +185,8 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)
 
 static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg)
 {
-	struct pcie_port *pp = arg;
-	struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
+	struct dra7xx_pcie *dra7xx = arg;
+	struct pcie_port *pp = &dra7xx->pp;
 	u32 reg;
 
 	reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI);
@@ -283,7 +283,7 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
 
 	ret = devm_request_irq(dev, pp->irq, dra7xx_pcie_msi_irq_handler,
 			       IRQF_SHARED | IRQF_NO_THREAD,
-			       "dra7-pcie-msi",	pp);
+			       "dra7-pcie-msi",	dra7xx);
 	if (ret) {
 		dev_err(dev, "failed to request irq\n");
 		return ret;


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 6/7] PCI: dra7xx: Move struct pcie_port setup to probe function
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
                   ` (4 preceding siblings ...)
  2016-10-12 13:33 ` [PATCH v2 5/7] PCI: dra7xx: Pass device-specific struct to internal functions Bjorn Helgaas
@ 2016-10-12 13:33 ` Bjorn Helgaas
  2016-10-12 19:58   ` Andrew F. Davis
  2016-10-12 13:33 ` [PATCH v2 7/7] PCI: dra7xx: Reorder struct dra7xx_pcie Bjorn Helgaas
  2016-10-12 16:04 ` [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
  7 siblings, 1 reply; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:33 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

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-dra7xx.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index efb24b8..bb77c35 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -267,13 +267,9 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
 				       struct platform_device *pdev)
 {
 	int ret;
-	struct pcie_port *pp;
+	struct pcie_port *pp = &dra7xx->pp;
+	struct device *dev = pp->dev;
 	struct resource *res;
-	struct device *dev = &pdev->dev;
-
-	pp = &dra7xx->pp;
-	pp->dev = dev;
-	pp->ops = &dra7xx_pcie_host_ops;
 
 	pp->irq = platform_get_irq(pdev, 1);
 	if (pp->irq < 0) {
@@ -320,6 +316,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	void __iomem *base;
 	struct resource *res;
 	struct dra7xx_pcie *dra7xx;
+	struct pcie_port *pp;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
 	char name[10];
@@ -331,6 +328,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	if (!dra7xx)
 		return -ENOMEM;
 
+	pp = &dra7xx->pp;
+	pp->dev = dev;
+	pp->ops = &dra7xx_pcie_host_ops;
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "missing IRQ resource\n");


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 7/7] PCI: dra7xx: Reorder struct dra7xx_pcie
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
                   ` (5 preceding siblings ...)
  2016-10-12 13:33 ` [PATCH v2 6/7] PCI: dra7xx: Move struct pcie_port setup to probe function Bjorn Helgaas
@ 2016-10-12 13:33 ` Bjorn Helgaas
  2016-10-12 16:04 ` [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
  7 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 13:33 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

Reorder struct dra7xx_pcie to put generic fields first.  No functional
change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pci-dra7xx.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index bb77c35..9595fad 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -64,10 +64,10 @@
 #define	DRA7XX_CPU_TO_BUS_ADDR				0x0FFFFFFF
 
 struct dra7xx_pcie {
-	void __iomem		*base;
-	struct phy		**phy;
-	int			phy_count;
 	struct pcie_port	pp;
+	void __iomem		*base;		/* DT ti_conf */
+	int			phy_count;	/* DT phy-names count */
+	struct phy		**phy;
 };
 
 #define to_dra7xx_pcie(x)	container_of((x), struct dra7xx_pcie, pp)


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/7] PCI: dra7xx: Cleanups
  2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
                   ` (6 preceding siblings ...)
  2016-10-12 13:33 ` [PATCH v2 7/7] PCI: dra7xx: Reorder struct dra7xx_pcie Bjorn Helgaas
@ 2016-10-12 16:04 ` Bjorn Helgaas
  7 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 16:04 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Kishon Vijay Abraham I, linux-pci, linux-omap

On Wed, Oct 12, 2016 at 08:32:31AM -0500, Bjorn Helgaas wrote:
>   - Add local "dev" pointers to reduce repetition of things like
>     "&pdev->dev".
> 
>   - Remove redundant struct members.
> 
>   - Use generic DesignWare accessors when possible.
> 
>   - Pass device-specific struct to internal functions for consistency.
> 
>   - Move struct pcie_port setup to probe function for consistency.
> 
> Nothing here should change the behavior of the driver.
> 
> Changes from v1:
>   I dropped the following patches because they were a lot of churn for
>   questionable benefit:
>     PCI: dra7xx: Rename accessors
>     PCI: dra7xx: Name private struct pointer "dra7xx" consistently
> 
> ---
> 
> Bjorn Helgaas (7):
>       PCI: dra7xx: Add local struct device pointers
>       PCI: dra7xx: Remove redundant struct device pointer from dra7xx_pcie
>       PCI: dra7xx: Set drvdata at end of probe function
>       PCI: dra7xx: Use generic DesignWare accessors
>       PCI: dra7xx: Pass device-specific struct to internal functions
>       PCI: dra7xx: Move struct pcie_port setup to probe function
>       PCI: dra7xx: Reorder struct dra7xx_pcie
> 
> 
>  drivers/pci/host/pci-dra7xx.c |  103 ++++++++++++++++++-----------------------
>  1 file changed, 45 insertions(+), 58 deletions(-)

I applied these to pci/host-dra7xx for v4.9.  I hope to ask Linus to
pull them tomorrow, so if you see any issues, let me know soon.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function
  2016-10-12 13:32 ` [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function Bjorn Helgaas
@ 2016-10-12 19:48   ` Andrew F. Davis
  2016-10-12 22:21     ` Bjorn Helgaas
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew F. Davis @ 2016-10-12 19:48 UTC (permalink / raw)
  To: Bjorn Helgaas, Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

On 10/12/2016 08:32 AM, Bjorn Helgaas wrote:
> Set the drvdata pointer at the end of probe function for consistency with
> other drivers. 

I've seen it done the current way many places.

> We don't need the drvdata until after the probe completes,
> and we don't need it at all if the probe fails. 

Are you sure this will always be true? Why not set it as soon as we have
the ability to, what do we gain by waiting till the end, something like
one less instruction in the failure case?

> No functional change
> intended.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host/pci-dra7xx.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
> index 1c24f34..3d184f6 100644
> --- a/drivers/pci/host/pci-dra7xx.c
> +++ b/drivers/pci/host/pci-dra7xx.c
> @@ -418,12 +418,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  	reg &= ~LTSSM_EN;
>  	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
>  
> -	platform_set_drvdata(pdev, dra7xx);
> -
>  	ret = dra7xx_add_pcie_port(dra7xx, pdev);
>  	if (ret < 0)
>  		goto err_gpio;
>  
> +	platform_set_drvdata(pdev, dra7xx);

Space here.

>  	return 0;
>  
>  err_gpio:
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 6/7] PCI: dra7xx: Move struct pcie_port setup to probe function
  2016-10-12 13:33 ` [PATCH v2 6/7] PCI: dra7xx: Move struct pcie_port setup to probe function Bjorn Helgaas
@ 2016-10-12 19:58   ` Andrew F. Davis
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew F. Davis @ 2016-10-12 19:58 UTC (permalink / raw)
  To: Bjorn Helgaas, Kishon Vijay Abraham I; +Cc: linux-pci, linux-omap

On 10/12/2016 08:33 AM, Bjorn Helgaas wrote:
> Do the basic pcie_port setup in the probe function for consistency with
> other drivers.  No functional change intended.

Other drivers may do this, but it is really logical? All the pcie_port
work and variables are isolated to the add_pcie_port function, now it
they are mixed into probe as well, I don't see any benefit to this
style, perhaps the other drivers should become more like this.

> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/host/pci-dra7xx.c |   13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
> index efb24b8..bb77c35 100644
> --- a/drivers/pci/host/pci-dra7xx.c
> +++ b/drivers/pci/host/pci-dra7xx.c
> @@ -267,13 +267,9 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
>  				       struct platform_device *pdev)
>  {
>  	int ret;
> -	struct pcie_port *pp;
> +	struct pcie_port *pp = &dra7xx->pp;
> +	struct device *dev = pp->dev;
>  	struct resource *res;
> -	struct device *dev = &pdev->dev;
> -
> -	pp = &dra7xx->pp;
> -	pp->dev = dev;
> -	pp->ops = &dra7xx_pcie_host_ops;
>  
>  	pp->irq = platform_get_irq(pdev, 1);
>  	if (pp->irq < 0) {
> @@ -320,6 +316,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  	void __iomem *base;
>  	struct resource *res;
>  	struct dra7xx_pcie *dra7xx;
> +	struct pcie_port *pp;
>  	struct device *dev = &pdev->dev;
>  	struct device_node *np = dev->of_node;
>  	char name[10];
> @@ -331,6 +328,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
>  	if (!dra7xx)
>  		return -ENOMEM;
>  
> +	pp = &dra7xx->pp;
> +	pp->dev = dev;
> +	pp->ops = &dra7xx_pcie_host_ops;
> +
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		dev_err(dev, "missing IRQ resource\n");
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function
  2016-10-12 19:48   ` Andrew F. Davis
@ 2016-10-12 22:21     ` Bjorn Helgaas
  2016-10-13 15:24       ` Andrew F. Davis
  0 siblings, 1 reply; 13+ messages in thread
From: Bjorn Helgaas @ 2016-10-12 22:21 UTC (permalink / raw)
  To: Andrew F. Davis
  Cc: Bjorn Helgaas, Kishon Vijay Abraham I, linux-pci, linux-omap

On Wed, Oct 12, 2016 at 02:48:02PM -0500, Andrew F. Davis wrote:
> On 10/12/2016 08:32 AM, Bjorn Helgaas wrote:
> > Set the drvdata pointer at the end of probe function for consistency with
> > other drivers. 
> 
> I've seen it done the current way many places.
> 
> > We don't need the drvdata until after the probe completes,
> > and we don't need it at all if the probe fails. 
> 
> Are you sure this will always be true? Why not set it as soon as we have
> the ability to, what do we gain by waiting till the end, something like
> one less instruction in the failure case?

I don't think it's likely anybody will need it before .probe()
completes, because the purpose of drvdata is for an external driver
entry point to locate its device data, and none of those entry points
will be called until after .probe() completes successfully.

But I don't care at all if we do it earlier, as long as all the
drivers do it the same way.

Bjorn

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function
  2016-10-12 22:21     ` Bjorn Helgaas
@ 2016-10-13 15:24       ` Andrew F. Davis
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew F. Davis @ 2016-10-13 15:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Bjorn Helgaas, Kishon Vijay Abraham I, linux-pci, linux-omap

On 10/12/2016 05:21 PM, Bjorn Helgaas wrote:
> On Wed, Oct 12, 2016 at 02:48:02PM -0500, Andrew F. Davis wrote:
>> On 10/12/2016 08:32 AM, Bjorn Helgaas wrote:
>>> Set the drvdata pointer at the end of probe function for consistency with
>>> other drivers. 
>>
>> I've seen it done the current way many places.
>>
>>> We don't need the drvdata until after the probe completes,
>>> and we don't need it at all if the probe fails. 
>>
>> Are you sure this will always be true? Why not set it as soon as we have
>> the ability to, what do we gain by waiting till the end, something like
>> one less instruction in the failure case?
> 
> I don't think it's likely anybody will need it before .probe()
> completes, because the purpose of drvdata is for an external driver
> entry point to locate its device data, and none of those entry points
> will be called until after .probe() completes successfully.
> 
> But I don't care at all if we do it earlier, as long as all the
> drivers do it the same way.
> 

Agree, then the standard needs to be one that will work for everyone, so
setting it early is my preference as some drivers may need to call into
their external entry points during probe to prime them for later calls
or initialization (like a device reset call you want to manually call
the first time during probe).

Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-10-13 15:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-12 13:32 [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas
2016-10-12 13:32 ` [PATCH v2 1/7] PCI: dra7xx: Add local struct device pointers Bjorn Helgaas
2016-10-12 13:32 ` [PATCH v2 2/7] PCI: dra7xx: Remove redundant struct device pointer from dra7xx_pcie Bjorn Helgaas
2016-10-12 13:32 ` [PATCH v2 3/7] PCI: dra7xx: Set drvdata at end of probe function Bjorn Helgaas
2016-10-12 19:48   ` Andrew F. Davis
2016-10-12 22:21     ` Bjorn Helgaas
2016-10-13 15:24       ` Andrew F. Davis
2016-10-12 13:33 ` [PATCH v2 4/7] PCI: dra7xx: Use generic DesignWare accessors Bjorn Helgaas
2016-10-12 13:33 ` [PATCH v2 5/7] PCI: dra7xx: Pass device-specific struct to internal functions Bjorn Helgaas
2016-10-12 13:33 ` [PATCH v2 6/7] PCI: dra7xx: Move struct pcie_port setup to probe function Bjorn Helgaas
2016-10-12 19:58   ` Andrew F. Davis
2016-10-12 13:33 ` [PATCH v2 7/7] PCI: dra7xx: Reorder struct dra7xx_pcie Bjorn Helgaas
2016-10-12 16:04 ` [PATCH v2 0/7] PCI: dra7xx: Cleanups Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).