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

Francois Berder fberder at outlook.fr
Tue Mar 1 13:34:13 CET 2022


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)
 
 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)



More information about the U-Boot mailing list