* [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale
@ 2026-10-14 17:37 Viral Patel
2026-10-15 9:07 ` Joshua Crofts
2026-10-17 22:09 ` Jonathan Cameron
0 siblings, 2 replies; 5+ messages in thread
From: Viral Patel @ 2026-10-14 17:37 UTC (permalink / raw)
To: Dixit Parmar, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko
Cc: linux-iio, linux-kernel, Jonathan Cameron, Viral Patel
The TLV493D-A1B6 datasheet specifies a magnetic resolution of
98 uT/LSB (0.098 mT/LSB). IIO reports magnetic field in Gauss
(1 mT = 10 G), so the scale should be 0.98 G/LSB.
The driver currently reports 98/1000 = 0.098 G/LSB, which
under-reports the magnetic field by a factor of 10. The comment
also gives the resolution as 0.0098 mT (9.8 uT), mixing up units.
Correct the scale value and the comment.
Fixes: 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")
Signed-off-by: Viral Patel <viral8854@gmail.com>
---
Found while comparing this driver against the TLE493D-W2B6 register
map for a new driver I am working on. Compile-tested only; I do not
have TLV493D-A1B6 hardware.
---
drivers/iio/magnetometer/tlv493d.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/magnetometer/tlv493d.c b/drivers/iio/magnetometer/tlv493d.c
index 03415cc2c9b3..234e3ce63ff7 100644
--- a/drivers/iio/magnetometer/tlv493d.c
+++ b/drivers/iio/magnetometer/tlv493d.c
@@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dev *indio_dev,
switch (chan->type) {
case IIO_MAGN:
/*
- * Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT)
- * Magnetic field in Gauss: mT * 10 = 0.098.
+ * Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB.
+ * In Gauss (1 mT = 10 G): 0.98 G per LSB.
*/
*val = 98;
- *val2 = 1000;
+ *val2 = 100;
return IIO_VAL_FRACTIONAL;
case IIO_TEMP:
/*
---
base-commit: ceb05f22e5cdc3f8bd3f7d5dcfc57843942191dd
change-id: 20261014-tlv493d-scale-fix-5a0b83b52d2a
Best regards,
--
Viral Patel <viral8854@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale
2026-10-14 17:37 [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale Viral Patel
@ 2026-10-15 9:07 ` Joshua Crofts
2026-10-17 22:09 ` Jonathan Cameron
1 sibling, 0 replies; 5+ messages in thread
From: Joshua Crofts @ 2026-10-15 9:07 UTC (permalink / raw)
To: Viral Patel
Cc: Dixit Parmar, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Wed, 14 Oct 2026 23:07:36 +0530
Viral Patel <viral8854@gmail.com> wrote:
> The TLV493D-A1B6 datasheet specifies a magnetic resolution of
> 98 uT/LSB (0.098 mT/LSB). IIO reports magnetic field in Gauss
> (1 mT = 10 G), so the scale should be 0.98 G/LSB.
>
> The driver currently reports 98/1000 = 0.098 G/LSB, which
> under-reports the magnetic field by a factor of 10. The comment
> also gives the resolution as 0.0098 mT (9.8 uT), mixing up units.
>
> Correct the scale value and the comment.
>
> Fixes: 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")
> Signed-off-by: Viral Patel <viral8854@gmail.com>
> ---
Good find.
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale
2026-10-14 17:37 [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale Viral Patel
2026-10-15 9:07 ` Joshua Crofts
@ 2026-10-17 22:09 ` Jonathan Cameron
[not found] ` <CAFmh=S2O7TzFEe5WqH+Te9dQOK5TwAtjB-7GC7uDj7LGS9=w_Q@mail.gmail.com>
1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2026-10-17 22:09 UTC (permalink / raw)
To: Viral Patel
Cc: Dixit Parmar, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Wed, 14 Oct 2026 23:07:36 +0530
Viral Patel <viral8854@gmail.com> wrote:
> The TLV493D-A1B6 datasheet specifies a magnetic resolution of
> 98 uT/LSB (0.098 mT/LSB). IIO reports magnetic field in Gauss
> (1 mT = 10 G), so the scale should be 0.98 G/LSB.
>
> The driver currently reports 98/1000 = 0.098 G/LSB, which
> under-reports the magnetic field by a factor of 10. The comment
> also gives the resolution as 0.0098 mT (9.8 uT), mixing up units.
>
> Correct the scale value and the comment.
>
> Fixes: 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")
> Signed-off-by: Viral Patel <viral8854@gmail.com>
I'll give some time for Dixit to take a look at this.
Thanks,
Jonathan
> ---
> Found while comparing this driver against the TLE493D-W2B6 register
> map for a new driver I am working on. Compile-tested only; I do not
> have TLV493D-A1B6 hardware.
> ---
> drivers/iio/magnetometer/tlv493d.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/tlv493d.c b/drivers/iio/magnetometer/tlv493d.c
> index 03415cc2c9b3..234e3ce63ff7 100644
> --- a/drivers/iio/magnetometer/tlv493d.c
> +++ b/drivers/iio/magnetometer/tlv493d.c
> @@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dev *indio_dev,
> switch (chan->type) {
> case IIO_MAGN:
> /*
> - * Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT)
> - * Magnetic field in Gauss: mT * 10 = 0.098.
> + * Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB.
> + * In Gauss (1 mT = 10 G): 0.98 G per LSB.
> */
> *val = 98;
> - *val2 = 1000;
> + *val2 = 100;
> return IIO_VAL_FRACTIONAL;
> case IIO_TEMP:
> /*
>
> ---
> base-commit: ceb05f22e5cdc3f8bd3f7d5dcfc57843942191dd
> change-id: 20261014-tlv493d-scale-fix-5a0b83b52d2a
>
> Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale
[not found] ` <CAFmh=S2O7TzFEe5WqH+Te9dQOK5TwAtjB-7GC7uDj7LGS9=w_Q@mail.gmail.com>
@ 2026-10-18 15:59 ` Dixit Parmar
2026-10-18 18:00 ` Jonathan Cameron
0 siblings, 1 reply; 5+ messages in thread
From: Dixit Parmar @ 2026-10-18 15:59 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Viral Patel, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
LGTM. Good catch. There seem to be miscalculated Gauss scale due to
multiple conversion factor.
Reviewed-by: Dixit Parmar <dixitparmar19@gmail.com>
On Sun, Oct 18, 2026 at 9:22 PM Dixit Parmar <dixitparmar19@gmail.com> wrote:
>
> This change looks correct, the Gauss scale value seem to be miscalculated due to multiple conversations and different reference. Good catch.
>
> On Sunday, October 18, 2026, Jonathan Cameron <jic23@kernel.org> wrote:
>>
>> On Wed, 14 Oct 2026 23:07:36 +0530
>> Viral Patel <viral8854@gmail.com> wrote:
>>
>> > The TLV493D-A1B6 datasheet specifies a magnetic resolution of
>> > 98 uT/LSB (0.098 mT/LSB). IIO reports magnetic field in Gauss
>> > (1 mT = 10 G), so the scale should be 0.98 G/LSB.
>> >
>> > The driver currently reports 98/1000 = 0.098 G/LSB, which
>> > under-reports the magnetic field by a factor of 10. The comment
>> > also gives the resolution as 0.0098 mT (9.8 uT), mixing up units.
>> >
>> > Correct the scale value and the comment.
>> >
>> > Fixes: 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")
>> > Signed-off-by: Viral Patel <viral8854@gmail.com>
>>
>> I'll give some time for Dixit to take a look at this.
>>
>> Thanks,
>>
>> Jonathan
>>
>> > ---
>> > Found while comparing this driver against the TLE493D-W2B6 register
>> > map for a new driver I am working on. Compile-tested only; I do not
>> > have TLV493D-A1B6 hardware.
>> > ---
>> > drivers/iio/magnetometer/tlv493d.c | 6 +++---
>> > 1 file changed, 3 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/drivers/iio/magnetometer/tlv493d.c b/drivers/iio/magnetometer/tlv493d.c
>> > index 03415cc2c9b3..234e3ce63ff7 100644
>> > --- a/drivers/iio/magnetometer/tlv493d.c
>> > +++ b/drivers/iio/magnetometer/tlv493d.c
>> > @@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dev *indio_dev,
>> > switch (chan->type) {
>> > case IIO_MAGN:
>> > /*
>> > - * Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT)
>> > - * Magnetic field in Gauss: mT * 10 = 0.098.
>> > + * Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB.
>> > + * In Gauss (1 mT = 10 G): 0.98 G per LSB.
>> > */
>> > *val = 98;
>> > - *val2 = 1000;
>> > + *val2 = 100;
>> > return IIO_VAL_FRACTIONAL;
>> > case IIO_TEMP:
>> > /*
>> >
>> > ---
>> > base-commit: ceb05f22e5cdc3f8bd3f7d5dcfc57843942191dd
>> > change-id: 20261014-tlv493d-scale-fix-5a0b83b52d2a
>> >
>> > Best regards,
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale
2026-10-18 15:59 ` Dixit Parmar
@ 2026-10-18 18:00 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-10-18 18:00 UTC (permalink / raw)
To: Dixit Parmar
Cc: Viral Patel, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Sun, 18 Oct 2026 21:29:49 +0530
Dixit Parmar <dixitparmar19@gmail.com> wrote:
> LGTM. Good catch. There seem to be miscalculated Gauss scale due to
> multiple conversion factor.
>
> Reviewed-by: Dixit Parmar <dixitparmar19@gmail.com>
>
Thanks for the fast response!
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> On Sun, Oct 18, 2026 at 9:22 PM Dixit Parmar <dixitparmar19@gmail.com> wrote:
> >
> > This change looks correct, the Gauss scale value seem to be miscalculated due to multiple conversations and different reference. Good catch.
> >
> > On Sunday, October 18, 2026, Jonathan Cameron <jic23@kernel.org> wrote:
> >>
> >> On Wed, 14 Oct 2026 23:07:36 +0530
> >> Viral Patel <viral8854@gmail.com> wrote:
> >>
> >> > The TLV493D-A1B6 datasheet specifies a magnetic resolution of
> >> > 98 uT/LSB (0.098 mT/LSB). IIO reports magnetic field in Gauss
> >> > (1 mT = 10 G), so the scale should be 0.98 G/LSB.
> >> >
> >> > The driver currently reports 98/1000 = 0.098 G/LSB, which
> >> > under-reports the magnetic field by a factor of 10. The comment
> >> > also gives the resolution as 0.0098 mT (9.8 uT), mixing up units.
> >> >
> >> > Correct the scale value and the comment.
> >> >
> >> > Fixes: 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")
> >> > Signed-off-by: Viral Patel <viral8854@gmail.com>
> >>
> >> I'll give some time for Dixit to take a look at this.
> >>
> >> Thanks,
> >>
> >> Jonathan
> >>
> >> > ---
> >> > Found while comparing this driver against the TLE493D-W2B6 register
> >> > map for a new driver I am working on. Compile-tested only; I do not
> >> > have TLV493D-A1B6 hardware.
> >> > ---
> >> > drivers/iio/magnetometer/tlv493d.c | 6 +++---
> >> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >> >
> >> > diff --git a/drivers/iio/magnetometer/tlv493d.c b/drivers/iio/magnetometer/tlv493d.c
> >> > index 03415cc2c9b3..234e3ce63ff7 100644
> >> > --- a/drivers/iio/magnetometer/tlv493d.c
> >> > +++ b/drivers/iio/magnetometer/tlv493d.c
> >> > @@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dev *indio_dev,
> >> > switch (chan->type) {
> >> > case IIO_MAGN:
> >> > /*
> >> > - * Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT)
> >> > - * Magnetic field in Gauss: mT * 10 = 0.098.
> >> > + * Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB.
> >> > + * In Gauss (1 mT = 10 G): 0.98 G per LSB.
> >> > */
> >> > *val = 98;
> >> > - *val2 = 1000;
> >> > + *val2 = 100;
> >> > return IIO_VAL_FRACTIONAL;
> >> > case IIO_TEMP:
> >> > /*
> >> >
> >> > ---
> >> > base-commit: ceb05f22e5cdc3f8bd3f7d5dcfc57843942191dd
> >> > change-id: 20261014-tlv493d-scale-fix-5a0b83b52d2a
> >> >
> >> > Best regards,
> >>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-18 18:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14 17:37 [PATCH] iio: magnetometer: tlv493d: fix magnetic field scale Viral Patel
2026-10-15 9:07 ` Joshua Crofts
2026-10-17 22:09 ` Jonathan Cameron
[not found] ` <CAFmh=S2O7TzFEe5WqH+Te9dQOK5TwAtjB-7GC7uDj7LGS9=w_Q@mail.gmail.com>
2026-10-18 15:59 ` Dixit Parmar
2026-10-18 18:00 ` Jonathan Cameron
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®