Skip to content

Commit

Permalink
iio: frequency: admv1013: propagate errors from regulator_get_voltage()
Browse files Browse the repository at this point in the history
commit 507397d upstream.

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: da35a7b ("iio: frequency: admv1013: add support for ADMV1013")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/ce75aac3-2aba-4435-8419-02e59fdd862b@moroto.mountain
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Aug 16, 2023
1 parent 366563c commit 5e1ed81
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/iio/frequency/admv1013.c
Expand Up @@ -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;
Expand Down

0 comments on commit 5e1ed81

Please sign in to comment.