linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lothar Rubusch <l.rubusch@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
	lars@metafoo.de, Michael.Hennerich@analog.com,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	corbet@lwn.net, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	eraretuya@gmail.com
Subject: Re: [PATCH v11 3/8] iio: accel: adxl345: add activity event feature
Date: Thu, 24 Jul 2025 14:43:31 +0100	[thread overview]
Message-ID: <20250724144331.25f64e47@jic23-huawei> (raw)
In-Reply-To: <CAFXKEHY61+OqwpOUJau+9afn3C6dya6AkAjfmrf+F=2bnFE-vQ@mail.gmail.com>

On Sun, 20 Jul 2025 20:36:09 +0200
Lothar Rubusch <l.rubusch@gmail.com> wrote:

> Hi, I appologize for late replying on this topic.
> 
> On Sun, Jul 6, 2025 at 6:09 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Thu, 3 Jul 2025 17:24:17 +0300
> > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> >  
> > > On Wed, Jul 02, 2025 at 11:03:10PM +0000, Lothar Rubusch wrote:  
> > > > Enable the sensor to detect activity and trigger interrupts accordingly.
> > > > Activity events are determined based on a threshold, which is initialized
> > > > to a sensible default during probe. This default value is adopted from the
> > > > legacy ADXL345 input driver to maintain consistent behavior.
> > > >
> > > > The combination of activity detection, ODR configuration, and range
> > > > settings lays the groundwork for the activity/inactivity hysteresis
> > > > mechanism, which will be implemented in a subsequent patch. As such,
> > > > portions of this patch prepare switch-case structures to support those
> > > > upcoming changes.  
> > >  
> > > >  #define ADXL345_REG_TAP_AXIS_MSK   GENMASK(2, 0)
> > > >  #define ADXL345_REG_TAP_SUPPRESS_MSK       BIT(3)
> > > >  #define ADXL345_REG_TAP_SUPPRESS   BIT(3)
> > > > +#define ADXL345_REG_ACT_AXIS_MSK   GENMASK(6, 4)
> > > >
> > > >  #define ADXL345_TAP_Z_EN           BIT(0)
> > > >  #define ADXL345_TAP_Y_EN           BIT(1)
> > > >  #define ADXL345_TAP_X_EN           BIT(2)
> > > >
> > > > +#define ADXL345_ACT_Z_EN           BIT(4)
> > > > +#define ADXL345_ACT_Y_EN           BIT(5)
> > > > +#define ADXL345_ACT_X_EN           BIT(6)
> > > > +#define ADXL345_ACT_XYZ_EN         (ADXL345_ACT_Z_EN | ADXL345_ACT_Y_EN | ADXL345_ACT_X_EN)  
> > >
> > > I'm trying to understand the logic behind the placement of the masks and bits.
> > > To me it sounds that the above should be rather
> > >
> > > #define ADXL345_REG_TAP_AXIS_MSK      GENMASK(2, 0)
> > > #define ADXL345_TAP_Z_EN              BIT(0)
> > > #define ADXL345_TAP_Y_EN              BIT(1)
> > > #define ADXL345_TAP_X_EN              BIT(2)
> > > #define ADXL345_REG_TAP_SUPPRESS_MSK  BIT(3) // Do we need this at all?
> > > #define ADXL345_REG_TAP_SUPPRESS      BIT(3) // or actually this? One is enough, no?
> > > #define ADXL345_REG_ACT_AXIS_MSK      GENMASK(6, 4)
> > > #define ADXL345_ACT_Z_EN              BIT(4)
> > > #define ADXL345_ACT_Y_EN              BIT(5)
> > > #define ADXL345_ACT_X_EN              BIT(6)
> > > #define ADXL345_ACT_XYZ_EN            (ADXL345_ACT_Z_EN | ADXL345_ACT_Y_EN | ADXL345_ACT_X_EN)
> > >
> > > (Yes, I know that the mess is preexisted, but try to keep some order in the
> > >  pieces you add here.)  
> >
> > FWIW I fully agree on keeping field definitions and field break up together.
> >
> > The ACT_MSK is a little odd as thing as then we'd expect there to be bits
> > within that. So that FIELD_GET(a, ADXL345_REG_ACT_AXIS_MSK) would return
> > a value from a list of things like
> > ADXL345_REG_ACT_AXIS_VALUE_A and similar.
> >
> > So I'd not define that as a mask a tall but just use the
> > ACT_XYZ_EN for it as then it's clear you are checking for any of the
> > 3 bits being set.
> >  
> 
> The reason is that ADXL345_REG_ACT_AXIS_MSK is used in the evaluation
> of the incoming interrupt status register for "activity" events, and
> ADXL345_ACT_XYZ_EN is supposed to group the enabled axis, when
> enabling the sensor feature "activity" in the enable register. At the
> end of the day, using only one of them would work for both, but
> there's a semantic difference.
> 
> Given this explanation, would you prefer to see a separate
> ADXL345_REG_ACT_AXIS_MSK and ADXL345_ACT_XYZ_EN as presented here, or
> just one ADXL345_ACT_XYZ_EN covering both cases, i.e. the evaluation
> of the interrupt status, and enabling activity axis?

I think just using the XYZ_EN is clear enough as we are checking for
'any of' those.

> 
> > Jonathan
> >  
> ...
> Best,
> L


  reply	other threads:[~2025-07-24 13:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 23:03 [PATCH v11 0/8] iio: accel: adxl345: add interrupt based sensor events Lothar Rubusch
2025-07-02 23:03 ` [PATCH v11 1/8] iio: accel: adxl345: simplify interrupt mapping Lothar Rubusch
2025-07-06 16:10   ` Jonathan Cameron
2025-07-02 23:03 ` [PATCH v11 2/8] iio: accel: adxl345: simplify reading the FIFO Lothar Rubusch
2025-07-06 16:11   ` Jonathan Cameron
2025-07-02 23:03 ` [PATCH v11 3/8] iio: accel: adxl345: add activity event feature Lothar Rubusch
2025-07-03 14:24   ` Andy Shevchenko
2025-07-06 16:09     ` Jonathan Cameron
2025-07-20 18:36       ` Lothar Rubusch
2025-07-24 13:43         ` Jonathan Cameron [this message]
2025-07-02 23:03 ` [PATCH v11 4/8] iio: accel: adxl345: add inactivity feature Lothar Rubusch
2025-07-03 14:26   ` Andy Shevchenko
2025-07-03 14:59     ` Lothar Rubusch
2025-07-03 15:45       ` Andy Shevchenko
2025-07-06 12:08         ` Jonathan Cameron
2025-07-02 23:03 ` [PATCH v11 5/8] iio: accel: adxl345: add coupling detection for activity/inactivity Lothar Rubusch
2025-07-02 23:03 ` [PATCH v11 6/8] iio: accel: adxl345: extend inactivity time for less than 1s Lothar Rubusch
2025-07-02 23:03 ` [PATCH v11 7/8] docs: iio: add documentation for adxl345 driver Lothar Rubusch
2025-07-02 23:03 ` [PATCH v11 8/8] docs: iio: describe inactivity and free-fall detection on the ADXL345 Lothar Rubusch
2025-07-06 16:16   ` Jonathan Cameron
2025-07-20 18:49     ` Lothar Rubusch
2025-07-24 13:47       ` 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=20250724144331.25f64e47@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dlechner@baylibre.com \
    --cc=eraretuya@gmail.com \
    --cc=l.rubusch@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-doc@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).