]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: accel: adxl380: fix FIFO watermark bit 8 always written as 0
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Fri, 27 Feb 2026 12:43:05 +0000 (14:43 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 1 Mar 2026 11:20:10 +0000 (11:20 +0000)
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>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/adxl380.c

index 8fab2fdbe147e263378ae6a2dbb8e1c9d0e95dd8..a51d1d61c4127575e53a26b7a82e5b3c6df2bfb8 100644 (file)
@@ -877,7 +877,7 @@ static int adxl380_set_fifo_samples(struct adxl380_state *st)
        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))));
        if (ret)
                return ret;