From 9176d156ca8d931bec0bf5fa3239524d94da866a Mon Sep 17 00:00:00 2001 From: Okash Khawaja Date: Tue, 14 Mar 2017 13:41:52 +0000 Subject: [PATCH] staging: speakup: spk_serial_out and spk_wait_for_xmitr to take synth arg These two functions are always called from a context where spk_synth instance is available. They also use the spk_synth instance but instead of taking it as an argument, they rely on a global spk_synth instance inside synth.c which points to the same synth as the one being passed in as argument. Signed-off-by: Okash Khawaja Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/serialio.c | 14 +++++++------- drivers/staging/speakup/speakup_apollo.c | 6 +++--- drivers/staging/speakup/speakup_audptr.c | 2 +- drivers/staging/speakup/speakup_decext.c | 8 ++++---- drivers/staging/speakup/speakup_dectlk.c | 12 ++++++------ drivers/staging/speakup/spk_priv.h | 4 ++-- drivers/staging/speakup/synth.c | 12 ++++++------ 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/staging/speakup/serialio.c b/drivers/staging/speakup/serialio.c index 657a48b6f8d3..f51ab5c25b49 100644 --- a/drivers/staging/speakup/serialio.c +++ b/drivers/staging/speakup/serialio.c @@ -143,14 +143,14 @@ void spk_stop_serial_interrupt(void) free_irq(serstate->irq, (void *)synth_readbuf_handler); } -int spk_wait_for_xmitr(void) +int spk_wait_for_xmitr(struct spk_synth *in_synth) { int tmout = SPK_XMITR_TIMEOUT; - if ((synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) { + if ((in_synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) { pr_warn("%s: too many timeouts, deactivating speakup\n", - synth->long_name); - synth->alive = 0; + in_synth->long_name); + in_synth->alive = 0; /* No synth any more, so nobody will restart TTYs, and we thus * need to do it ourselves. Now that there is no synth we can * let application flood anyway @@ -161,7 +161,7 @@ int spk_wait_for_xmitr(void) } while (spk_serial_tx_busy()) { if (--tmout == 0) { - pr_warn("%s: timed out (tx busy)\n", synth->long_name); + pr_warn("%s: timed out (tx busy)\n", in_synth->long_name); timeouts++; return 0; } @@ -206,9 +206,9 @@ unsigned char spk_serial_in_nowait(void) } EXPORT_SYMBOL_GPL(spk_serial_in_nowait); -int spk_serial_out(const char ch) +int spk_serial_out(struct spk_synth *in_synth, const char ch) { - if (synth->alive && spk_wait_for_xmitr()) { + if (in_synth->alive && spk_wait_for_xmitr(in_synth)) { outb_p(ch, speakup_info.port_tts); return 1; } diff --git a/drivers/staging/speakup/speakup_apollo.c b/drivers/staging/speakup/speakup_apollo.c index 93969688e754..07149b0b03bb 100644 --- a/drivers/staging/speakup/speakup_apollo.c +++ b/drivers/staging/speakup/speakup_apollo.c @@ -169,7 +169,7 @@ static void do_catch_up(struct spk_synth *synth) set_current_state(TASK_INTERRUPTIBLE); full_time_val = full_time->u.n.value; spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (!spk_serial_out(ch)) { + if (!spk_serial_out(synth, ch)) { outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR); outb(UART_MCR_DTR | UART_MCR_RTS, speakup_info.port_tts + UART_MCR); @@ -182,7 +182,7 @@ static void do_catch_up(struct spk_synth *synth) full_time_val = full_time->u.n.value; delay_time_val = delay_time->u.n.value; spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (spk_serial_out(synth->procspeech)) + if (spk_serial_out(synth, synth->procspeech)) schedule_timeout(msecs_to_jiffies (delay_time_val)); else @@ -195,7 +195,7 @@ static void do_catch_up(struct spk_synth *synth) synth_buffer_getc(); spin_unlock_irqrestore(&speakup_info.spinlock, flags); } - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); } module_param_named(ser, synth_apollo.ser, int, 0444); diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c index e696b87bf515..31dcd4ec25c6 100644 --- a/drivers/staging/speakup/speakup_audptr.c +++ b/drivers/staging/speakup/speakup_audptr.c @@ -135,7 +135,7 @@ static void synth_flush(struct spk_synth *synth) udelay(1); } outb(SYNTH_CLEAR, speakup_info.port_tts); - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); } static void synth_version(struct spk_synth *synth) diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c index 34e03c6b1ae5..8ac833e82580 100644 --- a/drivers/staging/speakup/speakup_decext.c +++ b/drivers/staging/speakup/speakup_decext.c @@ -186,7 +186,7 @@ static void do_catch_up(struct spk_synth *synth) spin_unlock_irqrestore(&speakup_info.spinlock, flags); if (ch == '\n') ch = 0x0D; - if (synth_full() || !spk_serial_out(ch)) { + if (synth_full() || !spk_serial_out(synth, ch)) { schedule_timeout(msecs_to_jiffies(delay_time_val)); continue; } @@ -200,10 +200,10 @@ static void do_catch_up(struct spk_synth *synth) in_escape = 0; else if (ch <= SPACE) { if (!in_escape && strchr(",.!?;:", last)) - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); if (time_after_eq(jiffies, jiff_max)) { if (!in_escape) - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); spin_lock_irqsave(&speakup_info.spinlock, flags); jiffy_delta_val = jiffy_delta->u.n.value; @@ -218,7 +218,7 @@ static void do_catch_up(struct spk_synth *synth) last = ch; } if (!in_escape) - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); } static void synth_flush(struct spk_synth *synth) diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c index e0f2d6121890..8cdf197d6800 100644 --- a/drivers/staging/speakup/speakup_dectlk.c +++ b/drivers/staging/speakup/speakup_dectlk.c @@ -251,7 +251,7 @@ static void do_catch_up(struct spk_synth *synth) spin_unlock_irqrestore(&speakup_info.spinlock, flags); if (ch == '\n') ch = 0x0D; - if (synth_full_val || !spk_serial_out(ch)) { + if (synth_full_val || !spk_serial_out(synth, ch)) { schedule_timeout(msecs_to_jiffies(delay_time_val)); continue; } @@ -265,10 +265,10 @@ static void do_catch_up(struct spk_synth *synth) in_escape = 0; else if (ch <= SPACE) { if (!in_escape && strchr(",.!?;:", last)) - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); if (time_after_eq(jiffies, jiff_max)) { if (!in_escape) - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); spin_lock_irqsave(&speakup_info.spinlock, flags); jiffy_delta_val = jiffy_delta->u.n.value; @@ -283,17 +283,17 @@ static void do_catch_up(struct spk_synth *synth) last = ch; } if (!in_escape) - spk_serial_out(PROCSPEECH); + spk_serial_out(synth, PROCSPEECH); } static void synth_flush(struct spk_synth *synth) { if (in_escape) /* if in command output ']' so we don't get an error */ - spk_serial_out(']'); + spk_serial_out(synth, ']'); in_escape = 0; is_flushing = 1; - spk_serial_out(SYNTH_CLEAR); + spk_serial_out(synth, SYNTH_CLEAR); } module_param_named(ser, synth_dectlk.ser, int, 0444); diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h index b8015d817cdd..170599c48155 100644 --- a/drivers/staging/speakup/spk_priv.h +++ b/drivers/staging/speakup/spk_priv.h @@ -42,10 +42,10 @@ const struct old_serial_port *spk_serial_init(int index); void spk_stop_serial_interrupt(void); -int spk_wait_for_xmitr(void); +int spk_wait_for_xmitr(struct spk_synth *in_synth); unsigned char spk_serial_in(void); unsigned char spk_serial_in_nowait(void); -int spk_serial_out(const char ch); +int spk_serial_out(struct spk_synth *in_synth, const char ch); void spk_serial_release(void); void synth_buffer_skip_nonlatin1(void); diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 4d59917a2961..41967c9e5003 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -120,7 +120,7 @@ void spk_do_catch_up(struct spk_synth *synth) spin_unlock_irqrestore(&speakup_info.spinlock, flags); if (ch == '\n') ch = synth->procspeech; - if (!spk_serial_out(ch)) { + if (!spk_serial_out(synth, ch)) { schedule_timeout(msecs_to_jiffies(full_time_val)); continue; } @@ -130,7 +130,7 @@ void spk_do_catch_up(struct spk_synth *synth) delay_time_val = delay_time->u.n.value; full_time_val = full_time->u.n.value; spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (spk_serial_out(synth->procspeech)) + if (spk_serial_out(synth, synth->procspeech)) schedule_timeout( msecs_to_jiffies(delay_time_val)); else @@ -143,7 +143,7 @@ void spk_do_catch_up(struct spk_synth *synth) synth_buffer_getc(); spin_unlock_irqrestore(&speakup_info.spinlock, flags); } - spk_serial_out(synth->procspeech); + spk_serial_out(synth, synth->procspeech); } EXPORT_SYMBOL_GPL(spk_do_catch_up); @@ -154,7 +154,7 @@ const char *spk_synth_immediate(struct spk_synth *synth, const char *buff) while ((ch = *buff)) { if (ch == '\n') ch = synth->procspeech; - if (spk_wait_for_xmitr()) + if (spk_wait_for_xmitr(synth)) outb(ch, speakup_info.port_tts); else return buff; @@ -166,7 +166,7 @@ EXPORT_SYMBOL_GPL(spk_synth_immediate); void spk_synth_flush(struct spk_synth *synth) { - spk_serial_out(synth->clear); + spk_serial_out(synth, synth->clear); } EXPORT_SYMBOL_GPL(spk_synth_flush); @@ -181,7 +181,7 @@ int spk_synth_is_alive_restart(struct spk_synth *synth) { if (synth->alive) return 1; - if (spk_wait_for_xmitr() > 0) { + if (spk_wait_for_xmitr(synth) > 0) { /* restart */ synth->alive = 1; synth_printf("%s", synth->init); -- 2.45.2