OSDN Git Service

staging: speakup: add send_xchar, tiocmset and input functionality for tty
authorOkash Khawaja <okash.khawaja@gmail.com>
Mon, 15 May 2017 17:45:35 +0000 (18:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 May 2017 12:19:41 +0000 (14:19 +0200)
commit6b9ad1c742bf227b1005a41d8baa315b747e3e8d
tree041dd958cc850297841057194d5f5b85232ba131
parentbd697e299609b94a19287e14a3f7926bb44ffc26
staging: speakup: add send_xchar, tiocmset and input functionality for tty

This patch adds further TTY-based functionality, specifically implementation
of send_xchar and tiocmset methods, and input. send_xchar and tiocmset
methods simply delegate to corresponding TTY operations.

For input, it implements the receive_buf2 callback in tty_ldisc_ops of
speakup's ldisc. If a synth defines read_buff_add method then receive_buf2
simply delegates to that and returns.

For spk_ttyio_in, the data is passed from receive_buf2 thread to
spk_ttyio_in thread through spk_ldisc_data structure. It has following
members:

- char buf: represents data received
- struct semaphore sem: used to signal to spk_ttyio_in thread that data
is available to be read without having to busy wait
- bool buf_free: this is used in comination with mb() calls to syncronise
the two threads over buf

receive_buf2 only writes to buf if buf_free is true. The check for buf_free
and writing to buf are separated by mb() to ensure that spk_ttyio_in has read
buf before receive_buf2 writes to it. After writing, it ups the semaphore to
signal to spk_ttyio_in that there is now data to read.

spk_ttyio_in waits for data to read by downing the semaphore. Thus when
signalled by receive_buf2 thread above, it reads from buf and sets buf_free
to true. These two operations are separated by mb() to ensure that
receive_buf2 thread finds buf_free to be true only after buf has been read.
After that spk_ttyio_in calls tty_schedule_flip for subsequent data to come
in through receive_buf2.

Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/serialio.h
drivers/staging/speakup/spk_priv.h
drivers/staging/speakup/spk_ttyio.c