Re: [PATCH 2/3] iio: light: vl6180: Added Interrupt support for single shot access
From: Jonathan Cameron
Date: Sat Oct 05 2024 - 14:09:44 EST
On Sat, 5 Oct 2024 23:05:25 +0530
Abhash jha <abhashkumarjha123@xxxxxxxxx> wrote:
> > > + if (client->irq) {
> > > + reinit_completion(&data->completion);
> >
> > That's late so there is a race condition. You might be delayed just before this
> > and finish the measurement before the reint_completion() in which case you'll
> > clear the complete() that happens in the interrupt handler before
> > then waiting on it.
> Yes this makes sense.
>
> > This reinit needs to be before whatever can potentially trigger
> > that interrupt.
> Can you explain this part, because where can i reinit it, The measurement
> starts when we write the START_STOP bit to SYSRANGE_START. So should
> it be before that.
Immediately above that write looks right to me. So before writing START_STOP.
That way the completion will be ready for a complete whenever
one turns up.
Jonathan
> I'm kind of confused with this.
>
> Thank you,
> Abhash