iio: imu: inv_icm42600: keep the temperature sensor always on
Subsystems (2)
cover iio: imu: inv_icm42600: keep the temperature sensor always on
On an ICM-42688-P, the gyro shows a large, stable offset at rest (about 8 to 23 dps) whenever the driver has the temperature sensor disabled (PWR_MGMT0.TEMP_DIS): without it, gyro data is not temperature compensated internally. As discussed with Jean-Baptiste and Jonathan, this series keeps the temperature sensor always on and removes the driver's temperature enable/disable handling; temperature reporting in the FIFO stays switchable.
The chip only measures temperature while the accel or gyro is on; with both off, its data register keeps the last measurement. Patch 1 makes a temperature read return -EBUSY in that case instead of stale data, so that patch 2 can remove the enable/disable handling without changing what a direct temperature read reports.
Discussion:
https://lore.kernel.org/linux-iio/20261118232418.7fc702a8@jic23-hlaptop/T/#t
Tested on an ICM-42688-P (SPI) on an i.MX8M Plus board: on 6.18 with these patches backported to the 6.18 driver (minor context adjustments, built as an external module), and on 6.6 with the driver backported from mainline:
- gyro correct from the first reads after boot and after runtime suspend; accel unchanged
- idle temperature read returns -EBUSY; current values whenever accel or gyro is on
- PWR_MGMT0.TEMP_DIS never set (regmap debugfs)
- buffered capture of gyro and accel, separately and concurrently (including stopping one while the other runs), with and without the temperature channel, and temperature-only: correct data at 50 Hz
- repeated buffer enable/disable; module reload
Build-tested on the IIO togreg branch.
I kept the INV_ICM42600_PWR_MGMT0_TEMP_DIS definition in inv_icm42600.h, now unused, to document the register bit; happy to drop it if you prefer.
Joe LeVeque (2):
iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
iio: imu: inv_icm42600: remove temperature sensor enable/disable
drivers/iio/imu/inv_icm42600/inv_icm42600.h | 6 --- .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 16 ++------ .../imu/inv_icm42600/inv_icm42600_buffer.c | 14 ++----- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 37 ++++--------------- .../iio/imu/inv_icm42600/inv_icm42600_gyro.c | 16 ++------ .../iio/imu/inv_icm42600/inv_icm42600_temp.c | 10 ++++- 6 files changed, 26 insertions(+), 73 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
The temperature sensor only measures while the accel or gyro is on. With both off, its data register keeps the last measurement, so a temperature read returns stale data. On an ICM-42688-P, a value held at about 52 C was returned while the chip was at about 62 C. The data only reads as invalid before the first measurement after power-up.
The temperature is the die temperature, used for accel and gyro compensation, so return -EBUSY when both are off instead of stale data.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +10 -0
@@ -23,6 +23,16 @@ static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp)pm_runtime_get_sync (dev);mutex_lock (&st->lock); +/* +* The temperature sensor only measures while the accel or gyro is +* on; with both off, its data register holds a stale value. +*/ +if (st->conf.gyro.mode ==INV_ICM42600_SENSOR_MODE_OFF && + st->conf.accel.mode ==INV_ICM42600_SENSOR_MODE_OFF ) { + ret = -EBUSY ; + goto exit; + } + ret =inv_icm42600_set_temp_conf (st, true,NULL );if (ret) goto exit;
Signature · 1 line
2.34.1
Re: [PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
Quoted 8 lines · Joe LeVeque
The temperature sensor only measures while the accel or gyro is on. With both off, its data register keeps the last measurement, so a temperature read returns stale data. On an ICM-42688-P, a value held at about 52 C was returned while the chip was at about 62 C. The data only reads as invalid before the first measurement after power-up.
The temperature is the die temperature, used for accel and gyro compensation, so return
-EBUSYwhen both are off instead of stale data.
Hmm... EBUSY means they are doing something and kinda hints user to come again. Would this condition change on its own if user comes again later with the same request?
...
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) · line 34
Quoted 9 lines
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +9
-0+/* +* The temperature sensor only measures while the accel or gyro is +* on; with both off, its data register holds a stale value. +*/ +if (st->conf.gyro.mode ==INV_ICM42600_SENSOR_MODE_OFF && + st->conf.accel.mode ==INV_ICM42600_SENSOR_MODE_OFF ) { + ret = -EBUSY ; + goto exit; + }
I would choose one from the below (they all have their pros and cons)
ESTALE
something like this, but error message is specific about file handle
EL3HLT
what is level 3? But we have the only user, and it is outside network and it sounds close to this case, but why not EL2HLT? (Also the users are outside network.)
ENODATA
also used a lot, so semantics not so clear, and data is there, but outdated
Depending on the answer to the question at the top of my reply, the error codes may be EIO, ENXIO, EPROTO, EAGAIN (but if EAGAIN fits to the flow, EBUSY also fits).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
Hi Andy,
The -EBUSY here is consistent with the existing invalid-data case in inv_icm42600_temp_read(), which commit dfdc31e7ccf3 (“iio: imu:inv_icm42600: change invalid data error to -EBUSY”) changed from -EINVAL to -EBUSY for the same situation (both accel and gyro off). Patch 1 returns the same error for the stale-data case, so userspace sees one consistent response.
https://git.kernel.org/torvalds/c/dfdc31e7ccf3
Thanks,
Joe
Quoted 49 lines · Andy Shevchenko
Quoted 8 lines · Joe LeVeque
The temperature sensor only measures while the accel or gyro is on. With both off, its data register keeps the last measurement, so a temperature read returns stale data. On an ICM-42688-P, a value held at about 52 C was returned while the chip was at about 62 C. The data only reads as invalid before the first measurement after power-up.
The temperature is the die temperature, used for accel and gyro compensation, so return
-EBUSYwhen both are off instead of stale data.Hmm... EBUSY means they are doing something and kinda hints user to come again. Would this condition change on its own if user comes again later with the same request?
...
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) · line 34
Quoted 9 lines
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +9
-0+/* +* The temperature sensor only measures while the accel or gyro is +* on; with both off, its data register holds a stale value. +*/ +if (st->conf.gyro.mode ==INV_ICM42600_SENSOR_MODE_OFF && + st->conf.accel.mode ==INV_ICM42600_SENSOR_MODE_OFF ) { + ret = -EBUSY ; + goto exit; + }I would choose one from the below (they all have their pros and cons)
ESTALE
something like this, but error message is specific about file handleEL3HLT
what is level 3? But we have the only user, and it is outside network and it sounds close to this case, but why not EL2HLT? (Also the users are outside network.)ENODATA
also used a lot, so semantics not so clear, and data is there, but outdatedDepending on the answer to the question at the top of my reply, the error codes may be EIO, ENXIO, EPROTO, EAGAIN (but if EAGAIN fits to the flow, EBUSY also fits).
--
With Best Regards,
Andy Shevchenko
Re: [PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
Quoted 10 lines · Joe LeVeque
Hi Andy,
The
-EBUSYhere is consistent with the existing invalid-data case ininv_icm42600_temp_read(), which commitdfdc31e7ccf3(“iio: imu:inv_icm42600: change invalid data error to -EBUSY”) changed from-EINVALto-EBUSYfor the same situation (both accel and gyro off). Patch 1 returns the same error for the stale-data case, so userspace sees one consistent response.
I see, but even if it's used otherwise, perhaps we need to consider to replace in both places (or rather replace existing one first).
What about using ESTALE?
Quoted 15 lines
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Joe LeVeque
The temperature sensor only measures while the accel or gyro is on. With both off, its data register keeps the last measurement, so a temperature read returns stale data. On an ICM-42688-P, a value held at about 52 C was returned while the chip was at about 62 C. The data only reads as invalid before the first measurement after power-up.
The temperature is the die temperature, used for accel and gyro compensation, so return
-EBUSYwhen both are off instead of stale data.Hmm... EBUSY means they are doing something and kinda hints user to come again. Would this condition change on its own if user comes again later with the same request?
...
Quoted 26 lines
Quoted 26 lines
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) · line 34
Quoted 9 lines
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +9
-0+/* +* The temperature sensor only measures while the accel or gyro is +* on; with both off, its data register holds a stale value. +*/ +if (st->conf.gyro.mode ==INV_ICM42600_SENSOR_MODE_OFF && + st->conf.accel.mode ==INV_ICM42600_SENSOR_MODE_OFF ) { + ret = -EBUSY ; + goto exit; + }I would choose one from the below (they all have their pros and cons)
ESTALE
something like this, but error message is specific about file handleEL3HLT
what is level 3? But we have the only user, and it is outside network and it sounds close to this case, but why not EL2HLT? (Also the users are outside network.)ENODATA
also used a lot, so semantics not so clear, and data is there, but outdatedDepending on the answer to the question at the top of my reply, the error codes may be EIO, ENXIO, EPROTO, EAGAIN (but if EAGAIN fits to the flow, EBUSY also fits).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
Quoted 10 lines · On Sat, 21 Nov 2026 16:58:23 +0200 Andy Shevchenko…
Quoted 9 lines · Joe LeVeque
Hi Andy,
The
-EBUSYhere is consistent with the existing invalid-data case ininv_icm42600_temp_read(), which commitdfdc31e7ccf3(“iio: imu:inv_icm42600: change invalid data error to -EBUSY”) changed from-EINVALto-EBUSYfor the same situation (both accel and gyro off). Patch 1 returns the same error for the stale-data case, so userspace sees one consistent response.
Quoted 22 lines
Quoted 1 line
I see, but even if it's used otherwise, perhaps we need to consider to replace in both places (or rather replace existing one first).
What about using ESTALE?
Quoted 15 lines
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Joe LeVeque
The temperature sensor only measures while the accel or gyro is on. With both off, its data register keeps the last measurement, so a temperature read returns stale data. On an ICM-42688-P, a value held at about 52 C was returned while the chip was at about 62 C. The data only reads as invalid before the first measurement after power-up.
The temperature is the die temperature, used for accel and gyro compensation, so return
-EBUSYwhen both are off instead of stale data.Hmm... EBUSY means they are doing something and kinda hints user to come again. Would this condition change on its own if user comes again later with the same request?
We use EBUSY for failure to claim direct mode as well.
In that case it doesn't clear on it's own as typically requires some state changes such as disabling the buffers.
So I think this is at least consistent with the subsystem.
However, we might have drivers that use this for things that should actually be retried, though in those cases I think EAGAIN is more appropriate.
This type of condition is tricky to describe well. Whenever I've though hard about this I've ended up with EBUSY even when user interaction is needed to clear the busy.
Jonathan
Quoted 30 lines
...
Quoted 26 lines
Quoted 26 lines
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) · line 34
Quoted 9 lines
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +9
-0+/* +* The temperature sensor only measures while the accel or gyro is +* on; with both off, its data register holds a stale value. +*/ +if (st->conf.gyro.mode ==INV_ICM42600_SENSOR_MODE_OFF && + st->conf.accel.mode ==INV_ICM42600_SENSOR_MODE_OFF ) { + ret = -EBUSY ; + goto exit; + }I would choose one from the below (they all have their pros and cons)
ESTALE
something like this, but error message is specific about file handleEL3HLT
what is level 3? But we have the only user, and it is outside network and it sounds close to this case, but why not EL2HLT? (Also the users are outside network.)ENODATA
also used a lot, so semantics not so clear, and data is there, but outdatedDepending on the answer to the question at the top of my reply, the error codes may be EIO, ENXIO, EPROTO, EAGAIN (but if EAGAIN fits to the flow, EBUSY also fits).
PATCH 2/2 iio: imu: inv_icm42600: remove temperature sensor enable/disable
In reply to Joe LeVequeThe driver turns the temperature sensor off (PWR_MGMT0.TEMP_DIS) whenever nothing has requested temperature data. With the temperature sensor disabled, gyro data is not temperature compensated internally. On an ICM-42688-P this shows up as a large, stable gyro offset at rest: about -139, 379 and -229 LSB at +-2000 dps (8 to 23 dps), instead of under 0.5 dps once the temperature sensor is enabled by a temperature read or a buffer with the temperature channel.
There is no benefit in disabling the temperature sensor, so remove the enable/disable handling and keep it always on: drop temp_en from the sensor configuration and the suspend state, the temp argument and TEMP_DIS handling from inv_icm42600_set_pwr_mgmt0(), the temperature startup delay, and inv_icm42600_set_temp_conf() with its callers. The temperature sensor now starts with the gyro or accel, whose startup delays are longer.
Temperature reporting in the FIFO is still enabled and disabled with the buffer's temperature channel.
--- drivers/iio/imu/inv_icm42600/inv_icm42600.h | 6 --- .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 16 ++------ .../imu/inv_icm42600/inv_icm42600_buffer.c | 14 ++----- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 37 ++++--------------- .../iio/imu/inv_icm42600/inv_icm42600_gyro.c | 16 ++------ .../iio/imu/inv_icm42600/inv_icm42600_temp.c | 4 -- 6 files changed, 18 insertions(+), 75 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600.h +0 -6
@@ -128,13 +128,11 @@ struct inv_icm42600_sensor_conf {struct inv_icm42600_conf {struct inv_icm42600_sensor_conf gyro;struct inv_icm42600_sensor_conf accel; -bool temp_en; };struct inv_icm42600_suspended {enum inv_icm42600_sensor_mode gyro;enum inv_icm42600_sensor_mode accel; -bool temp; };struct inv_icm42600_apex {
@@ -441,7 +439,6 @@ struct inv_icm42600_sensor_state {#define INV_ICM42600_ACCEL_STARTUP_TIME_MS 20#define INV_ICM42600_GYRO_STARTUP_TIME_MS 60#define INV_ICM42600_GYRO_STOP_TIME_MS 150 -#define INV_ICM42600_TEMP_STARTUP_TIME_MS 14#define INV_ICM42600_SUSPEND_DELAY_MS 2000typedef int (*inv_icm42600_bus_setup )(struct inv_icm42600_state *);
@@ -464,9 +461,6 @@ int inv_icm42600_set_gyro_conf(struct inv_icm42600_state *st,struct inv_icm42600_sensor_conf *conf, unsigned int *sleep_ms); -int inv_icm42600_set_temp_conf (struct inv_icm42600_state *st,bool enable, -unsigned int *sleep_ms); -int inv_icm42600_enable_wom (struct inv_icm42600_state *st);int inv_icm42600_disable_wom (struct inv_icm42600_state *st);
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +4 -12
@@ -229,37 +229,29 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,struct inv_icm42600_sensor_state *accel_st =iio_priv (indio_dev);struct inv_icm42600_sensor_conf conf =INV_ICM42600_SENSOR_CONF_INIT ;unsigned int fifo_en =0 ; -unsigned int sleep_temp =0 ; -unsigned int sleep_accel =0 ; -unsigned int sleep; +unsigned int sleep =0 ;int ret;mutex_lock (&st->lock); -if (*scan_mask &INV_ICM42600_SCAN_MASK_TEMP ) { -/* enable temp sensor */ - ret =inv_icm42600_set_temp_conf (st, true, &sleep_temp); -if (ret) - goto out_unlock; +if (*scan_mask &INV_ICM42600_SCAN_MASK_TEMP ) fifo_en |=INV_ICM42600_SENSOR_TEMP ; - }if (*scan_mask &INV_ICM42600_SCAN_MASK_ACCEL_3AXIS ) {/* enable accel sensor */ conf.mode = accel_st->power_mode; conf.filter = accel_st->filter; - ret =inv_icm42600_set_accel_conf (st, &conf, &sleep_accel); + ret =inv_icm42600_set_accel_conf (st, &conf, &sleep);if (ret) goto out_unlock; fifo_en |=INV_ICM42600_SENSOR_ACCEL ; }/* -* Sleep maximum stabilization time before enabling data in FIFO. +* Sleep stabilization time before enabling data in FIFO. * We need to release the driver lock to not block gyro data processing. * There is no possible race here since we are under IIO mutex locked. */ - sleep =max (sleep_accel, sleep_temp);if (sleep) {mutex_unlock (&st->lock);msleep (sleep);
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +3 -11
@@ -366,9 +366,7 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)unsigned int sensor;unsigned int *watermark;struct inv_icm42600_sensor_conf conf =INV_ICM42600_SENSOR_CONF_INIT ; -unsigned int sleep_temp =0 ; -unsigned int sleep_sensor =0 ; -unsigned int sleep; +unsigned int sleep =0 ;int ret;if (indio_dev == st->indio_gyro) {
@@ -398,21 +396,15 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev) conf.mode =INV_ICM42600_SENSOR_MODE_OFF ;if (sensor ==INV_ICM42600_SENSOR_GYRO ) - ret =inv_icm42600_set_gyro_conf (st, &conf, &sleep_sensor); + ret =inv_icm42600_set_gyro_conf (st, &conf, &sleep);else if (!st->apex.on) - ret =inv_icm42600_set_accel_conf (st, &conf, &sleep_sensor); + ret =inv_icm42600_set_accel_conf (st, &conf, &sleep);if (ret) goto out_unlock; -/* if FIFO is off, turn temperature off */ -if (!st->fifo.on) - ret =inv_icm42600_set_temp_conf (st, false, &sleep_temp); - out_unlock:mutex_unlock (&st->lock); -/* sleep maximum required time */ - sleep =max (sleep_sensor, sleep_temp);if (sleep)msleep (sleep);
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +7 -30
@@ -123,7 +123,6 @@ static const struct inv_icm42600_conf inv_icm42600_default_conf = { .odr = INV_ICM42600_ODR_50HZ, .filter = INV_ICM42600_FILTER_BW_ODR_DIV_2, }, - .temp_en = false, }; static const struct inv_icm42600_conf inv_icm42686_default_conf = {
@@ -139,7 +138,6 @@ static const struct inv_icm42600_conf inv_icm42686_default_conf = { .odr = INV_ICM42600_ODR_50HZ, .filter = INV_ICM42600_FILTER_BW_ODR_DIV_2, }, - .temp_en = false, }; static const struct inv_icm42600_hw inv_icm42600_hw[INV_CHIP_NB] = {
@@ -228,38 +226,29 @@ u32 inv_icm42600_odr_to_period(enum inv_icm42600_odr odr)static int inv_icm42600_set_pwr_mgmt0 (struct inv_icm42600_state *st,enum inv_icm42600_sensor_mode gyro,enum inv_icm42600_sensor_mode accel, -bool temp,unsigned int *sleep_ms) +unsigned int *sleep_ms) {enum inv_icm42600_sensor_mode oldgyro = st->conf.gyro.mode;enum inv_icm42600_sensor_mode oldaccel = st->conf.accel.mode; -bool oldtemp = st->conf.temp_en;unsigned int sleepval;unsigned int val;int ret;/* if nothing changed, exit */ -if (gyro == oldgyro && accel == oldaccel && temp == oldtemp) +if (gyro == oldgyro && accel == oldaccel)return 0 ; val =INV_ICM42600_PWR_MGMT0_GYRO (gyro) |INV_ICM42600_PWR_MGMT0_ACCEL (accel); -if (!temp) - val |=INV_ICM42600_PWR_MGMT0_TEMP_DIS ; ret =regmap_write (st->map,INV_ICM42600_REG_PWR_MGMT0 , val);if (ret)return ret; st->conf.gyro.mode = gyro; st->conf.accel.mode = accel; - st->conf.temp_en = temp;/* compute required wait time for sensors to stabilize */ sleepval =0 ; -/* temperature stabilization time */ -if (temp && !oldtemp) { -if (sleepval <INV_ICM42600_TEMP_STARTUP_TIME_MS ) - sleepval =INV_ICM42600_TEMP_STARTUP_TIME_MS ; - }/* accel startup time */ if (accel != oldaccel && oldaccel ==INV_ICM42600_SENSOR_MODE_OFF ) {/* block any register write for at least 200 µs */
@@ -357,7 +346,7 @@ int inv_icm42600_set_accel_conf(struct inv_icm42600_state *st,/* set PWR_MGMT0 register (accel sensor mode) */ return inv_icm42600_set_pwr_mgmt0 (st, st->conf.gyro.mode, conf->mode, - st->conf.temp_en, sleep_ms); + sleep_ms); } int inv_icm42600_set_gyro_conf(struct inv_icm42600_state *st,
@@ -401,19 +390,11 @@ int inv_icm42600_set_gyro_conf(struct inv_icm42600_state *st,/* set PWR_MGMT0 register (gyro sensor mode) */ return inv_icm42600_set_pwr_mgmt0 (st, conf->mode, st->conf.accel.mode, - st->conf.temp_en, sleep_ms); + sleep_ms);return 0 ; } -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); -} -int inv_icm42600_enable_wom (struct inv_icm42600_state *st) {int ret;
@@ -467,8 +448,6 @@ static int inv_icm42600_set_conf(struct inv_icm42600_state *st,/* set PWR_MGMT0 register (gyro & accel sensor mode, temp enabled) */ val =INV_ICM42600_PWR_MGMT0_GYRO (conf->gyro.mode) |INV_ICM42600_PWR_MGMT0_ACCEL (conf->accel.mode); -if (!conf->temp_en) - val |=INV_ICM42600_PWR_MGMT0_TEMP_DIS ; ret =regmap_write (st->map,INV_ICM42600_REG_PWR_MGMT0 , val);if (ret)return ret;
@@ -841,7 +820,6 @@ static int inv_icm42600_suspend(struct device *dev) st->suspended.gyro = st->conf.gyro.mode; st->suspended.accel = st->conf.accel.mode; - st->suspended.temp = st->conf.temp_en;if (pm_runtime_suspended (dev))return 0 ;
@@ -872,7 +850,7 @@ static int inv_icm42600_suspend(struct device *dev) } ret =inv_icm42600_set_pwr_mgmt0 (st,INV_ICM42600_SENSOR_MODE_OFF , - accel_conf, false,NULL ); + accel_conf,NULL );if (ret)return ret;
@@ -917,7 +895,7 @@ static int inv_icm42600_resume(struct device *dev)/* restore sensors state */ ret =inv_icm42600_set_pwr_mgmt0 (st, st->suspended.gyro, st->suspended.accel, - st->suspended.temp,NULL ); +NULL );if (ret)return ret;
@@ -949,8 +927,7 @@ static int inv_icm42600_runtime_suspend(struct device *dev)/* disable all sensors */ ret =inv_icm42600_set_pwr_mgmt0 (st,INV_ICM42600_SENSOR_MODE_OFF , -INV_ICM42600_SENSOR_MODE_OFF , false, -NULL ); +INV_ICM42600_SENSOR_MODE_OFF ,NULL );if (ret)return ret;
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +4 -12
@@ -102,36 +102,28 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,struct inv_icm42600_state *st =iio_device_get_drvdata (indio_dev);struct inv_icm42600_sensor_conf conf =INV_ICM42600_SENSOR_CONF_INIT ;unsigned int fifo_en =0 ; -unsigned int sleep_gyro =0 ; -unsigned int sleep_temp =0 ; -unsigned int sleep; +unsigned int sleep =0 ;int ret;mutex_lock (&st->lock); -if (*scan_mask &INV_ICM42600_SCAN_MASK_TEMP ) { -/* enable temp sensor */ - ret =inv_icm42600_set_temp_conf (st, true, &sleep_temp); -if (ret) - goto out_unlock; +if (*scan_mask &INV_ICM42600_SCAN_MASK_TEMP ) fifo_en |=INV_ICM42600_SENSOR_TEMP ; - }if (*scan_mask &INV_ICM42600_SCAN_MASK_GYRO_3AXIS ) {/* enable gyro sensor */ conf.mode =INV_ICM42600_SENSOR_MODE_LOW_NOISE ; - ret =inv_icm42600_set_gyro_conf (st, &conf, &sleep_gyro); + ret =inv_icm42600_set_gyro_conf (st, &conf, &sleep);if (ret) goto out_unlock; fifo_en |=INV_ICM42600_SENSOR_GYRO ; }/* -* Sleep maximum stabilization time before enabling data in FIFO. +* Sleep stabilization time before enabling data in FIFO. * We need to release the driver lock to not block accel data processing. * There is no possible race here since we are under IIO mutex locked. */ - sleep =max (sleep_gyro, sleep_temp);if (sleep) {mutex_unlock (&st->lock);msleep (sleep);
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +0 -4
@@ -33,10 +33,6 @@ static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) goto exit; } - ret =inv_icm42600_set_temp_conf (st, true,NULL ); -if (ret) - goto exit; - raw = (__be16 *)&st->buffer[0 ]; ret =regmap_bulk_read (st->map,INV_ICM42600_REG_TEMP_DATA , raw,sizeof (*raw));if (ret)
Signature · 1 line
2.34.1