[PATCH] staging: speakup: refactor synths array to use a list

Samuel Thibault samuel.thibault at ens-lyon.org
Sun Oct 21 16:50:30 EDT 2018


Keith Barrett, le dim. 21 oct. 2018 21:28:11 +0100, a ecrit:
> Do I need to downgrade to 4.15 to apply this or can I use a 4.18 kernel?

Ah, the changes were based on 4.15 indeed, here is a version rebased on
4.18

Samuel
-------------- next part --------------
Index: linux-4.15/drivers/staging/speakup/speakup_soft.c
===================================================================
--- linux-4.15.orig/drivers/staging/speakup/speakup_soft.c
+++ linux-4.15/drivers/staging/speakup/speakup_soft.c
@@ -214,12 +214,15 @@ static ssize_t softsynthx_read(struct fi
 	DEFINE_WAIT(wait);
 
 	spin_lock_irqsave(&speakup_info.spinlock, flags);
+	synth_soft.alive = 1;
 	while (1) {
 		prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE);
-		if (!unicode)
-			synth_buffer_skip_nonlatin1();
-		if (!synth_buffer_empty() || speakup_info.flushing)
-			break;
+		if (synth_current() == &synth_soft) {
+			if (!unicode)
+				synth_buffer_skip_nonlatin1();
+			if (!synth_buffer_empty() || speakup_info.flushing)
+				break;
+		}
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 		if (fp->f_flags & O_NONBLOCK) {
 			finish_wait(&speakup_event, &wait);
@@ -239,6 +242,8 @@ static ssize_t softsynthx_read(struct fi
 
 	/* Keep 3 bytes available for a 16bit UTF-8-encoded character */
 	while (chars_sent <= count - bytes_per_ch) {
+		if (synth_current() != &synth_soft)
+			break;
 		if (speakup_info.flushing) {
 			speakup_info.flushing = 0;
 			ch = '\x18';
@@ -335,7 +340,8 @@ static unsigned int softsynth_poll(struc
 	poll_wait(fp, &speakup_event, wait);
 
 	spin_lock_irqsave(&speakup_info.spinlock, flags);
-	if (!synth_buffer_empty() || speakup_info.flushing)
+	if (synth_current() == &synth_soft &&
+	    (!synth_buffer_empty() || speakup_info.flushing))
 		ret = EPOLLIN | EPOLLRDNORM;
 	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 	return ret;
Index: linux-4.15/drivers/staging/speakup/spk_priv.h
===================================================================
--- linux-4.15.orig/drivers/staging/speakup/spk_priv.h
+++ linux-4.15/drivers/staging/speakup/spk_priv.h
@@ -81,6 +81,7 @@ int synth_request_region(unsigned long s
 int synth_release_region(unsigned long start, unsigned long n);
 int synth_add(struct spk_synth *in_synth);
 void synth_remove(struct spk_synth *in_synth);
+struct spk_synth *synth_current(void);
 
 extern struct speakup_info_t speakup_info;
 
Index: linux-4.15/drivers/staging/speakup/synth.c
===================================================================
--- linux-4.15.orig/drivers/staging/speakup/synth.c
+++ linux-4.15/drivers/staging/speakup/synth.c
@@ -495,4 +495,10 @@ void synth_remove(struct spk_synth *in_s
 }
 EXPORT_SYMBOL_GPL(synth_remove);
 
+struct spk_synth *synth_current(void)
+{
+	return synth;
+}
+EXPORT_SYMBOL_GPL(synth_current);
+
 short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM };


More information about the Speakup mailing list