diff mbox series

i2c: qcom-geni: fix missing clk_disable_unprepare()

Message ID 20221228093209.3164540-1-yangyingliang@huawei.com
State New
Headers show
Series i2c: qcom-geni: fix missing clk_disable_unprepare() | expand

Commit Message

Yang Yingliang Dec. 28, 2022, 9:32 a.m. UTC
Add missing clk_disable_unprepare() in the error path in geni_i2c_probe().

Fixes: 14d02fbadb5d ("i2c: qcom-geni: add desc struct to prepare support for I2C Master Hub variant")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/i2c/busses/i2c-qcom-geni.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Bjorn Andersson Dec. 29, 2022, 3:42 a.m. UTC | #1
On Wed, Dec 28, 2022 at 05:32:09PM +0800, Yang Yingliang wrote:
> Add missing clk_disable_unprepare() in the error path in geni_i2c_probe().
> 
> Fixes: 14d02fbadb5d ("i2c: qcom-geni: add desc struct to prepare support for I2C Master Hub variant")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Nice.

> ---
>  drivers/i2c/busses/i2c-qcom-geni.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
> index fd70794bfcee..f292e4dab98f 100644
> --- a/drivers/i2c/busses/i2c-qcom-geni.c
> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
> @@ -859,6 +859,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
>  	ret = geni_se_resources_on(&gi2c->se);
>  	if (ret) {
>  		dev_err(dev, "Error turning on resources %d\n", ret);
> +		clk_disable_unprepare(gi2c->core_clk);
>  		return ret;
>  	}
>  	proto = geni_se_read_proto(&gi2c->se);
> @@ -878,8 +879,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
>  		/* FIFO is disabled, so we can only use GPI DMA */
>  		gi2c->gpi_mode = true;
>  		ret = setup_gpi_dma(gi2c);
> -		if (ret)
> +		if (ret) {
> +			clk_disable_unprepare(gi2c->core_clk);

If I'm not mistaken, we need a geni_se_resources_off() here as well.

>  			return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n");
> +		}
>  
>  		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
>  	} else {
> @@ -892,6 +895,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
>  
>  		if (!tx_depth) {
>  			dev_err(dev, "Invalid TX FIFO depth\n");

Same here.

Regards,
Bjorn

> +			clk_disable_unprepare(gi2c->core_clk);
>  			return -EINVAL;
>  		}
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index fd70794bfcee..f292e4dab98f 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -859,6 +859,7 @@  static int geni_i2c_probe(struct platform_device *pdev)
 	ret = geni_se_resources_on(&gi2c->se);
 	if (ret) {
 		dev_err(dev, "Error turning on resources %d\n", ret);
+		clk_disable_unprepare(gi2c->core_clk);
 		return ret;
 	}
 	proto = geni_se_read_proto(&gi2c->se);
@@ -878,8 +879,10 @@  static int geni_i2c_probe(struct platform_device *pdev)
 		/* FIFO is disabled, so we can only use GPI DMA */
 		gi2c->gpi_mode = true;
 		ret = setup_gpi_dma(gi2c);
-		if (ret)
+		if (ret) {
+			clk_disable_unprepare(gi2c->core_clk);
 			return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n");
+		}
 
 		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
 	} else {
@@ -892,6 +895,7 @@  static int geni_i2c_probe(struct platform_device *pdev)
 
 		if (!tx_depth) {
 			dev_err(dev, "Invalid TX FIFO depth\n");
+			clk_disable_unprepare(gi2c->core_clk);
 			return -EINVAL;
 		}