Re: [PATCH v2 14/16] iio: adc: max1027: Don't just sleep when the EOC interrupt is available

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

 



Hi Nuno,

Nuno.Sa@xxxxxxxxxx wrote on Mon, 6 Sep 2021 09:38:02 +0000:

> > -----Original Message-----
> > From: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
> > Sent: Thursday, September 2, 2021 11:15 PM
> > To: Jonathan Cameron <jic23@xxxxxxxxxx>; Lars-Peter Clausen
> > <lars@xxxxxxxxxx>; linux-iio@xxxxxxxxxxxxxxx; linux-
> > kernel@xxxxxxxxxxxxxxx
> > Cc: Thomas Petazzoni <thomas.petazzoni@xxxxxxxxxxx>; Sa, Nuno
> > <Nuno.Sa@xxxxxxxxxx>; Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
> > Subject: [PATCH v2 14/16] iio: adc: max1027: Don't just sleep when the
> > EOC interrupt is available
> > 
> > [External]
> > 
> > The interrupt will fire upon end of conversion. This currently can
> > happen in two situations: either the cnvst trigger was enabled and
> > toggled, or a single read was requested and the data is ready. The first
> > situation is already covered while the second is not. Instead, a waiting
> > delay is applied. Let's handle these interrupts more properly by adding
> > second path in our EOC helper.
> > 
> > Rename the interrupt handler to a more generic name as it won't only
> > handle triggered situations.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
> > ---
> >  drivers/iio/adc/max1027.c | 31 ++++++++++++++++++++++++++++---
> >  1 file changed, 28 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
> > index b85fe0a48ff9..e734d32a5507 100644
> > --- a/drivers/iio/adc/max1027.c
> > +++ b/drivers/iio/adc/max1027.c
> > @@ -256,15 +256,27 @@ struct max1027_state {
> >  	struct iio_trigger		*trig;
> >  	__be16				*buffer;
> >  	struct mutex			lock;
> > +	struct completion		complete;
> > 
> >  	u8				reg ____cacheline_aligned;
> >  };
> > 
> >  static int max1027_wait_eoc(struct iio_dev *indio_dev)
> >  {
> > +	struct max1027_state *st = iio_priv(indio_dev);
> >  	unsigned int conversion_time =
> > MAX1027_CONVERSION_UDELAY;
> > +	int ret;
> > 
> > -	usleep_range(conversion_time, conversion_time * 2);
> > +	if (st->spi->irq) {
> > +		ret = wait_for_completion_timeout(&st->complete,
> > +
> > msecs_to_jiffies(1000));
> > +		if (!ret)
> > +			return ret;
> > +
> > +		reinit_completion(&st->complete);  
> 
> I would call this before the waiting...

Sure, this is probably better.

Thanks,
Miquèl



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux