From 1e441594e509c35a222e397d224de17cee103740 Mon Sep 17 00:00:00 2001 From: Okash Khawaja Date: Tue, 14 Mar 2017 13:41:53 +0000 Subject: staging: speakup: add spk_io_ops struct to spk_synth This patch adds spk_io_ops struct which contain those methods whose job is to communicate with synth device. Currently, all comms with external synth device use raw serial i/o. The idea is to group all methods which do the actual communication with external device into this new struct. Then migrating a serial-based synth over to an alternative to raw serial i/o will mean swapping serial spk_io_ops instance with the io_ops instance of the new method, making the migration simpler. At the moment, this struct only contains one method, synth_out but more will be added in future when migrating synths which require input functionality. Also at the moment, synth_out method has one implementation which uses serial i/o. Plan is to add an alternative. Signed-off-by: Okash Khawaja Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/speakup_dectlk.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/staging/speakup/speakup_dectlk.c') diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c index 8cdf197d6800..f36d579015f0 100644 --- a/drivers/staging/speakup/speakup_dectlk.c +++ b/drivers/staging/speakup/speakup_dectlk.c @@ -130,6 +130,7 @@ static struct spk_synth synth_dectlk = { .vars = vars, .default_pitch = ap_defaults, .default_vol = g5_defaults, + .io_ops = &spk_serial_io_ops, .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, @@ -251,7 +252,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(synth, ch)) { + if (synth_full_val || !synth->io_ops->synth_out(synth, ch)) { schedule_timeout(msecs_to_jiffies(delay_time_val)); continue; } @@ -265,10 +266,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(synth, PROCSPEECH); + synth->io_ops->synth_out(synth, PROCSPEECH); if (time_after_eq(jiffies, jiff_max)) { if (!in_escape) - spk_serial_out(synth, PROCSPEECH); + synth->io_ops->synth_out(synth, PROCSPEECH); spin_lock_irqsave(&speakup_info.spinlock, flags); jiffy_delta_val = jiffy_delta->u.n.value; @@ -283,17 +284,17 @@ static void do_catch_up(struct spk_synth *synth) last = ch; } if (!in_escape) - spk_serial_out(synth, PROCSPEECH); + synth->io_ops->synth_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(synth, ']'); + synth->io_ops->synth_out(synth, ']'); in_escape = 0; is_flushing = 1; - spk_serial_out(synth, SYNTH_CLEAR); + synth->io_ops->synth_out(synth, SYNTH_CLEAR); } module_param_named(ser, synth_dectlk.ser, int, 0444); -- cgit v1.2.3