All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found
@ 2022-07-30  6:28 Manivannan Sadhasivam
  2022-07-30  6:42 ` Steev Klimaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2022-07-30  6:28 UTC (permalink / raw)
  To: bjorn.andersson
  Cc: linux-arm-msm, linux-kernel, Manivannan Sadhasivam, Abel Vesa,
	Steev Klimaszewski

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 <abel.vesa@linaro.org>
Fixes: 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with optional px and cx regulators")
Reported-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/remoteproc/qcom_q6v5_pas.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index 98f133f9bb60..5bf69ef53819 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -362,12 +362,24 @@ 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)) {
+		/* Do not fail if the regulator is not found */
+		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");
+	if (IS_ERR(adsp->px_supply)) {
+		/* Do not fail if the regulator is not found */
+		if (PTR_ERR(adsp->px_supply) == -ENODEV)
+			adsp->px_supply = NULL;
+	}
+
 	return PTR_ERR_OR_ZERO(adsp->px_supply);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found
  2022-07-30  6:28 [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found Manivannan Sadhasivam
@ 2022-07-30  6:42 ` Steev Klimaszewski
  2022-07-30 18:07 ` Abel Vesa
  2022-07-31  8:43 ` Johan Hovold
  2 siblings, 0 replies; 4+ messages in thread
From: Steev Klimaszewski @ 2022-07-30  6:42 UTC (permalink / raw)
  To: Manivannan Sadhasivam, bjorn.andersson
  Cc: linux-arm-msm, linux-kernel, Abel Vesa


On 7/30/22 1:28 AM, 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.
>
> Cc: Abel Vesa <abel.vesa@linaro.org>
> Fixes: 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with optional px and cx regulators")
> Reported-by: Steev Klimaszewski <steev@kali.org>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>   drivers/remoteproc/qcom_q6v5_pas.c | 18 +++++++++++++++---
>   1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index 98f133f9bb60..5bf69ef53819 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -362,12 +362,24 @@ 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)) {
> +		/* Do not fail if the regulator is not found */
> +		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");
> +	if (IS_ERR(adsp->px_supply)) {
> +		/* Do not fail if the regulator is not found */
> +		if (PTR_ERR(adsp->px_supply) == -ENODEV)
> +			adsp->px_supply = NULL;
> +	}
> +
>   	return PTR_ERR_OR_ZERO(adsp->px_supply);
>   }
>   

Tested on the Lenovo Thinkpad X13s

Tested-by: Steev Klimaszewski <steev@kali.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found
  2022-07-30  6:28 [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found Manivannan Sadhasivam
  2022-07-30  6:42 ` Steev Klimaszewski
@ 2022-07-30 18:07 ` Abel Vesa
  2022-07-31  8:43 ` Johan Hovold
  2 siblings, 0 replies; 4+ messages in thread
From: Abel Vesa @ 2022-07-30 18:07 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: bjorn.andersson, linux-arm-msm, linux-kernel, Steev Klimaszewski

On 22-07-30 11:58:34, 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.
>
> Cc: Abel Vesa <abel.vesa@linaro.org>
> Fixes: 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with optional px and cx regulators")
> Reported-by: Steev Klimaszewski <steev@kali.org>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Yep, makes sense.

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>

> ---
>  drivers/remoteproc/qcom_q6v5_pas.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index 98f133f9bb60..5bf69ef53819 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -362,12 +362,24 @@ 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)) {
> +		/* Do not fail if the regulator is not found */

Maybe this comment is redundant.

> +		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");
> +	if (IS_ERR(adsp->px_supply)) {
> +		/* Do not fail if the regulator is not found */

Same here.

> +		if (PTR_ERR(adsp->px_supply) == -ENODEV)
> +			adsp->px_supply = NULL;
> +	}
> +
>  	return PTR_ERR_OR_ZERO(adsp->px_supply);
>  }
>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found
  2022-07-30  6:28 [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found Manivannan Sadhasivam
  2022-07-30  6:42 ` Steev Klimaszewski
  2022-07-30 18:07 ` Abel Vesa
@ 2022-07-31  8:43 ` Johan Hovold
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2022-07-31  8:43 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: bjorn.andersson, linux-arm-msm, linux-kernel, Abel Vesa,
	Steev Klimaszewski

On Sat, Jul 30, 2022 at 11:58:34AM +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.
> 
> Cc: Abel Vesa <abel.vesa@linaro.org>
> Fixes: 3f52d118f992 ("remoteproc: qcom_q6v5_pas: Deal silently with optional px and cx regulators")
> Reported-by: Steev Klimaszewski <steev@kali.org>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/remoteproc/qcom_q6v5_pas.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index 98f133f9bb60..5bf69ef53819 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -362,12 +362,24 @@ 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)) {
> +		/* Do not fail if the regulator is not found */

I agree with Abel that these comments shouldn't be necessary.

> +		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");
> +	if (IS_ERR(adsp->px_supply)) {
> +		/* Do not fail if the regulator is not found */
> +		if (PTR_ERR(adsp->px_supply) == -ENODEV)
> +			adsp->px_supply = NULL;

Please return the error here as for cx.

> +	}
> +
>  	return PTR_ERR_OR_ZERO(adsp->px_supply);

And drop this abomination which just obfuscates code and return 0
explicitly in the success path.

With that fixed:

Reviewed-by: Johan Hovold <johan+linaro@kernel.org>

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-31  8:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-30  6:28 [PATCH] remoteproc: qcom_q6v5_pas: Do not fail if regulators are not found Manivannan Sadhasivam
2022-07-30  6:42 ` Steev Klimaszewski
2022-07-30 18:07 ` Abel Vesa
2022-07-31  8:43 ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.