[patch 6/6] staging: speakup: Migrate acntsa, bns, dectlk and txprt to ttyio

Okash Khawaja okash.khawaja at gmail.com
Sat Feb 25 14:30:31 EST 2017


This changes the above four synths to TTY-based comms. They were chosen as a
first pass because their serial comms are straightforward, i.e. they don't use
serial input and don't do internal port knocking. This also moves
spk_serial_synth_probe() into serialio.c in order to segregate those functions
which directly use serial comms into serialio.c.

Signed-off-by: Okash Khawaja <okash.khawaja at gmail.com>

Index: linux-stable/drivers/staging/speakup/speakup_acntsa.c
===================================================================
--- linux-stable.orig/drivers/staging/speakup/speakup_acntsa.c
+++ linux-stable/drivers/staging/speakup/speakup_acntsa.c
@@ -100,9 +100,9 @@
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
 	.probe = synth_probe,
-	.release = spk_serial_release,
-	.serial_out = spk_serial_out,
-	.synth_immediate = spk_synth_immediate,
+	.release = spk_ttyio_release,
+	.serial_out = spk_ttyio_out,
+	.synth_immediate = spk_ttyio_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -125,9 +125,9 @@
 {
 	int failed;
 
-	failed = spk_serial_synth_probe(synth);
+	failed = spk_ttyio_synth_probe(synth);
 	if (failed == 0) {
-		spk_synth_immediate(synth, "\033=R\r");
+		synth->synth_immediate(synth, "\033=R\r");
 		mdelay(100);
 	}
 	synth->alive = !failed;
Index: linux-stable/drivers/staging/speakup/speakup_bns.c
===================================================================
--- linux-stable.orig/drivers/staging/speakup/speakup_bns.c
+++ linux-stable/drivers/staging/speakup/speakup_bns.c
@@ -96,10 +96,10 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
-	.probe = spk_serial_synth_probe,
-	.release = spk_serial_release,
-	.serial_out = spk_serial_out,
-	.synth_immediate = spk_synth_immediate,
+	.probe = spk_ttyio_synth_probe,
+	.release = spk_ttyio_release,
+	.serial_out = spk_ttyio_out,
+	.synth_immediate = spk_ttyio_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-stable/drivers/staging/speakup/speakup_txprt.c
===================================================================
--- linux-stable.orig/drivers/staging/speakup/speakup_txprt.c
+++ linux-stable/drivers/staging/speakup/speakup_txprt.c
@@ -95,10 +95,10 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
-	.probe = spk_serial_synth_probe,
-	.release = spk_serial_release,
-	.serial_out = spk_serial_out,
-	.synth_immediate = spk_synth_immediate,
+	.probe = spk_ttyio_synth_probe,
+	.release = spk_ttyio_release,
+	.serial_out = spk_ttyio_out,
+	.synth_immediate = spk_ttyio_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-stable/drivers/staging/speakup/speakup_dectlk.c
===================================================================
--- linux-stable.orig/drivers/staging/speakup/speakup_dectlk.c
+++ linux-stable/drivers/staging/speakup/speakup_dectlk.c
@@ -130,10 +130,10 @@
 	.vars = vars,
 	.default_pitch = ap_defaults,
 	.default_vol = g5_defaults,
-	.probe = spk_serial_synth_probe,
-	.serial_out = spk_serial_out,
-	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.probe = spk_ttyio_synth_probe,
+	.serial_out = spk_ttyio_out,
+	.release = spk_ttyio_release,
+	.synth_immediate = spk_ttyio_immediate,
 	.catch_up = do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-stable/drivers/staging/speakup/serialio.c
===================================================================
--- linux-stable.orig/drivers/staging/speakup/serialio.c
+++ linux-stable/drivers/staging/speakup/serialio.c
@@ -181,6 +181,36 @@
 	return 1;
 }
 
+int spk_serial_synth_probe(struct spk_synth *synth)
+{
+	const struct old_serial_port *ser;
+	int failed = 0;
+
+	if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) {
+		ser = spk_serial_init(synth->ser);
+		if (ser == NULL) {
+			failed = -1;
+		} else {
+			outb_p(0, ser->port);
+			mdelay(1);
+			outb_p('\r', ser->port);
+		}
+	} else {
+		failed = -1;
+		pr_warn("ttyS%i is an invalid port\n", synth->ser);
+	}
+	if (failed) {
+		pr_info("%s: not found\n", synth->long_name);
+		return -ENODEV;
+	}
+	pr_info("%s: ttyS%i, Driver Version %s\n",
+		synth->long_name, synth->ser, synth->version);
+	synth->alive = 1;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(spk_serial_synth_probe);
+
+
 unsigned char spk_serial_in(void)
 {
 	int tmout = SPK_SERIAL_TIMEOUT;
Index: linux-stable/drivers/staging/speakup/synth.c
===================================================================
--- linux-stable.orig/drivers/staging/speakup/synth.c
+++ linux-stable/drivers/staging/speakup/synth.c
@@ -44,35 +44,6 @@
 
 static int do_synth_init(struct spk_synth *in_synth);
 
-int spk_serial_synth_probe(struct spk_synth *synth)
-{
-	const struct old_serial_port *ser;
-	int failed = 0;
-
-	if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) {
-		ser = spk_serial_init(synth->ser);
-		if (ser == NULL) {
-			failed = -1;
-		} else {
-			outb_p(0, ser->port);
-			mdelay(1);
-			outb_p('\r', ser->port);
-		}
-	} else {
-		failed = -1;
-		pr_warn("ttyS%i is an invalid port\n", synth->ser);
-	}
-	if (failed) {
-		pr_info("%s: not found\n", synth->long_name);
-		return -ENODEV;
-	}
-	pr_info("%s: ttyS%i, Driver Version %s\n",
-		synth->long_name, synth->ser, synth->version);
-	synth->alive = 1;
-	return 0;
-}
-EXPORT_SYMBOL_GPL(spk_serial_synth_probe);
-
 /*
  * Main loop of the progression thread: keep eating from the buffer
  * and push to the serial port, waiting as needed


More information about the Speakup mailing list