Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE
@ 2026-10-11  4:54 Arnav Kapoor
  2026-10-11 17:16 ` Joshua Crofts
  0 siblings, 1 reply; 6+ messages in thread
From: Arnav Kapoor @ 2026-10-11  4:54 UTC (permalink / raw)
  To: Jonathan Cameron, Benson Leung
  Cc: Guenter Roeck, David Lechner, Nuno Sá, Andy Shevchenko,
	chrome-platform, linux-iio, linux-kernel, Arnav Kapoor

The IIO_CHAN_INFO_CALIBSCALE read and write paths send
MOTIONSENSE_CMD_SENSOR_SCALE, but set the flags through the
sensor_offset member of the request union, while the scale values in
the write path are filled through sensor_scale.

This only works because the sensor_offset and sensor_scale structs of
struct ec_params_motion_sense happen to place flags at the same offset.
Use the sensor_scale member that matches the command, so all fields of
the request are set through the same struct.

No functional change.

Assisted-by: LLM
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
Compile-tested only (W=1); I don't have ChromeOS EC hardware. Both
union members place flags at the same offset, so the generated host
command is unchanged.

 drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 551b86236abc..2839714f5bc8 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -70,7 +70,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev,
 		break;
 	case IIO_CHAN_INFO_CALIBSCALE:
 		st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_SCALE;
-		st->core.param.sensor_offset.flags = 0;
+		st->core.param.sensor_scale.flags = 0;
 
 		ret = cros_ec_motion_send_host_cmd(&st->core, 0);
 		if (ret == -EPROTO || ret == -EOPNOTSUPP) {
@@ -178,8 +178,7 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
 		/* Send to EC for each axis, even if not complete */
 
 		st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_SCALE;
-		st->core.param.sensor_offset.flags =
-			MOTION_SENSE_SET_OFFSET;
+		st->core.param.sensor_scale.flags = MOTION_SENSE_SET_OFFSET;
 		for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
 			st->core.param.sensor_scale.scale[i] =
 				st->core.calib[i].scale;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE
  2026-10-11  4:54 [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE Arnav Kapoor
@ 2026-10-11 17:16 ` Joshua Crofts
  2026-10-12 21:17   ` Arnav Kapoor
  0 siblings, 1 reply; 6+ messages in thread
From: Joshua Crofts @ 2026-10-11 17:16 UTC (permalink / raw)
  To: Arnav Kapoor
  Cc: Jonathan Cameron, Benson Leung, Guenter Roeck, David Lechner,
	Nuno Sá, Andy Shevchenko, chrome-platform, linux-iio,
	linux-kernel

On Sun, 11 Oct 2026 10:24:08 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:

> The IIO_CHAN_INFO_CALIBSCALE read and write paths send
> MOTIONSENSE_CMD_SENSOR_SCALE, but set the flags through the
> sensor_offset member of the request union, while the scale values in
> the write path are filled through sensor_scale.
> 
> This only works because the sensor_offset and sensor_scale structs of
> struct ec_params_motion_sense happen to place flags at the same offset.
> Use the sensor_scale member that matches the command, so all fields of
> the request are set through the same struct.
> 
> No functional change.
> 
> Assisted-by: LLM
> Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
> ---

Please add a Fixes tag. Otherwise looks good to me!

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE
  2026-10-11 17:16 ` Joshua Crofts
@ 2026-10-12 21:17   ` Arnav Kapoor
  2026-10-13 19:55     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Arnav Kapoor @ 2026-10-12 21:17 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Arnav Kapoor, Jonathan Cameron, Benson Leung, Guenter Roeck,
	David Lechner, Nuno Sa, Andy Shevchenko, chrome-platform,
	linux-iio, linux-kernel

On Sun, 11 Oct 2026 19:16:41 +0200, Joshua Crofts wrote:
> Please add a Fixes tag. Otherwise looks good to me!
>
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

Thanks for the review. The mismatch was introduced when CALIBSCALE
support was added:

Fixes: ed1f2e85da79 ("iio: cros_ec: Add calibscale for 3d MEMS")

Jonathan, could you pick this up when applying, or would you prefer a v2?

Thanks,
Arnav

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE
  2026-10-12 21:17   ` Arnav Kapoor
@ 2026-10-13 19:55     ` Andy Shevchenko
  2026-10-17 23:02       ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-10-13 19:55 UTC (permalink / raw)
  To: Arnav Kapoor
  Cc: Joshua Crofts, Jonathan Cameron, Benson Leung, Guenter Roeck,
	David Lechner, Nuno Sa, Andy Shevchenko, chrome-platform,
	linux-iio, linux-kernel

On Tue, Oct 13, 2026 at 02:47:30AM +0530, Arnav Kapoor wrote:
> On Sun, 11 Oct 2026 19:16:41 +0200, Joshua Crofts wrote:
> > Please add a Fixes tag. Otherwise looks good to me!
> >
> > Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> 
> Thanks for the review. The mismatch was introduced when CALIBSCALE
> support was added:
> 
> Fixes: ed1f2e85da79 ("iio: cros_ec: Add calibscale for 3d MEMS")
> 
> Jonathan, could you pick this up when applying, or would you prefer a v2?

No need to resend, `b4` will scan the whole email thread for the tags.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE
  2026-10-13 19:55     ` Andy Shevchenko
@ 2026-10-17 23:02       ` Jonathan Cameron
  2026-10-18  7:05         ` Tzung-Bi Shih
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2026-10-17 23:02 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Arnav Kapoor, Joshua Crofts, Benson Leung, Guenter Roeck,
	David Lechner, Nuno Sa, Andy Shevchenko, chrome-platform,
	linux-iio, linux-kernel

On Tue, 13 Oct 2026 22:55:27 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Tue, Oct 13, 2026 at 02:47:30AM +0530, Arnav Kapoor wrote:
> > On Sun, 11 Oct 2026 19:16:41 +0200, Joshua Crofts wrote:  
> > > Please add a Fixes tag. Otherwise looks good to me!
> > >
> > > Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>  
> > 
> > Thanks for the review. The mismatch was introduced when CALIBSCALE
> > support was added:
> > 
> > Fixes: ed1f2e85da79 ("iio: cros_ec: Add calibscale for 3d MEMS")
> > 
> > Jonathan, could you pick this up when applying, or would you prefer a v2?  
> 
> No need to resend, `b4` will scan the whole email thread for the tags.
If it could put them in the right order for 'late' fixes tags it would
be perfect (easy fix though so don't resend!)
> 

This driver tends to be well maintained so whilst I'm fine
with the change I'll wait a bit for a tag from one of the maintainers.

Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE
  2026-10-17 23:02       ` Jonathan Cameron
@ 2026-10-18  7:05         ` Tzung-Bi Shih
  0 siblings, 0 replies; 6+ messages in thread
From: Tzung-Bi Shih @ 2026-10-18  7:05 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Shevchenko, Arnav Kapoor, Joshua Crofts, Benson Leung,
	Guenter Roeck, David Lechner, Nuno Sa, Andy Shevchenko,
	chrome-platform, linux-iio, linux-kernel

On Sun, Oct 18, 2026 at 12:02:06AM +0100, Jonathan Cameron wrote:
> On Tue, 13 Oct 2026 22:55:27 +0300
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> 
> > On Tue, Oct 13, 2026 at 02:47:30AM +0530, Arnav Kapoor wrote:
> > > On Sun, 11 Oct 2026 19:16:41 +0200, Joshua Crofts wrote:  
> > > > Please add a Fixes tag. Otherwise looks good to me!
> > > >
> > > > Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>  
> > > 
> > > Thanks for the review. The mismatch was introduced when CALIBSCALE
> > > support was added:
> > > 
> > > Fixes: ed1f2e85da79 ("iio: cros_ec: Add calibscale for 3d MEMS")
> > > 
> > > Jonathan, could you pick this up when applying, or would you prefer a v2?  
> > 
> > No need to resend, `b4` will scan the whole email thread for the tags.
> If it could put them in the right order for 'late' fixes tags it would
> be perfect (easy fix though so don't resend!)
> > 
> 
> This driver tends to be well maintained so whilst I'm fine
> with the change I'll wait a bit for a tag from one of the maintainers.

Sorry for the delay, I somehow missed this in my inbox.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-18  7:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11  4:54 [PATCH] iio: common: cros_ec_sensors: use sensor_scale union member for CALIBSCALE Arnav Kapoor
2026-10-11 17:16 ` Joshua Crofts
2026-10-12 21:17   ` Arnav Kapoor
2026-10-13 19:55     ` Andy Shevchenko
2026-10-17 23:02       ` Jonathan Cameron
2026-10-18  7:05         ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox