Re: [PATCH v3 3/4] iio: light: veml6031x00: add support for triggered buffers

From: Jonathan Cameron

Date: Tue May 26 2026 - 14:08:54 EST


On Sun, 24 May 2026 23:53:57 +0200
Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx> wrote:

> Add triggered buffer functionality for the two channels the device
> provides (ALS and IR).
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
Trivial stuff only.
> diff --git a/drivers/iio/light/veml6031x00.c b/drivers/iio/light/veml6031x00.c
> index 50979d239230..9968d4414dc9 100644
> --- a/drivers/iio/light/veml6031x00.c
> +++ b/drivers/iio/light/veml6031x00.c

> +
> +static int veml6031x00_buffer_postdisable(struct iio_dev *iio)
> +{
> + struct veml6031x00_data *data = iio_priv(iio);
> +
> + pm_runtime_put_autosuspend(data->dev);
> +
> + return 0;
> +}
> +
> +static const struct iio_buffer_setup_ops veml6031x00_buffer_setup_ops = {
> + .preenable = veml6031x00_buffer_preenable,
> + .postdisable = veml6031x00_buffer_postdisable,
> +};
> +
> +static irqreturn_t veml6031x00_trig_handler(int irq, void *p)
> +{
> + struct iio_poll_func *pf = p;
> + struct iio_dev *iio = pf->indio_dev;
> + struct veml6031x00_data *data = iio_priv(iio);
> + int ch, ret, i = 0;
> + struct {
> + __le16 chans[2];
> + aligned_s64 timestamp;
> + } scan = { };
> +
> + if (*iio->active_scan_mask == (BIT(VEML6031X00_SCAN_ALS) |
> + BIT(VEML6031X00_SCAN_IR))) {
I'd prefer we always treat that as a bitmap and do the more costly check
test_bit(VEML6041X00_SCAN_ALS, iio->active_scan_mask) &&
test_bit(VEML6041X00_SCAN_IR, iio->active_scan_mask)


> + ret = regmap_bulk_read(data->regmap,
> + VEML6031X00_REG_ALS_L,
> + &scan.chans, sizeof(scan.chans));
> + if (ret)
> + goto done;
> + } else {
> + iio_for_each_active_channel(iio, ch) {
> + ret = regmap_bulk_read(data->regmap,
> + iio->channels[ch].address,
> + &scan.chans[i++],
> + sizeof(*scan.chans));
> + if (ret)
> + goto done;
> + }
> + }
> +
> + iio_push_to_buffers_with_ts(iio, &scan, sizeof(scan), pf->timestamp);
> +
> +done:
> + iio_trigger_notify_done(iio->trig);
> +
> + return IRQ_HANDLED;
> +}