diff mbox series

[2/2] i2c: qcom-geni: Use goto for clearer exit path

Message ID 20240812194029.2222697-3-andi.shyti@kernel.org
State New
Headers show
Series Add missing icc_disable in exit path | expand

Commit Message

Andi Shyti Aug. 12, 2024, 7:40 p.m. UTC
Refactor the code by using goto statements to reduce duplication
and make the exit path clearer.

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
Cc: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>

 drivers/i2c/busses/i2c-qcom-geni.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

Comments

Andi Shyti Aug. 21, 2024, 2:11 p.m. UTC | #1
On Mon, Aug 12, 2024 at 09:40:29PM GMT, Andi Shyti wrote:
> Refactor the code by using goto statements to reduce duplication
> and make the exit path clearer.
> 
> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>

merged to i2c/i2c-host.

Andi
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 06e836e3e8773..ebb5900fd3227 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -986,21 +986,24 @@  static int __maybe_unused geni_i2c_runtime_resume(struct device *dev)
 		return ret;
 
 	ret = clk_prepare_enable(gi2c->core_clk);
-	if (ret) {
-		geni_icc_disable(&gi2c->se);
-		return ret;
-	}
+	if (ret)
+		goto out_icc_disable;
 
 	ret = geni_se_resources_on(&gi2c->se);
-	if (ret) {
-		clk_disable_unprepare(gi2c->core_clk);
-		geni_icc_disable(&gi2c->se);
-		return ret;
-	}
+	if (ret)
+		goto out_clk_disable;
 
 	enable_irq(gi2c->irq);
 	gi2c->suspended = 0;
+
 	return 0;
+
+out_clk_disable:
+	clk_disable_unprepare(gi2c->core_clk);
+out_icc_disable:
+	geni_icc_disable(&gi2c->se);
+
+	return ret;
 }
 
 static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev)