Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: frequency: admv1013: propagate errors from regulator_get_voltage()
@ 2023-07-18  7:02 Dan Carpenter
  2023-07-22 16:34 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-07-18  7:02 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	linux-iio, kernel-janitors

The regulator_get_voltage() function returns negative error codes.
This function saves it to an unsigned int and then does some range
checking and, since the error code falls outside the correct range,
it returns -EINVAL.

Beyond the messiness, this is bad because the regulator_get_voltage()
function can return -EPROBE_DEFER and it's important to propagate that
back properly so it can be handled.

Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/iio/frequency/admv1013.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/frequency/admv1013.c b/drivers/iio/frequency/admv1013.c
index 9bf8337806fc..8c8e0bbfc99f 100644
--- a/drivers/iio/frequency/admv1013.c
+++ b/drivers/iio/frequency/admv1013.c
@@ -344,9 +344,12 @@ static int admv1013_update_quad_filters(struct admv1013_state *st)
 
 static int admv1013_update_mixer_vgate(struct admv1013_state *st)
 {
-	unsigned int vcm, mixer_vgate;
+	unsigned int mixer_vgate;
+	int vcm;
 
 	vcm = regulator_get_voltage(st->reg);
+	if (vcm < 0)
+		return vcm;
 
 	if (vcm < 1800000)
 		mixer_vgate = (2389 * vcm / 1000000 + 8100) / 100;
-- 
2.39.2


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

* Re: [PATCH] iio: frequency: admv1013: propagate errors from regulator_get_voltage()
  2023-07-18  7:02 [PATCH] iio: frequency: admv1013: propagate errors from regulator_get_voltage() Dan Carpenter
@ 2023-07-22 16:34 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2023-07-22 16:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich, linux-iio,
	kernel-janitors

On Tue, 18 Jul 2023 10:02:18 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:

> The regulator_get_voltage() function returns negative error codes.
> This function saves it to an unsigned int and then does some range
> checking and, since the error code falls outside the correct range,
> it returns -EINVAL.
> 
> Beyond the messiness, this is bad because the regulator_get_voltage()
> function can return -EPROBE_DEFER and it's important to propagate that
> back properly so it can be handled.
> 
> Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> ---
>  drivers/iio/frequency/admv1013.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/frequency/admv1013.c b/drivers/iio/frequency/admv1013.c
> index 9bf8337806fc..8c8e0bbfc99f 100644
> --- a/drivers/iio/frequency/admv1013.c
> +++ b/drivers/iio/frequency/admv1013.c
> @@ -344,9 +344,12 @@ static int admv1013_update_quad_filters(struct admv1013_state *st)
>  
>  static int admv1013_update_mixer_vgate(struct admv1013_state *st)
>  {
> -	unsigned int vcm, mixer_vgate;
> +	unsigned int mixer_vgate;
> +	int vcm;
>  
>  	vcm = regulator_get_voltage(st->reg);
> +	if (vcm < 0)
> +		return vcm;
>  
>  	if (vcm < 1800000)
>  		mixer_vgate = (2389 * vcm / 1000000 + 8100) / 100;


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

end of thread, other threads:[~2023-07-22 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18  7:02 [PATCH] iio: frequency: admv1013: propagate errors from regulator_get_voltage() Dan Carpenter
2023-07-22 16:34 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox