From: David Lechner <dlechner@baylibre.com>
To: "Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Ramona Gradinariu" <ramona.gradinariu@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: accel: adxl380: fix FIFO watermark bit 8 always written as 0
Date: Sat, 28 Feb 2026 10:50:00 -0600 [thread overview]
Message-ID: <84fae6b8-d188-4e5c-af06-b342f3d27514@baylibre.com> (raw)
In-Reply-To: <20260227124305.55271-1-antoniu.miclaus@analog.com>
On 2/27/26 6:43 AM, Antoniu Miclaus wrote:
> FIELD_PREP(BIT(0), fifo_samples & BIT(8)) produces either 0 or 256,
> and since FIELD_PREP masks to bit 0, 256 & 1 evaluates to 0. Use !!
> to convert the result to a proper 0-or-1 value.
>
> Fixes: df36de13677a ("iio: accel: add ADXL380 driver")
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
> drivers/iio/accel/adxl380.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
> index 8fab2fdbe147..a51d1d61c412 100644
> --- a/drivers/iio/accel/adxl380.c
> +++ b/drivers/iio/accel/adxl380.c
> @@ -877,7 +877,7 @@ static int adxl380_set_fifo_samples(struct adxl380_state *st)
Some relevant context...
u16 fifo_samples = st->watermark * st->fifo_set_size;
> ret = regmap_update_bits(st->regmap, ADXL380_FIFO_CONFIG_0_REG,
> ADXL380_FIFO_SAMPLES_8_MSK,
> FIELD_PREP(ADXL380_FIFO_SAMPLES_8_MSK,
> - (fifo_samples & BIT(8))));
> + !!(fifo_samples & BIT(8))));
Technically, this works, but in terms of understanding the code I think
fifo_samples >= BIT(8) would make more sense.
fifo_samples is a count, not bit flags.
> if (ret)
> return ret;
>
next prev parent reply other threads:[~2026-02-28 16:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 12:43 [PATCH] iio: accel: adxl380: fix FIFO watermark bit 8 always written as 0 Antoniu Miclaus
2026-02-28 12:03 ` Jonathan Cameron
2026-02-28 16:50 ` David Lechner [this message]
2026-03-01 12:02 ` Jonathan Cameron
2026-03-02 7:56 ` Andy Shevchenko
2026-03-02 14:54 ` David Lechner
2026-03-02 15:03 ` 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=84fae6b8-d188-4e5c-af06-b342f3d27514@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=ramona.gradinariu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.