• Narcisa Ana Maria Vasile's avatar
    staging: iio: ad5933: Protect DIRECT mode using claim/release helpers · 984fb244
    Narcisa Ana Maria Vasile authored
    This device operates in DIRECT_MODE and BUFFER_HARDWARE mode.
    Replace usages of iio_dev->mlock with iio_device_{claim|release}_direct_mode()
    helper functions to guarantee DIRECT mode and consequently protect
    BUFFER mode too.
    
    Add and use a device private lock to protect against conflicting access of the
    state data.
    This helps with IIO subsystem redefining iio_dev->mlock to be used by
    the IIO core only for protecting device operating mode changes.
    ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.
    
    Protect changing of attributes inside ad5933_store(). Attributes
    can no longer be changed while in buffered mode.
    
    Remove lock from ad5933_work() because buffer mode should be enabled
    when we reach this, and claiming DIRECT mode in all the other places
    should protect it.
    Signed-off-by: default avatarNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
    Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
    984fb244
ad5933.c 19.7 KB