Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: gyro: bmg160: wait full startup time after mode change at probe
@ 2026-05-11  6:27 Stepan Ionichev
  2026-05-11  6:40 ` [PATCH v2] " Stepan Ionichev
  2026-05-11 13:49 ` [PATCH] " Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Stepan Ionichev @ 2026-05-11  6:27 UTC (permalink / raw)
  To: jic23
  Cc: dlechner, nuno.sa, andy, gregkh, hcazarim, linux-iio,
	linux-kernel, sozdayvek

bmg160_chip_init() calls bmg160_set_mode(BMG160_MODE_NORMAL) and
then waits only 500-1000 us. Per the BMG160 datasheet
(BST-BMG160-DS000-07 Rev. 1.0, May 2013), the start-up and wake-up
times (tsu, twusm) are 30 ms.

The same file already waits BMG160_MAX_STARTUP_TIME_MS (80 ms)
in bmg160_runtime_resume() after the same set_mode(NORMAL)
operation. The 500 us value at probe was likely a unit mix-up;
the old comment said "500 ms" while the code used microseconds.

Reuse the same constant via msleep_interruptible() to match the
runtime resume path. Without this, register writes that follow
the mode change can hit the chip before it is ready.

Fixes: 22b46c45fb9b ("iio:gyro:bmg160 Gyro Sensor driver")
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
 drivers/iio/gyro/bmg160_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 38394b5f3..44e90af5c 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -258,8 +258,7 @@ static int bmg160_chip_init(struct bmg160_data *data)
 	if (ret < 0)
 		return ret;
 
-	/* Wait upto 500 ms to be ready after changing mode */
-	usleep_range(500, 1000);
+	msleep_interruptible(BMG160_MAX_STARTUP_TIME_MS);
 
 	/* Set Bandwidth */
 	ret = bmg160_set_bw(data, BMG160_DEF_BW);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-11 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11  6:27 [PATCH] iio: gyro: bmg160: wait full startup time after mode change at probe Stepan Ionichev
2026-05-11  6:40 ` [PATCH v2] " Stepan Ionichev
2026-05-11 14:47   ` Jonathan Cameron
2026-05-11 13:49 ` [PATCH] " Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox