[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240519150351.6c248b1d@jic23-huawei>
Date: Sun, 19 May 2024 15:03:51 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: Gustavo Silva <gustavograzs@...il.com>, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, lars@...afoo.de,
gerald.loacker@...fvision.net, devicetree@...r.kernel.org,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/6] iio: chemical: ens160: add triggered buffer support
On Mon, 13 May 2024 21:13:07 +0200
Christophe JAILLET <christophe.jaillet@...adoo.fr> wrote:
> Le 12/05/2024 à 23:04, Gustavo Silva a écrit :
> > ENS160 supports a data ready interrupt. Use it in combination with
> > triggered buffer for continuous data readings.
> >
> > Signed-off-by: Gustavo Silva <gustavograzs-Re5JQEeQqe8AvxtiuMwx3w@...lic.gmane.org>
> > ---
>
> ...
>
> > +static irqreturn_t ens160_trigger_handler(int irq, void *p)
> > +{
> > + struct iio_poll_func *pf = p;
> > + struct iio_dev *indio_dev = pf->indio_dev;
> > + struct ens160_data *data = iio_priv(indio_dev);
> > + __le16 val;
> > + int ret, i, j = 0;
> > +
> > + mutex_lock(&data->mutex);
> > +
> > + for_each_set_bit(i, indio_dev->active_scan_mask,
> > + indio_dev->masklength) {
> > + ret = regmap_bulk_read(data->regmap,
> > + ENS160_REG_DATA_TVOC + 2 * i, &val, 2U);
> > + if (ret)
> > + goto err;
> > +
> > + data->scan.chans[j++] = val;
>
> Is it safe? How can we know if it has been only *partly* updated? Does
> it matter to know?
You've lost me. What do you mean by partly updated?
This won't push anything to the kfifo etc unless all succeeded.
Or is there a race with something else in here?
>
> CJ
>
> > + }
> > +
> > + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
> > + pf->timestamp);
> > +err:
> > + mutex_unlock(&data->mutex);
> > + iio_trigger_notify_done(indio_dev->trig);
> > +
> > + return IRQ_HANDLED;
> > +}
>
> ...
Powered by blists - more mailing lists