• Peter Hurley's avatar
    tty: Simplify tty buffer/ldisc interface with helper function · da261e7f
    Peter Hurley authored
    Ldisc interface functions must be called with interrupts enabled.
    Separating the ldisc calls into a helper function simplies the
    eventual removal of the spinlock.
    
    Note that access to the buf->head ptr outside the spinlock is
    safe here because;
    * __tty_buffer_flush() is prevented from running while buffer work
      performs i/o,
    * tty_buffer_find() only assigns buf->head if the flip buffer list
      is empty (which is never the case in flush_to_ldisc() since at
      least one buffer is always left in the list after use)
    Access to the read index outside the spinlock is safe here for the
    same reasons.
    
    Update the buffer's read index _after_ the data has been received
    by the ldisc.
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    da261e7f
tty_buffer.c 14.3 KB