linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] i2c: bcm2835: add missing disable and put clk on error in bcm2835_i2c_probe()
@ 2021-06-01 14:08 Yang Yingliang
  2022-02-07 14:49 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-06-01 14:08 UTC (permalink / raw)
  To: linux-kernel, linux-i2c; +Cc: wsa, f.fainelli

Add clk_disable_unprepare() and clk_rate_exclusive_put() on error
path in bcm2835_i2c_probe().

Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/i2c/busses/i2c-bcm2835.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 37443edbf754..a7fa3429c389 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -449,13 +449,14 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(i2c_dev->bus_clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Couldn't prepare clock");
-		return ret;
+		goto err_put_clk;
 	}
 
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!irq) {
 		dev_err(&pdev->dev, "No IRQ resource\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_disable_clk;
 	}
 	i2c_dev->irq = irq->start;
 
@@ -463,7 +464,8 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 			  dev_name(&pdev->dev), i2c_dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not request IRQ\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_disable_clk;
 	}
 
 	adap = &i2c_dev->adapter;
@@ -480,9 +482,17 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
 
 	ret = i2c_add_adapter(adap);
-	if (ret)
+	if (ret) {
 		free_irq(i2c_dev->irq, i2c_dev);
+		goto err_disable_clk;
+	}
 
+	return 0;
+
+err_disable_clk:
+	clk_disable_unprepare(i2c_dev->bus_clk);
+err_put_clk:
+	clk_rate_exclusive_put(i2c_dev->bus_clk);
 	return ret;
 }
 
-- 
2.25.1


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

* Re: [PATCH -next] i2c: bcm2835: add missing disable and put clk on error in bcm2835_i2c_probe()
  2021-06-01 14:08 [PATCH -next] i2c: bcm2835: add missing disable and put clk on error in bcm2835_i2c_probe() Yang Yingliang
@ 2022-02-07 14:49 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2022-02-07 14:49 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, linux-i2c, f.fainelli

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

On Tue, Jun 01, 2021 at 10:08:35PM +0800, Yang Yingliang wrote:
> Add clk_disable_unprepare() and clk_rate_exclusive_put() on error
> path in bcm2835_i2c_probe().
> 
> Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Correct, but I applied another version instead which was a tad better:
http://patchwork.ozlabs.org/project/linux-i2c/patch/338008c444af4785a07fb5a402b60225a4964ae9.1629484876.git.christophe.jaillet@wanadoo.fr/

But thanks for working on it!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-02-07 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 14:08 [PATCH -next] i2c: bcm2835: add missing disable and put clk on error in bcm2835_i2c_probe() Yang Yingliang
2022-02-07 14:49 ` Wolfram Sang

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).