Re: [PATCH v7 3/4] iio: light: veml6031x00: add support for triggered buffers
From: Andy Shevchenko
Date: Tue Aug 18 2026 - 09:37:35 EST
On Tue, Aug 18, 2026 at 01:34:28PM +0200, Javier Carrasco wrote:
> Add triggered buffer functionality for the two channels the device
> provides (ALS and IR).
...
> +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);
> + struct regmap *map = data->regmap;
> + IIO_DECLARE_BUFFER_WITH_TS(__le16, scan, 2) = { };
> + unsigned int i = 0;
Split assignment, so the code becomes robust in case this variable gets reused.
> + int ch, ret;
> +
> + if (test_bit(VEML6031X00_SCAN_ALS, iio->active_scan_mask) &&
> + test_bit(VEML6031X00_SCAN_IR, iio->active_scan_mask)) {
> + ret = regmap_bulk_read(map, VEML6031X00_REG_ALS_L,
> + scan, 2 * sizeof(*scan));
> + if (ret)
> + goto done;
> + } else {
i = 0;
> + iio_for_each_active_channel(iio, ch) {
> + ret = regmap_bulk_read(map, iio->channels[ch].address,
> + &scan[i++], sizeof(*scan));
> + 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;
> +}
...
Also no need to resend, this is minor thing.
--
With Best Regards,
Andy Shevchenko