mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Gustavo Silva <gustavograzs@gmail.com>
Cc: "Alex Lanzano" <lanzano.alex@gmail.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Lothar Rubusch" <l.rubusch@gmail.com>
Subject: Re: [PATCH v4 3/3] iio: imu: bmi270: add support for motion events
Date: Tue, 15 Jul 2025 10:37:21 +0300	[thread overview]
Message-ID: <aHYFMf8QGDNt-5Nf@smile.fi.intel.com> (raw)
In-Reply-To: <20250711-bmi270-events-v4-3-53ec7da35046@gmail.com>

On Fri, Jul 11, 2025 at 08:36:03PM -0300, Gustavo Silva wrote:
> Any-motion event can be enabled on a per-axis basis and triggers a
> combined event when motion is detected on any axis.
> 
> No-motion event is triggered if the rate of change on all axes falls
> below a specified threshold for a configurable duration. A fake channel
> is used to report this event.
> 
> Threshold and duration can be configured from userspace.

...

> +/* 9.81 * 1000000 m/s^2 */
> +#define BMI270_G_MEGA_M_S_2				9810000

I thought this is MICRO...

...

> +#define BMI270_INT_MICRO_TO_RAW(val, val2, scale) \
> +	((val) * (scale) + ((val2) * (scale)) / MEGA)

Side note: Perhaps good candidate to have it in math.h
(AFAIR there are more users of the same.)

> +#define BMI270_RAW_TO_MICRO(raw, scale) \
> +	((((raw) % (scale)) * MEGA) / scale)

...

> +static ssize_t bmi270_show_accel_value_avail(struct device *dev,
> +					     struct device_attribute *attr,
> +					     char *buf)
> +{
> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> +	struct bmi270_data *data = iio_priv(indio_dev);
> +	int ret, scale, uscale;
> +	unsigned int step, max;
> +
> +	ret = bmi270_get_scale(data, IIO_ACCEL, &scale, &uscale);
> +	if (ret)
> +		return ret;
> +
> +	max = BMI270_G_MEGA_M_S_2 / uscale;

...as here we divide 10^6/10^-6 semantically speaking.

> +	step = max / BMI270_MOTION_THRES_FULL_SCALE;
> +
> +	return sysfs_emit(buf, "[0 %u %u]\n", step, max);
> +}

Is this already documented in ABI?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-07-15  7:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250711-bmi270-events-v4-0-53ec7da35046@gmail.com>
2025-07-11 23:36 ` Gustavo Silva
2025-07-15  7:37   ` Andy Shevchenko [this message]
2025-07-15  7:49     ` Andy Shevchenko
2025-07-15 23:55       ` Gustavo Silva
2025-07-16  9:53         ` Andy Shevchenko
2025-07-24 15:22           ` Jonathan Cameron
2025-07-24 21:26             ` Andy Shevchenko
2025-07-27 15:49               ` Jonathan Cameron
2025-08-02 11:58                 ` Jonathan Cameron
2025-08-04 22:26                   ` Gustavo Silva
2025-08-10 18:25                     ` Jonathan Cameron
2025-07-15 23:52     ` Gustavo Silva
2025-07-16  9:49       ` Andy Shevchenko
2025-07-24 15:28         ` Jonathan Cameron

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=aHYFMf8QGDNt-5Nf@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gustavograzs@gmail.com \
    --cc=jic23@kernel.org \
    --cc=l.rubusch@gmail.com \
    --cc=lanzano.alex@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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®