* [PATCH] iio: adis16201: Correct accelerometer scale factor
@ 2025-04-19 12:54 Gabriel Shahrouzi
2025-04-19 18:14 ` Marcelo Schmitt
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Shahrouzi @ 2025-04-19 12:54 UTC (permalink / raw)
To: himanshujha199640, jic23, lars, linux-iio, linux-kernel,
Michael.Hennerich
Cc: gshahrouzi, skhan, linux-kernel-mentees, stable
The IIO_CHAN_INFO_SCALE previously reported for accelerometer channels
used 0.4624 mg/LSB. This value matches the datasheet specification for
the offset calibration registers (X/YACCL_OFFS_REG, pg 18).
However, the scale should reflect the sensor output data registers
(X/YACCL_OUT, pg 15, Tables 7 & 8), which use 0.4625 mg/LSB. This is
also consistent with the typical sensitivity in Table 1 (1 / 2.162 ≈
0.4625).
Fixes: 57f9386405a2 ("Staging: iio: accel: adis16201: Add comments about units in read_raw()")
Cc: stable@vger.kernel.org
Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
---
drivers/iio/accel/adis16201.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
index 8601b9a8b8e75..982b33f6eccac 100644
--- a/drivers/iio/accel/adis16201.c
+++ b/drivers/iio/accel/adis16201.c
@@ -133,7 +133,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
* 1 LSB represents 0.244 mg.
*/
*val = 0;
- *val2 = IIO_G_TO_M_S_2(462400);
+ *val2 = IIO_G_TO_M_S_2(462500);
return IIO_VAL_INT_PLUS_NANO;
case IIO_INCLI:
*val = 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adis16201: Correct accelerometer scale factor
2025-04-19 12:54 [PATCH] iio: adis16201: Correct accelerometer scale factor Gabriel Shahrouzi
@ 2025-04-19 18:14 ` Marcelo Schmitt
2025-04-20 0:57 ` Gabriel Shahrouzi
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Schmitt @ 2025-04-19 18:14 UTC (permalink / raw)
To: Gabriel Shahrouzi
Cc: himanshujha199640, jic23, lars, linux-iio, linux-kernel,
Michael.Hennerich, skhan, linux-kernel-mentees, stable
LGTM. Minor comments inline.
On 04/19, Gabriel Shahrouzi wrote:
> The IIO_CHAN_INFO_SCALE previously reported for accelerometer channels
> used 0.4624 mg/LSB. This value matches the datasheet specification for
> the offset calibration registers (X/YACCL_OFFS_REG, pg 18).
>
> However, the scale should reflect the sensor output data registers
> (X/YACCL_OUT, pg 15, Tables 7 & 8), which use 0.4625 mg/LSB. This is
> also consistent with the typical sensitivity in Table 1 (1 / 2.162 ≈
> 0.4625).
>
> Fixes: 57f9386405a2 ("Staging: iio: accel: adis16201: Add comments about units in read_raw()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
> ---
> drivers/iio/accel/adis16201.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
> index 8601b9a8b8e75..982b33f6eccac 100644
> --- a/drivers/iio/accel/adis16201.c
> +++ b/drivers/iio/accel/adis16201.c
> @@ -133,7 +133,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
> * 1 LSB represents 0.244 mg.
Maybe also update the comment?
> */
> *val = 0;
> - *val2 = IIO_G_TO_M_S_2(462400);
> + *val2 = IIO_G_TO_M_S_2(462500);
If we do the math with more decimal digitis we have 1 / 2.162 == 0.46253469010176
Would it make sense to do
*val2 = IIO_G_TO_M_S_2(462535);
?
> return IIO_VAL_INT_PLUS_NANO;
> case IIO_INCLI:
> *val = 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adis16201: Correct accelerometer scale factor
2025-04-19 18:14 ` Marcelo Schmitt
@ 2025-04-20 0:57 ` Gabriel Shahrouzi
0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Shahrouzi @ 2025-04-20 0:57 UTC (permalink / raw)
To: Marcelo Schmitt
Cc: himanshujha199640, jic23, lars, linux-iio, linux-kernel,
Michael.Hennerich, skhan, linux-kernel-mentees, stable
On Sat, Apr 19, 2025 at 2:13 PM Marcelo Schmitt
<marcelo.schmitt1@gmail.com> wrote:
>
> LGTM. Minor comments inline.
>
> On 04/19, Gabriel Shahrouzi wrote:
> > The IIO_CHAN_INFO_SCALE previously reported for accelerometer channels
> > used 0.4624 mg/LSB. This value matches the datasheet specification for
> > the offset calibration registers (X/YACCL_OFFS_REG, pg 18).
> >
> > However, the scale should reflect the sensor output data registers
> > (X/YACCL_OUT, pg 15, Tables 7 & 8), which use 0.4625 mg/LSB. This is
> > also consistent with the typical sensitivity in Table 1 (1 / 2.162 ≈
> > 0.4625).
> >
> > Fixes: 57f9386405a2 ("Staging: iio: accel: adis16201: Add comments about units in read_raw()")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
> > ---
>
> > drivers/iio/accel/adis16201.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
> > index 8601b9a8b8e75..982b33f6eccac 100644
> > --- a/drivers/iio/accel/adis16201.c
> > +++ b/drivers/iio/accel/adis16201.c
> > @@ -133,7 +133,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
> > * 1 LSB represents 0.244 mg.
> Maybe also update the comment?
Good catch. I will update that for v2.
>
> > */
> > *val = 0;
> > - *val2 = IIO_G_TO_M_S_2(462400);
> > + *val2 = IIO_G_TO_M_S_2(462500);
> If we do the math with more decimal digitis we have 1 / 2.162 == 0.46253469010176
> Would it make sense to do
> *val2 = IIO_G_TO_M_S_2(462535);
> ?
Since the datasheet lists the scale factor as 0.4625 mg, I believe
using *val2 = IIO_G_TO_M_S_2(462500); is correct. However, I'm not
sure so I'll postpone v2.
>
> > return IIO_VAL_INT_PLUS_NANO;
> > case IIO_INCLI:
> > *val = 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-20 0:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-19 12:54 [PATCH] iio: adis16201: Correct accelerometer scale factor Gabriel Shahrouzi
2025-04-19 18:14 ` Marcelo Schmitt
2025-04-20 0:57 ` Gabriel Shahrouzi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox