[PATCH] drivers: adc: fix return value if timeout occurs

Michael Nazzareno Trimarchi michael at amarulasolutions.com
Tue Mar 1 13:48:58 CET 2022


Hi

On Tue, Mar 1, 2022 at 1:38 PM Francois Berder <fberder at outlook.fr> wrote:
>
> Because unsigned integers cannot be negative,
> timeout variable is never less than zero. Hence, checks
> in Amlogic Meson ADC driver to detect timeouts always
> evaluated to false. Fix that.
>
> Signed-off-by: Francois Berder <fberder at outlook.fr>
> ---
>
>  drivers/adc/meson-saradc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/adc/meson-saradc.c b/drivers/adc/meson-saradc.c
> index 1a45a3a265..a48200a769 100644
> --- a/drivers/adc/meson-saradc.c
> +++ b/drivers/adc/meson-saradc.c
> @@ -192,7 +192,8 @@ meson_saradc_get_fifo_count(struct meson_saradc_priv *priv)
>
>  static int meson_saradc_lock(struct meson_saradc_priv *priv)
>  {
> -       uint val, timeout = 10000;
> +       uint val;
> +       int timeout = 10000;
>
>         /* prevent BL30 from using the SAR ADC while we are using it */
>         regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY,
> @@ -246,7 +247,8 @@ static int meson_saradc_calib_val(struct meson_saradc_priv *priv, int val)
>

Can you use regmap_read_poll_timeout?

Michael

>  static int meson_saradc_wait_busy_clear(struct meson_saradc_priv *priv)
>  {
> -       uint regval, timeout = 10000;
> +       uint regval;
> +       int timeout = 10000;
>
>         /*
>          * NOTE: we need a small delay before reading the status, otherwise
> --
> 2.30.1 (Apple Git-130)
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael at amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info at amarulasolutions.com
www.amarulasolutions.com


More information about the U-Boot mailing list