From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Joe LeVeque <joe.l@reflexrobotics.com>,
jean-baptiste.maneyrol@tdk.com, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle
Date: Sat, 21 Nov 2026 22:12:49 +0000 [thread overview]
Message-ID: <20261121221249.7eec65d6@jic23-hlaptop> (raw)
In-Reply-To: <awGxj7xP6oTlkUt0@ashevche-desk.local>
On Sat, 21 Nov 2026 16:58:23 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Nov 20, 2026 at 10:32:52AM -0800, Joe LeVeque wrote:
> > 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
>
> 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?
>
> > On Fri, Nov 20, 2026 at 1:33 AM Andy Shevchenko
> > <andriy.shevchenko@intel.com> wrote:
> > > On Thu, Nov 19, 2026 at 06:08:49PM -0800, Joe LeVeque wrote:
> > > > 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.
> > >
> > > 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
>
> ...
>
> > > > + /*
> > > > + * 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).
>
next prev parent reply other threads:[~2026-11-21 22:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 2:08 [PATCH 0/2] iio: imu: inv_icm42600: keep the temperature sensor always on Joe LeVeque
2026-11-20 2:08 ` [PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle Joe LeVeque
2026-11-20 9:33 ` Andy Shevchenko
2026-11-20 18:32 ` Joe LeVeque
2026-11-21 14:58 ` Andy Shevchenko
2026-11-21 22:12 ` Jonathan Cameron [this message]
2026-11-20 2:08 ` [PATCH 2/2] iio: imu: inv_icm42600: remove temperature sensor enable/disable Joe LeVeque
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=20261121221249.7eec65d6@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=joe.l@reflexrobotics.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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®