2023-08-07 15:11:54

by Antoniu Miclaus

[permalink] [raw]
Subject: [PATCH] iio: admv1013: add mixer_vgate corner cases

Include the corner cases in the computation of the MIXER_VGATE register
value.

According to the datasheet: The MIXER_VGATE values follows the VCM such
as, that for a 0V to 1.8V VCM, MIXER_VGATE = 23.89 VCM + 81, and for a >
1.8V to 2.6V VCM, MIXER_VGATE = 23.75 VCM + 1.25.

Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")
Signed-off-by: Antoniu Miclaus <[email protected]>
---
drivers/iio/frequency/admv1013.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/frequency/admv1013.c b/drivers/iio/frequency/admv1013.c
index 9bf8337806fc..df29f1216b9a 100644
--- a/drivers/iio/frequency/admv1013.c
+++ b/drivers/iio/frequency/admv1013.c
@@ -348,9 +348,9 @@ static int admv1013_update_mixer_vgate(struct admv1013_state *st)

vcm = regulator_get_voltage(st->reg);

- if (vcm < 1800000)
+ if (vcm <= 1800000)
mixer_vgate = (2389 * vcm / 1000000 + 8100) / 100;
- else if (vcm > 1800000 && vcm < 2600000)
+ else if (vcm > 1800000 && vcm <= 2600000)
mixer_vgate = (2375 * vcm / 1000000 + 125) / 100;
else
return -EINVAL;
--
2.41.0



2023-08-08 20:13:55

by Nuno Sá

[permalink] [raw]
Subject: Re: [PATCH] iio: admv1013: add mixer_vgate corner cases

On Mon, 2023-08-07 at 17:38 +0300, Antoniu Miclaus wrote:
> Include the corner cases in the computation of the MIXER_VGATE register
> value.
>
> According to the datasheet: The MIXER_VGATE values follows the VCM such
> as, that for a 0V to 1.8V VCM, MIXER_VGATE = 23.89 VCM + 81, and for a >
> 1.8V to 2.6V VCM, MIXER_VGATE = 23.75 VCM + 1.25.
>
> Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")
> Signed-off-by: Antoniu Miclaus <[email protected]>
> ---

Reviewed-by: Nuno Sa <[email protected]>

>  drivers/iio/frequency/admv1013.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/frequency/admv1013.c
> b/drivers/iio/frequency/admv1013.c
> index 9bf8337806fc..df29f1216b9a 100644
> --- a/drivers/iio/frequency/admv1013.c
> +++ b/drivers/iio/frequency/admv1013.c
> @@ -348,9 +348,9 @@ static int admv1013_update_mixer_vgate(struct
> admv1013_state *st)
>  
>         vcm = regulator_get_voltage(st->reg);
>  
> -       if (vcm < 1800000)
> +       if (vcm <= 1800000)
>                 mixer_vgate = (2389 * vcm / 1000000 + 8100) / 100;
> -       else if (vcm > 1800000 && vcm < 2600000)
> +       else if (vcm > 1800000 && vcm <= 2600000)
>                 mixer_vgate = (2375 * vcm / 1000000 + 125) / 100;
>         else
>                 return -EINVAL;