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 v9 3/4] iio: accel: adxl345: add FIFO with watermark events
Date: Sat, 4 Jan 2025 13:08:02 +0000 [thread overview]
Message-ID: <20250104130802.17026d85@jic23-huawei> (raw)
In-Reply-To: <20241228232949.72487-4-l.rubusch@gmail.com>
On Sat, 28 Dec 2024 23:29:48 +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>
Hi Lothar,
Applied with a tweak. See below and please check my testing branch
to see if I messed this mechanical change up (wouldn't be the first time!)
Thanks,
Jonathan
>
> +#define ADXL345_FIFO_CTL_SAMPLES(x) FIELD_PREP(GENMASK(4, 0), x)
> +/* 0: INT1, 1: INT2 */
> +#define ADXL345_FIFO_CTL_TRIGGER(x) FIELD_PREP(BIT(5), x)
> +#define ADXL345_FIFO_CTL_MODE(x) FIELD_PREP(GENMASK(7, 6), x)
Ah. I now realize I subtly misread your reply to v8.
What I want to see the masks defined with the rest of the fields and
the FIELD_PREP used with those masks inline.
Rather than go around again, I've applied the following tweak.
diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h
index b78b4973a4d4..9fcf6756768e 100644
--- a/drivers/iio/accel/adxl345.h
+++ b/drivers/iio/accel/adxl345.h
@@ -25,6 +25,10 @@
(ADXL345_REG_XYZ_BASE + (index) * sizeof(__le16))
#define ADXL345_REG_FIFO_CTL 0x38
+#define ADXL345_FIFO_CTL_SAMPLES_MSK GENMASK(4, 0)
+/* 0: INT1, 1: INT2 */
+#define ADXL345_FIFO_CTL_TRIGGER_MSK BIT(5)
+#define ADXL345_FIFO_CTL_MODE_MSK GENMASK(7, 6)
#define ADXL345_REG_FIFO_STATUS 0x39
#define ADXL345_REG_FIFO_STATUS_MSK 0x3F
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index d33e3c6528a9..d1b2d3985a40 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -31,11 +31,6 @@
#define ADXL345_INT1 0
#define ADXL345_INT2 1
-#define ADXL345_FIFO_CTL_SAMPLES(x) FIELD_PREP(GENMASK(4, 0), x)
-/* 0: INT1, 1: INT2 */
-#define ADXL345_FIFO_CTL_TRIGGER(x) FIELD_PREP(BIT(5), x)
-#define ADXL345_FIFO_CTL_MODE(x) FIELD_PREP(GENMASK(7, 6), x)
-
struct adxl345_state {
const struct adxl345_chip_info *info;
struct regmap *regmap;
@@ -269,9 +264,12 @@ static int adxl345_set_fifo(struct adxl345_state *st)
return ret;
ret = regmap_write(st->regmap, ADXL345_REG_FIFO_CTL,
- ADXL345_FIFO_CTL_SAMPLES(st->watermark) |
- ADXL345_FIFO_CTL_TRIGGER(st->intio) |
- ADXL345_FIFO_CTL_MODE(st->fifo_mode));
+ FIELD_PREP(ADXL345_FIFO_CTL_SAMPLES_MSK,
+ st->watermark) |
+ FIELD_PREP(ADXL345_FIFO_CTL_TRIGGER_MSK,
+ st->intio) |
+ FIELD_PREP(ADXL345_FIFO_CTL_MODE_MSK,
+ st->fifo_mode));
if (ret < 0)
return ret;
@@ -500,7 +498,6 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
ADXL345_DATA_FORMAT_JUSTIFY |
ADXL345_DATA_FORMAT_FULL_RES |
ADXL345_DATA_FORMAT_SELF_TEST);
- u8 fifo_ctl;
int ret;
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
@@ -583,9 +580,9 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
if (ret)
return ret;
} else {
- /* FIFO_BYPASS mode */
- fifo_ctl = ADXL345_FIFO_CTL_MODE(ADXL345_FIFO_BYPASS);
- ret = regmap_write(st->regmap, ADXL345_REG_FIFO_CTL, fifo_ctl);
+ ret = regmap_write(st->regmap, ADXL345_REG_FIFO_CTL,
+ FIELD_PREP(ADXL345_FIFO_CTL_MODE_MSK,
+ ADXL345_FIFO_BYPASS));
if (ret < 0)
return ret;
}
next prev parent reply other threads:[~2025-01-04 13:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-28 23:29 [PATCH v9 0/4] iio: accel: adxl345: add FIFO operating with IRQ triggered watermark events Lothar Rubusch
2024-12-28 23:29 ` [PATCH v9 1/4] iio: accel: adxl345: introduce interrupt handling Lothar Rubusch
2024-12-28 23:29 ` [PATCH v9 2/4] iio: accel: adxl345: initialize FIFO delay value for SPI Lothar Rubusch
2025-01-12 15:54 ` Andy Shevchenko
2024-12-28 23:29 ` [PATCH v9 3/4] iio: accel: adxl345: add FIFO with watermark events Lothar Rubusch
2025-01-04 13:08 ` Jonathan Cameron [this message]
2025-01-12 16:05 ` Andy Shevchenko
2024-12-28 23:29 ` [PATCH v9 4/4] iio: accel: adxl345: complete the list of defines Lothar Rubusch
2025-01-04 13:09 ` [PATCH v9 0/4] iio: accel: adxl345: add FIFO operating with IRQ triggered watermark events Jonathan Cameron
2025-01-05 22:22 ` Lothar Rubusch
2025-01-12 16:06 ` Andy Shevchenko
2025-01-12 16:38 ` Jonathan Cameron
2025-01-12 19:28 ` Andy Shevchenko
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=20250104130802.17026d85@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