Re: [PATCH v4 3/4] drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor
From: Jonathan Cameron
Date: Sat Oct 02 2021 - 12:12:30 EST
On Fri, 1 Oct 2021 09:02:53 +0200
Roan van Dijk <roan@xxxxxxxxxxx> wrote:
> This is a driver for the SCD4x CO2 sensor from Sensirion. The sensor is
> able to measure CO2 concentration, temperature and relative humdity.
> The sensor uses a photoacoustic principle for measuring CO2 concentration.
> An I2C interface is supported by this driver in order to communicate with
> the sensor.
>
> Signed-off-by: Roan van Dijk <roan@xxxxxxxxxxx>
Hi Roan,
Looks like you sent out wrong version or similar as the trigger_handler
won't work as you have it here. Otherwise looks good to me.
...
> +static irqreturn_t scd4x_trigger_handler(int irq, void *p)
> +{
> + struct iio_poll_func *pf = p;
> + struct iio_dev *indio_dev = pf->indio_dev;
> + struct scd4x_state *state = iio_priv(indio_dev);
> + struct {
> + uint16_t data[3];
> + int64_t ts __aligned(8);
> + } scan;
> + int ret;
> + uint16_t buf[3];
> +
> + memset(&scan, 0, sizeof(scan));
> + mutex_lock(&state->lock);
> + ret = scd4x_read_poll(state, buf);
scan->data and drop the local variable buf as unused.
If I've interpreted the intent right here I'm happy to make this tweak
whilst applying. If you prefer to send a v5 with it fixed up that is
fine as well.
> + mutex_unlock(&state->lock);
> + if (ret)
> + goto out;
> +
> + iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
> +out:
> + iio_trigger_notify_done(indio_dev->trig);
> + return IRQ_HANDLED;
> +}
> +
...