• Okash Khawaja's avatar
    staging: speakup: refactor to use existing code in vt · 41f13084
    Okash Khawaja authored
    This patch replaces speakup's implementations with calls to functions
    in tty/vt/selection.c. Those functions are:
    
    cancel_selection()
    set_selection_kernel()
    paste_selection()
    
    Currently setting selection is done in interrupt context. However,
    set_selection_kernel() can sleep - for instance, it requires console_lock
    which can sleep. Therefore we offload that work to a work_struct thread,
    following the same pattern which was already set for paste_selection().
    When setting selection, we also get a reference to tty and make sure to
    release the reference before returning.
    
    struct speakup_paste_work has been renamed to the more generic
    speakup_selection_work because it is now used for both pasting as well
    as setting selection. When paste work is cancelled, the code wasn't
    setting tty to NULL. This patch also fixes that by setting tty to NULL
    so that in case of failure we don't get EBUSY forever.
    Signed-off-by: default avatarOkash Khawaja <okash.khawaja@gmail.com>
    Reviewed-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
    Tested-by: default avatarGregory Nowak <greg@gregn.net>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    41f13084
main.c 58.5 KB