[PATCH v3] iio:frequency:adf4377: Fix duplicated soft reset mask

SeungJu Cheon posted 1 patch 2 weeks ago
drivers/iio/frequency/adf4377.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v3] iio:frequency:adf4377: Fix duplicated soft reset mask
Posted by SeungJu Cheon 2 weeks ago
The regmap_read_poll_timeout() uses ADF4377_0000_SOFT_RESET_R_MSK
twice instead of checking both SOFT_RESET_MSK (bit 0) and
SOFT_RESET_R_MSK (bit 7). This causes an incomplete reset status check.

The code first sets both SOFT_RESET and SOFT_RESET_R bits to 1 via
regmap_update_bits(), then polls for them to be cleared. Since we set
both bits before polling, we should be waiting for both to clear.

Fix by using both masks as done in regmap_update_bits() above.

Fixes: eda549e2e524 ("iio:frequency:adf4377: add support for ADF4377")
Signed-off-by: SeungJu Cheon <suunj1331@gmail.com>
---
v3:
 - Summarize discussion about why both bits need to be checked

v2:
 - Add Fixes tag

 drivers/iio/frequency/adf4377.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
index 08833b7035e4..48aa4b015a14 100644
--- a/drivers/iio/frequency/adf4377.c
+++ b/drivers/iio/frequency/adf4377.c
@@ -501,7 +501,7 @@ static int adf4377_soft_reset(struct adf4377_state *st)
 		return ret;
 
 	return regmap_read_poll_timeout(st->regmap, 0x0, read_val,
-					!(read_val & (ADF4377_0000_SOFT_RESET_R_MSK |
+					!(read_val & (ADF4377_0000_SOFT_RESET_MSK |
 					ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100);
 }
 
-- 
2.52.0
Re: [PATCH v3] iio:frequency:adf4377: Fix duplicated soft reset mask
Posted by Jonathan Cameron 6 days, 8 hours ago
On Sat, 24 Jan 2026 04:47:58 +0900
SeungJu Cheon <suunj1331@gmail.com> wrote:

> The regmap_read_poll_timeout() uses ADF4377_0000_SOFT_RESET_R_MSK
> twice instead of checking both SOFT_RESET_MSK (bit 0) and
> SOFT_RESET_R_MSK (bit 7). This causes an incomplete reset status check.
> 
> The code first sets both SOFT_RESET and SOFT_RESET_R bits to 1 via
> regmap_update_bits(), then polls for them to be cleared. Since we set
> both bits before polling, we should be waiting for both to clear.
> 
> Fix by using both masks as done in regmap_update_bits() above.
> 
> Fixes: eda549e2e524 ("iio:frequency:adf4377: add support for ADF4377")
> Signed-off-by: SeungJu Cheon <suunj1331@gmail.com>
For now I've applied this to a local branch which I'll push out once
I have a suitable base (release, or rc1 depending on when I do it).

Given Antoniu and Andy's involvement in earlier discussion, still plenty of time
to add tags or indeed suggest I drop it again for a v4!

Thanks,

Jonathan

> ---
> v3:
>  - Summarize discussion about why both bits need to be checked
> 
> v2:
>  - Add Fixes tag
> 
>  drivers/iio/frequency/adf4377.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
> index 08833b7035e4..48aa4b015a14 100644
> --- a/drivers/iio/frequency/adf4377.c
> +++ b/drivers/iio/frequency/adf4377.c
> @@ -501,7 +501,7 @@ static int adf4377_soft_reset(struct adf4377_state *st)
>  		return ret;
>  
>  	return regmap_read_poll_timeout(st->regmap, 0x0, read_val,
> -					!(read_val & (ADF4377_0000_SOFT_RESET_R_MSK |
> +					!(read_val & (ADF4377_0000_SOFT_RESET_MSK |
>  					ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100);
>  }
>