On Sun, 17 Nov 2024 18:26:48 +0000 Lothar Rubusch <l.rubusch@xxxxxxxxx> wrote: > Add the feature of the adxl345 and related sensors to manage a FIFO in > stream mode by a watermark level. Provide means to set the watermark > through the IIO api and sysfs interface. > > Signed-off-by: Lothar Rubusch <l.rubusch@xxxxxxxxx> > +/* > + * NB: The buffer/hwfifo_watermark is a read-only entry to display the > + * currently set hardware FIFO watermark. First set a value to buffer0/length. > + * This allows to configure buffer0/watermark. After enabling buffer0/enable > + * the hwfifo_watermark shall show the configured FIFO watermark value. > + * > + * ref: Documentation/ABI/testing/sysfs-bus-iio > + */ > +IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_watermark_min, "1"); > +IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_watermark_max, > + __stringify(ADXL34x_FIFO_SIZE)); > +static IIO_DEVICE_ATTR(hwfifo_watermark, 0444, > + adxl345_get_fifo_watermark, NULL, 0); > +static IIO_DEVICE_ATTR(hwfifo_enabled, 0444, > + adxl345_get_fifo_enabled, NULL, 0); > + > +static IIO_DEVICE_ATTR_RW(watermark_en, 0); > + > static const struct iio_dev_attr *adxl345_fifo_attributes[] = { > + &iio_dev_attr_hwfifo_watermark_min, > + &iio_dev_attr_hwfifo_watermark_max, > + &iio_dev_attr_hwfifo_watermark, > + &iio_dev_attr_hwfifo_enabled, > NULL, Introduce the whole array only when you bring in the entries (so here). > }; > > @@ -345,6 +434,7 @@ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( > > static struct attribute *adxl345_attrs[] = { > &iio_const_attr_sampling_frequency_available.dev_attr.attr, > + &iio_dev_attr_watermark_en.dev_attr.attr, Non standard ABI. This should be indirectly controlled by the watermark on the software buffer IIRC. (it's been a while since I last looked at that). If the watermark passed to hwfifo_set_watermark is 0 then turn it off. Otherwise turn it on. Jonathan > NULL > };