fifo_format));
}
-static int adxl367_set_fifo_samples(struct adxl367_state *st,
- unsigned int fifo_watermark,
- unsigned int fifo_set_size)
+static int adxl367_set_fifo_watermark(struct adxl367_state *st,
+ unsigned int fifo_watermark)
{
- unsigned int fifo_samples = fifo_watermark * fifo_set_size;
+ unsigned int fifo_samples = fifo_watermark * st->fifo_set_size;
unsigned int fifo_samples_h, fifo_samples_l;
int ret;
if (fifo_samples > ADXL367_FIFO_MAX_WATERMARK)
fifo_samples = ADXL367_FIFO_MAX_WATERMARK;
- if (fifo_set_size == 0)
- return 0;
-
- fifo_samples /= fifo_set_size;
+ fifo_samples /= st->fifo_set_size;
fifo_samples_h = FIELD_PREP(ADXL367_SAMPLES_H_MASK,
FIELD_GET(ADXL367_SAMPLES_VAL_H_MASK,
if (ret)
return ret;
- return regmap_update_bits(st->regmap, ADXL367_REG_FIFO_SAMPLES,
- ADXL367_SAMPLES_L_MASK, fifo_samples_l);
-}
-
-static int adxl367_set_fifo_set_size(struct adxl367_state *st,
- unsigned int fifo_set_size)
-{
- int ret;
-
- ret = adxl367_set_fifo_samples(st, st->fifo_watermark, fifo_set_size);
- if (ret)
- return ret;
-
- st->fifo_set_size = fifo_set_size;
-
- return 0;
-}
-
-static int adxl367_set_fifo_watermark(struct adxl367_state *st,
- unsigned int fifo_watermark)
-{
- int ret;
-
- ret = adxl367_set_fifo_samples(st, fifo_watermark, st->fifo_set_size);
+ ret = regmap_update_bits(st->regmap, ADXL367_REG_FIFO_SAMPLES,
+ ADXL367_SAMPLES_L_MASK, fifo_samples_l);
if (ret)
return ret;
{
struct adxl367_state *st = iio_priv(indio_dev);
enum adxl367_fifo_format fifo_format;
- unsigned int fifo_set_size;
int ret;
if (!adxl367_find_mask_fifo_format(active_scan_mask, &fifo_format))
return -EINVAL;
- fifo_set_size = bitmap_weight(active_scan_mask, indio_dev->masklength);
-
mutex_lock(&st->lock);
ret = adxl367_set_measure_en(st, false);
if (ret)
goto out;
- ret = adxl367_set_fifo_set_size(st, fifo_set_size);
+ ret = adxl367_set_measure_en(st, true);
if (ret)
goto out;
- ret = adxl367_set_measure_en(st, true);
+ st->fifo_set_size = bitmap_weight(active_scan_mask,
+ indio_dev->masklength);
out:
mutex_unlock(&st->lock);