All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 0/4] staging: speakup: refactor to make raw serial i/o swappable
@ 2017-03-14 13:41 Okash Khawaja
  2017-03-14 13:41 ` [patch 1/4] staging: speakup: spk_serial_out and spk_wait_for_xmitr to take synth arg Okash Khawaja
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Okash Khawaja @ 2017-03-14 13:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Samuel Thibault, linux-kernel
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, speakup, devel

Hi,

The following patches group together most of raw serial comms with external
synth and makes rest of the code agnostic to it, so that raw serial comms
can be easily replaced by an alternate way to communicate with external
synths. Plan is to follow these patches with alternate implementation
of comms with external synths and then migrate existing synths to use the new
implementation.

Okash

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 1/4] staging: speakup: spk_serial_out and spk_wait_for_xmitr to take synth arg
  2017-03-14 13:41 [patch 0/4] staging: speakup: refactor to make raw serial i/o swappable Okash Khawaja
@ 2017-03-14 13:41 ` Okash Khawaja
  2017-03-14 13:41 ` [patch 2/4] staging: serial: add spk_io_ops struct to spk_synth Okash Khawaja
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Okash Khawaja @ 2017-03-14 13:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Samuel Thibault, linux-kernel
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, speakup, devel, Okash Khawaja

[-- Attachment #1: 01_spk_serial_out_and_xmitr_to_take_synth --]
[-- Type: text/plain, Size: 8487 bytes --]

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 <okash.khawaja@gmail.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/serialio.c
+++ linux-4.11-rc2/drivers/staging/speakup/serialio.c
@@ -144,14 +144,14 @@
 	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
@@ -162,7 +162,7 @@
 	}
 	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;
 		}
@@ -207,9 +207,9 @@
 }
 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;
 	}
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_apollo.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_apollo.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_apollo.c
@@ -168,7 +168,7 @@
 		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);
@@ -181,7 +181,7 @@
 			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
@@ -194,7 +194,7 @@
 		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);
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_audptr.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_audptr.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_audptr.c
@@ -135,7 +135,7 @@
 		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)
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_decext.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_decext.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_decext.c
@@ -185,7 +185,7 @@
 		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;
 		}
@@ -199,10 +199,10 @@
 			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;
@@ -217,7 +217,7 @@
 		last = ch;
 	}
 	if (!in_escape)
-		spk_serial_out(PROCSPEECH);
+		spk_serial_out(synth, PROCSPEECH);
 }
 
 static void synth_flush(struct spk_synth *synth)
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dectlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dectlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dectlk.c
@@ -250,7 +250,7 @@
 		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;
 		}
@@ -264,10 +264,10 @@
 			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;
@@ -282,17 +282,17 @@
 		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);
Index: linux-4.11-rc2/drivers/staging/speakup/spk_priv.h
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/spk_priv.h
+++ linux-4.11-rc2/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);
 
 char synth_buffer_getc(void);
Index: linux-4.11-rc2/drivers/staging/speakup/synth.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/synth.c
+++ linux-4.11-rc2/drivers/staging/speakup/synth.c
@@ -119,7 +119,7 @@
 		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;
 		}
@@ -129,7 +129,7 @@
 			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
@@ -142,7 +142,7 @@
 		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);
 
@@ -153,7 +153,7 @@
 	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;
@@ -165,7 +165,7 @@
 
 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);
 
@@ -180,7 +180,7 @@
 {
 	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);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 2/4] staging: serial: add spk_io_ops struct to spk_synth
  2017-03-14 13:41 [patch 0/4] staging: speakup: refactor to make raw serial i/o swappable Okash Khawaja
  2017-03-14 13:41 ` [patch 1/4] staging: speakup: spk_serial_out and spk_wait_for_xmitr to take synth arg Okash Khawaja
@ 2017-03-14 13:41 ` Okash Khawaja
  2017-03-14 13:41 ` [patch 3/4] staging: speakup: move spk_stop_serial_interrupt into synth-specific release function Okash Khawaja
  2017-03-14 13:41 ` [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c Okash Khawaja
  3 siblings, 0 replies; 9+ messages in thread
From: Okash Khawaja @ 2017-03-14 13:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Samuel Thibault, linux-kernel
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, speakup, devel, Okash Khawaja

[-- Attachment #1: 02_add_spk_io_ops --]
[-- Type: text/plain, Size: 14836 bytes --]

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 <okash.khawaja@gmail.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/serialio.c
+++ linux-4.11-rc2/drivers/staging/speakup/serialio.c
@@ -24,6 +24,12 @@
 static const struct old_serial_port *serstate;
 static int timeouts;
 
+static int spk_serial_out(struct spk_synth *in_synth, const char ch);
+struct spk_io_ops spk_serial_io_ops = {
+	.synth_out = spk_serial_out,
+};
+EXPORT_SYMBOL_GPL(spk_serial_io_ops);
+
 const struct old_serial_port *spk_serial_init(int index)
 {
 	int baud = 9600, quot = 0;
@@ -215,7 +221,6 @@
 	}
 	return 0;
 }
-EXPORT_SYMBOL_GPL(spk_serial_out);
 
 void spk_serial_release(void)
 {
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_acntpc.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_acntpc.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_acntpc.c
@@ -113,6 +113,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = accent_release,
 	.synth_immediate = synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_acntsa.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_acntsa.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_acntsa.c
@@ -99,6 +99,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_apollo.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_apollo.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_apollo.c
@@ -108,6 +108,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
@@ -168,7 +169,7 @@
 		set_current_state(TASK_INTERRUPTIBLE);
 		full_time_val = full_time->u.n.value;
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
-		if (!spk_serial_out(synth, ch)) {
+		if (!synth->io_ops->synth_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);
@@ -181,7 +182,7 @@
 			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, synth->procspeech))
+			if (synth->io_ops->synth_out(synth, synth->procspeech))
 				schedule_timeout(msecs_to_jiffies
 						 (delay_time_val));
 			else
@@ -194,7 +195,7 @@
 		synth_buffer_getc();
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 	}
-	spk_serial_out(synth, PROCSPEECH);
+	synth->io_ops->synth_out(synth, PROCSPEECH);
 }
 
 module_param_named(ser, synth_apollo.ser, int, 0444);
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_audptr.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_audptr.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_audptr.c
@@ -104,6 +104,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
@@ -135,7 +136,7 @@
 		udelay(1);
 	}
 	outb(SYNTH_CLEAR, speakup_info.port_tts);
-	spk_serial_out(synth, PROCSPEECH);
+	synth->io_ops->synth_out(synth, PROCSPEECH);
 }
 
 static void synth_version(struct spk_synth *synth)
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_decext.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_decext.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_decext.c
@@ -127,6 +127,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
@@ -185,7 +186,7 @@
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 		if (ch == '\n')
 			ch = 0x0D;
-		if (synth_full() || !spk_serial_out(synth, ch)) {
+		if (synth_full() || !synth->io_ops->synth_out(synth, ch)) {
 			schedule_timeout(msecs_to_jiffies(delay_time_val));
 			continue;
 		}
@@ -199,10 +200,10 @@
 			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;
@@ -217,7 +218,7 @@
 		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)
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dectlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dectlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dectlk.c
@@ -130,6 +130,7 @@
 	.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,
@@ -250,7 +251,7 @@
 		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;
 		}
@@ -264,10 +265,10 @@
 			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;
@@ -282,17 +283,17 @@
 		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);
Index: linux-4.11-rc2/drivers/staging/speakup/spk_priv.h
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/spk_priv.h
+++ linux-4.11-rc2/drivers/staging/speakup/spk_priv.h
@@ -45,7 +45,6 @@
 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(struct spk_synth *in_synth, const char ch);
 void spk_serial_release(void);
 
 char synth_buffer_getc(void);
@@ -73,4 +72,6 @@
 
 extern struct var_t synth_time_vars[];
 
+extern struct spk_io_ops spk_serial_io_ops;
+
 #endif
Index: linux-4.11-rc2/drivers/staging/speakup/spk_types.h
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/spk_types.h
+++ linux-4.11-rc2/drivers/staging/speakup/spk_types.h
@@ -146,6 +146,12 @@
 	unsigned char currindex;
 };
 
+struct spk_synth;
+
+struct spk_io_ops {
+	int (*synth_out)(struct spk_synth *synth, const char ch);
+};
+
 struct spk_synth {
 	const char *name;
 	const char *version;
@@ -164,6 +170,7 @@
 	struct var_t *vars;
 	int *default_pitch;
 	int *default_vol;
+	struct spk_io_ops *io_ops;
 	int (*probe)(struct spk_synth *synth);
 	void (*release)(void);
 	const char *(*synth_immediate)(struct spk_synth *synth,
Index: linux-4.11-rc2/drivers/staging/speakup/synth.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/synth.c
+++ linux-4.11-rc2/drivers/staging/speakup/synth.c
@@ -119,7 +119,7 @@
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 		if (ch == '\n')
 			ch = synth->procspeech;
-		if (!spk_serial_out(synth, ch)) {
+		if (!synth->io_ops->synth_out(synth, ch)) {
 			schedule_timeout(msecs_to_jiffies(full_time_val));
 			continue;
 		}
@@ -129,7 +129,7 @@
 			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, synth->procspeech))
+			if (synth->io_ops->synth_out(synth, synth->procspeech))
 				schedule_timeout(
 					msecs_to_jiffies(delay_time_val));
 			else
@@ -142,7 +142,7 @@
 		synth_buffer_getc();
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 	}
-	spk_serial_out(synth, synth->procspeech);
+	synth->io_ops->synth_out(synth, synth->procspeech);
 }
 EXPORT_SYMBOL_GPL(spk_do_catch_up);
 
@@ -165,7 +165,7 @@
 
 void spk_synth_flush(struct spk_synth *synth)
 {
-	spk_serial_out(synth, synth->clear);
+	synth->io_ops->synth_out(synth, synth->clear);
 }
 EXPORT_SYMBOL_GPL(spk_synth_flush);
 
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_bns.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_bns.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_bns.c
@@ -96,6 +96,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_decpc.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_decpc.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_decpc.c
@@ -220,6 +220,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = dtpc_release,
 	.synth_immediate = synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dtlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dtlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dtlk.c
@@ -128,6 +128,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = dtlk_release,
 	.synth_immediate = synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dummy.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dummy.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dummy.c
@@ -98,6 +98,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_keypc.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_keypc.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_keypc.c
@@ -105,6 +105,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = keynote_release,
 	.synth_immediate = synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_ltlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_ltlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_ltlk.c
@@ -111,6 +111,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_soft.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_soft.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_soft.c
@@ -130,6 +130,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = NULL,
 	.probe = softsynth_probe,
 	.release = softsynth_release,
 	.synth_immediate = NULL,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_spkout.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_spkout.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_spkout.c
@@ -102,6 +102,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_txprt.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_txprt.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_txprt.c
@@ -95,6 +95,7 @@
 	.startup = SYNTH_START,
 	.checkval = SYNTH_CHECK,
 	.vars = vars,
+	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
 	.synth_immediate = spk_synth_immediate,

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 3/4] staging: speakup: move spk_stop_serial_interrupt into synth-specific release function
  2017-03-14 13:41 [patch 0/4] staging: speakup: refactor to make raw serial i/o swappable Okash Khawaja
  2017-03-14 13:41 ` [patch 1/4] staging: speakup: spk_serial_out and spk_wait_for_xmitr to take synth arg Okash Khawaja
  2017-03-14 13:41 ` [patch 2/4] staging: serial: add spk_io_ops struct to spk_synth Okash Khawaja
@ 2017-03-14 13:41 ` Okash Khawaja
  2017-03-14 13:41 ` [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c Okash Khawaja
  3 siblings, 0 replies; 9+ messages in thread
From: Okash Khawaja @ 2017-03-14 13:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Samuel Thibault, linux-kernel
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, speakup, devel, Okash Khawaja

[-- Attachment #1: 03_refactor_spk_stop_serial_interrupt --]
[-- Type: text/plain, Size: 3405 bytes --]

This moves call to spk_stop_serial_interrupt() function out of synth_release()
and into release() method of specific spk_synth instances. This is because
the spk_stop_serial_interrupt() call is specific to current serial i/o
implementation. Moving it into each synth's release() method gives the
decision of calling  spk_stop_serial_interrupt() to that synth.

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

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/serialio.c
+++ linux-4.11-rc2/drivers/staging/speakup/serialio.c
@@ -149,6 +149,7 @@
 	/* Free IRQ */
 	free_irq(serstate->irq, (void *)synth_readbuf_handler);
 }
+EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt);
 
 int spk_wait_for_xmitr(struct spk_synth *in_synth)
 {
@@ -224,6 +225,7 @@
 
 void spk_serial_release(void)
 {
+	spk_stop_serial_interrupt();
 	if (speakup_info.port_tts == 0)
 		return;
 	synth_release_region(speakup_info.port_tts, 8);
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_acntpc.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_acntpc.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_acntpc.c
@@ -303,6 +303,7 @@
 
 static void accent_release(void)
 {
+	spk_stop_serial_interrupt();
 	if (speakup_info.port_tts)
 		synth_release_region(speakup_info.port_tts-1, SYNTH_IO_EXTENT);
 	speakup_info.port_tts = 0;
Index: linux-4.11-rc2/drivers/staging/speakup/synth.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/synth.c
+++ linux-4.11-rc2/drivers/staging/speakup/synth.c
@@ -432,7 +432,6 @@
 		sysfs_remove_group(speakup_kobj, &synth->attributes);
 	for (var = synth->vars; var->var_id != MAXVARS; var++)
 		speakup_unregister_var(var->var_id);
-	spk_stop_serial_interrupt();
 	synth->release();
 	synth = NULL;
 }
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_decpc.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_decpc.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_decpc.c
@@ -482,6 +482,7 @@
 
 static void dtpc_release(void)
 {
+	spk_stop_serial_interrupt();
 	if (speakup_info.port_tts)
 		synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT);
 	speakup_info.port_tts = 0;
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dtlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dtlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dtlk.c
@@ -374,6 +374,7 @@
 
 static void dtlk_release(void)
 {
+	spk_stop_serial_interrupt();
 	if (speakup_info.port_tts)
 		synth_release_region(speakup_info.port_tts-1, SYNTH_IO_EXTENT);
 	speakup_info.port_tts = 0;
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_keypc.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_keypc.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_keypc.c
@@ -305,6 +305,7 @@
 
 static void keynote_release(void)
 {
+	spk_stop_serial_interrupt();
 	if (synth_port)
 		synth_release_region(synth_port, SYNTH_IO_EXTENT);
 	synth_port = 0;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c
  2017-03-14 13:41 [patch 0/4] staging: speakup: refactor to make raw serial i/o swappable Okash Khawaja
                   ` (2 preceding siblings ...)
  2017-03-14 13:41 ` [patch 3/4] staging: speakup: move spk_stop_serial_interrupt into synth-specific release function Okash Khawaja
@ 2017-03-14 13:41 ` Okash Khawaja
  2017-03-16  2:14   ` Greg Kroah-Hartman
  3 siblings, 1 reply; 9+ messages in thread
From: Okash Khawaja @ 2017-03-14 13:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Samuel Thibault, linux-kernel
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, speakup, devel, Okash Khawaja

[-- Attachment #1: 04_move_spk_synth_immediate_and_spk_serial_synth_probe_into_serialio --]
[-- Type: text/plain, Size: 10991 bytes --]

This moves spk_synth_immediate and spk_serial_synth_probe functions into
serialio.c. These functions do outgoing serial comms. The move is a step
towards collecting all serial comms in serialio.c. This also renames
spk_synth_immediate to spk_serial_synth_immediate.

Code inside those functions has not been changed. Along the way, this patch
also fixes a couple of spots which were calling spk_synth_immediate directly,
so that the calls now happen via the spk_syth struct.

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

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/serialio.c
+++ linux-4.11-rc2/drivers/staging/speakup/serialio.c
@@ -136,6 +136,35 @@
 	outb(1, speakup_info.port_tts + UART_FCR);	/* Turn FIFO On */
 }
 
+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);
+
 void spk_stop_serial_interrupt(void)
 {
 	if (speakup_info.port_tts == 0)
@@ -223,6 +252,23 @@
 	return 0;
 }
 
+const char *spk_serial_synth_immediate(struct spk_synth *synth, const char *buff)
+{
+	u_char ch;
+
+	while ((ch = *buff)) {
+		if (ch == '\n')
+			ch = synth->procspeech;
+		if (spk_wait_for_xmitr(synth))
+			outb(ch, speakup_info.port_tts);
+		else
+			return buff;
+		buff++;
+	}
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(spk_serial_synth_immediate);
+
 void spk_serial_release(void)
 {
 	spk_stop_serial_interrupt();
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_acntsa.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_acntsa.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_acntsa.c
@@ -102,7 +102,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -127,7 +127,7 @@
 
 	failed = spk_serial_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-4.11-rc2/drivers/staging/speakup/speakup_apollo.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_apollo.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_apollo.c
@@ -111,7 +111,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_audptr.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_audptr.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_audptr.c
@@ -107,7 +107,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -144,7 +144,7 @@
 	unsigned char test = 0;
 	char synth_id[40] = "";
 
-	spk_synth_immediate(synth, "\x05[Q]");
+	synth->synth_immediate(synth, "\x05[Q]");
 	synth_id[test] = spk_serial_in();
 	if (synth_id[test] == 'A') {
 		do {
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_bns.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_bns.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_bns.c
@@ -99,7 +99,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_decext.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_decext.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_decext.c
@@ -130,7 +130,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -224,7 +224,7 @@
 static void synth_flush(struct spk_synth *synth)
 {
 	in_escape = 0;
-	spk_synth_immediate(synth, "\033P;10z\033\\");
+	synth->synth_immediate(synth, "\033P;10z\033\\");
 }
 
 module_param_named(ser, synth_decext.ser, int, 0444);
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dectlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dectlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dectlk.c
@@ -133,7 +133,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_dummy.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_dummy.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_dummy.c
@@ -101,7 +101,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_ltlk.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_ltlk.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_ltlk.c
@@ -114,7 +114,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -139,7 +139,7 @@
 	unsigned char *t, i;
 	unsigned char buf[50], rom_v[20];
 
-	spk_synth_immediate(synth, "\x18\x01?");
+	synth->synth_immediate(synth, "\x18\x01?");
 	for (i = 0; i < 50; i++) {
 		buf[i] = spk_serial_in();
 		if (i > 2 && buf[i] == 0x7f)
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_spkout.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_spkout.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_spkout.c
@@ -105,7 +105,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-4.11-rc2/drivers/staging/speakup/speakup_txprt.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/speakup_txprt.c
+++ linux-4.11-rc2/drivers/staging/speakup/speakup_txprt.c
@@ -98,7 +98,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-4.11-rc2/drivers/staging/speakup/spk_priv.h
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/spk_priv.h
+++ linux-4.11-rc2/drivers/staging/speakup/spk_priv.h
@@ -57,7 +57,7 @@
 		      const char *buf, size_t count);
 
 int spk_serial_synth_probe(struct spk_synth *synth);
-const char *spk_synth_immediate(struct spk_synth *synth, const char *buff);
+const char *spk_serial_synth_immediate(struct spk_synth *synth, const char *buff);
 void spk_do_catch_up(struct spk_synth *synth);
 void spk_synth_flush(struct spk_synth *synth);
 int spk_synth_is_alive_nop(struct spk_synth *synth);
Index: linux-4.11-rc2/drivers/staging/speakup/synth.c
===================================================================
--- linux-4.11-rc2.orig/drivers/staging/speakup/synth.c
+++ linux-4.11-rc2/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
@@ -146,23 +117,6 @@
 }
 EXPORT_SYMBOL_GPL(spk_do_catch_up);
 
-const char *spk_synth_immediate(struct spk_synth *synth, const char *buff)
-{
-	u_char ch;
-
-	while ((ch = *buff)) {
-		if (ch == '\n')
-			ch = synth->procspeech;
-		if (spk_wait_for_xmitr(synth))
-			outb(ch, speakup_info.port_tts);
-		else
-			return buff;
-		buff++;
-	}
-	return NULL;
-}
-EXPORT_SYMBOL_GPL(spk_synth_immediate);
-
 void spk_synth_flush(struct spk_synth *synth)
 {
 	synth->io_ops->synth_out(synth, synth->clear);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c
  2017-03-14 13:41 ` [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c Okash Khawaja
@ 2017-03-16  2:14   ` Greg Kroah-Hartman
  2017-03-16  6:51     ` Okash Khawaja
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-03-16  2:14 UTC (permalink / raw)
  To: Okash Khawaja
  Cc: Samuel Thibault, linux-kernel, devel, Kirk Reiser, speakup,
	Chris Brannon

On Tue, Mar 14, 2017 at 01:41:55PM +0000, Okash Khawaja wrote:
> This moves spk_synth_immediate and spk_serial_synth_probe functions into
> serialio.c. These functions do outgoing serial comms. The move is a step
> towards collecting all serial comms in serialio.c. This also renames
> spk_synth_immediate to spk_serial_synth_immediate.
> 
> Code inside those functions has not been changed. Along the way, this patch
> also fixes a couple of spots which were calling spk_synth_immediate directly,
> so that the calls now happen via the spk_syth struct.
> 
> Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c

This patch doesn't apply to my tree at all.  The first 3 applied with
some fuzz, so I think you are not working against linux-next. Please
rebase your patch against linux-next, or my staging-testing branch, and
resend so I can apply it.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c
  2017-03-16  2:14   ` Greg Kroah-Hartman
@ 2017-03-16  6:51     ` Okash Khawaja
  2017-03-16  7:01       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 9+ messages in thread
From: Okash Khawaja @ 2017-03-16  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Samuel Thibault, linux-kernel, devel, Kirk Reiser, speakup,
	Chris Brannon

On Thu, Mar 16, 2017 at 11:14:09AM +0900, Greg Kroah-Hartman wrote:
> On Tue, Mar 14, 2017 at 01:41:55PM +0000, Okash Khawaja wrote:
> > This moves spk_synth_immediate and spk_serial_synth_probe functions into
> > serialio.c. These functions do outgoing serial comms. The move is a step
> > towards collecting all serial comms in serialio.c. This also renames
> > spk_synth_immediate to spk_serial_synth_immediate.
> > 
> > Code inside those functions has not been changed. Along the way, this patch
> > also fixes a couple of spots which were calling spk_synth_immediate directly,
> > so that the calls now happen via the spk_syth struct.
> > 
> > Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
> > Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > 
> > Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c
> 
> This patch doesn't apply to my tree at all.  The first 3 applied with
> some fuzz, so I think you are not working against linux-next. Please
> rebase your patch against linux-next, or my staging-testing branch, and
> resend so I can apply it.

Sure, will rebase against staging-testing. Just this patch or the
patch set?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c
  2017-03-16  6:51     ` Okash Khawaja
@ 2017-03-16  7:01       ` Greg Kroah-Hartman
  2017-03-16  8:10         ` Okash Khawaja
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-03-16  7:01 UTC (permalink / raw)
  To: Okash Khawaja
  Cc: Samuel Thibault, linux-kernel, devel, Kirk Reiser, speakup,
	Chris Brannon

On Thu, Mar 16, 2017 at 06:51:54AM +0000, Okash Khawaja wrote:
> On Thu, Mar 16, 2017 at 11:14:09AM +0900, Greg Kroah-Hartman wrote:
> > On Tue, Mar 14, 2017 at 01:41:55PM +0000, Okash Khawaja wrote:
> > > This moves spk_synth_immediate and spk_serial_synth_probe functions into
> > > serialio.c. These functions do outgoing serial comms. The move is a step
> > > towards collecting all serial comms in serialio.c. This also renames
> > > spk_synth_immediate to spk_serial_synth_immediate.
> > > 
> > > Code inside those functions has not been changed. Along the way, this patch
> > > also fixes a couple of spots which were calling spk_synth_immediate directly,
> > > so that the calls now happen via the spk_syth struct.
> > > 
> > > Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
> > > Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > 
> > > Index: linux-4.11-rc2/drivers/staging/speakup/serialio.c
> > 
> > This patch doesn't apply to my tree at all.  The first 3 applied with
> > some fuzz, so I think you are not working against linux-next. Please
> > rebase your patch against linux-next, or my staging-testing branch, and
> > resend so I can apply it.
> 
> Sure, will rebase against staging-testing. Just this patch or the
> patch set?

I applied the first 3, so if you rebase, they should just "go away" :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c
  2017-03-16  7:01       ` Greg Kroah-Hartman
@ 2017-03-16  8:10         ` Okash Khawaja
  0 siblings, 0 replies; 9+ messages in thread
From: Okash Khawaja @ 2017-03-16  8:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Samuel Thibault, linux-kernel, devel, Kirk Reiser, speakup,
	Chris Brannon

This moves spk_synth_immediate and spk_serial_synth_probe functions into
serialio.c. These functions do outgoing serial comms. The move is a step
towards collecting all serial comms in serialio.c. This also renames
spk_synth_immediate to spk_serial_synth_immediate.

Code inside those functions has not been changed. Along the way, this patch
also fixes a couple of spots which were calling spk_synth_immediate directly,
so that the calls now happen via the spk_syth struct.

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

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-staging/drivers/staging/speakup/serialio.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/serialio.c
+++ linux-staging/drivers/staging/speakup/serialio.c
@@ -136,6 +136,35 @@
 	outb(1, speakup_info.port_tts + UART_FCR);	/* Turn FIFO On */
 }
 
+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) {
+			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);
+
 void spk_stop_serial_interrupt(void)
 {
 	if (speakup_info.port_tts == 0)
@@ -223,6 +252,23 @@
 	return 0;
 }
 
+const char *spk_serial_synth_immediate(struct spk_synth *synth, const char *buff)
+{
+	u_char ch;
+
+	while ((ch = *buff)) {
+		if (ch == '\n')
+			ch = synth->procspeech;
+		if (spk_wait_for_xmitr(synth))
+			outb(ch, speakup_info.port_tts);
+		else
+			return buff;
+		buff++;
+	}
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(spk_serial_synth_immediate);
+
 void spk_serial_release(void)
 {
 	spk_stop_serial_interrupt();
Index: linux-staging/drivers/staging/speakup/speakup_acntsa.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_acntsa.c
+++ linux-staging/drivers/staging/speakup/speakup_acntsa.c
@@ -102,7 +102,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -127,7 +127,7 @@
 
 	failed = spk_serial_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-staging/drivers/staging/speakup/speakup_apollo.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_apollo.c
+++ linux-staging/drivers/staging/speakup/speakup_apollo.c
@@ -111,7 +111,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-staging/drivers/staging/speakup/speakup_audptr.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_audptr.c
+++ linux-staging/drivers/staging/speakup/speakup_audptr.c
@@ -107,7 +107,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -144,7 +144,7 @@
 	unsigned char test = 0;
 	char synth_id[40] = "";
 
-	spk_synth_immediate(synth, "\x05[Q]");
+	synth->synth_immediate(synth, "\x05[Q]");
 	synth_id[test] = spk_serial_in();
 	if (synth_id[test] == 'A') {
 		do {
Index: linux-staging/drivers/staging/speakup/speakup_bns.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_bns.c
+++ linux-staging/drivers/staging/speakup/speakup_bns.c
@@ -99,7 +99,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-staging/drivers/staging/speakup/speakup_decext.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_decext.c
+++ linux-staging/drivers/staging/speakup/speakup_decext.c
@@ -130,7 +130,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -225,7 +225,7 @@
 static void synth_flush(struct spk_synth *synth)
 {
 	in_escape = 0;
-	spk_synth_immediate(synth, "\033P;10z\033\\");
+	synth->synth_immediate(synth, "\033P;10z\033\\");
 }
 
 module_param_named(ser, synth_decext.ser, int, 0444);
Index: linux-staging/drivers/staging/speakup/speakup_dectlk.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_dectlk.c
+++ linux-staging/drivers/staging/speakup/speakup_dectlk.c
@@ -133,7 +133,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-staging/drivers/staging/speakup/speakup_dummy.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_dummy.c
+++ linux-staging/drivers/staging/speakup/speakup_dummy.c
@@ -101,7 +101,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-staging/drivers/staging/speakup/speakup_ltlk.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_ltlk.c
+++ linux-staging/drivers/staging/speakup/speakup_ltlk.c
@@ -114,7 +114,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
@@ -139,7 +139,7 @@
 	unsigned char *t, i;
 	unsigned char buf[50], rom_v[20];
 
-	spk_synth_immediate(synth, "\x18\x01?");
+	synth->synth_immediate(synth, "\x18\x01?");
 	for (i = 0; i < 50; i++) {
 		buf[i] = spk_serial_in();
 		if (i > 2 && buf[i] == 0x7f)
Index: linux-staging/drivers/staging/speakup/speakup_spkout.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_spkout.c
+++ linux-staging/drivers/staging/speakup/speakup_spkout.c
@@ -105,7 +105,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-staging/drivers/staging/speakup/speakup_txprt.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_txprt.c
+++ linux-staging/drivers/staging/speakup/speakup_txprt.c
@@ -98,7 +98,7 @@
 	.io_ops = &spk_serial_io_ops,
 	.probe = spk_serial_synth_probe,
 	.release = spk_serial_release,
-	.synth_immediate = spk_synth_immediate,
+	.synth_immediate = spk_serial_synth_immediate,
 	.catch_up = spk_do_catch_up,
 	.flush = spk_synth_flush,
 	.is_alive = spk_synth_is_alive_restart,
Index: linux-staging/drivers/staging/speakup/spk_priv.h
===================================================================
--- linux-staging.orig/drivers/staging/speakup/spk_priv.h
+++ linux-staging/drivers/staging/speakup/spk_priv.h
@@ -58,7 +58,7 @@
 		      const char *buf, size_t count);
 
 int spk_serial_synth_probe(struct spk_synth *synth);
-const char *spk_synth_immediate(struct spk_synth *synth, const char *buff);
+const char *spk_serial_synth_immediate(struct spk_synth *synth, const char *buff);
 void spk_do_catch_up(struct spk_synth *synth);
 void spk_synth_flush(struct spk_synth *synth);
 int spk_synth_is_alive_nop(struct spk_synth *synth);
Index: linux-staging/drivers/staging/speakup/synth.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/synth.c
+++ linux-staging/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) {
-			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
@@ -147,23 +118,6 @@
 }
 EXPORT_SYMBOL_GPL(spk_do_catch_up);
 
-const char *spk_synth_immediate(struct spk_synth *synth, const char *buff)
-{
-	u_char ch;
-
-	while ((ch = *buff)) {
-		if (ch == '\n')
-			ch = synth->procspeech;
-		if (spk_wait_for_xmitr(synth))
-			outb(ch, speakup_info.port_tts);
-		else
-			return buff;
-		buff++;
-	}
-	return NULL;
-}
-EXPORT_SYMBOL_GPL(spk_synth_immediate);
-
 void spk_synth_flush(struct spk_synth *synth)
 {
 	synth->io_ops->synth_out(synth, synth->clear);

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-16  8:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14 13:41 [patch 0/4] staging: speakup: refactor to make raw serial i/o swappable Okash Khawaja
2017-03-14 13:41 ` [patch 1/4] staging: speakup: spk_serial_out and spk_wait_for_xmitr to take synth arg Okash Khawaja
2017-03-14 13:41 ` [patch 2/4] staging: serial: add spk_io_ops struct to spk_synth Okash Khawaja
2017-03-14 13:41 ` [patch 3/4] staging: speakup: move spk_stop_serial_interrupt into synth-specific release function Okash Khawaja
2017-03-14 13:41 ` [patch 4/4] staging: speakup: move those functions which do outgoing serial comms, into serialio.c Okash Khawaja
2017-03-16  2:14   ` Greg Kroah-Hartman
2017-03-16  6:51     ` Okash Khawaja
2017-03-16  7:01       ` Greg Kroah-Hartman
2017-03-16  8:10         ` Okash Khawaja

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.