Skip to content

Commit eab4c1e

Browse files
jhovoldandersson
authored andcommitted
clk: qcom: gdsc: add missing error handling
Since commit 7eb231c ("PM / Domains: Convert pm_genpd_init() to return an error code") pm_genpd_init() can return an error which the caller must handle. The current error handling was also incomplete as the runtime PM and regulator use counts were not balanced in all error paths. Add the missing error handling to the GDSC initialisation to avoid continuing as if nothing happened on errors. Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20220929155816.17425-1-johan+linaro@kernel.org
1 parent 6632a6a commit eab4c1e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

drivers/clk/qcom/gdsc.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,8 @@ static int gdsc_init(struct gdsc *sc)
449449

450450
/* ...and the power-domain */
451451
ret = gdsc_pm_runtime_get(sc);
452-
if (ret) {
453-
if (sc->rsupply)
454-
regulator_disable(sc->rsupply);
455-
return ret;
456-
}
452+
if (ret)
453+
goto err_disable_supply;
457454

458455
/*
459456
* Votable GDSCs can be ON due to Vote from other masters.
@@ -462,14 +459,14 @@ static int gdsc_init(struct gdsc *sc)
462459
if (sc->flags & VOTABLE) {
463460
ret = gdsc_update_collapse_bit(sc, false);
464461
if (ret)
465-
return ret;
462+
goto err_put_rpm;
466463
}
467464

468465
/* Turn on HW trigger mode if supported */
469466
if (sc->flags & HW_CTRL) {
470467
ret = gdsc_hwctrl(sc, true);
471468
if (ret < 0)
472-
return ret;
469+
goto err_put_rpm;
473470
}
474471

475472
/*
@@ -496,9 +493,21 @@ static int gdsc_init(struct gdsc *sc)
496493
sc->pd.power_off = gdsc_disable;
497494
if (!sc->pd.power_on)
498495
sc->pd.power_on = gdsc_enable;
499-
pm_genpd_init(&sc->pd, NULL, !on);
496+
497+
ret = pm_genpd_init(&sc->pd, NULL, !on);
498+
if (ret)
499+
goto err_put_rpm;
500500

501501
return 0;
502+
503+
err_put_rpm:
504+
if (on)
505+
gdsc_pm_runtime_put(sc);
506+
err_disable_supply:
507+
if (on && sc->rsupply)
508+
regulator_disable(sc->rsupply);
509+
510+
return ret;
502511
}
503512

504513
int gdsc_register(struct gdsc_desc *desc,

0 commit comments

Comments
 (0)