Skip to content

Commit

Permalink
i2c: qcom-geni: Use goto for clearer exit path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andi Shyti committed Sep 9, 2024
1 parent 2d30c63 commit 23cc961
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions drivers/i2c/busses/i2c-qcom-geni.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 23cc961

Please sign in to comment.