2022-08-01 06:09:05

by Manivannan Sadhasivam

[permalink] [raw]
Subject: [PATCH v2] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found

devm_regulator_get_optional() API will return -ENODEV if the regulator was
not found. For the optional supplies CX, PX we should not fail in that case
but rather continue. So let's catch that error and continue silently if
those regulators are not found.

The commit 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with
optional px and cx regulators") was supposed to do the same but it missed
the fact that devm_regulator_get_optional() API returns -ENODEV when the
regulator was not found.

Cc: Abel Vesa <[email protected]>
Fixes: 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with optional px and cx regulators")
Reported-by: Steev Klimaszewski <[email protected]>
Reviewed-by: Abel Vesa <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
Tested-by: Steev Klimaszewski <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
---

Changes in v2:

* Removed comment in error path
* Returned px error code directly
* Collected tags

drivers/remoteproc/qcom_q6v5_pas.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index 98f133f9bb60..6afd0941e552 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -362,13 +362,25 @@ static int adsp_init_clock(struct qcom_adsp *adsp)
static int adsp_init_regulator(struct qcom_adsp *adsp)
{
adsp->cx_supply = devm_regulator_get_optional(adsp->dev, "cx");
- if (IS_ERR(adsp->cx_supply))
- return PTR_ERR(adsp->cx_supply);
+ if (IS_ERR(adsp->cx_supply)) {
+ if (PTR_ERR(adsp->cx_supply) == -ENODEV)
+ adsp->cx_supply = NULL;
+ else
+ return PTR_ERR(adsp->cx_supply);
+ }

- regulator_set_load(adsp->cx_supply, 100000);
+ if (adsp->cx_supply)
+ regulator_set_load(adsp->cx_supply, 100000);

adsp->px_supply = devm_regulator_get_optional(adsp->dev, "px");
- return PTR_ERR_OR_ZERO(adsp->px_supply);
+ if (IS_ERR(adsp->px_supply)) {
+ if (PTR_ERR(adsp->px_supply) == -ENODEV)
+ adsp->px_supply = NULL;
+ else
+ return PTR_ERR(adsp->px_supply);
+ }
+
+ return 0;
}

static int adsp_pds_attach(struct device *dev, struct device **devs,
--
2.25.1



2022-08-08 18:34:23

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v2] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found

On Mon, 1 Aug 2022 11:09:39 +0530, Manivannan Sadhasivam wrote:
> devm_regulator_get_optional() API will return -ENODEV if the regulator was
> not found. For the optional supplies CX, PX we should not fail in that case
> but rather continue. So let's catch that error and continue silently if
> those regulators are not found.
>
> The commit 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with
> optional px and cx regulators") was supposed to do the same but it missed
> the fact that devm_regulator_get_optional() API returns -ENODEV when the
> regulator was not found.
>
> [...]

Applied, thanks!

[1/1] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found
commit: 8447d0e75099eb54eea9306c2d43ecfc956d09ed

Please remember to Cc linux-remoteproc@vger next time.

Best regards,
--
Bjorn Andersson <[email protected]>