speakup: add the missing synth parameter to all io functions
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 26 Jan 2021 22:21:44 +0000 (23:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 12:12:04 +0000 (13:12 +0100)
So that we can avoid the spk_ttyio_synth global variable in the next
commit.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Link: https://lore.kernel.org/r/20210126222147.3848175-2-samuel.thibault@ens-lyon.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 files changed:
drivers/accessibility/speakup/serialio.c
drivers/accessibility/speakup/speakup_acntpc.c
drivers/accessibility/speakup/speakup_apollo.c
drivers/accessibility/speakup/speakup_audptr.c
drivers/accessibility/speakup/speakup_decext.c
drivers/accessibility/speakup/speakup_decpc.c
drivers/accessibility/speakup/speakup_dectlk.c
drivers/accessibility/speakup/speakup_dtlk.c
drivers/accessibility/speakup/speakup_keypc.c
drivers/accessibility/speakup/speakup_ltlk.c
drivers/accessibility/speakup/speakup_soft.c
drivers/accessibility/speakup/speakup_spkout.c
drivers/accessibility/speakup/spk_priv.h
drivers/accessibility/speakup/spk_ttyio.c
drivers/accessibility/speakup/spk_types.h
drivers/accessibility/speakup/synth.c

index 403b01d66367e69651afeffa60dfc155a25f1aac..53580bdc5baa1be549edeea82b577f878a16ad92 100644 (file)
@@ -27,11 +27,11 @@ static const struct old_serial_port *serstate;
 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);
-static void spk_serial_flush_buffer(void);
+static void spk_serial_send_xchar(struct spk_synth *in_synth, char ch);
+static void spk_serial_tiocmset(struct spk_synth *in_synth, unsigned int set, unsigned int clear);
+static unsigned char spk_serial_in(struct spk_synth *in_synth);
+static unsigned char spk_serial_in_nowait(struct spk_synth *in_synth);
+static void spk_serial_flush_buffer(struct spk_synth *in_synth);
 static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_serial_io_ops = {
@@ -150,7 +150,7 @@ static void start_serial_interrupt(int irq)
        outb(1, speakup_info.port_tts + UART_FCR);      /* Turn FIFO On */
 }
 
-static void spk_serial_send_xchar(char ch)
+static void spk_serial_send_xchar(struct spk_synth *synth, char ch)
 {
        int timeout = SPK_XMITR_TIMEOUT;
 
@@ -162,7 +162,7 @@ static void spk_serial_send_xchar(char ch)
        outb(ch, speakup_info.port_tts);
 }
 
-static void spk_serial_tiocmset(unsigned int set, unsigned int clear)
+static void spk_serial_tiocmset(struct spk_synth *in_synth, unsigned int set, unsigned int clear)
 {
        int old = inb(speakup_info.port_tts + UART_MCR);
 
@@ -251,7 +251,7 @@ static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth)
        return 1;
 }
 
-static unsigned char spk_serial_in(void)
+static unsigned char spk_serial_in(struct spk_synth *in_synth)
 {
        int tmout = SPK_SERIAL_TIMEOUT;
 
@@ -265,7 +265,7 @@ static unsigned char spk_serial_in(void)
        return inb_p(speakup_info.port_tts + UART_RX);
 }
 
-static unsigned char spk_serial_in_nowait(void)
+static unsigned char spk_serial_in_nowait(struct spk_synth *in_synth)
 {
        unsigned char lsr;
 
@@ -275,7 +275,7 @@ static unsigned char spk_serial_in_nowait(void)
        return inb_p(speakup_info.port_tts + UART_RX);
 }
 
-static void spk_serial_flush_buffer(void)
+static void spk_serial_flush_buffer(struct spk_synth *in_synth)
 {
        /* TODO: flush the UART 16550 buffer */
 }
@@ -307,7 +307,7 @@ const char *spk_serial_synth_immediate(struct spk_synth *synth,
 }
 EXPORT_SYMBOL_GPL(spk_serial_synth_immediate);
 
-void spk_serial_release(void)
+void spk_serial_release(struct spk_synth *synth)
 {
        spk_stop_serial_interrupt();
        if (speakup_info.port_tts == 0)
index c94328a5bd4ac928d21b8204b1719db3a5d56ddd..c1ec087dca1307f8934942ac4a8f13103ab746f3 100644 (file)
@@ -25,7 +25,7 @@
 #define PROCSPEECH '\r'
 
 static int synth_probe(struct spk_synth *synth);
-static void accent_release(void);
+static void accent_release(struct spk_synth *synth);
 static const char *synth_immediate(struct spk_synth *synth, const char *buf);
 static void do_catch_up(struct spk_synth *synth);
 static void synth_flush(struct spk_synth *synth);
@@ -294,7 +294,7 @@ static int synth_probe(struct spk_synth *synth)
        return 0;
 }
 
-static void accent_release(void)
+static void accent_release(struct spk_synth *synth)
 {
        spk_stop_serial_interrupt();
        if (speakup_info.port_tts)
index 0877b4044c28d079ceb56cb84dd09e852c73ce6b..cd63581b2e99edec7b7020e578bc8f3c3164cfb6 100644 (file)
@@ -163,8 +163,8 @@ static void do_catch_up(struct spk_synth *synth)
                full_time_val = full_time->u.n.value;
                spin_unlock_irqrestore(&speakup_info.spinlock, flags);
                if (!synth->io_ops->synth_out(synth, ch)) {
-                       synth->io_ops->tiocmset(0, UART_MCR_RTS);
-                       synth->io_ops->tiocmset(UART_MCR_RTS, 0);
+                       synth->io_ops->tiocmset(synth, 0, UART_MCR_RTS);
+                       synth->io_ops->tiocmset(synth, UART_MCR_RTS, 0);
                        schedule_timeout(msecs_to_jiffies(full_time_val));
                        continue;
                }
index e6a6a9665d8fc8ae79e70151bb8d48415a56a05f..e89fd72579e609937821e0f43399a4034e5d49c0 100644 (file)
@@ -119,8 +119,8 @@ static struct spk_synth synth_audptr = {
 
 static void synth_flush(struct spk_synth *synth)
 {
-       synth->io_ops->flush_buffer();
-       synth->io_ops->send_xchar(SYNTH_CLEAR);
+       synth->io_ops->flush_buffer(synth);
+       synth->io_ops->send_xchar(synth, SYNTH_CLEAR);
        synth->io_ops->synth_out(synth, PROCSPEECH);
 }
 
@@ -130,11 +130,11 @@ static void synth_version(struct spk_synth *synth)
        char synth_id[40] = "";
 
        synth->synth_immediate(synth, "\x05[Q]");
-       synth_id[test] = synth->io_ops->synth_in();
+       synth_id[test] = synth->io_ops->synth_in(synth);
        if (synth_id[test] == 'A') {
                do {
                        /* read version string from synth */
-                       synth_id[++test] = synth->io_ops->synth_in();
+                       synth_id[++test] = synth->io_ops->synth_in(synth);
                } while (synth_id[test] != '\n' && test < 32);
                synth_id[++test] = 0x00;
        }
index 7408eb29cf3893fc64f0e07bced6103f38229d6c..092cfd08a9e18d8a274d7e4d14ea5d0a47b1afec 100644 (file)
@@ -218,7 +218,7 @@ static void do_catch_up(struct spk_synth *synth)
 static void synth_flush(struct spk_synth *synth)
 {
        in_escape = 0;
-       synth->io_ops->flush_buffer();
+       synth->io_ops->flush_buffer(synth);
        synth->synth_immediate(synth, "\033P;10z\033\\");
 }
 
index 96f24c848cc56329c68e897613ebc9bc8319f0d0..dec314dee214f0ccdd63f0a6f94f615f892fcbdc 100644 (file)
@@ -125,7 +125,7 @@ enum {      PRIMARY_DIC     = 0, USER_DIC, COMMAND_DIC, ABBREV_DIC };
 #define SYNTH_IO_EXTENT 8
 
 static int synth_probe(struct spk_synth *synth);
-static void dtpc_release(void);
+static void dtpc_release(struct spk_synth *synth);
 static const char *synth_immediate(struct spk_synth *synth, const char *buf);
 static void do_catch_up(struct spk_synth *synth);
 static void synth_flush(struct spk_synth *synth);
@@ -474,7 +474,7 @@ static int synth_probe(struct spk_synth *synth)
        return 0;
 }
 
-static void dtpc_release(void)
+static void dtpc_release(struct spk_synth *synth)
 {
        spk_stop_serial_interrupt();
        if (speakup_info.port_tts)
index ab6d61e80b1cbac8d66951190a89d5f6c99ee7f7..d75de36e96c353dce58e18bcd46b11ea5293413f 100644 (file)
@@ -289,7 +289,7 @@ static void synth_flush(struct spk_synth *synth)
                synth->io_ops->synth_out(synth, ']');
        in_escape = 0;
        is_flushing = 1;
-       synth->io_ops->flush_buffer();
+       synth->io_ops->flush_buffer(synth);
        synth->io_ops->synth_out(synth, SYNTH_CLEAR);
 }
 
index dbebed0eeeec519cf53bf7e942aa89aa37796994..92838d3ae9eb8d3462f8f33ee0525b14fd7d7e63 100644 (file)
@@ -24,7 +24,7 @@
 #define PROCSPEECH 0x00
 
 static int synth_probe(struct spk_synth *synth);
-static void dtlk_release(void);
+static void dtlk_release(struct spk_synth *synth);
 static const char *synth_immediate(struct spk_synth *synth, const char *buf);
 static void do_catch_up(struct spk_synth *synth);
 static void synth_flush(struct spk_synth *synth);
@@ -365,7 +365,7 @@ static int synth_probe(struct spk_synth *synth)
        return 0;
 }
 
-static void dtlk_release(void)
+static void dtlk_release(struct spk_synth *synth)
 {
        spk_stop_serial_interrupt();
        if (speakup_info.port_tts)
index 414827e888fcb9fdf8d8bca90ad8f2817d950ec8..311f4aa0be22d6bc62f8e53e36580025ad6ef66a 100644 (file)
@@ -24,7 +24,7 @@
 #define SYNTH_CLEAR 0x03
 
 static int synth_probe(struct spk_synth *synth);
-static void keynote_release(void);
+static void keynote_release(struct spk_synth *synth);
 static const char *synth_immediate(struct spk_synth *synth, const char *buf);
 static void do_catch_up(struct spk_synth *synth);
 static void synth_flush(struct spk_synth *synth);
@@ -295,7 +295,7 @@ static int synth_probe(struct spk_synth *synth)
        return 0;
 }
 
-static void keynote_release(void)
+static void keynote_release(struct spk_synth *synth)
 {
        spk_stop_serial_interrupt();
        if (synth_port)
index 3c59519a871f76248ae400e9f18adc6c720529ba..3e59b387d0c4f92e9c14be441bc1235b350f5b62 100644 (file)
@@ -132,7 +132,7 @@ static void synth_interrogate(struct spk_synth *synth)
 
        synth->synth_immediate(synth, "\x18\x01?");
        for (i = 0; i < 50; i++) {
-               buf[i] = synth->io_ops->synth_in();
+               buf[i] = synth->io_ops->synth_in(synth);
                if (i > 2 && buf[i] == 0x7f)
                        break;
        }
index 9a7029539f35ddfa30d3535c447f9315c2198f9c..c3f97c572fb64f790e90fb011e3c54347786bfde 100644 (file)
@@ -24,7 +24,7 @@
 #define CLEAR_SYNTH 0x18
 
 static int softsynth_probe(struct spk_synth *synth);
-static void softsynth_release(void);
+static void softsynth_release(struct spk_synth *synth);
 static int softsynth_is_alive(struct spk_synth *synth);
 static unsigned char get_index(struct spk_synth *synth);
 
@@ -402,7 +402,7 @@ static int softsynth_probe(struct spk_synth *synth)
        return 0;
 }
 
-static void softsynth_release(void)
+static void softsynth_release(struct spk_synth *synth)
 {
        misc_deregister(&synth_device);
        misc_deregister(&synthu_device);
index 6e933bf1de2e2ecb8396c8a33e02297b27826b8d..bd3d8dc300ff331b4128784a4a66914e3fa6ca7b 100644 (file)
@@ -117,8 +117,8 @@ static struct spk_synth synth_spkout = {
 
 static void synth_flush(struct spk_synth *synth)
 {
-       synth->io_ops->flush_buffer();
-       synth->io_ops->send_xchar(SYNTH_CLEAR);
+       synth->io_ops->flush_buffer(synth);
+       synth->io_ops->send_xchar(synth, SYNTH_CLEAR);
 }
 
 module_param_named(ser, synth_spkout.ser, int, 0444);
index 0f4bcbe5ddb93974fcfbe7979d8cff60f8b0c403..9da57ead17cbe309890640e76899acd54e7e804d 100644 (file)
@@ -34,8 +34,8 @@
 
 const struct old_serial_port *spk_serial_init(int index);
 void spk_stop_serial_interrupt(void);
-void spk_serial_release(void);
-void spk_ttyio_release(void);
+void spk_serial_release(struct spk_synth *synth);
+void spk_ttyio_release(struct spk_synth *synth);
 void spk_ttyio_register_ldisc(void);
 void spk_ttyio_unregister_ldisc(void);
 
index 6284aff434a1af562c53781f2b2684a0b7bf9dbe..d62fb74a5add5d71030a77d69deb3d3282b04e43 100644 (file)
@@ -114,11 +114,11 @@ static struct tty_ldisc_ops spk_ttyio_ldisc_ops = {
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch);
 static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch);
-static void spk_ttyio_send_xchar(char ch);
-static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear);
-static unsigned char spk_ttyio_in(void);
-static unsigned char spk_ttyio_in_nowait(void);
-static void spk_ttyio_flush_buffer(void);
+static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch);
+static void spk_ttyio_tiocmset(struct spk_synth *in_synth, unsigned int set, unsigned int clear);
+static unsigned char spk_ttyio_in(struct spk_synth *in_synth);
+static unsigned char spk_ttyio_in_nowait(struct spk_synth *in_synth);
+static void spk_ttyio_flush_buffer(struct spk_synth *in_synth);
 static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_ttyio_ops = {
@@ -281,7 +281,7 @@ static int check_tty(struct tty_struct *tty)
        return 0;
 }
 
-static void spk_ttyio_send_xchar(char ch)
+static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch)
 {
        mutex_lock(&speakup_tty_mutex);
        if (check_tty(speakup_tty)) {
@@ -294,7 +294,7 @@ static void spk_ttyio_send_xchar(char ch)
        mutex_unlock(&speakup_tty_mutex);
 }
 
-static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear)
+static void spk_ttyio_tiocmset(struct spk_synth *in_synth, unsigned int set, unsigned int clear)
 {
        mutex_lock(&speakup_tty_mutex);
        if (check_tty(speakup_tty)) {
@@ -312,7 +312,7 @@ static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth)
        return 1;
 }
 
-static unsigned char ttyio_in(int timeout)
+static unsigned char ttyio_in(struct spk_synth *in_synth, int timeout)
 {
        struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
        char rv;
@@ -339,19 +339,19 @@ static unsigned char ttyio_in(int timeout)
        return rv;
 }
 
-static unsigned char spk_ttyio_in(void)
+static unsigned char spk_ttyio_in(struct spk_synth *in_synth)
 {
-       return ttyio_in(SPK_SYNTH_TIMEOUT);
+       return ttyio_in(in_synth, SPK_SYNTH_TIMEOUT);
 }
 
-static unsigned char spk_ttyio_in_nowait(void)
+static unsigned char spk_ttyio_in_nowait(struct spk_synth *in_synth)
 {
-       u8 rv = ttyio_in(0);
+       u8 rv = ttyio_in(in_synth, 0);
 
        return (rv == 0xff) ? 0 : rv;
 }
 
-static void spk_ttyio_flush_buffer(void)
+static void spk_ttyio_flush_buffer(struct spk_synth *in_synth)
 {
        mutex_lock(&speakup_tty_mutex);
        if (check_tty(speakup_tty)) {
@@ -379,7 +379,7 @@ int spk_ttyio_synth_probe(struct spk_synth *synth)
 }
 EXPORT_SYMBOL_GPL(spk_ttyio_synth_probe);
 
-void spk_ttyio_release(void)
+void spk_ttyio_release(struct spk_synth *in_synth)
 {
        if (!speakup_tty)
                return;
@@ -395,15 +395,15 @@ void spk_ttyio_release(void)
 }
 EXPORT_SYMBOL_GPL(spk_ttyio_release);
 
-const char *spk_ttyio_synth_immediate(struct spk_synth *synth, const char *buff)
+const char *spk_ttyio_synth_immediate(struct spk_synth *in_synth, const char *buff)
 {
        u_char ch;
 
        while ((ch = *buff)) {
                if (ch == '\n')
-                       ch = synth->procspeech;
+                       ch = in_synth->procspeech;
                if (tty_write_room(speakup_tty) < 1 ||
-                   !synth->io_ops->synth_out(synth, ch))
+                   !in_synth->io_ops->synth_out(in_synth, ch))
                        return buff;
                buff++;
        }
index 91fca3033a45a6a987c282b3d035aa084d0a45e2..2dc17c2e6749b8a82b1798c5aca6aae93c130bbe 100644 (file)
@@ -157,11 +157,11 @@ struct spk_synth;
 struct spk_io_ops {
        int (*synth_out)(struct spk_synth *synth, const char ch);
        int (*synth_out_unicode)(struct spk_synth *synth, u16 ch);
-       void (*send_xchar)(char ch);
-       void (*tiocmset)(unsigned int set, unsigned int clear);
-       unsigned char (*synth_in)(void);
-       unsigned char (*synth_in_nowait)(void);
-       void (*flush_buffer)(void);
+       void (*send_xchar)(struct spk_synth *synth, char ch);
+       void (*tiocmset)(struct spk_synth *synth, unsigned int set, unsigned int clear);
+       unsigned char (*synth_in)(struct spk_synth *synth);
+       unsigned char (*synth_in_nowait)(struct spk_synth *synth);
+       void (*flush_buffer)(struct spk_synth *synth);
        int (*wait_for_xmitr)(struct spk_synth *synth);
 };
 
@@ -188,7 +188,7 @@ struct spk_synth {
        int *default_vol;
        struct spk_io_ops *io_ops;
        int (*probe)(struct spk_synth *synth);
-       void (*release)(void);
+       void (*release)(struct spk_synth *synth);
        const char *(*synth_immediate)(struct spk_synth *synth,
                                       const char *buff);
        void (*catch_up)(struct spk_synth *synth);
index ac47dbac72075d03f7a67c51c8c8ce66c9351f6f..6c14b682da13d335aa764eea53aff36231a5fd13 100644 (file)
@@ -137,14 +137,14 @@ EXPORT_SYMBOL_GPL(spk_do_catch_up_unicode);
 
 void spk_synth_flush(struct spk_synth *synth)
 {
-       synth->io_ops->flush_buffer();
+       synth->io_ops->flush_buffer(synth);
        synth->io_ops->synth_out(synth, synth->clear);
 }
 EXPORT_SYMBOL_GPL(spk_synth_flush);
 
 unsigned char spk_synth_get_index(struct spk_synth *synth)
 {
-       return synth->io_ops->synth_in_nowait();
+       return synth->io_ops->synth_in_nowait(synth);
 }
 EXPORT_SYMBOL_GPL(spk_synth_get_index);
 
@@ -440,7 +440,7 @@ void synth_release(void)
                sysfs_remove_group(speakup_kobj, &synth->attributes);
        for (var = synth->vars; var->var_id != MAXVARS; var++)
                speakup_unregister_var(var->var_id);
-       synth->release();
+       synth->release(synth);
        synth = NULL;
 }