* [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale
@ 2025-02-02 10:07 Antoni Pokusinski
2025-02-03 9:26 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Antoni Pokusinski @ 2025-02-02 10:07 UTC (permalink / raw)
To: jic23, lars, andriy.shevchenko; +Cc: linux-kernel, linux-iio, Antoni Pokusinski
Applying the current scale value to the raw magnetic field measurements
gives the result in mT.
Fix the scale by increasing it 10 times, so that the final result after
applying the scale is in Gauss.
Fixes: cb29542a178f ("iio: magnetometer: si7210: add driver for Si7210")
Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com>
---
drivers/iio/magnetometer/si7210.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/magnetometer/si7210.c b/drivers/iio/magnetometer/si7210.c
index 43b00d76505a..27e3feba7a0f 100644
--- a/drivers/iio/magnetometer/si7210.c
+++ b/drivers/iio/magnetometer/si7210.c
@@ -203,9 +203,9 @@ static int si7210_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
*val = 0;
if (data->curr_scale == 20)
- *val2 = 1250;
- else /* data->curr_scale == 200 */
*val2 = 12500;
+ else /* data->curr_scale == 200 */
+ *val2 = 125000;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OFFSET:
*val = -16384;
@@ -274,9 +274,9 @@ static int si7210_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_SCALE:
- if (val == 0 && val2 == 1250)
+ if (val == 0 && val2 == 12500)
scale = 20;
- else if (val == 0 && val2 == 12500)
+ else if (val == 0 && val2 == 125000)
scale = 200;
else
return -EINVAL;
base-commit: aa61400ca17e264a4b597e3c0cda011c6b9b3bb5
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale
2025-02-02 10:07 [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale Antoni Pokusinski
@ 2025-02-03 9:26 ` Andy Shevchenko
2025-02-03 15:27 ` Jonathan Cameron
2025-02-03 19:39 ` Antoni Pokusinski
0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:26 UTC (permalink / raw)
To: Antoni Pokusinski; +Cc: jic23, lars, linux-kernel, linux-iio
On Sun, Feb 02, 2025 at 11:07:10AM +0100, Antoni Pokusinski wrote:
> Applying the current scale value to the raw magnetic field measurements
> gives the result in mT.
>
> Fix the scale by increasing it 10 times, so that the final result after
> applying the scale is in Gauss.
No objections against this change, just wondering since these are
the ABI changes (correct?) how should we really handle them in case
some of the user space stuff already relies on 'bad' values?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale
2025-02-03 9:26 ` Andy Shevchenko
@ 2025-02-03 15:27 ` Jonathan Cameron
2025-02-03 19:39 ` Antoni Pokusinski
1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2025-02-03 15:27 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Antoni Pokusinski, jic23, lars, linux-kernel, linux-iio
On Mon, 3 Feb 2025 11:26:27 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Sun, Feb 02, 2025 at 11:07:10AM +0100, Antoni Pokusinski wrote:
> > Applying the current scale value to the raw magnetic field measurements
> > gives the result in mT.
> >
> > Fix the scale by increasing it 10 times, so that the final result after
> > applying the scale is in Gauss.
>
> No objections against this change, just wondering since these are
> the ABI changes (correct?) how should we really handle them in case
> some of the user space stuff already relies on 'bad' values?
>
If it's broken wrt to the published ABI (and hence what other sensors
are exporting) then not a whole lot we can do other than
backport the fix. This is one of the few cases where ABI backwards
compatibility comes second :(
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale
2025-02-03 9:26 ` Andy Shevchenko
2025-02-03 15:27 ` Jonathan Cameron
@ 2025-02-03 19:39 ` Antoni Pokusinski
2025-02-04 19:24 ` Jonathan Cameron
1 sibling, 1 reply; 6+ messages in thread
From: Antoni Pokusinski @ 2025-02-03 19:39 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: jic23, lars, linux-kernel, linux-iio
On Mon, Feb 03, 2025 at 11:26:27AM +0200, Andy Shevchenko wrote:
> On Sun, Feb 02, 2025 at 11:07:10AM +0100, Antoni Pokusinski wrote:
> > Applying the current scale value to the raw magnetic field measurements
> > gives the result in mT.
> >
> > Fix the scale by increasing it 10 times, so that the final result after
> > applying the scale is in Gauss.
>
> No objections against this change, just wondering since these are
> the ABI changes (correct?) how should we really handle them in case
> some of the user space stuff already relies on 'bad' values?
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Just to clarify: yes, this patch makes the output values compliant to
ABI (Documentation/ABI/testing/sysfs-bus-iio). According to the ABI, the
output values for the magnetic field should be in Gauss, but during
the driver development I missed the fact that I return values in mT
instead... (1 Gauss = 0.1mT)
BTW I see that the patch cb29542a178f ("iio: magnetometer: si7210: add
driver for Si7210") is still on the "testing" branch only, so perhaps
it's still not too late to apply the fix?
Kind regards,
Antoni
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale
2025-02-03 19:39 ` Antoni Pokusinski
@ 2025-02-04 19:24 ` Jonathan Cameron
2025-02-08 13:06 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2025-02-04 19:24 UTC (permalink / raw)
To: Antoni Pokusinski; +Cc: Andy Shevchenko, lars, linux-kernel, linux-iio
On Mon, 3 Feb 2025 20:39:20 +0100
Antoni Pokusinski <apokusinski01@gmail.com> wrote:
> On Mon, Feb 03, 2025 at 11:26:27AM +0200, Andy Shevchenko wrote:
> > On Sun, Feb 02, 2025 at 11:07:10AM +0100, Antoni Pokusinski wrote:
> > > Applying the current scale value to the raw magnetic field measurements
> > > gives the result in mT.
> > >
> > > Fix the scale by increasing it 10 times, so that the final result after
> > > applying the scale is in Gauss.
> >
> > No objections against this change, just wondering since these are
> > the ABI changes (correct?) how should we really handle them in case
> > some of the user space stuff already relies on 'bad' values?
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
> >
> >
>
> Just to clarify: yes, this patch makes the output values compliant to
> ABI (Documentation/ABI/testing/sysfs-bus-iio). According to the ABI, the
> output values for the magnetic field should be in Gauss, but during
> the driver development I missed the fact that I return values in mT
> instead... (1 Gauss = 0.1mT)
>
> BTW I see that the patch cb29542a178f ("iio: magnetometer: si7210: add
> driver for Si7210") is still on the "testing" branch only, so perhaps
> it's still not too late to apply the fix?
>
Ah. I'd not registered that. Definitely makes life easier.
This will just get queued up behind it and land upstream at the same
time.
Jonathan
> Kind regards,
> Antoni
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale
2025-02-04 19:24 ` Jonathan Cameron
@ 2025-02-08 13:06 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2025-02-08 13:06 UTC (permalink / raw)
To: Antoni Pokusinski; +Cc: Andy Shevchenko, lars, linux-kernel, linux-iio
On Tue, 4 Feb 2025 19:24:54 +0000
Jonathan Cameron <jic23@kernel.org> wrote:
> On Mon, 3 Feb 2025 20:39:20 +0100
> Antoni Pokusinski <apokusinski01@gmail.com> wrote:
>
> > On Mon, Feb 03, 2025 at 11:26:27AM +0200, Andy Shevchenko wrote:
> > > On Sun, Feb 02, 2025 at 11:07:10AM +0100, Antoni Pokusinski wrote:
> > > > Applying the current scale value to the raw magnetic field measurements
> > > > gives the result in mT.
> > > >
> > > > Fix the scale by increasing it 10 times, so that the final result after
> > > > applying the scale is in Gauss.
> > >
> > > No objections against this change, just wondering since these are
> > > the ABI changes (correct?) how should we really handle them in case
> > > some of the user space stuff already relies on 'bad' values?
> > >
> > > --
> > > With Best Regards,
> > > Andy Shevchenko
> > >
> > >
> >
> > Just to clarify: yes, this patch makes the output values compliant to
> > ABI (Documentation/ABI/testing/sysfs-bus-iio). According to the ABI, the
> > output values for the magnetic field should be in Gauss, but during
> > the driver development I missed the fact that I return values in mT
> > instead... (1 Gauss = 0.1mT)
> >
> > BTW I see that the patch cb29542a178f ("iio: magnetometer: si7210: add
> > driver for Si7210") is still on the "testing" branch only, so perhaps
> > it's still not too late to apply the fix?
> >
> Ah. I'd not registered that. Definitely makes life easier.
> This will just get queued up behind it and land upstream at the same
> time.
>
> Jonathan
Applied.
>
> > Kind regards,
> > Antoni
> >
> >
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-08 13:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-02 10:07 [PATCH] iio: magnetometer: si7210: fix magnetic field measurement scale Antoni Pokusinski
2025-02-03 9:26 ` Andy Shevchenko
2025-02-03 15:27 ` Jonathan Cameron
2025-02-03 19:39 ` Antoni Pokusinski
2025-02-04 19:24 ` Jonathan Cameron
2025-02-08 13:06 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).