[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f2b74e41-45d4-4efd-9a16-df763987a7fe@wanadoo.fr>
Date: Mon, 20 May 2024 08:50:19 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: jic23@...nel.org
Cc: conor+dt@...nel.org, devicetree@...r.kernel.org,
gerald.loacker@...fvision.net, krzk+dt@...nel.org, lars@...afoo.de,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, robh@...nel.org,
Gustavo Silva <gustavograzs@...il.com>
Subject: Re: [PATCH 4/6] iio: chemical: ens160: add triggered buffer support
Le 19/05/2024 à 16:03, Jonathan Cameron a écrit :
> On Mon, 13 May 2024 21:13:07 +0200
> Christophe JAILLET <christophe.jaillet-39ZsbGIQGT5GWvitb5QawA@...lic.gmane.org> 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?
Forget it, I misread the place of iio_push_to_buffers_with_timestamp().
I thought we were going through it when 'goto err'.
CJ
>
>>
>> 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