staging: speakup: refactor to use existing code in vt
authorOkash Khawaja <okash.khawaja@gmail.com>
Wed, 17 Apr 2019 12:21:14 +0000 (13:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Apr 2019 13:09:10 +0000 (15:09 +0200)
commit41f13084506aba1d50412026764cf7ad460fd9c2
treece255d8992943c07da29d434b5f77747178af60c
parent496124e5e16e4974c71404bc9ddaa016156f8cb0
staging: speakup: refactor to use existing code in vt

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: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Tested-by: Gregory Nowak <greg@gregn.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/main.c
drivers/staging/speakup/selection.c
drivers/staging/speakup/speakup.h