* [PATCH] drivers: adc: fix return value if timeout occurs
@ 2022-03-01 12:34 Francois Berder
2022-03-01 12:48 ` Michael Nazzareno Trimarchi
0 siblings, 1 reply; 3+ messages in thread
From: Francois Berder @ 2022-03-01 12:34 UTC (permalink / raw)
To: u-boot; +Cc: Francois Berder, Neil Armstrong, u-boot-amlogic
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@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)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: adc: fix return value if timeout occurs
2022-03-01 12:34 [PATCH] drivers: adc: fix return value if timeout occurs Francois Berder
@ 2022-03-01 12:48 ` Michael Nazzareno Trimarchi
2022-03-01 13:08 ` Neil Armstrong
0 siblings, 1 reply; 3+ messages in thread
From: Michael Nazzareno Trimarchi @ 2022-03-01 12:48 UTC (permalink / raw)
To: Francois Berder; +Cc: u-boot, Neil Armstrong, u-boot-amlogic
Hi
On Tue, Mar 1, 2022 at 1:38 PM Francois Berder <fberder@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@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@amarulasolutions.com
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: adc: fix return value if timeout occurs
2022-03-01 12:48 ` Michael Nazzareno Trimarchi
@ 2022-03-01 13:08 ` Neil Armstrong
0 siblings, 0 replies; 3+ messages in thread
From: Neil Armstrong @ 2022-03-01 13:08 UTC (permalink / raw)
To: Michael Nazzareno Trimarchi, Francois Berder; +Cc: u-boot, u-boot-amlogic
Hi,
On 01/03/2022 13:48, Michael Nazzareno Trimarchi wrote:
> Hi
>
> On Tue, Mar 1, 2022 at 1:38 PM Francois Berder <fberder@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@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?
Good point, it's weird I haven't use it at submission.
Neil
>
> 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)
>>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-01 13:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 12:34 [PATCH] drivers: adc: fix return value if timeout occurs Francois Berder
2022-03-01 12:48 ` Michael Nazzareno Trimarchi
2022-03-01 13:08 ` Neil Armstrong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.