linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence
@ 2015-08-13 17:37 Fabio Estevam
  2015-08-13 17:37 ` [PATCH 2/4] PCI: dra7xx: Remove unneeded use of IS_ERR_VALUE() Fabio Estevam
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Fabio Estevam @ 2015-08-13 17:37 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Lucas Stach

Simplify a trivial if-return sequence by combining it with a
preceding function call.

The semantic patch that makes this change is available
in scripts/coccinelle/misc/simple_return.cocci.

Cc: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/pci/host/pci-imx6.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index 233a196..8f3a981 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -117,11 +117,7 @@ static int pcie_phy_wait_ack(void __iomem *dbi_base, int addr)
 	val = addr << PCIE_PHY_CTRL_DATA_LOC;
 	writel(val, dbi_base + PCIE_PHY_CTRL);
 
-	ret = pcie_phy_poll_ack(dbi_base, 0);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pcie_phy_poll_ack(dbi_base, 0);
 }
 
 /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */
@@ -148,11 +144,7 @@ static int pcie_phy_read(void __iomem *dbi_base, int addr , int *data)
 	/* deassert Read signal */
 	writel(0x00, dbi_base + PCIE_PHY_CTRL);
 
-	ret = pcie_phy_poll_ack(dbi_base, 0);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pcie_phy_poll_ack(dbi_base, 0);
 }
 
 static int pcie_phy_write(void __iomem *dbi_base, int addr, int data)
-- 
1.9.1


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

* [PATCH 2/4] PCI: dra7xx: Remove unneeded use of IS_ERR_VALUE()
  2015-08-13 17:37 [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Fabio Estevam
@ 2015-08-13 17:37 ` Fabio Estevam
  2015-08-13 17:37 ` [PATCH 3/4] PCI: spear: Use BUG_ON() Fabio Estevam
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2015-08-13 17:37 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Kishon Vijay Abraham I

There is no need to use the IS_ERR_VALUE() macro for checking
the return value from pm_runtime_* functions.

Just do a simple negative test instead.

The semantic patch that makes this change is available
in scripts/coccinelle/api/pm_runtime.cocci.

Cc: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/pci/host/pci-dra7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 80db09e..8d72bb9 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -382,7 +382,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
-	if (IS_ERR_VALUE(ret)) {
+	if (ret < 0) {
 		dev_err(dev, "pm_runtime_get_sync failed\n");
 		goto err_phy;
 	}
-- 
1.9.1


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

* [PATCH 3/4] PCI: spear: Use BUG_ON()
  2015-08-13 17:37 [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Fabio Estevam
  2015-08-13 17:37 ` [PATCH 2/4] PCI: dra7xx: Remove unneeded use of IS_ERR_VALUE() Fabio Estevam
@ 2015-08-13 17:37 ` Fabio Estevam
  2015-08-13 17:37 ` [PATCH 4/4] PCI: ats: " Fabio Estevam
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2015-08-13 17:37 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Pratyush Anand

Use BUG_ON() instead of an if condition followed by BUG().

The semantic patch that makes this change is available
in scripts/coccinelle/misc/bugon.cocci.

Cc: Pratyush Anand <pratyush.anand@gmail.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/pci/host/pcie-spear13xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/host/pcie-spear13xx.c b/drivers/pci/host/pcie-spear13xx.c
index c49fbdc..98d2683 100644
--- a/drivers/pci/host/pcie-spear13xx.c
+++ b/drivers/pci/host/pcie-spear13xx.c
@@ -223,8 +223,7 @@ static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg)
 	status = readl(&app_reg->int_sts);
 
 	if (status & MSI_CTRL_INT) {
-		if (!IS_ENABLED(CONFIG_PCI_MSI))
-			BUG();
+		BUG_ON(!IS_ENABLED(CONFIG_PCI_MSI));
 		dw_handle_msi_irq(pp);
 	}
 
-- 
1.9.1


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

* [PATCH 4/4] PCI: ats: Use BUG_ON()
  2015-08-13 17:37 [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Fabio Estevam
  2015-08-13 17:37 ` [PATCH 2/4] PCI: dra7xx: Remove unneeded use of IS_ERR_VALUE() Fabio Estevam
  2015-08-13 17:37 ` [PATCH 3/4] PCI: spear: Use BUG_ON() Fabio Estevam
@ 2015-08-13 17:37 ` Fabio Estevam
  2015-08-14  8:49 ` [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Lucas Stach
  2015-08-15 16:11 ` Bjorn Helgaas
  4 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2015-08-13 17:37 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam

Use BUG_ON() instead of an if condition followed by BUG().

The semantic patch that makes this change is available
in scripts/coccinelle/misc/bugon.cocci.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/pci/ats.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index a8099d4..1c25b20 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -134,8 +134,7 @@ void pci_restore_ats_state(struct pci_dev *dev)
 
 	if (!pci_ats_enabled(dev))
 		return;
-	if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS))
-		BUG();
+	BUG_ON(!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS));
 
 	ctrl = PCI_ATS_CTRL_ENABLE;
 	if (!dev->is_virtfn)
-- 
1.9.1


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

* Re: [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence
  2015-08-13 17:37 [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Fabio Estevam
                   ` (2 preceding siblings ...)
  2015-08-13 17:37 ` [PATCH 4/4] PCI: ats: " Fabio Estevam
@ 2015-08-14  8:49 ` Lucas Stach
  2015-08-15 16:11 ` Bjorn Helgaas
  4 siblings, 0 replies; 6+ messages in thread
From: Lucas Stach @ 2015-08-14  8:49 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: bhelgaas, linux-pci

Am Donnerstag, den 13.08.2015, 14:37 -0300 schrieb Fabio Estevam:
> Simplify a trivial if-return sequence by combining it with a
> preceding function call.
> 
> The semantic patch that makes this change is available
> in scripts/coccinelle/misc/simple_return.cocci.
> 
I don't really see that this helps code clarity/readability, but it
certainly also doesn't make things harder to follow.

So if Bjorn wants to take the series I'm okay with this going in.

Regards,
Lucas

> Cc: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/pci/host/pci-imx6.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
> index 233a196..8f3a981 100644
> --- a/drivers/pci/host/pci-imx6.c
> +++ b/drivers/pci/host/pci-imx6.c
> @@ -117,11 +117,7 @@ static int pcie_phy_wait_ack(void __iomem *dbi_base, int addr)
>  	val = addr << PCIE_PHY_CTRL_DATA_LOC;
>  	writel(val, dbi_base + PCIE_PHY_CTRL);
>  
> -	ret = pcie_phy_poll_ack(dbi_base, 0);
> -	if (ret)
> -		return ret;
> -
> -	return 0;
> +	return pcie_phy_poll_ack(dbi_base, 0);
>  }
>  
>  /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */
> @@ -148,11 +144,7 @@ static int pcie_phy_read(void __iomem *dbi_base, int addr , int *data)
>  	/* deassert Read signal */
>  	writel(0x00, dbi_base + PCIE_PHY_CTRL);
>  
> -	ret = pcie_phy_poll_ack(dbi_base, 0);
> -	if (ret)
> -		return ret;
> -
> -	return 0;
> +	return pcie_phy_poll_ack(dbi_base, 0);
>  }
>  
>  static int pcie_phy_write(void __iomem *dbi_base, int addr, int data)

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |


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

* Re: [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence
  2015-08-13 17:37 [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Fabio Estevam
                   ` (3 preceding siblings ...)
  2015-08-14  8:49 ` [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Lucas Stach
@ 2015-08-15 16:11 ` Bjorn Helgaas
  4 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2015-08-15 16:11 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: linux-pci, Lucas Stach

On Thu, Aug 13, 2015 at 02:37:13PM -0300, Fabio Estevam wrote:
> Simplify a trivial if-return sequence by combining it with a
> preceding function call.
> 
> The semantic patch that makes this change is available
> in scripts/coccinelle/misc/simple_return.cocci.
> 
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

I applied 1-3 to pci/misc for v4.3, thanks!

I dropped 4 ("PCI: ats: Use BUG_ON()") because I reworked
pci_restore_ats_state() so it no longer looks for the ATS capability:

https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=pci/iommu&id=a021f3019db7


> ---
>  drivers/pci/host/pci-imx6.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
> index 233a196..8f3a981 100644
> --- a/drivers/pci/host/pci-imx6.c
> +++ b/drivers/pci/host/pci-imx6.c
> @@ -117,11 +117,7 @@ static int pcie_phy_wait_ack(void __iomem *dbi_base, int addr)
>  	val = addr << PCIE_PHY_CTRL_DATA_LOC;
>  	writel(val, dbi_base + PCIE_PHY_CTRL);
>  
> -	ret = pcie_phy_poll_ack(dbi_base, 0);
> -	if (ret)
> -		return ret;
> -
> -	return 0;
> +	return pcie_phy_poll_ack(dbi_base, 0);
>  }
>  
>  /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */
> @@ -148,11 +144,7 @@ static int pcie_phy_read(void __iomem *dbi_base, int addr , int *data)
>  	/* deassert Read signal */
>  	writel(0x00, dbi_base + PCIE_PHY_CTRL);
>  
> -	ret = pcie_phy_poll_ack(dbi_base, 0);
> -	if (ret)
> -		return ret;
> -
> -	return 0;
> +	return pcie_phy_poll_ack(dbi_base, 0);
>  }
>  
>  static int pcie_phy_write(void __iomem *dbi_base, int addr, int data)
> -- 
> 1.9.1
> 

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

end of thread, other threads:[~2015-08-15 16:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 17:37 [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Fabio Estevam
2015-08-13 17:37 ` [PATCH 2/4] PCI: dra7xx: Remove unneeded use of IS_ERR_VALUE() Fabio Estevam
2015-08-13 17:37 ` [PATCH 3/4] PCI: spear: Use BUG_ON() Fabio Estevam
2015-08-13 17:37 ` [PATCH 4/4] PCI: ats: " Fabio Estevam
2015-08-14  8:49 ` [PATCH 1/4] PCI: imx6: Simplify a trivial if-return sequence Lucas Stach
2015-08-15 16:11 ` 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).