From: Jonathan Cameron <jic23@kernel.org>
To: Lothar Rubusch <l.rubusch@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
eraretuya@gmail.com
Subject: Re: [PATCH v5 06/11] iio: accel: adxl345: extend sample frequency adjustments
Date: Mon, 14 Apr 2025 19:30:10 +0100 [thread overview]
Message-ID: <20250414193010.0ff1ea59@jic23-huawei> (raw)
In-Reply-To: <CAFXKEHau6n2o_MPimiEkYRNvE3TO9f5j_tDH0FwJYsk6V5B9WA@mail.gmail.com>
On Mon, 14 Apr 2025 13:41:20 +0200
Lothar Rubusch <l.rubusch@gmail.com> wrote:
> On Mon, Mar 31, 2025 at 12:33 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Tue, 18 Mar 2025 23:08:38 +0000
> > Lothar Rubusch <l.rubusch@gmail.com> wrote:
> >
> > > Introduce enums and functions to work with the sample frequency
> > > adjustments. Let the sample frequency adjust via IIO and configure
> > > a reasonable default.
> > >
> > > Replace the old static sample frequency handling. During adjustment of
> > > bw registers, measuring is disabled and afterwards enabled again.
> > >
> > > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
> > One minor thing inline.
> >
> >
> > > return -EINVAL;
> > > @@ -504,7 +581,12 @@ static int adxl345_write_raw(struct iio_dev *indio_dev,
> > > int val, int val2, long mask)
> > > {
> > > struct adxl345_state *st = iio_priv(indio_dev);
> > > - s64 n;
> > > + enum adxl345_odr odr;
> > > + int ret;
> > > +
> > > + ret = adxl345_set_measure_en(st, false);
> >
> > Why is this necessary but wasn't before?
> > If it should always have been done for existing calibbias etc,
> > perhaps a separate precursor patch is appropriate?
> >
>
> On the one side the datasheet recommends to have measurement disabled,
> when adjusting certain sensor registers, mostly related to interrupt
> events. Before the sensor was operated in FIFO_BYPASS mode only
> without using the sensor events. With interrupt based events, it will
> operate in FIFO_STREAM or similar. Then it seems to me to be a better
> approach to put it generally in standby mode when configuring
> registers to avoid ending up e.g. in FIFO overrun or the like. On the
> other side, I saw similar approaches in the sources of Analog sensors.
> Enable/disable measurement was done there in the particular functions.
> In the particular case of adxl345_write_raw, odr and range values are
> going to be set and I implement enable/disable measurement directly in
> the write_raw. In comparison to the ADXL380 (different sensor!) where
> this is done, too, but down in the specific setter functions. I can
> see a bit of an advantage, if something fails, the sensor generally
> stays turned off. I'll keep this in v6 of the patches.
Thanks for the explanation. That answered my question nicely and
this is fine.
>
> Pls, note, I did not observe faulty behavior due to that or analyzed
> it thoroughly if and where it is probably better to have measurement
> turned off. At best, it won't make any difference and is probably
> rather kind of "best practice". If not, I would expect rather sporadic
> minor issues.
>
> As always, pls consider my patch(es) as a proposal, sometimes with an
> invisible question mark ;) If you have a contrary opinion and/or
> experience, please let me know.
>
> >
> > > + if (ret)
> > > + return ret;
> > >
> > > switch (mask) {
> > > case IIO_CHAN_INFO_CALIBBIAS:
> > > @@ -512,20 +594,26 @@ static int adxl345_write_raw(struct iio_dev *indio_dev,
> > > * 8-bit resolution at +/- 2g, that is 4x accel data scale
> > > * factor
> > > */
> > > - return regmap_write(st->regmap,
> > > - ADXL345_REG_OFS_AXIS(chan->address),
> > > - val / 4);
> > > + ret = regmap_write(st->regmap,
> > > + ADXL345_REG_OFS_AXIS(chan->address),
> > > + val / 4);
> > > + if (ret)
> > > + return ret;
> > > + break;
> > > case IIO_CHAN_INFO_SAMP_FREQ:
> > > - n = div_s64(val * NANOHZ_PER_HZ + val2,
> > > - ADXL345_BASE_RATE_NANO_HZ);
> > > + ret = adxl345_find_odr(st, val, val2, &odr);
> > > + if (ret)
> > > + return ret;
> > >
> > > - return regmap_update_bits(st->regmap, ADXL345_REG_BW_RATE,
> > > - ADXL345_BW_RATE,
> > > - clamp_val(ilog2(n), 0,
> > > - ADXL345_BW_RATE));
> > > + ret = adxl345_set_odr(st, odr);
> > > + if (ret)
> > > + return ret;
> > > + break;
> > > + default:
> > > + return -EINVAL;
> > > }
> > >
> > > - return -EINVAL;
> > > + return adxl345_set_measure_en(st, true);
> > > }
next prev parent reply other threads:[~2025-04-14 18:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 23:08 [PATCH v5 00/11] iio: accel: adxl345: add interrupt based sensor events Lothar Rubusch
2025-03-18 23:08 ` [PATCH v5 01/11] iio: accel: adxl345: introduce adxl345_push_event function Lothar Rubusch
2025-03-18 23:08 ` [PATCH v5 02/11] iio: accel: adxl345: add single tap feature Lothar Rubusch
2025-03-31 10:22 ` Jonathan Cameron
2025-03-18 23:08 ` [PATCH v5 03/11] iio: accel: adxl345: add double " Lothar Rubusch
2025-03-18 23:08 ` [PATCH v5 04/11] iio: accel: adxl345: set the tap suppress bit permanently Lothar Rubusch
2025-03-18 23:08 ` [PATCH v5 05/11] iio: accel: adxl345: add freefall feature Lothar Rubusch
2025-03-31 10:28 ` Jonathan Cameron
2025-03-31 17:23 ` Lothar Rubusch
2025-04-06 11:18 ` Jonathan Cameron
2025-04-14 14:30 ` Lothar Rubusch
2025-04-14 18:28 ` Jonathan Cameron
2025-03-18 23:08 ` [PATCH v5 06/11] iio: accel: adxl345: extend sample frequency adjustments Lothar Rubusch
2025-03-31 10:33 ` Jonathan Cameron
2025-04-14 11:41 ` Lothar Rubusch
2025-04-14 18:30 ` Jonathan Cameron [this message]
2025-03-18 23:08 ` [PATCH v5 07/11] iio: accel: adxl345: add g-range configuration Lothar Rubusch
2025-03-18 23:08 ` [PATCH v5 08/11] iio: accel: adxl345: add activity event feature Lothar Rubusch
2025-03-31 10:40 ` Jonathan Cameron
2025-04-14 11:58 ` Lothar Rubusch
2025-04-14 18:31 ` Jonathan Cameron
2025-03-18 23:08 ` [PATCH v5 09/11] iio: accel: adxl345: add inactivity feature Lothar Rubusch
2025-03-31 10:47 ` Jonathan Cameron
2025-04-14 13:19 ` Lothar Rubusch
2025-04-14 18:34 ` Jonathan Cameron
2025-03-18 23:08 ` [PATCH v5 10/11] iio: accel: adxl345: add coupling detection for activity/inactivity Lothar Rubusch
2025-03-31 10:52 ` Jonathan Cameron
2025-03-18 23:08 ` [PATCH v5 11/11] docs: iio: add documentation for adxl345 driver Lothar Rubusch
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=20250414193010.0ff1ea59@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=eraretuya@gmail.com \
--cc=l.rubusch@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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