[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250713144747.667aac5f@jic23-huawei>
Date: Sun, 13 Jul 2025 14:47:47 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Sean Nyekjaer <sean@...nix.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@....com>, David Lechner
<dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, Andy
Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: imu: inv_icm42600: fix temperature reading if
accel/gyro is off
On Tue, 08 Jul 2025 14:09:17 +0200
Sean Nyekjaer <sean@...nix.com> wrote:
> 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.
I'm not sure we are going ahead with this anyway given the other thread,
but if we did, then relying on runtime_put() in read of a different
channel seems like a bad design. If we think someone is interested
in reading the temperature of this sensor, are they guaranteed to
also be reading the acceleration?
>
> Signed-off-by: Sean Nyekjaer <sean@...nix.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,
Powered by blists - more mailing lists