Re: [PATCH v5 2/2] iio: light: add AS7343 multi-spectral sensor driver
From: Jose A. Perez de Azpillaga
Date: Thu Sep 24 2026 - 18:07:09 EST
On Sat, Sep 19, 2026 at 04:51:45PM -0700, Chang Yu wrote:
> +static int as7343_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + struct as7343_data *data = iio_priv(indio_dev);
> + struct regmap *map = data->regmap;
> + struct device *dev = regmap_get_device(map);
> + unsigned int unused;
> + __le16 result;
> + int ret;
> +
> + PM_RUNTIME_ACQUIRE_AUTOSUSPEND(dev, pm);
> + ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> + if (ret)
> + return ret;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW: {
> + /* Wait until integration time passes for all 3 cycles. */
> + msleep(160);
three integration periods hardcoded next to a hardcoded integration
time, so nothing keeps them in sync. make ATIME/ASTEP writable and the
fixed wait no longer covers a readout. as73211, which this is based on,
computes the timeout and polls NDATA. STATUS2 (0x90) bit 6 is AVALID is
defined and never read, does it cover all three cycles? the datasheet
does not say.
> +
> + /*
> + * Reading ASTATUS latches all data registers to this read.
> + * We don't care about the returned saturation/gain status for
> + * now.
> + */
> + guard(mutex)(&data->mutex);
> +
> + ret = regmap_read(map, AS7343_ASTATUS_REG, &unused);
> + if (ret)
> + return ret;
> +
> + ret = regmap_bulk_read(map, chan->address,
> + &result, sizeof(result));
> + if (ret)
> + return ret;
> +
> + *val = le16_to_cpu(result);
> + return IIO_VAL_INT;
> + }
> +
> + default:
> + return -EINVAL;
> + }
> +}
--
cheers, jose a. p-a