diff mbox

[1/4] PCI: imx6: Simplify a trivial if-return sequence

Message ID 1439487436-26989-1-git-send-email-fabio.estevam@freescale.com
State Accepted
Headers show

Commit Message

Fabio Estevam Aug. 13, 2015, 5:37 p.m. UTC
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(-)

Comments

Lucas Stach Aug. 14, 2015, 8:49 a.m. UTC | #1
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)
Bjorn Helgaas Aug. 15, 2015, 4:11 p.m. UTC | #2
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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)