mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Sean Nyekjaer <sean@geanix.com>
Cc: "Jean-Baptiste Maneyrol" <jean-baptiste.maneyrol@tdk.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: imu: inv_icm42600: fix temperature reading if accel/gyro is off
Date: Sun, 13 Jul 2025 14:47:47 +0100	[thread overview]
Message-ID: <20250713144747.667aac5f@jic23-huawei> (raw)
In-Reply-To: <20250708-icm42temp-v1-1-81af60aab82a@geanix.com>

On Tue, 08 Jul 2025 14:09:17 +0200
Sean Nyekjaer <sean@geanix.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@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,


      parent reply	other threads:[~2025-07-13 13:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08 12:09 Sean Nyekjaer
2025-07-08 13:14 ` Andy Shevchenko
2025-07-13 13:47 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250713144747.667aac5f@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=sean@geanix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®