mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: imu: inv_icm42600: fix temperature reading if accel/gyro is off
@ 2025-07-08 12:09 Sean Nyekjaer
  2025-07-08 13:14 ` Andy Shevchenko
  2025-07-13 13:47 ` Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Nyekjaer @ 2025-07-08 12:09 UTC (permalink / raw)
  To: Jean-Baptiste Maneyrol, Jonathan Cameron, David Lechner,
	Nuno Sá,
	Andy Shevchenko
  Cc: linux-iio, linux-kernel, Sean Nyekjaer

Avoid return invalid argument if one tries to read the temperature,.
if both the accelerometer and gyro are off. Power the accelerometer on
before reading the temperature.
The original state will be restored by runtine_suspend() or the next
reading of the accelerometer.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index a4d42e7e21807f7954def431e9cf03dffaa5bd5e..f97376bc8bb3dd225236e3f5036fd58af4af35ac 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
@@ -399,9 +399,14 @@ int inv_icm42600_set_gyro_conf(struct inv_icm42600_state *st,
 int inv_icm42600_set_temp_conf(struct inv_icm42600_state *st, bool enable,
 			       unsigned int *sleep_ms)
 {
-	return inv_icm42600_set_pwr_mgmt0(st, st->conf.gyro.mode,
-					  st->conf.accel.mode, enable,
-					  sleep_ms);
+	enum inv_icm42600_sensor_mode accel = st->conf.accel.mode;
+
+	if (st->conf.gyro.mode == INV_ICM42600_SENSOR_MODE_OFF &&
+	    st->conf.accel.mode == INV_ICM42600_SENSOR_MODE_OFF)
+		accel = INV_ICM42600_SENSOR_MODE_LOW_POWER;
+
+	return inv_icm42600_set_pwr_mgmt0(st, st->conf.gyro.mode, accel,
+					  enable, sleep_ms);
 }
 
 int inv_icm42600_enable_wom(struct inv_icm42600_state *st)

---
base-commit: 3e28fa06444e7031aba0b3552cce332b776fe267
change-id: 20250708-icm42temp-6292abddb6e6

Best regards,
-- 
Sean Nyekjaer <sean@geanix.com>


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

end of thread, other threads:[~2025-07-13 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-08 12:09 [PATCH] iio: imu: inv_icm42600: fix temperature reading if accel/gyro is off Sean Nyekjaer
2025-07-08 13:14 ` Andy Shevchenko
2025-07-13 13:47 ` Jonathan Cameron

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

all inboxes | Powered by JetHome®