Re: [PATCH 4/6] iio: chemical: ens160: add triggered buffer support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 13 May 2024 21:13:07 +0200
Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> 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@xxxxxxxxxxxxxxxx>
> > ---  
> 
> ...
> 
> > +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;
> > +}  
> 
> ...






[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux