Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kanak Shilledar" <kanak.shilledar@axis.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 3/6] iio: imu: inv_icm42607: Initialize gyro based on chip_info
Date: Fri, 09 Oct 2026 14:24:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-165704@kernel.org> (raw)
In-Reply-To: <20261009-b4-inv_icm42370p-v6-3-e53884f185ff@axis.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] iio: imu: inv_icm42607: missing get_pwr_mgmt0() abstraction in temp_read()
--

commit 5fda28961eccacb1192dc6807416c716d0058712
Author: Kanak Shilledar <kanak.shilledar@axis.com>

iio: imu: inv_icm42607: Initialize gyro based on chip_info

This commit updates the chip_info struct with a has_gyro property to
support devices without gyroscope functionality, specifically as a
precursor for the Invensense ICM-42370-P. It updates various operations
to check this boolean before configuring or accessing gyroscope features.

> diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> index 190e998f7b8ef..46274ecfa7b94 100644
> --- a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
[ ... ]
> @@ -160,7 +162,11 @@ int inv_icm42607_get_pwr_mgmt0(struct inv_icm42607_state *st,
>  	if (ret)
>  		return ret;
>  
> -	*gyro = FIELD_GET(INV_ICM42607_PWR_MGMT0_GYRO_MODE_MASK, val);
> +	if (st->hw->has_gyro)
> +		*gyro = FIELD_GET(INV_ICM42607_PWR_MGMT0_GYRO_MODE_MASK, val);
> +	else
> +		*gyro = INV_ICM42607_SENSOR_MODE_OFF;
> +
>  	*accel = FIELD_GET(INV_ICM42607_PWR_MGMT0_ACCEL_MODE_MASK, val);
>  
>  	return 0;

[Severity: Medium]
Does inv_icm42607_temp_read() also need to use this updated wrapper instead
of directly reading the register?

Currently, inv_icm42607_temp_read() in
drivers/iio/imu/inv_icm42607/inv_icm42607_temp.c bypasses
inv_icm42607_get_pwr_mgmt0() and directly reads the register:

    ret = regmap_read(st->map, INV_ICM42607_REG_PWR_MGMT0, &val);
    if (ret)
        return ret;

    accel_mode = FIELD_GET(INV_ICM42607_PWR_MGMT0_ACCEL_MODE_MASK, val);
    gyro_mode = FIELD_GET(INV_ICM42607_PWR_MGMT0_GYRO_MODE_MASK, val);
    if (!gyro_mode && !accel_mode) {
        /* enable accel sensor */
        ...
    }

If the reserved gyroscope bits on the new accel-only hardware (ICM-42370-P)
return non-zero values, the condition !gyro_mode && !accel_mode will
incorrectly evaluate to false.

This would cause the driver to skip enabling the accelerometer when reading
the temperature, which could lead to invalid reads or timeouts from
powered-off sensors on gyro-less devices.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009-b4-inv_icm42370p-v6-0-e53884f185ff@axis.com?part=3

  reply	other threads:[~2026-10-09 14:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 14:12 [PATCH v6 0/6] Add support for InvenSense ICM-42370-P accelerometer Kanak Shilledar
2026-10-09 14:12 ` [PATCH v6 1/6] dt-bindings: iio: imu: icm42600: Add ICM-42670-P Kanak Shilledar
2026-10-09 14:12 ` [PATCH v6 2/6] iio: imu: inv_icm42607: Simplify IIO channel macros Kanak Shilledar
2026-10-09 14:12 ` [PATCH v6 3/6] iio: imu: inv_icm42607: Initialize gyro based on chip_info Kanak Shilledar
2026-10-09 14:24   ` sashiko-bot [this message]
2026-10-09 14:12 ` [PATCH v6 4/6] iio: imu: inv_icm42607: Add support for ICM-42370-P Kanak Shilledar
2026-10-09 14:12 ` [PATCH v6 5/6] iio: imu: inv_icm42607: Implement MREGx register access Kanak Shilledar
2026-10-09 14:24   ` sashiko-bot
2026-10-09 14:12 ` [PATCH v6 6/6] iio: imu: inv_icm42607: Add accelerometer calibbias support Kanak Shilledar

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=sashiko-outbox-165704@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kanak.shilledar@axis.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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