From ca693dcd5c02645063210e2352ff4909d9ddc7e9 Mon Sep 17 00:00:00 2001 From: Okash Khawaja Date: Sat, 29 Apr 2017 20:52:58 +0100 Subject: staging: speakup: make input functionality swappable This moves functions which take input from external synth, into struct spk_io_ops. The calling code then uses serial implementation of those methods through spk_io_ops. That way we can add a parallel TTY-based implementation and simply replace serial with TTY. That is what the next patch in this series does. speakup_decext.c has get_last_char function which reads the most recent available character from the synth. This patch changes that by defining read_buff_add callback method of spk_syth and letting that update the last_char global character read from the synth. read_buff_add is called from ISR, so there is a possibility for last_char to be stale. Therefore it is marked as volatile. It also pulls a repeated get_index implementation into synth.c, to be used as a utility function. Signed-off-by: Okash Khawaja Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/serialio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/staging/speakup/serialio.c') diff --git a/drivers/staging/speakup/serialio.c b/drivers/staging/speakup/serialio.c index ba060d0ceca2..5f96b5ba7acb 100644 --- a/drivers/staging/speakup/serialio.c +++ b/drivers/staging/speakup/serialio.c @@ -28,11 +28,15 @@ static int timeouts; static int spk_serial_out(struct spk_synth *in_synth, const char ch); static void spk_serial_send_xchar(char ch); static void spk_serial_tiocmset(unsigned int set, unsigned int clear); +static unsigned char spk_serial_in(void); +static unsigned char spk_serial_in_nowait(void); struct spk_io_ops spk_serial_io_ops = { .synth_out = spk_serial_out, .send_xchar = spk_serial_send_xchar, .tiocmset = spk_serial_tiocmset, + .synth_in = spk_serial_in, + .synth_in_nowait = spk_serial_in_nowait, }; EXPORT_SYMBOL_GPL(spk_serial_io_ops); @@ -240,7 +244,7 @@ int spk_wait_for_xmitr(struct spk_synth *in_synth) return 1; } -unsigned char spk_serial_in(void) +static unsigned char spk_serial_in(void) { int tmout = SPK_SERIAL_TIMEOUT; @@ -253,9 +257,8 @@ unsigned char spk_serial_in(void) } return inb_p(speakup_info.port_tts + UART_RX); } -EXPORT_SYMBOL_GPL(spk_serial_in); -unsigned char spk_serial_in_nowait(void) +static unsigned char spk_serial_in_nowait(void) { unsigned char lsr; @@ -264,7 +267,6 @@ unsigned char spk_serial_in_nowait(void) return 0; return inb_p(speakup_info.port_tts + UART_RX); } -EXPORT_SYMBOL_GPL(spk_serial_in_nowait); static int spk_serial_out(struct spk_synth *in_synth, const char ch) { -- cgit v1.2.3-59-g8ed1b