lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHp75Vf0zHU3103xGeO4pt7LO7yWvd_WGssHAM87srQxHyFXvg@mail.gmail.com>
Date: Sat, 6 Sep 2025 12:07:23 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Dixit Parmar <dixitparmar19@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>, 
	Nuno Sá <nuno.sa@...log.com>, 
	Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, linux-kernel@...r.kernel.org, 
	linux-iio@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v6 2/2] iio: magnetometer: add support for Infineon
 TLV493D 3D Magentic sensor

On Sat, Sep 6, 2025 at 11:38 AM Dixit Parmar <dixitparmar19@...il.com> wrote:
>
> The Infineon TLV493D is a Low-Power 3D Magnetic Sensor. The Sensor
> applications includes joysticks, control elements (white goods,
> multifunction knops), or electric meters (anti tampering) and any
> other application that requires accurate angular measurements at
> low power consumptions.
>
> The Sensor is configured over I2C, and as part of Sensor measurement
> data it provides 3-Axis magnetic fields and temperature core measurement.
>
> The driver supports raw value read and buffered input via external trigger
> to allow streaming values with the same sensing timestamp.
>
> While the sensor has an interrupt pin multiplexed with an I2C SCL pin.
> But for bus configurations interrupt(INT) is not recommended, unless timing
> constraints between I2C data transfers and interrupt pulses are monitored
> and aligned.
>
> The Sensor's I2C register map and mode information is described in product
> User Manual [1].

This version looks good enough to me.
Reviewed-by: Andy Shevchenko <andy@...nel.org>

...

> +static int tlv493d_read_raw(struct iio_dev *indio_dev,
> +                       const struct iio_chan_spec *chan, int *val,
> +                       int *val2, long mask)
> +{
> +       struct tlv493d_data *data = iio_priv(indio_dev);
> +       s16 x, y, z, t;
> +       int ret;
> +
> +       switch (mask) {
> +       case IIO_CHAN_INFO_RAW:
> +               ret = tlv493d_get_measurements(data, &x, &y, &z, &t);
> +               if (ret)
> +                       return ret;
> +
> +               switch (chan->address) {
> +               case TLV493D_AXIS_X:
> +                       *val = x;
> +                       return IIO_VAL_INT;
> +               case TLV493D_AXIS_Y:
> +                       *val = y;
> +                       return IIO_VAL_INT;
> +               case TLV493D_AXIS_Z:
> +                       *val = z;
> +                       return IIO_VAL_INT;
> +               case TLV493D_TEMPERATURE:
> +                       *val = t;
> +                       return IIO_VAL_INT;
> +               default:
> +                       return -EINVAL;
> +               }
> +       case IIO_CHAN_INFO_SCALE:
> +               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.
> +                        */
> +                       *val = 98;
> +                       *val2 = 1000;
> +                       return IIO_VAL_FRACTIONAL;
> +               case IIO_TEMP:
> +                       /*
> +                        * Temperature scale: 1.1 °C per LSB, expressed as 1100 m°C
> +                        * Returned as integer for IIO core to apply:
> +                        * temp = (raw + offset) * scale
> +                        */
> +                       *val = 1100;
> +                       return IIO_VAL_INT;
> +               default:
> +                       return -EINVAL;
> +               }
> +       case IIO_CHAN_INFO_OFFSET:
> +               switch (chan->type) {
> +               case IIO_TEMP:
> +                       /*
> +                        * Temperature offset includes sensor-specific raw offset
> +                        * plus compensation for +25°C bias in formula.
> +                        * offset = -raw_offset + (25000 / 1100)
> +                        * -340 + 22.72 = -317.28
> +                        */
> +                       *val = -31728;
> +                       *val2 = 100;
> +                       return IIO_VAL_FRACTIONAL;
> +               default:
> +                       return -EINVAL;
> +               }

> +

Inconsistent (redundant) blank line.

> +       default:
> +               return -EINVAL;
> +       }
> +}


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ