mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Francesco Lavra <flavra@baylibre.com>
Cc: "Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH v7 6/6] iio: imu: st_lsm6dsx: Add support for rotation sensor
Date: Wed, 4 Mar 2026 15:39:09 +0200	[thread overview]
Message-ID: <aag1_TpKpwpS59k6@ashevche-desk.local> (raw)
In-Reply-To: <20260304080712.2844514-1-flavra@baylibre.com>

On Wed, Mar 04, 2026 at 09:07:11AM +0100, Francesco Lavra wrote:
> Some IMU chips in the LSM6DSX family have sensor fusion features that
> combine data from the accelerometer and gyroscope. One of these features
> generates rotation vector data and makes it available in the hardware
> FIFO as a quaternion (more specifically, the X, Y and Z components of the
> quaternion vector, expressed as 16-bit half-precision floating-point
> numbers).
> 
> Add support for a new sensor instance that allows receiving sensor fusion
> data, by defining a new struct st_lsm6dsx_fusion_settings (which contains
> chip-specific details for the sensor fusion functionality), and adding this
> struct as a new field in struct st_lsm6dsx_settings. In st_lsm6dsx_core.c,
> populate this new struct for the LSM6DSV and LSM6DSV16X chips, and add the
> logic to initialize an additional IIO device if this struct is populated
> for the hardware type being probed.
> Note: a new IIO device is being defined (as opposed to adding channels to
> an existing device) because the rate at which sensor fusion data is
> generated may not match the data rate from any of the existing devices.
> 
> Tested on LSMDSV16X.

...

> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_fusion.c

+ cleanup.h
+ errno.h

> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> +#include <linux/mutex.h>
> +#include <linux/regmap.h>
> +#include <linux/sprintf.h>
> +#include <linux/types.h>
> +#include <linux/units.h>

...

> +	case IIO_CHAN_INFO_SAMP_FREQ: {
> +		u32 odr_mHz = val * MILLI + val2 * (MILLI / MICRO);
> +		u8 odr_val;
> +
> +		/* check that the requested frequency is supported */
> +		err = st_lsm6dsx_fusion_get_odr_val(settings, odr_mHz,
> +						    &odr_val);

In cases like this I would leave it on a single line. Here I counted only 81
characters.

> +		if (err)
> +			return err;
> +
> +		sensor->hwfifo_odr_mHz = odr_mHz;
> +		return 0;
> +	}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-03-04 13:39 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04  8:05 [PATCH v7 0/6] " Francesco Lavra
2026-03-04  8:06 ` [PATCH v7 1/6] iio: imu: st_lsm6dsx: Fix check for invalid samples from FIFO Francesco Lavra
2026-03-07 12:46   ` Jonathan Cameron
2026-03-07 15:23     ` Lorenzo Bianconi
2026-03-07 17:04       ` Jonathan Cameron
2026-03-07 17:20         ` Lorenzo Bianconi
2026-03-04  8:06 ` [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra
2026-03-04 22:55   ` David Lechner
2026-03-07 12:47     ` Jonathan Cameron
2026-03-07 13:10   ` Jonathan Cameron
2026-03-04  8:06 ` [PATCH v7 3/6] iio: tools: Add support for floating-point numbers in buffer scan elements Francesco Lavra
2026-03-04 22:53   ` David Lechner
2026-03-04  8:06 ` [PATCH v7 4/6] iio: ABI: " Francesco Lavra
2026-03-04 22:45   ` David Lechner
2026-03-05  9:09     ` Francesco Lavra
2026-03-05  9:23       ` Andy Shevchenko
2026-03-05 14:37         ` David Lechner
2026-03-06 12:09           ` Andy Shevchenko
2026-03-07 12:51             ` Jonathan Cameron
2026-03-17 10:40               ` Francesco Lavra
2026-03-04  8:07 ` [PATCH v7 5/6] iio: ABI: Add partial quaternion modifier Francesco Lavra
2026-03-04 11:51   ` Andy Shevchenko
2026-03-04 14:21     ` Francesco Lavra
2026-03-04 22:42       ` David Lechner
2026-03-05  8:50         ` Francesco Lavra
2026-03-05 14:40           ` David Lechner
2026-03-06 12:10             ` Andy Shevchenko
2026-03-04 19:25   ` kernel test robot
2026-03-04 22:35   ` David Lechner
2026-03-05  7:04     ` Andy Shevchenko
2026-03-07 13:00       ` Jonathan Cameron
2026-03-07 13:03     ` Jonathan Cameron
2026-03-08 20:27       ` Andy Shevchenko
2026-03-14 11:14         ` Jonathan Cameron
2026-03-07 13:05   ` Jonathan Cameron
2026-03-04  8:07 ` [PATCH v7 6/6] iio: imu: st_lsm6dsx: Add support for rotation sensor Francesco Lavra
2026-03-04 13:39   ` Andy Shevchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aag1_TpKpwpS59k6@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=flavra@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®