Skip to content
  • Lars-Peter Clausen's avatar
    iio: __iio_update_buffers: Leave device in sane state on error · 1250186a
    Lars-Peter Clausen authored
    
    
    Currently when something goes wrong at some step when disabling the buffers
    we immediately abort. This has the effect that the enable/disable calls are
    no longer balanced. So make sure that even if one step in the disable
    sequence fails the other steps are still executed.
    
    The other issue is that when either enable or disable fails buffers that
    were active at that time stay active while the device itself is disabled.
    This leaves things in a inconsistent state and can cause unbalanced
    enable/disable calls. Furthermore when enable fails we restore the old scan
    mask, but still keeps things disabled.
    
    Given that verification of the configuration was performed earlier and it
    is valid at the point where we try to enable/disable the most likely reason
    of failure is a communication failure with the device or maybe a
    out-of-memory situation. There is not really a good recovery strategy in
    such a case, so it makes sense to leave the device disabled, but we should
    still leave it in a consistent state.
    
    What the patch does if disable/enable fails is to deactivate all buffers
    and make sure that the device will be in the same state as if all buffers
    had been manually disabled.
    
    Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
    1250186a