Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653884 > unrolled thread

[PATCH] i2c: at91: Handle return value of clk_prepare_enable

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2017-05-31 09:00 +0200
Last post2017-05-31 14:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] i2c: at91: Handle return value of clk_prepare_enable Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-05-31 09:00 +0200
    Re: [PATCH] i2c: at91: Handle return value of clk_prepare_enable Ludovic Desroches <ludovic.desroches@microchip.com> - 2017-05-31 14:10 +0200

#1653884 — [PATCH] i2c: at91: Handle return value of clk_prepare_enable

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2017-05-31 09:00 +0200
Subject[PATCH] i2c: at91: Handle return value of clk_prepare_enable
Message-ID<tN5LP-1k9-1@gated-at.bofh.it>
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/i2c/busses/i2c-at91.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index fabbb9e..2525cd9 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -1083,12 +1083,16 @@ static int at91_twi_probe(struct platform_device *pdev)
 		dev_err(dev->dev, "no clock defined\n");
 		return -ENODEV;
 	}
-	clk_prepare_enable(dev->clk);
+	rc = clk_prepare_enable(dev->clk);
+	if (rc)
+		return rc;
 
 	if (dev->dev->of_node) {
 		rc = at91_twi_configure_dma(dev, phy_addr);
-		if (rc == -EPROBE_DEFER)
+		if (rc == -EPROBE_DEFER) {
+			clk_disable_unprepare(dev->clk);
 			return rc;
+		}
 	}
 
 	if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
-- 
1.9.1

[toc] | [next] | [standalone]


#1654166

FromLudovic Desroches <ludovic.desroches@microchip.com>
Date2017-05-31 14:10 +0200
Message-ID<tNaBQ-4zj-23@gated-at.bofh.it>
In reply to#1653884
On Wed, May 31, 2017 at 12:27:44PM +0530, Arvind Yadav wrote:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
I would split this patch in:
- add missing clk_disable_unprepare()
- check clk_prepare_enable() return value

Since there are trivial fixes, maybe having them squashed is ok.

Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>

Thanks
> ---
>  drivers/i2c/busses/i2c-at91.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index fabbb9e..2525cd9 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -1083,12 +1083,16 @@ static int at91_twi_probe(struct platform_device *pdev)
>  		dev_err(dev->dev, "no clock defined\n");
>  		return -ENODEV;
>  	}
> -	clk_prepare_enable(dev->clk);
> +	rc = clk_prepare_enable(dev->clk);
> +	if (rc)
> +		return rc;
>  
>  	if (dev->dev->of_node) {
>  		rc = at91_twi_configure_dma(dev, phy_addr);
> -		if (rc == -EPROBE_DEFER)
> +		if (rc == -EPROBE_DEFER) {
> +			clk_disable_unprepare(dev->clk);
>  			return rc;
> +		}
>  	}
>  
>  	if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web