mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Kanak Shilledar <kanak.shilledar@axis.com>
Cc: "Henrik Grimler" <henrik.grimler@axis.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Jean-Baptiste Maneyrol" <jean-baptiste.maneyrol@tdk.com>,
	"Joshua Crofts" <joshua.crofts1@gmail.com>,
	"Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
	"Chris Morgan" <macromorgan@hotmail.com>,
	kernel@axis.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski@oss.qualcomm.com>
Subject: Re: [PATCH v7 4/7] iio: imu: inv_icm42607: Initialize gyro based on chip_info
Date: Mon, 26 Oct 2026 15:07:14 +0200	[thread overview]
Message-ID: <at9Qggd3hyGD1Hp6@ashevche-desk.local> (raw)
In-Reply-To: <20261026-b4-inv_icm42370p-v7-4-222e296ac1e0@axis.com>

On Mon, Oct 26, 2026 at 12:02:52PM +0100, Kanak Shilledar wrote:
> Update the chip_info struct with a new `has_gyro` property to support,
> devices which do not have gyro functionality. This is a precursor for
> adding support for the Invensense, ICM-42370-P. It is similar to the
> existing device except it only has accelerometer. Check all operations
> related to gyro with the boolean. Replace all the implicit comparision
> checks with explicit to make it easier to follow the code flow.

...

>  	odr_us = 0;
> -	if (accel && !oldaccel) {
> +	if (accel != INV_ICM42607_SENSOR_MODE_OFF &&
> +		oldaccel == INV_ICM42607_SENSOR_MODE_OFF) {

Broken indentation.

>  		sleepval_us = max(sleepval_us, INV_ICM42607_ACCEL_STARTUP_TIME_US);
>  		odr_us = max(odr_us, inv_icm42607_odr_to_period_us(st->conf.accel.odr));
>  	}

> -	if (gyro && !oldgyro) {
> +	if (gyro != INV_ICM42607_SENSOR_MODE_OFF &&
> +		oldgyro == INV_ICM42607_SENSOR_MODE_OFF) {

Ditto.

>  		sleepval_us = max(sleepval_us, INV_ICM42607_GYRO_STARTUP_TIME_US);
>  		odr_us = max(odr_us, inv_icm42607_odr_to_period_us(st->conf.gyro.odr));
>  		/* Track the earliest we can turn off the gyroscope. */

...

> +	if (st->hw->has_gyro)
> +		val = FIELD_PREP(INV_ICM42607_PWR_MGMT0_ACCEL_MODE_MASK, conf->accel.mode) |
> +		      FIELD_PREP(INV_ICM42607_PWR_MGMT0_GYRO_MODE_MASK, conf->gyro.mode);

Swap them to make lines shorter

		val = FIELD_PREP(INV_ICM42607_PWR_MGMT0_GYRO_MODE_MASK, conf->gyro.mode) |
		      FIELD_PREP(INV_ICM42607_PWR_MGMT0_ACCEL_MODE_MASK, conf->accel.mode);

> +	else
> +		val = FIELD_PREP(INV_ICM42607_PWR_MGMT0_ACCEL_MODE_MASK, conf->accel.mode);
> +
>  	ret = regmap_write(st->map, INV_ICM42607_REG_PWR_MGMT0, val);
>  	if (ret)
>  		return ret;

...

> +	if (st->hw->has_gyro) {
> +		val = FIELD_PREP(INV_ICM42607_GYRO_CONFIG0_FS_SEL_MASK, conf->gyro.fs) |
> +		      FIELD_PREP(INV_ICM42607_GYRO_CONFIG0_ODR_MASK, conf->gyro.odr);
> +		ret = regmap_write(st->map, INV_ICM42607_REG_GYRO_CONFIG0, val);
> +		if (ret)
> +			return ret;
> +	}

Use same trick.

...

> +	val = FIELD_PREP(INV_ICM42607_ACCEL_CONFIG0_FS_SEL_MASK, conf->accel.fs) |
> +	      FIELD_PREP(INV_ICM42607_ACCEL_CONFIG0_ODR_MASK, conf->accel.odr);

Ditto.

...

> -	ret = inv_icm42607_set_pwr_mgmt0(st, st->conf.gyro.mode,
> +	ret = inv_icm42607_set_sensor_modes(st, st->conf.gyro.mode,
>  					 st->conf.accel.mode);

Broken indentation.

>  	if (ret)
>  		dev_err(dev, "Unable to turn off sensors\n");

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-10-26 13:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 11:02 [PATCH v7 0/7] Add support for InvenSense ICM-42370-P accelerometer Kanak Shilledar
2026-10-26 11:02 ` [PATCH v7 1/7] dt-bindings: iio: imu: icm42600: Drop interrupt requirement Kanak Shilledar
2026-10-26 11:02 ` [PATCH v7 2/7] dt-bindings: iio: imu: icm42600: Add ICM-42670-P Kanak Shilledar
2026-10-26 11:02 ` [PATCH v7 3/7] iio: imu: inv_icm42607: Simplify IIO channel macros Kanak Shilledar
2026-10-26 11:02 ` [PATCH v7 4/7] iio: imu: inv_icm42607: Initialize gyro based on chip_info Kanak Shilledar
2026-10-26 13:07   ` Andy Shevchenko [this message]
2026-10-26 11:02 ` [PATCH v7 5/7] iio: imu: inv_icm42607: Add support for ICM-42370-P Kanak Shilledar
2026-10-26 11:02 ` [PATCH v7 6/7] iio: imu: inv_icm42607: Implement MREGx register access Kanak Shilledar
2026-10-26 11:02 ` [PATCH v7 7/7] 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=at9Qggd3hyGD1Hp6@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=henrik.grimler@axis.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jic23@kernel.org \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=kanak.shilledar@axis.com \
    --cc=kernel@axis.com \
    --cc=krzk+dt@kernel.org \
    --cc=krzysztof.kozlowski@oss.qualcomm.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macromorgan@hotmail.com \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /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®