public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lothar Rubusch <l.rubusch@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, eraretuya@gmail.com
Subject: Re: [PATCH v8 6/7] iio: accel: adxl345: add FIFO with watermark events
Date: Sat, 4 Jan 2025 12:49:44 +0000	[thread overview]
Message-ID: <20250104124944.14deae84@jic23-huawei> (raw)
In-Reply-To: <CAFXKEHbVFsv2pQvPc-0aHCPmCJ0=RX2ezYrXf1PeMq1QUwf7ZA@mail.gmail.com>

On Sat, 28 Dec 2024 17:11:58 +0100
Lothar Rubusch <l.rubusch@gmail.com> wrote:

> On Sat, Dec 28, 2024 at 3:45 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Wed, 25 Dec 2024 18:13:37 +0000
> > Lothar Rubusch <l.rubusch@gmail.com> wrote:
> >  
> > > Add a basic setup for FIFO with configurable watermark. Add a handler
> > > for watermark interrupt events and extend the channel for the
> > > scan_index needed for the iio channel. The sensor is configurable to use
> > > a FIFO_BYPASSED mode or a FIFO_STREAM mode. For the FIFO_STREAM mode now
> > > a watermark can be configured, or disabled by setting 0. Further features
> > > require a working FIFO setup.
> > >
> > > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
> > > ---
> > >  drivers/iio/accel/adxl345.h      |  27 ++-
> > >  drivers/iio/accel/adxl345_core.c | 305 ++++++++++++++++++++++++++++++-
> > >  2 files changed, 321 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h
> > > index 6f39f16d3..bf9e86cff 100644
> > > --- a/drivers/iio/accel/adxl345.h
> > > +++ b/drivers/iio/accel/adxl345.h
> > > @@ -15,18 +15,32 @@
> > >  #define ADXL345_REG_OFS_AXIS(index)  (ADXL345_REG_OFSX + (index))
> > >  #define ADXL345_REG_BW_RATE          0x2C
> > >  #define ADXL345_REG_POWER_CTL                0x2D
> > > +#define ADXL345_REG_INT_ENABLE               0x2E
> > > +#define ADXL345_REG_INT_MAP          0x2F
> > > +#define ADXL345_REG_INT_SOURCE               0x30
> > > +#define ADXL345_REG_INT_SOURCE_MSK   0xFF
> > >  #define ADXL345_REG_DATA_FORMAT              0x31
> > > -#define ADXL345_REG_DATAX0           0x32
> > > -#define ADXL345_REG_DATAY0           0x34
> > > -#define ADXL345_REG_DATAZ0           0x36
> > > -#define ADXL345_REG_DATA_AXIS(index) \
> > > -     (ADXL345_REG_DATAX0 + (index) * sizeof(__le16))
> > > +#define ADXL345_REG_XYZ_BASE         0x32
> > > +#define ADXL345_REG_DATA_AXIS(index)                         \
> > > +     (ADXL345_REG_XYZ_BASE + (index) * sizeof(__le16))
> > >
> > > +#define ADXL345_REG_FIFO_CTL         0x38
> > > +#define ADXL345_REG_FIFO_STATUS      0x39
> > > +#define ADXL345_REG_FIFO_STATUS_MSK  0x3F
> > > +
> > > +#define ADXL345_FIFO_CTL_SAMPLES(x)  FIELD_PREP(GENMASK(4, 0), x)  
> > These need linux/bitfield.h to be included.
> >  
> 
> Sure, I can do this.
> 
> > However, that got me looking closer at this and it should be done
> > differently.
> >
> > Just define the masks in here and put the FIELD_PREP() inline in the
> > c file.  Same for the various other FIELD_PREP macros in here.
> >
> > It may seem convenient to wrap all this up here, but in general
> > I'd rather see that these are simple FIELD_PREP() calls where they
> > are used inline.
> >  
> 
> Ok, I understand, the masks stay in the adxl345.h and the FIELD_RPEP()
> macros better go to where they are used, i.e. the adxl345_core.c.
> 
> Thank you for reviewing this. I was a bit unsure about using the
> FIELD_PREP() / GENMASK() combinations correctly. The code seems to
> work for me, though. For future usage of those macros: Generally my
> usage of those macros is correct?

Yes, the usage is fine otherwise.

> 
> Do I understand correctly, on the long run it would generally be
> cleaner, also to migrate the defines to the adxl345_core.c? IMHO,
> probably most of the constants in the adxl345.h can be private to
> adxl345_core.c, and probably better should.

Exactly.

Thanks,

Jonathan

> 
> Best regards,
> L

  reply	other threads:[~2025-01-04 12:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-25 18:13 [PATCH v8 0/7] iio: accel: adxl345: add FIFO operating with IRQ triggered watermark events Lothar Rubusch
2024-12-25 18:13 ` [PATCH v8 1/7] iio: accel: adxl345: add function to switch measuring mode Lothar Rubusch
2024-12-28 14:29   ` Jonathan Cameron
2024-12-25 18:13 ` [PATCH v8 2/7] dt-bindings: iio: accel: adxl345: make interrupts not a required property Lothar Rubusch
2024-12-28 14:30   ` Jonathan Cameron
2024-12-25 18:13 ` [PATCH v8 3/7] dt-bindings: iio: accel: adxl345: add interrupt-names Lothar Rubusch
2024-12-27  7:58   ` Krzysztof Kozlowski
2024-12-28 14:30     ` Jonathan Cameron
2024-12-25 18:13 ` [PATCH v8 4/7] iio: accel: adxl345: introduce interrupt handling Lothar Rubusch
2024-12-25 18:13 ` [PATCH v8 5/7] iio: accel: adxl345: initialize FIFO delay value for SPI Lothar Rubusch
2024-12-25 18:13 ` [PATCH v8 6/7] iio: accel: adxl345: add FIFO with watermark events Lothar Rubusch
2024-12-28 14:45   ` Jonathan Cameron
2024-12-28 16:11     ` Lothar Rubusch
2025-01-04 12:49       ` Jonathan Cameron [this message]
2024-12-25 18:13 ` [PATCH v8 7/7] iio: accel: adxl345: complete the list of defines Lothar Rubusch
2024-12-28 14:47   ` Jonathan Cameron
2024-12-28 15:48     ` Lothar Rubusch
2025-01-04 12:51       ` 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=20250104124944.14deae84@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=eraretuya@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=l.rubusch@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@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