Skip to content
  • Shreeya Patel's avatar
    Staging: iio: ade7758: Expand buf_lock to cover both buffer and state protection · 0bd39455
    Shreeya Patel authored
    
    
    iio_dev->mlock is to be used only by the IIO core for protecting
    device mode changes between INDIO_DIRECT and INDIO_BUFFER.
    
    This patch replaces the use of mlock with the already established
    buf_lock mutex.
    
    Introducing 'unlocked' forms of read and write registers. The
    read/write frequency functions now require buf_lock to be held.
    That's not obvious so avoid this but moving the locking inside
    the functions where it is then clear that they are taking the
    unlocked forms of the register read/write.
    
    It isn't readily apparent that write frequency function requires
    the locks to be taken, so move it inside the function to where it
    is required to protect.
    
    Also, the read raw does not require iio_dev->mlock for
    reads. It can run concurrently as resource protection is handled
    by buf_lock in read register.
    
    Signed-off-by: default avatarShreeya Patel <shreeya.patel23498@gmail.com>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    0bd39455