On Tue, Feb 12, 2019 at 11:40 PM Sven Van Asbroeck <thesven73@xxxxxxxxx> wrote: > > Next, read ALS and PS _exclusively_ in the irq handler, guard it with > a mutex: > Wait a second, that wouldn't work, because we don't get an interrupt on every ALS/PS conversion, correct ? In that case, don't cache the als/ps value in the irq handler, but read it from the hardware in ap3216c_read_raw, while holding the mutex. That would still guard against: - _LO and _HI getting interleaved - userspace reading the value in between sending the event, and clearing the int bit - the int handler not immediately seeing _thresh_en Apologies for the confusion :)