All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Chris Morgan <macroalpha82@gmail.com>
Cc: linux-iio@vger.kernel.org, andy@kernel.org, nuno.sa@analog.com,
	dlechner@baylibre.com, jean-baptiste.maneyrol@tdk.com,
	linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
	heiko@sntech.de, conor+dt@kernel.org, krzk+dt@kernel.org,
	robh@kernel.org, andriy.shevchenko@intel.com,
	Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [PATCH V15 7/9] iio: imu: inv_icm42607: Add Gyroscope to icm42607
Date: Wed, 1 Jul 2026 20:28:15 +0100	[thread overview]
Message-ID: <20260701202815.7d930b56@jic23-huawei> (raw)
In-Reply-To: <20260626161230.93069-8-macroalpha82@gmail.com>

On Fri, 26 Jun 2026 11:12:28 -0500
Chris Morgan <macroalpha82@gmail.com> wrote:

> From: Chris Morgan <macromorgan@hotmail.com>
> 
> Add gyroscope functions to the icm42607 driver.
> 
> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Similar comments to those in the accel driver.

Thanks,

Jonathan

> diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_gyro.c b/drivers/iio/imu/inv_icm42607/inv_icm42607_gyro.c
> new file mode 100644
> index 000000000000..c7215b3826ad
> --- /dev/null
> +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_gyro.c

> +static int inv_icm42607_gyro_read_odr(struct inv_icm42607_state *st,
> +				      int *val, int *val2)
> +{
> +	unsigned int odr;
> +	unsigned int i;
> +
> +	guard(mutex)(&st->lock);
> +
> +	odr = st->conf.gyro.odr;
> +
> +	for (i = 5; i < ARRAY_SIZE(inv_icm42607_gyro_odr); ++i) {
> +		if (i == odr)

As below.

> +
> +static int inv_icm42607_gyro_write_odr(struct iio_dev *indio_dev,
> +				       int val, int val2)
> +{
> +	struct inv_icm42607_state *st = iio_device_get_drvdata(indio_dev);
> +	struct device *dev = regmap_get_device(st->map);
> +	unsigned int idx;
> +	struct inv_icm42607_sensor_conf conf = INV_ICM42607_SENSOR_CONF_INIT;
> +	int ret;
> +
> +	for (idx = 5; idx < ARRAY_SIZE(inv_icm42607_gyro_odr); ++idx) {

Similar comments to accel. Use the appropriate define for that 5 and
post increment.

> +		if (val == inv_icm42607_gyro_odr[idx][0] &&
> +		    val2 == inv_icm42607_gyro_odr[idx][1])
> +			break;
> +	}

> +static int inv_icm42607_gyro_read_avail(struct iio_dev *indio_dev,
> +					struct iio_chan_spec const *chan,
> +					const int **vals,
> +					int *type, int *length, long mask)
> +{
> +	if (chan->type != IIO_ANGL_VEL)

This was the one sashiko noted was less than ideal as it rules out
reading this for temperature channels - in practice that doesn't happen
but that is due to an internal detail of how we create shared_by_all
attributes. The code should support reading for temperature channels as well.

> +		return -EINVAL;
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_SCALE:
> +		*vals = (const int *)inv_icm42607_gyro_scale_nano;
> +		*type = IIO_VAL_INT_PLUS_NANO;
> +		*length = ARRAY_SIZE(inv_icm42607_gyro_scale_nano) * 2;
> +		return IIO_AVAIL_LIST;
> +	case IIO_CHAN_INFO_SAMP_FREQ:
> +		*vals = (const int *)inv_icm42607_gyro_odr[5];
> +		*type = IIO_VAL_INT_PLUS_MICRO;
> +		*length = (ARRAY_SIZE(inv_icm42607_gyro_odr) - 5) * 2;
> +		return IIO_AVAIL_LIST;
> +	default:
> +		return -EINVAL;
> +	}
> +}



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: Chris Morgan <macroalpha82@gmail.com>
Cc: linux-iio@vger.kernel.org, andy@kernel.org, nuno.sa@analog.com,
	dlechner@baylibre.com, jean-baptiste.maneyrol@tdk.com,
	linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
	heiko@sntech.de, conor+dt@kernel.org, krzk+dt@kernel.org,
	robh@kernel.org, andriy.shevchenko@intel.com,
	Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [PATCH V15 7/9] iio: imu: inv_icm42607: Add Gyroscope to icm42607
Date: Wed, 1 Jul 2026 20:28:15 +0100	[thread overview]
Message-ID: <20260701202815.7d930b56@jic23-huawei> (raw)
In-Reply-To: <20260626161230.93069-8-macroalpha82@gmail.com>

On Fri, 26 Jun 2026 11:12:28 -0500
Chris Morgan <macroalpha82@gmail.com> wrote:

> From: Chris Morgan <macromorgan@hotmail.com>
> 
> Add gyroscope functions to the icm42607 driver.
> 
> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Similar comments to those in the accel driver.

Thanks,

Jonathan

> diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_gyro.c b/drivers/iio/imu/inv_icm42607/inv_icm42607_gyro.c
> new file mode 100644
> index 000000000000..c7215b3826ad
> --- /dev/null
> +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_gyro.c

> +static int inv_icm42607_gyro_read_odr(struct inv_icm42607_state *st,
> +				      int *val, int *val2)
> +{
> +	unsigned int odr;
> +	unsigned int i;
> +
> +	guard(mutex)(&st->lock);
> +
> +	odr = st->conf.gyro.odr;
> +
> +	for (i = 5; i < ARRAY_SIZE(inv_icm42607_gyro_odr); ++i) {
> +		if (i == odr)

As below.

> +
> +static int inv_icm42607_gyro_write_odr(struct iio_dev *indio_dev,
> +				       int val, int val2)
> +{
> +	struct inv_icm42607_state *st = iio_device_get_drvdata(indio_dev);
> +	struct device *dev = regmap_get_device(st->map);
> +	unsigned int idx;
> +	struct inv_icm42607_sensor_conf conf = INV_ICM42607_SENSOR_CONF_INIT;
> +	int ret;
> +
> +	for (idx = 5; idx < ARRAY_SIZE(inv_icm42607_gyro_odr); ++idx) {

Similar comments to accel. Use the appropriate define for that 5 and
post increment.

> +		if (val == inv_icm42607_gyro_odr[idx][0] &&
> +		    val2 == inv_icm42607_gyro_odr[idx][1])
> +			break;
> +	}

> +static int inv_icm42607_gyro_read_avail(struct iio_dev *indio_dev,
> +					struct iio_chan_spec const *chan,
> +					const int **vals,
> +					int *type, int *length, long mask)
> +{
> +	if (chan->type != IIO_ANGL_VEL)

This was the one sashiko noted was less than ideal as it rules out
reading this for temperature channels - in practice that doesn't happen
but that is due to an internal detail of how we create shared_by_all
attributes. The code should support reading for temperature channels as well.

> +		return -EINVAL;
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_SCALE:
> +		*vals = (const int *)inv_icm42607_gyro_scale_nano;
> +		*type = IIO_VAL_INT_PLUS_NANO;
> +		*length = ARRAY_SIZE(inv_icm42607_gyro_scale_nano) * 2;
> +		return IIO_AVAIL_LIST;
> +	case IIO_CHAN_INFO_SAMP_FREQ:
> +		*vals = (const int *)inv_icm42607_gyro_odr[5];
> +		*type = IIO_VAL_INT_PLUS_MICRO;
> +		*length = (ARRAY_SIZE(inv_icm42607_gyro_odr) - 5) * 2;
> +		return IIO_AVAIL_LIST;
> +	default:
> +		return -EINVAL;
> +	}
> +}



  parent reply	other threads:[~2026-07-01 19:28 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 16:12 [PATCH V15 0/9] Add Invensense ICM42607 Chris Morgan
2026-06-26 16:12 ` Chris Morgan
2026-06-26 16:12 ` [PATCH V15 1/9] dt-bindings: iio: imu: icm42600: Add mount-matrix Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-06-26 16:12 ` [PATCH V15 2/9] dt-bindings: iio: imu: icm42600: Add icm42607 Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-07-01  1:45   ` Jonathan Cameron
2026-07-01  1:45     ` Jonathan Cameron
2026-07-01  1:45     ` Jonathan Cameron
2026-07-01  1:45     ` Jonathan Cameron
2026-06-26 16:12 ` [PATCH V15 3/9] iio: imu: inv_icm42607: Add inv_icm42607 Core Driver Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-07-01 19:15   ` Jonathan Cameron
2026-07-01 19:15     ` Jonathan Cameron
2026-06-26 16:12 ` [PATCH V15 4/9] iio: imu: inv_icm42607: Add SPI For icm42607 Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-06-26 16:12 ` [PATCH V15 5/9] iio: imu: inv_icm42607: Add PM support for icm42607 Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-06-29  7:21   ` Andy Shevchenko
2026-06-29  7:21     ` Andy Shevchenko
2026-06-26 16:12 ` [PATCH V15 6/9] iio: imu: inv_icm42607: Add Accelerometer " Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-06-26 16:29   ` sashiko-bot
2026-07-01 19:24   ` Jonathan Cameron
2026-07-01 19:24     ` Jonathan Cameron
2026-06-26 16:12 ` [PATCH V15 7/9] iio: imu: inv_icm42607: Add Gyroscope to icm42607 Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-06-26 16:28   ` sashiko-bot
2026-07-01 19:28   ` Jonathan Cameron [this message]
2026-07-01 19:28     ` Jonathan Cameron
2026-06-26 16:12 ` [PATCH V15 8/9] iio: imu: inv_icm42607: Add Temp Support in icm42607 Chris Morgan
2026-06-26 16:12   ` Chris Morgan
2026-06-26 16:29   ` sashiko-bot
2026-07-01 19:30   ` Jonathan Cameron
2026-07-01 19:30     ` Jonathan Cameron
2026-06-26 16:12 ` [PATCH V15 9/9] arm64: dts: rockchip: Add icm42607p IMU for RG-DS Chris Morgan
2026-06-26 16:12   ` Chris Morgan

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=20260701202815.7d930b56@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=heiko@sntech.de \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=macroalpha82@gmail.com \
    --cc=macromorgan@hotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.