• Martin Kelly's avatar
    iio:st_magn: Fix enable device after trigger · fe5192ac
    Martin Kelly authored
    Currently, we enable the device before we enable the device trigger. At
    high frequencies, this can cause interrupts that don't yet have a poll
    function associated with them and are thus treated as spurious. At high
    frequencies with level interrupts, this can even cause an interrupt storm
    of repeated spurious interrupts (~100,000 on my Beagleboard with the
    LSM9DS1 magnetometer). If these repeat too much, the interrupt will get
    disabled and the device will stop functioning.
    
    To prevent these problems, enable the device prior to enabling the device
    trigger, and disable the divec prior to disabling the trigger. This means
    there's no window of time during which the device creates interrupts but we
    have no trigger to answer them.
    
    Fixes: 90efe055 ("iio: st_sensors: harden interrupt handling")
    Signed-off-by: default avatarMartin Kelly <martin@martingkelly.com>
    Tested-by: default avatarDenis Ciocca <denis.ciocca@st.com>
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    fe5192ac
st_magn_buffer.c 2.16 KB