From: Bjorn Andersson <andersson@kernel.org>
To: Johan Hovold <johan+linaro@kernel.org>
Cc: Andy Gross <agross@kernel.org>,
Konrad Dybcio <konrad.dybcio@somainline.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: qcom: gdsc: add missing error handling
Date: Thu, 29 Sep 2022 11:34:30 -0500 [thread overview]
Message-ID: <20220929163430.ozkfdiv5n2snwhkn@builder.lan> (raw)
In-Reply-To: <20220929155816.17425-1-johan+linaro@kernel.org>
On Thu, Sep 29, 2022 at 05:58:16PM +0200, Johan Hovold wrote:
> Since commit 7eb231c337e0 ("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>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Regards,
Bjorn
> ---
> drivers/clk/qcom/gdsc.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> index e1d6574d2797..0b67bd72e217 100644
> --- a/drivers/clk/qcom/gdsc.c
> +++ b/drivers/clk/qcom/gdsc.c
> @@ -451,11 +451,8 @@ static int gdsc_init(struct gdsc *sc)
>
> /* ...and the power-domain */
> ret = gdsc_pm_runtime_get(sc);
> - if (ret) {
> - if (sc->rsupply)
> - regulator_disable(sc->rsupply);
> - return ret;
> - }
> + if (ret)
> + goto err_disable_supply;
>
> /*
> * Votable GDSCs can be ON due to Vote from other masters.
> @@ -464,14 +461,14 @@ static int gdsc_init(struct gdsc *sc)
> if (sc->flags & VOTABLE) {
> ret = gdsc_update_collapse_bit(sc, false);
> if (ret)
> - return ret;
> + goto err_put_rpm;
> }
>
> /* Turn on HW trigger mode if supported */
> if (sc->flags & HW_CTRL) {
> ret = gdsc_hwctrl(sc, true);
> if (ret < 0)
> - return ret;
> + goto err_put_rpm;
> }
>
> /*
> @@ -498,9 +495,21 @@ static int gdsc_init(struct gdsc *sc)
> sc->pd.power_off = gdsc_disable;
> if (!sc->pd.power_on)
> sc->pd.power_on = gdsc_enable;
> - pm_genpd_init(&sc->pd, NULL, !on);
> +
> + ret = pm_genpd_init(&sc->pd, NULL, !on);
> + if (ret)
> + goto err_put_rpm;
>
> return 0;
> +
> +err_put_rpm:
> + if (on)
> + gdsc_pm_runtime_put(sc);
> +err_disable_supply:
> + if (on && sc->rsupply)
> + regulator_disable(sc->rsupply);
> +
> + return ret;
> }
>
> int gdsc_register(struct gdsc_desc *desc,
> --
> 2.35.1
>
next prev parent reply other threads:[~2022-09-29 16:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 15:58 [PATCH] clk: qcom: gdsc: add missing error handling Johan Hovold
2022-09-29 16:34 ` Bjorn Andersson [this message]
2022-09-29 16:45 ` Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220929163430.ozkfdiv5n2snwhkn@builder.lan \
--to=andersson@kernel.org \
--cc=agross@kernel.org \
--cc=johan+linaro@kernel.org \
--cc=konrad.dybcio@somainline.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox