Skip to content

Commit e0fafee

Browse files
committed
iio: ad9361: Make sure the part is in the desired ENSM state
ad9361_ensm_force_state() should verify if the part is really in the desired ENSM state before exit. Otherwise, other operations that are executed afterwards may fail. Signed-off-by: Dragos Bogdan <[email protected]>
1 parent 0fa1a63 commit e0fafee

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/iio/adc/ad9361.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ void ad9361_ensm_force_state(struct ad9361_rf_phy *phy, u8 ensm_state)
15821582
struct spi_device *spi = phy->spi;
15831583
struct device *dev = &phy->spi->dev;
15841584
u8 dev_ensm_state;
1585-
int rc;
1585+
int rc, timeout = 10;
15861586
u32 val;
15871587

15881588
dev_ensm_state = ad9361_spi_readf(spi, REG_STATE, ENSM_STATE(~0));
@@ -1635,7 +1635,16 @@ void ad9361_ensm_force_state(struct ad9361_rf_phy *phy, u8 ensm_state)
16351635
ad9361_spi_write(spi, REG_ENSM_CONFIG_1, TO_ALERT | FORCE_ALERT_STATE);
16361636

16371637
rc = ad9361_spi_write(spi, REG_ENSM_CONFIG_1, val);
1638-
if (rc)
1638+
if (rc) {
1639+
dev_err(dev, "Failed to restore state\n");
1640+
goto out;
1641+
}
1642+
1643+
do {
1644+
mdelay(1);
1645+
} while (ad9361_ensm_get_state(phy) != ensm_state && --timeout);
1646+
1647+
if (timeout == 0)
16391648
dev_err(dev, "Failed to restore state\n");
16401649

16411650
out:

0 commit comments

Comments
 (0)