Re: [PATCH] accessibility: speakup: refactor deprecated strncpy

2023-09-16 Thread Samuel Thibault
Hello,

Justin Stitt, le ven. 25 août 2023 15:41:03 -0700, a ecrit:
> Thanks for the review Kees and Samuel. Hoping to get this picked-up soon :)
> 
> FWIW, I've quickly copy/pasted Kees' suggested refactor of
> synth_direct_store and rebased against v6.5-rc7 if anyone has the
> means by which to test it.
> 
> TEST PATCH BELOW
> ---
> From e7216bca30673a162660c51f8bad3b463d283041 Mon Sep 17 00:00:00 2001
> From: Justin Stitt 
> Date: Fri, 25 Aug 2023 22:32:03 +
> Subject: [PATCH NEEDS TEST] synth_direct_store refactor to use synth_write
> 
> I've just copy/pasted Kees' suggestion here [1] and rebased it against
> 6.5-rc7.
> 
> This patch needs testing as it refactors behavior in synth_direct_store.
> 
> [1]: https://lore.kernel.org/all/202308251439.36BC33ADB2@keescook/
> 
> Signed-off-by: Justin Stitt 

Tested-by: Samuel Thibault 

but please submit it properly :) It was completely mangled in the mail.

> ---
>  drivers/accessibility/speakup/kobjects.c | 25 +++-
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/accessibility/speakup/kobjects.c
> b/drivers/accessibility/speakup/kobjects.c
> index a7522d409802..0dfdb6608e02 100644
> --- a/drivers/accessibility/speakup/kobjects.c
> +++ b/drivers/accessibility/speakup/kobjects.c
> @@ -413,27 +413,24 @@ static ssize_t synth_direct_store(struct kobject *kobj,
> struct kobj_attribute *attr,
> const char *buf, size_t count)
>  {
> - u_char tmp[256];
> - int len;
> - int bytes;
> - const char *ptr = buf;
> + char *unescaped;
>   unsigned long flags;
> 
>   if (!synth)
>   return -EPERM;
> 
> - len = strlen(buf);
> + unescaped = kstrdup(buf, GFP_KERNEL);
> + if (!unescaped)
> + return -ENOMEM;
> +
> + string_unescape_any_inplace(unescaped);
> +
>   spin_lock_irqsave(_info.spinlock, flags);
> - while (len > 0) {
> - bytes = min_t(size_t, len, 250);
> - strncpy(tmp, ptr, bytes);
> - tmp[bytes] = '\0';
> - string_unescape_any_inplace(tmp);
> - synth_printf("%s", tmp);
> - ptr += bytes;
> - len -= bytes;
> - }
> + synth_write(unescaped, strlen(unescaped));
>   spin_unlock_irqrestore(_info.spinlock, flags);
> +
> + kfree(unescaped);
> +
>   return count;
>  }
> 
> --
> 2.42.0.rc1.204.g551eb34607-goog
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.


[PATCH 0/2] speakup update

2021-01-28 Thread Samuel Thibault
Samuel Thibault (2):
  speakup ABI: Advertise synth parameters for all synths
  speakup: Make dectlk flush timeout configurable

 Documentation/ABI/stable/sysfs-driver-speakup | 37 +++
 .../accessibility/speakup/speakup_dectlk.c| 11 +-
 drivers/accessibility/speakup/spk_types.h |  3 +-
 drivers/accessibility/speakup/synth.c |  3 ++
 drivers/accessibility/speakup/varhandlers.c   |  1 +
 5 files changed, 38 insertions(+), 17 deletions(-)

-- 
2.20.1



[PATCH 1/2] speakup ABI: Advertise synth parameters for all synths

2021-01-28 Thread Samuel Thibault
The parameters were advertised for the "soft" synth, but they are
available for all synths.

Signed-off-by: Samuel Thibault 
---
 Documentation/ABI/stable/sysfs-driver-speakup | 30 +--
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/Documentation/ABI/stable/sysfs-driver-speakup 
b/Documentation/ABI/stable/sysfs-driver-speakup
index 792f58b..47f5c8a 100644
--- a/Documentation/ABI/stable/sysfs-driver-speakup
+++ b/Documentation/ABI/stable/sysfs-driver-speakup
@@ -273,7 +273,7 @@ Description:In `/sys/accessibility/speakup` is a 
directory corresponding to
Below is a description of values and  parameters for soft
synthesizer, which is currently the most commonly used.
 
-What:  /sys/accessibility/speakup/soft/caps_start
+What:  /sys/accessibility/speakup//caps_start
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   This is the string that is sent to the synthesizer to cause it
@@ -281,7 +281,7 @@ Description:This is the string that is sent to the 
synthesizer to cause it
and most others, this causes the pitch of the voice to rise
above the currently set pitch.
 
-What:  /sys/accessibility/speakup/soft/caps_stop
+What:  /sys/accessibility/speakup//caps_stop
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   This is the string sent to the synthesizer to cause it to stop
@@ -290,12 +290,12 @@ Description:  This is the string sent to the 
synthesizer to cause it to stop
down to the
currently set pitch.
 
-What:  /sys/accessibility/speakup/soft/delay_time
+What:  /sys/accessibility/speakup//delay_time
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   TODO:
 
-What:  /sys/accessibility/speakup/soft/direct
+What:  /sys/accessibility/speakup//direct
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   Controls if punctuation is spoken by speakup, or by the
@@ -306,36 +306,36 @@ Description:  Controls if punctuation is spoken by 
speakup, or by the
than". Zero lets speakup speak the punctuation. One lets the
synthesizer itself speak punctuation.
 
-What:  /sys/accessibility/speakup/soft/freq
+What:  /sys/accessibility/speakup//freq
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the frequency of the speech synthesizer. Range is
0-9.
 
-What:  /sys/accessibility/speakup/soft/full_time
+What:  /sys/accessibility/speakup//full_time
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   TODO:
 
-What:  /sys/accessibility/speakup/soft/jiffy_delta
+What:  /sys/accessibility/speakup//jiffy_delta
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   This controls how many jiffys the kernel gives to the
synthesizer. Setting this too high can make a system unstable,
or even crash it.
 
-What:  /sys/accessibility/speakup/soft/pitch
+What:  /sys/accessibility/speakup//pitch
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the pitch of the synthesizer. The range is 0-9.
 
-What:  /sys/accessibility/speakup/soft/inflection
+What:  /sys/accessibility/speakup//inflection
 KernelVersion: 5.8
 Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the inflection of the synthesizer, i.e. the pitch
range. The range is 0-9.
 
-What:  /sys/accessibility/speakup/soft/punct
+What:  /sys/accessibility/speakup//punct
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the amount of punctuation spoken by the
@@ -343,13 +343,13 @@ Description:  Gets or sets the amount of punctuation 
spoken by the
TODO: How is this related to speakup's punc_level, or
reading_punc.
 
-What:  /sys/accessibility/speakup/soft/rate
+What:  /sys/accessibility/speakup//rate
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the rate of the synthesizer. Range is from zero
slowest, to nine fastest.
 
-What:  /sys/accessibility/speakup/soft/tone
+What:  /sys/accessibility/speakup//tone
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the tone of the speech synthesizer. The range for
@@ -357,12 +357,12 @@ Description:  Gets or sets the tone of the speech 
synthesizer. The range for
difference if using espeak and the espeakup connector.
TODO: does espeakup support different tonalities?
 
-What:  /sys/accessibility/speakup/soft/trigger_time
+What:  /sy

[PATCH 2/2] speakup: Make dectlk flush timeout configurable

2021-01-28 Thread Samuel Thibault
In case the serial port or cable got faulty, we may not be getting
acknowledgements any more. The driver then currently waits for 4s to
avoid jamming the device. This makes this delay configurable.

Signed-off-by: Samuel Thibault 
---
 Documentation/ABI/stable/sysfs-driver-speakup  |  7 +++
 drivers/accessibility/speakup/speakup_dectlk.c | 11 ++-
 drivers/accessibility/speakup/spk_types.h  |  3 ++-
 drivers/accessibility/speakup/synth.c  |  3 +++
 drivers/accessibility/speakup/varhandlers.c|  1 +
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/stable/sysfs-driver-speakup 
b/Documentation/ABI/stable/sysfs-driver-speakup
index 47f5c8a..dc2a6ba 100644
--- a/Documentation/ABI/stable/sysfs-driver-speakup
+++ b/Documentation/ABI/stable/sysfs-driver-speakup
@@ -312,6 +312,13 @@ Contact:   spea...@linux-speakup.org
 Description:   Gets or sets the frequency of the speech synthesizer. Range is
0-9.
 
+What:  /sys/accessibility/speakup//flush_time
+KernelVersion: 5.12
+Contact:   spea...@linux-speakup.org
+Description:   Gets or sets the timeout to wait for the synthesizer flush to
+   complete. This can be used when the cable gets faulty and flush
+   notifications are getting lost.
+
 What:  /sys/accessibility/speakup//full_time
 KernelVersion: 2.6
 Contact:   spea...@linux-speakup.org
diff --git a/drivers/accessibility/speakup/speakup_dectlk.c 
b/drivers/accessibility/speakup/speakup_dectlk.c
index d75de36..580ec79 100644
--- a/drivers/accessibility/speakup/speakup_dectlk.c
+++ b/drivers/accessibility/speakup/speakup_dectlk.c
@@ -78,6 +78,8 @@ static struct kobj_attribute direct_attribute =
__ATTR(direct, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute full_time_attribute =
__ATTR(full_time, 0644, spk_var_show, spk_var_store);
+static struct kobj_attribute flush_time_attribute =
+   __ATTR(flush_time, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute jiffy_delta_attribute =
__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute trigger_time_attribute =
@@ -99,6 +101,7 @@ static struct attribute *synth_attrs[] = {
_time_attribute.attr,
_attribute.attr,
_time_attribute.attr,
+   _time_attribute.attr,
_delta_attribute.attr,
_time_attribute.attr,
NULL,   /* need to NULL terminate the list of attributes */
@@ -118,6 +121,7 @@ static struct spk_synth synth_dectlk = {
.trigger = 50,
.jiffies = 50,
.full = 4,
+   .flush_time = 4000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
@@ -200,18 +204,23 @@ static void do_catch_up(struct spk_synth *synth)
static u_char last = '\0';
unsigned long flags;
unsigned long jiff_max;
-   unsigned long timeout = msecs_to_jiffies(4000);
+   unsigned long timeout;
DEFINE_WAIT(wait);
struct var_t *jiffy_delta;
struct var_t *delay_time;
+   struct var_t *flush_time;
int jiffy_delta_val;
int delay_time_val;
+   int timeout_val;
 
jiffy_delta = spk_get_var(JIFFY);
delay_time = spk_get_var(DELAY);
+   flush_time = spk_get_var(FLUSH);
spin_lock_irqsave(_info.spinlock, flags);
jiffy_delta_val = jiffy_delta->u.n.value;
+   timeout_val = flush_time->u.n.value;
spin_unlock_irqrestore(_info.spinlock, flags);
+   timeout = msecs_to_jiffies(timeout_val);
jiff_max = jiffies + jiffy_delta_val;
 
while (!kthread_should_stop()) {
diff --git a/drivers/accessibility/speakup/spk_types.h 
b/drivers/accessibility/speakup/spk_types.h
index 7789f5d..6a96ad9 100644
--- a/drivers/accessibility/speakup/spk_types.h
+++ b/drivers/accessibility/speakup/spk_types.h
@@ -48,7 +48,7 @@ enum var_id_t {
ATTRIB_BLEEP, BLEEPS,
RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
DIRECT, PAUSE,
-   CAPS_START, CAPS_STOP, CHARTAB, INFLECTION,
+   CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH,
MAXVARS
 };
 
@@ -178,6 +178,7 @@ struct spk_synth {
int trigger;
int jiffies;
int full;
+   int flush_time;
int ser;
char *dev_name;
short flags;
diff --git a/drivers/accessibility/speakup/synth.c 
b/drivers/accessibility/speakup/synth.c
index 6c14b68..2b86996 100644
--- a/drivers/accessibility/speakup/synth.c
+++ b/drivers/accessibility/speakup/synth.c
@@ -348,6 +348,7 @@ struct var_t synth_time_vars[] = {
{ TRIGGER, .u.n = {NULL, 20, 10, 2000, 0, 0, NULL } },
{ JIFFY, .u.n = {NULL, 50, 20, 200, 0, 0, NULL } },
{ FULL, .u.n = {NULL, 400, 200, 6, 0, 0, NULL } },
+   { FLUSH, .u.n = {NULL, 4000, 100, 4000, 0, 0, NULL } },
V_LAST_VAR
 };
 
@@ -408,6 +409,8 @@ static int do_synth_init(struct spk

Re: [PATCH] speakup: Make dectlk flush timeout configurable

2021-01-28 Thread Samuel Thibault
Greg KH, le jeu. 28 janv. 2021 08:54:16 +0100, a ecrit:
> On Thu, Jan 28, 2021 at 12:44:44AM +0100, Samuel Thibault wrote:
> >  static struct kobj_attribute full_time_attribute =
> > __ATTR(full_time, 0644, spk_var_show, spk_var_store);
> > +static struct kobj_attribute flush_time_attribute =
> > +   __ATTR(flush_time, 0644, spk_var_show, spk_var_store);
> 
> __ATTR_RW()?

Unfortunately no because __ATTR_RW only takes the name, and uses that
for the function to be called. In our case the functions are shared.

> Also, no Documentation/ABI/ update for the new one user-visable
> attribute?  Please fix up.

Right, I'll fix it.

Samuel


[PATCH] speakup: Make dectlk flush timeout configurable

2021-01-27 Thread Samuel Thibault
In case the serial port or cable got faulty, we may not be getting
acknowledgements any more. The driver then currently waits for 4s to
avoid jamming the device. This makes this delay configurable.

Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/speakup_dectlk.c | 11 ++-
 drivers/accessibility/speakup/spk_types.h  |  3 ++-
 drivers/accessibility/speakup/synth.c  |  3 +++
 drivers/accessibility/speakup/varhandlers.c|  1 +
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/accessibility/speakup/speakup_dectlk.c 
b/drivers/accessibility/speakup/speakup_dectlk.c
index d75de36..580ec79 100644
--- a/drivers/accessibility/speakup/speakup_dectlk.c
+++ b/drivers/accessibility/speakup/speakup_dectlk.c
@@ -78,6 +78,8 @@ static struct kobj_attribute direct_attribute =
__ATTR(direct, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute full_time_attribute =
__ATTR(full_time, 0644, spk_var_show, spk_var_store);
+static struct kobj_attribute flush_time_attribute =
+   __ATTR(flush_time, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute jiffy_delta_attribute =
__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute trigger_time_attribute =
@@ -99,6 +101,7 @@ static struct attribute *synth_attrs[] = {
_time_attribute.attr,
_attribute.attr,
_time_attribute.attr,
+   _time_attribute.attr,
_delta_attribute.attr,
_time_attribute.attr,
NULL,   /* need to NULL terminate the list of attributes */
@@ -118,6 +121,7 @@ static struct spk_synth synth_dectlk = {
.trigger = 50,
.jiffies = 50,
.full = 4,
+   .flush_time = 4000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
@@ -200,18 +204,23 @@ static void do_catch_up(struct spk_synth *synth)
static u_char last = '\0';
unsigned long flags;
unsigned long jiff_max;
-   unsigned long timeout = msecs_to_jiffies(4000);
+   unsigned long timeout;
DEFINE_WAIT(wait);
struct var_t *jiffy_delta;
struct var_t *delay_time;
+   struct var_t *flush_time;
int jiffy_delta_val;
int delay_time_val;
+   int timeout_val;
 
jiffy_delta = spk_get_var(JIFFY);
delay_time = spk_get_var(DELAY);
+   flush_time = spk_get_var(FLUSH);
spin_lock_irqsave(_info.spinlock, flags);
jiffy_delta_val = jiffy_delta->u.n.value;
+   timeout_val = flush_time->u.n.value;
spin_unlock_irqrestore(_info.spinlock, flags);
+   timeout = msecs_to_jiffies(timeout_val);
jiff_max = jiffies + jiffy_delta_val;
 
while (!kthread_should_stop()) {
diff --git a/drivers/accessibility/speakup/spk_types.h 
b/drivers/accessibility/speakup/spk_types.h
index 7789f5d..6a96ad9 100644
--- a/drivers/accessibility/speakup/spk_types.h
+++ b/drivers/accessibility/speakup/spk_types.h
@@ -48,7 +48,7 @@ enum var_id_t {
ATTRIB_BLEEP, BLEEPS,
RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
DIRECT, PAUSE,
-   CAPS_START, CAPS_STOP, CHARTAB, INFLECTION,
+   CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH,
MAXVARS
 };
 
@@ -178,6 +178,7 @@ struct spk_synth {
int trigger;
int jiffies;
int full;
+   int flush_time;
int ser;
char *dev_name;
short flags;
diff --git a/drivers/accessibility/speakup/synth.c 
b/drivers/accessibility/speakup/synth.c
index 6c14b68..2b86996 100644
--- a/drivers/accessibility/speakup/synth.c
+++ b/drivers/accessibility/speakup/synth.c
@@ -348,6 +348,7 @@ struct var_t synth_time_vars[] = {
{ TRIGGER, .u.n = {NULL, 20, 10, 2000, 0, 0, NULL } },
{ JIFFY, .u.n = {NULL, 50, 20, 200, 0, 0, NULL } },
{ FULL, .u.n = {NULL, 400, 200, 6, 0, 0, NULL } },
+   { FLUSH, .u.n = {NULL, 4000, 100, 4000, 0, 0, NULL } },
V_LAST_VAR
 };
 
@@ -408,6 +409,8 @@ static int do_synth_init(struct spk_synth *in_synth)
synth_time_vars[2].u.n.default_val = synth->jiffies;
synth_time_vars[3].u.n.value =
synth_time_vars[3].u.n.default_val = synth->full;
+   synth_time_vars[4].u.n.value =
+   synth_time_vars[4].u.n.default_val = synth->flush_time;
synth_printf("%s", synth->init);
for (var = synth->vars;
(var->var_id >= 0) && (var->var_id < MAXVARS); var++)
diff --git a/drivers/accessibility/speakup/varhandlers.c 
b/drivers/accessibility/speakup/varhandlers.c
index d7f6bec..067c0da 100644
--- a/drivers/accessibility/speakup/varhandlers.c
+++ b/drivers/accessibility/speakup/varhandlers.c
@@ -23,6 +23,7 @@ static struct st_var_header var_headers[] = {
{ "trigger_time", TRIGGER, VAR_TIME, NULL, NULL },
{ "jiffy_delta", JIFFY, VA

Re: [PATCH 1/4] This merely adds the missing synth parameter to all io functions.

2021-01-26 Thread Samuel Thibault
Greg KH, le mar. 26 janv. 2021 19:37:53 +0100, a ecrit:
> Can you fix this up and resend the series?

Yep! done so.

Samuel


[PATCH 3/4] speakup: Simplify spk_ttyio_out error handling.

2021-01-26 Thread Samuel Thibault
This avoids most code indentation

Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/spk_ttyio.c | 38 ---
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c 
b/drivers/accessibility/speakup/spk_ttyio.c
index adc1cdb..4dbd24c 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void)
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
struct tty_struct *tty = in_synth->dev;
+   int ret;
+
+   if (!in_synth->alive || !tty->ops->write)
+   return 0;
 
-   if (in_synth->alive && tty->ops->write) {
-   int ret = tty->ops->write(tty, , 1);
-
-   if (ret == 0)
-   /* No room */
-   return 0;
-   if (ret < 0) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   in_synth->long_name);
-   /* 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
-*/
-   in_synth->alive = 0;
-   speakup_start_ttys();
-   return 0;
-   }
+   ret = tty->ops->write(tty, , 1);
+
+   if (ret == 0)
+   /* No room */
+   return 0;
+
+   if (ret > 0)
+   /* Success */
return 1;
-   }
 
+   pr_warn("%s: I/O error, deactivating speakup\n",
+   in_synth->long_name);
+   /* 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
+*/
+   in_synth->alive = 0;
+   speakup_start_ttys();
return 0;
 }
 
-- 
2.20.1



[PATCH 2/4] speakup: Reference synth from tty and tty from synth

2021-01-26 Thread Samuel Thibault
We do not actually need speakup_tty and spk_ttyio_synth global
variables, the synth can store the pointer to the tty, and the tty
ldisc_data can store the pointer to the synth.

Along the way, we can clench the initialization of the synth and the
creation of the tty, so that tty is never NULL. Even if the device
disappears (e.g. USB unplug), the tty structure will still be there,
and we automatically stop speakup in the spk_ttyio_out error handler
but keep tty until the user cleans things up.

As a result, this simplifies locking a lot.

Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/spk_ttyio.c | 117 --
 drivers/accessibility/speakup/spk_types.h |   2 +
 2 files changed, 46 insertions(+), 73 deletions(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c 
b/drivers/accessibility/speakup/spk_ttyio.c
index d62fb74..adc1cdb 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -12,14 +12,15 @@ struct spk_ldisc_data {
char buf;
struct completion completion;
bool buf_free;
+   struct spk_synth *synth;
 };
 
-static struct spk_synth *spk_ttyio_synth;
-static struct tty_struct *speakup_tty;
-/* mutex to protect against speakup_tty disappearing from underneath us while
- * we are using it. this can happen when the device physically unplugged,
- * while in use. it also serialises access to speakup_tty.
+/*
+ * This allows to catch within spk_ttyio_ldisc_open whether it is getting set
+ * on for a speakup-driven device.
  */
+static struct tty_struct *speakup_tty;
+/* This mutex serializes the use of such global speakup_tty variable */
 static DEFINE_MUTEX(speakup_tty_mutex);
 
 static int ser_to_dev(int ser, dev_t *dev_no)
@@ -67,22 +68,20 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty)
 
 static void spk_ttyio_ldisc_close(struct tty_struct *tty)
 {
-   mutex_lock(_tty_mutex);
-   kfree(speakup_tty->disc_data);
-   speakup_tty = NULL;
-   mutex_unlock(_tty_mutex);
+   kfree(tty->disc_data);
 }
 
 static int spk_ttyio_receive_buf2(struct tty_struct *tty,
  const unsigned char *cp, char *fp, int count)
 {
struct spk_ldisc_data *ldisc_data = tty->disc_data;
+   struct spk_synth *synth = ldisc_data->synth;
 
-   if (spk_ttyio_synth->read_buff_add) {
+   if (synth->read_buff_add) {
int i;
 
for (i = 0; i < count; i++)
-   spk_ttyio_synth->read_buff_add(cp[i]);
+   synth->read_buff_add(cp[i]);
 
return count;
}
@@ -187,13 +186,17 @@ static int spk_ttyio_initialise_ldisc(struct spk_synth 
*synth)
mutex_lock(_tty_mutex);
speakup_tty = tty;
ret = tty_set_ldisc(tty, N_SPEAKUP);
-   if (ret)
-   speakup_tty = NULL;
+   speakup_tty = NULL;
mutex_unlock(_tty_mutex);
 
-   if (!ret)
+   if (!ret) {
/* Success */
+   struct spk_ldisc_data *ldisc_data = tty->disc_data;
+
+   ldisc_data->synth = synth;
+   synth->dev = tty;
return 0;
+   }
 
pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
 
@@ -221,11 +224,11 @@ void spk_ttyio_unregister_ldisc(void)
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (in_synth->alive && speakup_tty && speakup_tty->ops->write) {
-   int ret = speakup_tty->ops->write(speakup_tty, , 1);
+   struct tty_struct *tty = in_synth->dev;
+
+   if (in_synth->alive && tty->ops->write) {
+   int ret = tty->ops->write(tty, , 1);
 
-   mutex_unlock(_tty_mutex);
if (ret == 0)
/* No room */
return 0;
@@ -243,7 +246,6 @@ static int spk_ttyio_out(struct spk_synth *in_synth, const 
char ch)
return 1;
}
 
-   mutex_unlock(_tty_mutex);
return 0;
 }
 
@@ -264,47 +266,20 @@ static int spk_ttyio_out_unicode(struct spk_synth 
*in_synth, u16 ch)
return ret;
 }
 
-static int check_tty(struct tty_struct *tty)
-{
-   if (!tty) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   spk_ttyio_synth->long_name);
-   /* 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
-*/
-   spk_ttyio_synth->alive = 0;
-   speakup_start_ttys();
-   return 1;
-   }
-
-   return 0;
-}
-
 static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (check_tty(speakup_tty)) {
-  

[PATCH 4/4] speakup: Add documentation on changing the speakup messages language

2021-01-26 Thread Samuel Thibault
This documents how to use speakup_setlocale to set the speakup messages
language.

Signed-off-by: Samuel Thibault 
---
 Documentation/admin-guide/spkguide.txt | 48 --
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/spkguide.txt 
b/Documentation/admin-guide/spkguide.txt
index 5ff6a0f..977ab3f 100644
--- a/Documentation/admin-guide/spkguide.txt
+++ b/Documentation/admin-guide/spkguide.txt
@@ -1033,7 +1033,9 @@ speakup + keypad 3, you would hear:
 The speakup key is depressed, so the name of the key state is speakup.
 This part of the message comes from the states collection.
 
-14.2.  Loading Your Own Messages
+14.2.  Changing language
+
+14.2.1. Loading Your Own Messages
 
 The files under the i18n subdirectory all follow the same format.
 They consist of lines, with one message per line.
@@ -1066,8 +1068,50 @@ echo '1 azul' > /speakup/i18n/colors
 The next time that Speakup says message 1 from the colors group, it will
 say "azul", rather than "blue."
 
+14.2.2. Choose a language
+
 In the future, translations into various languages will be made available,
-and most users will just load the files necessary for their language.
+and most users will just load the files necessary for their language. So far,
+only French language is available beyond native Canadian English language.
+
+French is only available after you are logged in.
+
+Canadian English is the default language. To toggle another language,
+download the source of Speakup and untar it in your home directory. The
+following command should let you do this:
+
+tar xvjf speakup-.tar.bz2
+
+where  is the version number of the application.
+
+Next, change to the newly created directory, then into the tools/ directory, 
and
+run the script speakup_setlocale. You are asked the language that you want to
+use. Type the number associated to your language (e.g. fr for French) then 
press
+Enter. Needed files are copied in the i18n directory.
+
+Note: the speakupconf must be installed on your system so that settings are 
saved.
+Otherwise, you will have an error: your language will be loaded but you will
+have to run the script again every time Speakup restarts.
+See section 16.1. for information about speakupconf.
+
+You will have to repeat these steps for any change of locale, i.e. if you wish
+change the speakup's language or charset (iso-8859-15 ou UTF-8).
+
+If you wish store the settings, note that at your next login, you will need to
+do:
+
+speakup load
+
+Alternatively, you can add the above line to your file
+~/.bashrc or ~/.bash_profile.
+
+If your system administrator ran himself the script, all the users will be able
+to change from English to the language choosed by root and do directly
+speakupconf load (or add this to the ~/.bashrc or
+~/.bash_profile file). If there are several languages to handle, the
+administrator (or every user) will have to run the first steps until 
speakupconf
+save, choosing the appropriate language, in every user's home directory. Every
+user will then be able to do speakupconf load, Speakup will load his own 
settings.
 
 14.3.  No Support for Non-Western-European Languages
 
-- 
2.20.1



[PATCH 1/4] speakup: add the missing synth parameter to all io functions

2021-01-26 Thread Samuel Thibault
So that we can avoid the spk_ttyio_synth global variable in the next
commit.

Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/serialio.c  | 22 ++--
 .../accessibility/speakup/speakup_acntpc.c|  4 +--
 .../accessibility/speakup/speakup_apollo.c|  4 +--
 .../accessibility/speakup/speakup_audptr.c|  8 ++---
 .../accessibility/speakup/speakup_decext.c|  2 +-
 drivers/accessibility/speakup/speakup_decpc.c |  4 +--
 .../accessibility/speakup/speakup_dectlk.c|  2 +-
 drivers/accessibility/speakup/speakup_dtlk.c  |  4 +--
 drivers/accessibility/speakup/speakup_keypc.c |  4 +--
 drivers/accessibility/speakup/speakup_ltlk.c  |  2 +-
 drivers/accessibility/speakup/speakup_soft.c  |  4 +--
 .../accessibility/speakup/speakup_spkout.c|  4 +--
 drivers/accessibility/speakup/spk_priv.h  |  4 +--
 drivers/accessibility/speakup/spk_ttyio.c | 34 +--
 drivers/accessibility/speakup/spk_types.h | 12 +++
 drivers/accessibility/speakup/synth.c |  6 ++--
 16 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/accessibility/speakup/serialio.c 
b/drivers/accessibility/speakup/serialio.c
index 403b01d..53580bd 100644
--- a/drivers/accessibility/speakup/serialio.c
+++ b/drivers/accessibility/speakup/serialio.c
@@ -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)
diff --git a/drivers/accessibility/speakup/speakup_acntpc.c 
b/drivers/accessibility/speakup/speakup_acntpc.c
index c94328a..c1ec087 100644
--- a/drivers/accessibility/speakup/speakup_acntpc.c
+++ b/drivers/accessibility/speakup/speakup_acntpc.c
@@ -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)
diff --git a/drivers/accessibility/speakup/speakup_apollo.c 
b/drivers/accessibility/speakup/speakup_apollo.c
index 0877b40..cd63581 100644

[PATCH 0/4] speakup update

2021-01-26 Thread Samuel Thibault
Samuel Thibault (4):
  speakup: add the missing synth parameter to all io functions
  speakup: Reference synth from tty and tty from synth
  speakup: Simplify spk_ttyio_out error handling.
  speakup: Add documentation on changing the speakup messages language

 Documentation/admin-guide/spkguide.txt|  48 -
 drivers/accessibility/speakup/serialio.c  |  22 +--
 .../accessibility/speakup/speakup_acntpc.c|   4 +-
 .../accessibility/speakup/speakup_apollo.c|   4 +-
 .../accessibility/speakup/speakup_audptr.c|   8 +-
 .../accessibility/speakup/speakup_decext.c|   2 +-
 drivers/accessibility/speakup/speakup_decpc.c |   4 +-
 .../accessibility/speakup/speakup_dectlk.c|   2 +-
 drivers/accessibility/speakup/speakup_dtlk.c  |   4 +-
 drivers/accessibility/speakup/speakup_keypc.c |   4 +-
 drivers/accessibility/speakup/speakup_ltlk.c  |   2 +-
 drivers/accessibility/speakup/speakup_soft.c  |   4 +-
 .../accessibility/speakup/speakup_spkout.c|   4 +-
 drivers/accessibility/speakup/spk_priv.h  |   4 +-
 drivers/accessibility/speakup/spk_ttyio.c | 185 --
 drivers/accessibility/speakup/spk_types.h |  14 +-
 drivers/accessibility/speakup/synth.c |   6 +-
 17 files changed, 170 insertions(+), 151 deletions(-)

-- 
2.20.1



[PATCH 0/4] speakup update

2021-01-11 Thread Samuel Thibault
Samuel Thibault (4):
  This merely adds the missing synth parameter to all io functions.
  speakup: Reference synth from tty and tty from synth
  speakup: Simplify spk_ttyio_out error handling.
  speakup: Add documentation on changing the speakup messages language

 Documentation/admin-guide/spkguide.txt|  48 -
 drivers/accessibility/speakup/serialio.c  |  22 +--
 .../accessibility/speakup/speakup_acntpc.c|   4 +-
 .../accessibility/speakup/speakup_apollo.c|   4 +-
 .../accessibility/speakup/speakup_audptr.c|   8 +-
 .../accessibility/speakup/speakup_decext.c|   2 +-
 drivers/accessibility/speakup/speakup_decpc.c |   4 +-
 .../accessibility/speakup/speakup_dectlk.c|   2 +-
 drivers/accessibility/speakup/speakup_dtlk.c  |   4 +-
 drivers/accessibility/speakup/speakup_keypc.c |   4 +-
 drivers/accessibility/speakup/speakup_ltlk.c  |   2 +-
 drivers/accessibility/speakup/speakup_soft.c  |   4 +-
 .../accessibility/speakup/speakup_spkout.c|   4 +-
 drivers/accessibility/speakup/spk_priv.h  |   4 +-
 drivers/accessibility/speakup/spk_ttyio.c | 185 --
 drivers/accessibility/speakup/spk_types.h |  14 +-
 drivers/accessibility/speakup/synth.c |   6 +-
 17 files changed, 170 insertions(+), 151 deletions(-)

-- 
2.20.1



[PATCH 2/4] speakup: Reference synth from tty and tty from synth

2021-01-11 Thread Samuel Thibault
We do not actually need speakup_tty and spk_ttyio_synth global
variables, the synth can store the pointer to the tty, and the tty
ldisc_data can store the pointer to the synth.

Along the way, we can clench the initialization of the synth and the
creation of the tty, so that tty is never NULL. Even if the device
disappears (e.g. USB unplug), the tty structure will still be there,
and we automatically stop speakup in the spk_ttyio_out error handler
but keep tty until the user cleans things up.

As a result, this simplifies locking a lot.

Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/spk_ttyio.c | 117 --
 drivers/accessibility/speakup/spk_types.h |   2 +
 2 files changed, 46 insertions(+), 73 deletions(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c 
b/drivers/accessibility/speakup/spk_ttyio.c
index d62fb74..adc1cdb 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -12,14 +12,15 @@ struct spk_ldisc_data {
char buf;
struct completion completion;
bool buf_free;
+   struct spk_synth *synth;
 };
 
-static struct spk_synth *spk_ttyio_synth;
-static struct tty_struct *speakup_tty;
-/* mutex to protect against speakup_tty disappearing from underneath us while
- * we are using it. this can happen when the device physically unplugged,
- * while in use. it also serialises access to speakup_tty.
+/*
+ * This allows to catch within spk_ttyio_ldisc_open whether it is getting set
+ * on for a speakup-driven device.
  */
+static struct tty_struct *speakup_tty;
+/* This mutex serializes the use of such global speakup_tty variable */
 static DEFINE_MUTEX(speakup_tty_mutex);
 
 static int ser_to_dev(int ser, dev_t *dev_no)
@@ -67,22 +68,20 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty)
 
 static void spk_ttyio_ldisc_close(struct tty_struct *tty)
 {
-   mutex_lock(_tty_mutex);
-   kfree(speakup_tty->disc_data);
-   speakup_tty = NULL;
-   mutex_unlock(_tty_mutex);
+   kfree(tty->disc_data);
 }
 
 static int spk_ttyio_receive_buf2(struct tty_struct *tty,
  const unsigned char *cp, char *fp, int count)
 {
struct spk_ldisc_data *ldisc_data = tty->disc_data;
+   struct spk_synth *synth = ldisc_data->synth;
 
-   if (spk_ttyio_synth->read_buff_add) {
+   if (synth->read_buff_add) {
int i;
 
for (i = 0; i < count; i++)
-   spk_ttyio_synth->read_buff_add(cp[i]);
+   synth->read_buff_add(cp[i]);
 
return count;
}
@@ -187,13 +186,17 @@ static int spk_ttyio_initialise_ldisc(struct spk_synth 
*synth)
mutex_lock(_tty_mutex);
speakup_tty = tty;
ret = tty_set_ldisc(tty, N_SPEAKUP);
-   if (ret)
-   speakup_tty = NULL;
+   speakup_tty = NULL;
mutex_unlock(_tty_mutex);
 
-   if (!ret)
+   if (!ret) {
/* Success */
+   struct spk_ldisc_data *ldisc_data = tty->disc_data;
+
+   ldisc_data->synth = synth;
+   synth->dev = tty;
return 0;
+   }
 
pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
 
@@ -221,11 +224,11 @@ void spk_ttyio_unregister_ldisc(void)
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (in_synth->alive && speakup_tty && speakup_tty->ops->write) {
-   int ret = speakup_tty->ops->write(speakup_tty, , 1);
+   struct tty_struct *tty = in_synth->dev;
+
+   if (in_synth->alive && tty->ops->write) {
+   int ret = tty->ops->write(tty, , 1);
 
-   mutex_unlock(_tty_mutex);
if (ret == 0)
/* No room */
return 0;
@@ -243,7 +246,6 @@ static int spk_ttyio_out(struct spk_synth *in_synth, const 
char ch)
return 1;
}
 
-   mutex_unlock(_tty_mutex);
return 0;
 }
 
@@ -264,47 +266,20 @@ static int spk_ttyio_out_unicode(struct spk_synth 
*in_synth, u16 ch)
return ret;
 }
 
-static int check_tty(struct tty_struct *tty)
-{
-   if (!tty) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   spk_ttyio_synth->long_name);
-   /* 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
-*/
-   spk_ttyio_synth->alive = 0;
-   speakup_start_ttys();
-   return 1;
-   }
-
-   return 0;
-}
-
 static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (check_tty(speakup_tty)) {
-  

[PATCH 3/4] speakup: Simplify spk_ttyio_out error handling.

2021-01-11 Thread Samuel Thibault
This avoids most code indentation

Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/spk_ttyio.c | 38 ---
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c 
b/drivers/accessibility/speakup/spk_ttyio.c
index adc1cdb..4dbd24c 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void)
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
struct tty_struct *tty = in_synth->dev;
+   int ret;
+
+   if (!in_synth->alive || !tty->ops->write)
+   return 0;
 
-   if (in_synth->alive && tty->ops->write) {
-   int ret = tty->ops->write(tty, , 1);
-
-   if (ret == 0)
-   /* No room */
-   return 0;
-   if (ret < 0) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   in_synth->long_name);
-   /* 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
-*/
-   in_synth->alive = 0;
-   speakup_start_ttys();
-   return 0;
-   }
+   ret = tty->ops->write(tty, , 1);
+
+   if (ret == 0)
+   /* No room */
+   return 0;
+
+   if (ret > 0)
+   /* Success */
return 1;
-   }
 
+   pr_warn("%s: I/O error, deactivating speakup\n",
+   in_synth->long_name);
+   /* 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
+*/
+   in_synth->alive = 0;
+   speakup_start_ttys();
return 0;
 }
 
-- 
2.20.1



[PATCH 4/4] speakup: Add documentation on changing the speakup messages language

2021-01-11 Thread Samuel Thibault
Signed-off-by: Samuel Thibault 
---
 Documentation/admin-guide/spkguide.txt | 48 --
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/spkguide.txt 
b/Documentation/admin-guide/spkguide.txt
index 5ff6a0f..96d4c87 100644
--- a/Documentation/admin-guide/spkguide.txt
+++ b/Documentation/admin-guide/spkguide.txt
@@ -1033,7 +1033,9 @@ speakup + keypad 3, you would hear:
 The speakup key is depressed, so the name of the key state is speakup.
 This part of the message comes from the states collection.
 
-14.2.  Loading Your Own Messages
+14.2.  Changing language
+
+14.2.1. Loading Your Own Messages
 
 The files under the i18n subdirectory all follow the same format.
 They consist of lines, with one message per line.
@@ -1066,8 +1068,50 @@ echo '1 azul' > /speakup/i18n/colors
 The next time that Speakup says message 1 from the colors group, it will
 say "azul", rather than "blue."
 
+14.2.2. Choose a language
+
 In the future, translations into various languages will be made available,
-and most users will just load the files necessary for their language.
+and most users will just load the files necessary for their language. So far,
+only French language is available beyond native Canadian English language.
+
+French is only available after you are logged in.
+
+Canadian English is the default language. To toogle another language,
+download the source of Speakup and untar it in your home directory. The
+following command should let you do this:
+
+tar xvjf speakup-.tar.bz2
+
+where  is the version number of the application.
+
+Next, change to the newly created directory, then into the tools/ directory, 
and
+run the script speakup_setlocale. You are asked the language that you want to
+use. Type the number associated to your language (e.g. fr for French) then 
press
+Enter. Needed files are copied in the i18n directory.
+
+Note: the speakupconf must be installed on your system so that settings are 
saved.
+Otherwise, you will have an error: your language will be loaded but you will
+have to run the script again every time Speakup restarts.
+See section 16.1. for information about speakupconf.
+
+You will have to repeat these steps for any change of locale, i.e. if you wish
+change the speakup's language or charset (iso-8859-15 ou UTF-8).
+
+If you wish store the settings, note that at your next login, you will need to
+do:
+
+speakup load
+
+Alternatively, you can add the above line to your file
+~/.bashrc or ~/.bash_profile.
+
+If your system administrator ran himself the script, all the users will be able
+to change from English to the language choosed by root and do directly
+speakupconf load (or add this to the ~/.bashrc or
+~/.bash_profile file). If there are several languages to handle, the
+administrator (or every user) will have to run the first steps until 
speakupconf
+save, choosing the appropriate language, in every user's home directory. Every
+user will then be able to do speakupconf load, Speakup will load his own 
settings.
 
 14.3.  No Support for Non-Western-European Languages
 
-- 
2.20.1



[PATCH 1/4] This merely adds the missing synth parameter to all io functions.

2021-01-11 Thread Samuel Thibault
Signed-off-by: Samuel Thibault 
---
 drivers/accessibility/speakup/serialio.c  | 22 ++--
 .../accessibility/speakup/speakup_acntpc.c|  4 +--
 .../accessibility/speakup/speakup_apollo.c|  4 +--
 .../accessibility/speakup/speakup_audptr.c|  8 ++---
 .../accessibility/speakup/speakup_decext.c|  2 +-
 drivers/accessibility/speakup/speakup_decpc.c |  4 +--
 .../accessibility/speakup/speakup_dectlk.c|  2 +-
 drivers/accessibility/speakup/speakup_dtlk.c  |  4 +--
 drivers/accessibility/speakup/speakup_keypc.c |  4 +--
 drivers/accessibility/speakup/speakup_ltlk.c  |  2 +-
 drivers/accessibility/speakup/speakup_soft.c  |  4 +--
 .../accessibility/speakup/speakup_spkout.c|  4 +--
 drivers/accessibility/speakup/spk_priv.h  |  4 +--
 drivers/accessibility/speakup/spk_ttyio.c | 34 +--
 drivers/accessibility/speakup/spk_types.h | 12 +++
 drivers/accessibility/speakup/synth.c |  6 ++--
 16 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/accessibility/speakup/serialio.c 
b/drivers/accessibility/speakup/serialio.c
index 403b01d..53580bd 100644
--- a/drivers/accessibility/speakup/serialio.c
+++ b/drivers/accessibility/speakup/serialio.c
@@ -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)
diff --git a/drivers/accessibility/speakup/speakup_acntpc.c 
b/drivers/accessibility/speakup/speakup_acntpc.c
index c94328a..c1ec087 100644
--- a/drivers/accessibility/speakup/speakup_acntpc.c
+++ b/drivers/accessibility/speakup/speakup_acntpc.c
@@ -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)
diff --git a/drivers/accessibility/speakup/speakup_apollo.c 
b/drivers/accessibility/speakup/speakup_apollo.c
index 0877b40..cd63581 100644
--- a/drivers/accessibility/speakup/speakup_apollo.c
+++ b/drivers/accessibility

Re: [patch 1/3] speakup: Add synth parameter to io functions

2021-01-05 Thread Samuel Thibault
Greg KH, le mar. 05 janv. 2021 14:39:47 +0100, a ecrit:
> On Thu, Dec 10, 2020 at 09:03:00PM +0100, Samuel Thibault wrote:
> > Greg KH, le jeu. 10 déc. 2020 16:23:11 +0100, a ecrit:
> > > The build still breaks when this patch is applied:
> > 
> > > drivers/accessibility/speakup/spk_ttyio.c:344:18: note: in expansion of 
> > > macro ‘SPK_SYNTH_TIMEOUT’
> > >   344 |  return ttyio_in(SPK_SYNTH_TIMEOUT);
> > 
> > Sorry, I had a refresh missing. I don't contribute often enough to Linux
> > any more, my quilt-fu is lacking :)
> > 
> > I'll resend the series.
> 
> Did you resend this?  I can't find it...

I believe so, but I'll resend again anyway (with some more changes iirc)

Samuel


[PATCH] speakup: Add github repository URL and bug tracker

2020-12-21 Thread Samuel Thibault
We have set up a repository for users to try newer releases more easily, and
keep records of known bugs.

Signed-off-by: Samuel Thibault 

Index: linux-5.10/MAINTAINERS
===
--- linux-5.10.orig/MAINTAINERS
+++ linux-5.10/MAINTAINERS
@@ -16325,6 +16325,8 @@ M:  Samuel Thibault http://www.linux-speakup.org/
+W: https://github.com/linux-speakup/speakup
+B: https://github.com/linux-speakup/speakup/issues
 F: drivers/accessibility/speakup/
 
 SPEAR CLOCK FRAMEWORK SUPPORT


[patch 0/3] speakup: simplify relation between line disc and synth

2020-12-10 Thread samuel . thibault
This series reworks the relation between the speakup line discipline and the
speakup synthesizers. This is probably fixing a few minor issues, but since it
is invasive it'll better wait for 5.11.



[patch 3/3] speakup: Simplify spk_ttyio_out error handling.

2020-12-10 Thread samuel . thibault
This avoids most code indentation

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void)
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
struct tty_struct *tty = in_synth->dev;
+   int ret;
 
-   if (in_synth->alive && tty->ops->write) {
-   int ret = tty->ops->write(tty, , 1);
+   if (!in_synth->alive || !tty->ops->write)
+   return 0;
 
-   if (ret == 0)
-   /* No room */
-   return 0;
-   if (ret < 0) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   in_synth->long_name);
-   /* 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
-*/
-   in_synth->alive = 0;
-   speakup_start_ttys();
-   return 0;
-   }
+   ret = tty->ops->write(tty, , 1);
+
+   if (ret == 0)
+   /* No room */
+   return 0;
+
+   if (ret > 0)
+   /* Success */
return 1;
-   }
 
+   pr_warn("%s: I/O error, deactivating speakup\n",
+   in_synth->long_name);
+   /* 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
+*/
+   in_synth->alive = 0;
+   speakup_start_ttys();
return 0;
 }
 




Re: [patch 1/3] speakup: Add synth parameter to io functions

2020-12-10 Thread Samuel Thibault
Greg KH, le jeu. 10 déc. 2020 16:23:11 +0100, a ecrit:
> The build still breaks when this patch is applied:

> drivers/accessibility/speakup/spk_ttyio.c:344:18: note: in expansion of macro 
> ‘SPK_SYNTH_TIMEOUT’
>   344 |  return ttyio_in(SPK_SYNTH_TIMEOUT);

Sorry, I had a refresh missing. I don't contribute often enough to Linux
any more, my quilt-fu is lacking :)

I'll resend the series.

Samuel


[patch 1/3] speakup: Add synth parameter to io functions

2020-12-10 Thread samuel . thibault
This merely adds the missing synth parameter to all io functions.

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -114,11 +114,11 @@ static struct tty_ldisc_ops spk_ttyio_ld
 
 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 *
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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -294,7 +294,7 @@ static void spk_ttyio_send_xchar(char ch
mutex_unlock(_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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -312,7 +312,7 @@ static int spk_ttyio_wait_for_xmitr(stru
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 timeou
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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -379,7 +379,7 @@ int spk_ttyio_synth_probe(struct spk_syn
 }
 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: linux-5.9/drivers/accessibility/speakup/serialio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/serialio.c
+++ linux-5.9/drivers/accessibility/speakup/serialio.c
@@ -27,11 +27,11 @@ static const struct old_serial_port *ser
 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

[patch 2/3] speakup: Reference synth from tty and tty from synth

2020-12-10 Thread samuel . thibault
We do not actually need speakup_tty and spk_ttyio_synth global
variables, the synth can store the pointer to the tty, and the tty
ldisc_data can store the pointer to the synth.

Along the way, we can clench the initialization of the synth and the
creation of the tty, so that tty is never NULL. Even if the device
disappears (e.g. USB unplug), the tty structure will still be there,
and we automatically stop speakup in the spk_ttyio_out error handler
but keep tty until the user cleans things up.

As a result, this simplifies locking a lot.

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -12,14 +12,15 @@ struct spk_ldisc_data {
char buf;
struct completion completion;
bool buf_free;
+   struct spk_synth *synth;
 };
 
-static struct spk_synth *spk_ttyio_synth;
-static struct tty_struct *speakup_tty;
-/* mutex to protect against speakup_tty disappearing from underneath us while
- * we are using it. this can happen when the device physically unplugged,
- * while in use. it also serialises access to speakup_tty.
+/*
+ * This allows to catch within spk_ttyio_ldisc_open whether it is getting set
+ * on for a speakup-driven device.
  */
+static struct tty_struct *speakup_tty;
+/* This mutex serializes the use of such global speakup_tty variable */
 static DEFINE_MUTEX(speakup_tty_mutex);
 
 static int ser_to_dev(int ser, dev_t *dev_no)
@@ -67,22 +68,20 @@ static int spk_ttyio_ldisc_open(struct t
 
 static void spk_ttyio_ldisc_close(struct tty_struct *tty)
 {
-   mutex_lock(_tty_mutex);
-   kfree(speakup_tty->disc_data);
-   speakup_tty = NULL;
-   mutex_unlock(_tty_mutex);
+   kfree(tty->disc_data);
 }
 
 static int spk_ttyio_receive_buf2(struct tty_struct *tty,
  const unsigned char *cp, char *fp, int count)
 {
struct spk_ldisc_data *ldisc_data = tty->disc_data;
+   struct spk_synth *synth = ldisc_data->synth;
 
-   if (spk_ttyio_synth->read_buff_add) {
+   if (synth->read_buff_add) {
int i;
 
for (i = 0; i < count; i++)
-   spk_ttyio_synth->read_buff_add(cp[i]);
+   synth->read_buff_add(cp[i]);
 
return count;
}
@@ -187,13 +186,17 @@ static int spk_ttyio_initialise_ldisc(st
mutex_lock(_tty_mutex);
speakup_tty = tty;
ret = tty_set_ldisc(tty, N_SPEAKUP);
-   if (ret)
-   speakup_tty = NULL;
+   speakup_tty = NULL;
mutex_unlock(_tty_mutex);
 
-   if (!ret)
+   if (!ret) {
/* Success */
+   struct spk_ldisc_data *ldisc_data = tty->disc_data;
+
+   ldisc_data->synth = synth;
+   synth->dev = tty;
return 0;
+   }
 
pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
 
@@ -221,11 +224,11 @@ void spk_ttyio_unregister_ldisc(void)
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (in_synth->alive && speakup_tty && speakup_tty->ops->write) {
-   int ret = speakup_tty->ops->write(speakup_tty, , 1);
+   struct tty_struct *tty = in_synth->dev;
+
+   if (in_synth->alive && tty->ops->write) {
+   int ret = tty->ops->write(tty, , 1);
 
-   mutex_unlock(_tty_mutex);
if (ret == 0)
/* No room */
return 0;
@@ -243,7 +246,6 @@ static int spk_ttyio_out(struct spk_synt
return 1;
}
 
-   mutex_unlock(_tty_mutex);
return 0;
 }
 
@@ -264,47 +266,20 @@ static int spk_ttyio_out_unicode(struct
return ret;
 }
 
-static int check_tty(struct tty_struct *tty)
-{
-   if (!tty) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   spk_ttyio_synth->long_name);
-   /* 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
-*/
-   spk_ttyio_synth->alive = 0;
-   speakup_start_ttys();
-   return 1;
-   }
-
-   return 0;
-}
-
 static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (check_tty(speakup_tty)) {
-   mutex_unlock(_tty_mutex);
-   return;
-   }
+   struct tty_struct *tty = in_synth->dev;
 
-   if (speakup_tty->ops->send_xchar)
-   speakup_tty->ops->send_xchar(speakup_tty, ch)

Re: [patch 1/3] speakup: Add synth parameter to io functions

2020-12-10 Thread Samuel Thibault
Greg KH, le jeu. 10 déc. 2020 16:23:11 +0100, a ecrit:
> On Wed, Dec 09, 2020 at 09:58:30PM +0100, samuel.thiba...@ens-lyon.org wrote:
> > This merely adds the missing synth parameter to all io functions.
> > 
> > Signed-off-by: Samuel Thibault 
> > 
> 
> The build still breaks when this patch is applied:

?? I'll have to check

> You can't break the build on any patches in a series :(

Sure ! In my tests the build passes fine without any warning at each
patch...

Samuel


[patch 3/3] speakup: Simplify spk_ttyio_out error handling.

2020-12-09 Thread samuel . thibault
This avoids most code indentation

Signed-off-by: Samuel Thibault 

Index: linux-5.10/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.10.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.10/drivers/accessibility/speakup/spk_ttyio.c
@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void)
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
struct tty_struct *tty = in_synth->dev;
+   int ret;
 
-   if (in_synth->alive && tty->ops->write) {
-   int ret = tty->ops->write(tty, , 1);
+   if (!in_synth->alive || !tty->ops->write)
+   return 0;
 
-   if (ret == 0)
-   /* No room */
-   return 0;
-   if (ret < 0) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   in_synth->long_name);
-   /* 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
-*/
-   in_synth->alive = 0;
-   speakup_start_ttys();
-   return 0;
-   }
+   ret = tty->ops->write(tty, , 1);
+
+   if (ret == 0)
+   /* No room */
+   return 0;
+
+   if (ret > 0)
+   /* Success */
return 1;
-   }
 
+   pr_warn("%s: I/O error, deactivating speakup\n",
+   in_synth->long_name);
+   /* 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
+*/
+   in_synth->alive = 0;
+   speakup_start_ttys();
return 0;
 }
 




Re: [patch 1/3] speakup: Add synth parameter to io functions

2020-12-09 Thread Samuel Thibault
Greg KH, le mer. 09 déc. 2020 15:40:29 +0100, a ecrit:
> On Mon, Nov 30, 2020 at 11:26:41PM +0100, Samuel Thibault wrote:
> > This merely adds the missing synth parameter to all io functions.
> > 
> > Signed-off-by: Samuel Thibault 
> 
> This patch breaks the build :(
> 
> Can you rebase and resend this whole series, as the other patches do not
> apply anymore due to the recent fixes in the speakup code.

Ok, I rebased and resent.

Samuel


[patch 2/3] speakup: Reference synth from tty and tty from synth

2020-12-09 Thread samuel . thibault
We do not actually need speakup_tty and spk_ttyio_synth global
variables, the synth can store the pointer to the tty, and the tty
ldisc_data can store the pointer to the synth.

Along the way, we can clench the initialization of the synth and the
creation of the tty, so that tty is never NULL. Even if the device
disappears (e.g. USB unplug), the tty structure will still be there,
and we automatically stop speakup in the spk_ttyio_out error handler
but keep tty until the user cleans things up.

As a result, this simplifies locking a lot.

Signed-off-by: Samuel Thibault 

Index: linux-5.10/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.10.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.10/drivers/accessibility/speakup/spk_ttyio.c
@@ -12,14 +12,15 @@ struct spk_ldisc_data {
char buf;
struct completion completion;
bool buf_free;
+   struct spk_synth *synth;
 };
 
-static struct spk_synth *spk_ttyio_synth;
-static struct tty_struct *speakup_tty;
-/* mutex to protect against speakup_tty disappearing from underneath us while
- * we are using it. this can happen when the device physically unplugged,
- * while in use. it also serialises access to speakup_tty.
+/*
+ * This allows to catch within spk_ttyio_ldisc_open whether it is getting set
+ * on for a speakup-driven device.
  */
+static struct tty_struct *speakup_tty;
+/* This mutex serializes the use of such global speakup_tty variable */
 static DEFINE_MUTEX(speakup_tty_mutex);
 
 static int ser_to_dev(int ser, dev_t *dev_no)
@@ -67,22 +68,20 @@ static int spk_ttyio_ldisc_open(struct t
 
 static void spk_ttyio_ldisc_close(struct tty_struct *tty)
 {
-   mutex_lock(_tty_mutex);
-   kfree(speakup_tty->disc_data);
-   speakup_tty = NULL;
-   mutex_unlock(_tty_mutex);
+   kfree(tty->disc_data);
 }
 
 static int spk_ttyio_receive_buf2(struct tty_struct *tty,
  const unsigned char *cp, char *fp, int count)
 {
struct spk_ldisc_data *ldisc_data = tty->disc_data;
+   struct spk_synth *synth = ldisc_data->synth;
 
-   if (spk_ttyio_synth->read_buff_add) {
+   if (synth->read_buff_add) {
int i;
 
for (i = 0; i < count; i++)
-   spk_ttyio_synth->read_buff_add(cp[i]);
+   synth->read_buff_add(cp[i]);
 
return count;
}
@@ -187,13 +186,17 @@ static int spk_ttyio_initialise_ldisc(st
mutex_lock(_tty_mutex);
speakup_tty = tty;
ret = tty_set_ldisc(tty, N_SPEAKUP);
-   if (ret)
-   speakup_tty = NULL;
+   speakup_tty = NULL;
mutex_unlock(_tty_mutex);
 
-   if (!ret)
+   if (!ret) {
/* Success */
+   struct spk_ldisc_data *ldisc_data = tty->disc_data;
+
+   ldisc_data->synth = synth;
+   synth->dev = tty;
return 0;
+   }
 
pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
 
@@ -221,11 +224,11 @@ void spk_ttyio_unregister_ldisc(void)
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (in_synth->alive && speakup_tty && speakup_tty->ops->write) {
-   int ret = speakup_tty->ops->write(speakup_tty, , 1);
+   struct tty_struct *tty = in_synth->dev;
+
+   if (in_synth->alive && tty->ops->write) {
+   int ret = tty->ops->write(tty, , 1);
 
-   mutex_unlock(_tty_mutex);
if (ret == 0)
/* No room */
return 0;
@@ -243,7 +246,6 @@ static int spk_ttyio_out(struct spk_synt
return 1;
}
 
-   mutex_unlock(_tty_mutex);
return 0;
 }
 
@@ -264,47 +266,20 @@ static int spk_ttyio_out_unicode(struct
return ret;
 }
 
-static int check_tty(struct tty_struct *tty)
-{
-   if (!tty) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   spk_ttyio_synth->long_name);
-   /* 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
-*/
-   spk_ttyio_synth->alive = 0;
-   speakup_start_ttys();
-   return 1;
-   }
-
-   return 0;
-}
-
 static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (check_tty(speakup_tty)) {
-   mutex_unlock(_tty_mutex);
-   return;
-   }
+   struct tty_struct *tty = in_synth->dev;
 
-   if (speakup_tty->ops->send_xchar)
-   speakup_tty->ops->send_xchar(speakup_tty, ch)

[patch 1/3] speakup: Add synth parameter to io functions

2020-12-09 Thread samuel . thibault
This merely adds the missing synth parameter to all io functions.

Signed-off-by: Samuel Thibault 

Index: linux-5.10/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.10.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.10/drivers/accessibility/speakup/spk_ttyio.c
@@ -114,11 +114,11 @@ static struct tty_ldisc_ops spk_ttyio_ld
 
 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 *
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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -294,7 +294,7 @@ static void spk_ttyio_send_xchar(char ch
mutex_unlock(_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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -312,7 +312,7 @@ static int spk_ttyio_wait_for_xmitr(stru
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 timeou
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);
 }
 
-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);
 
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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -379,7 +379,7 @@ int spk_ttyio_synth_probe(struct spk_syn
 }
 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: linux-5.10/drivers/accessibility/speakup/serialio.c
===
--- linux-5.10.orig/drivers/accessibility/speakup/serialio.c
+++ linux-5.10/drivers/accessibility/speakup/serialio.c
@@ -27,11 +27,11 @@ static const struct old_serial_port *ser
 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 i
outb(1, speakup_

[patch 0/3] speakup: simplify relation between line disc and synth

2020-12-09 Thread samuel . thibault
This series reworks the relation between the speakup line discipline and the
speakup synthesizers. This is probably fixing a few minor issues, but since it
is invasive it'll better wait for 5.11.



[patch 3/3] speakup: Simplify spk_ttyio_out error handling.

2020-11-30 Thread Samuel Thibault
This avoids most code indentation

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void)
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
struct tty_struct *tty = in_synth->dev;
+   int ret;
 
-   if (in_synth->alive && tty->ops->write) {
-   int ret = tty->ops->write(tty, , 1);
+   if (!in_synth->alive || !tty->ops->write)
+   return 0;
 
-   if (ret == 0)
-   /* No room */
-   return 0;
-   if (ret < 0) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   in_synth->long_name);
-   /* 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
-*/
-   in_synth->alive = 0;
-   speakup_start_ttys();
-   return 0;
-   }
+   ret = tty->ops->write(tty, , 1);
+
+   if (ret == 0)
+   /* No room */
+   return 0;
+
+   if (ret > 0)
+   /* Success */
return 1;
-   }
 
+   pr_warn("%s: I/O error, deactivating speakup\n",
+   in_synth->long_name);
+   /* 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
+*/
+   in_synth->alive = 0;
+   speakup_start_ttys();
return 0;
 }
 





[patch 1/3] speakup: Add synth parameter to io functions

2020-11-30 Thread Samuel Thibault
This merely adds the missing synth parameter to all io functions.

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -114,11 +114,11 @@ static struct tty_ldisc_ops spk_ttyio_ld
 
 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 *
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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -294,7 +294,7 @@ static void spk_ttyio_send_xchar(char ch
mutex_unlock(_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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -312,7 +312,7 @@ static int spk_ttyio_wait_for_xmitr(stru
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;
@@ -337,19 +337,19 @@ static unsigned char ttyio_in(int timeou
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);
 }
 
-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);
 
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(_tty_mutex);
if (check_tty(speakup_tty)) {
@@ -377,7 +377,7 @@ int spk_ttyio_synth_probe(struct spk_syn
 }
 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;
@@ -393,15 +393,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: linux-5.9/drivers/accessibility/speakup/serialio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/serialio.c
+++ linux-5.9/drivers/accessibility/speakup/serialio.c
@@ -27,11 +27,11 @@ static const struct old_serial_port *ser
 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 i
outb(1, speakup_info.port_tts +

[patch 2/3] speakup: Reference synth from tty and tty from synth

2020-11-30 Thread Samuel Thibault
We do not actually need speakup_tty and spk_ttyio_synth global
variables, the synth can store the pointer to the tty, and the tty
ldisc_data can store the pointer to the synth.

Along the way, we can clench the initialization of the synth and the
creation of the tty, so that tty is never NULL. Even if the device
disappears (e.g. USB unplug), the tty structure will still be there,
and we automatically stop speakup in the spk_ttyio_out error handler
but keep tty until the user cleans things up.

As a result, this simplifies locking a lot.

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -12,14 +12,15 @@ struct spk_ldisc_data {
char buf;
struct completion completion;
bool buf_free;
+   struct spk_synth *synth;
 };
 
-static struct spk_synth *spk_ttyio_synth;
-static struct tty_struct *speakup_tty;
-/* mutex to protect against speakup_tty disappearing from underneath us while
- * we are using it. this can happen when the device physically unplugged,
- * while in use. it also serialises access to speakup_tty.
+/*
+ * This allows to catch within spk_ttyio_ldisc_open whether it is getting set
+ * on for a speakup-driven device.
  */
+static struct tty_struct *speakup_tty;
+/* This mutex serializes the use of such global speakup_tty variable */
 static DEFINE_MUTEX(speakup_tty_mutex);
 
 static int ser_to_dev(int ser, dev_t *dev_no)
@@ -67,22 +68,20 @@ static int spk_ttyio_ldisc_open(struct t
 
 static void spk_ttyio_ldisc_close(struct tty_struct *tty)
 {
-   mutex_lock(_tty_mutex);
-   kfree(speakup_tty->disc_data);
-   speakup_tty = NULL;
-   mutex_unlock(_tty_mutex);
+   kfree(tty->disc_data);
 }
 
 static int spk_ttyio_receive_buf2(struct tty_struct *tty,
  const unsigned char *cp, char *fp, int count)
 {
struct spk_ldisc_data *ldisc_data = tty->disc_data;
+   struct spk_synth *synth = ldisc_data->synth;
 
-   if (spk_ttyio_synth->read_buff_add) {
+   if (synth->read_buff_add) {
int i;
 
for (i = 0; i < count; i++)
-   spk_ttyio_synth->read_buff_add(cp[i]);
+   synth->read_buff_add(cp[i]);
 
return count;
}
@@ -187,13 +186,17 @@ static int spk_ttyio_initialise_ldisc(st
mutex_lock(_tty_mutex);
speakup_tty = tty;
ret = tty_set_ldisc(tty, N_SPEAKUP);
-   if (ret)
-   speakup_tty = NULL;
+   speakup_tty = NULL;
mutex_unlock(_tty_mutex);
 
-   if (!ret)
+   if (!ret) {
/* Success */
+   struct spk_ldisc_data *ldisc_data = tty->disc_data;
+
+   ldisc_data->synth = synth;
+   synth->dev = tty;
return 0;
+   }
 
pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
 
@@ -221,11 +224,11 @@ void spk_ttyio_unregister_ldisc(void)
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (in_synth->alive && speakup_tty && speakup_tty->ops->write) {
-   int ret = speakup_tty->ops->write(speakup_tty, , 1);
+   struct tty_struct *tty = in_synth->dev;
+
+   if (in_synth->alive && tty->ops->write) {
+   int ret = tty->ops->write(tty, , 1);
 
-   mutex_unlock(_tty_mutex);
if (ret == 0)
/* No room */
return 0;
@@ -243,7 +246,6 @@ static int spk_ttyio_out(struct spk_synt
return 1;
}
 
-   mutex_unlock(_tty_mutex);
return 0;
 }
 
@@ -264,47 +266,20 @@ static int spk_ttyio_out_unicode(struct
return ret;
 }
 
-static int check_tty(struct tty_struct *tty)
-{
-   if (!tty) {
-   pr_warn("%s: I/O error, deactivating speakup\n",
-   spk_ttyio_synth->long_name);
-   /* 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
-*/
-   spk_ttyio_synth->alive = 0;
-   speakup_start_ttys();
-   return 1;
-   }
-
-   return 0;
-}
-
 static void spk_ttyio_send_xchar(struct spk_synth *in_synth, char ch)
 {
-   mutex_lock(_tty_mutex);
-   if (check_tty(speakup_tty)) {
-   mutex_unlock(_tty_mutex);
-   return;
-   }
+   struct tty_struct *tty = in_synth->dev;
 
-   if (speakup_tty->ops->send_xchar)
-   speakup_tty->ops->send_xchar(speakup_tty, ch)

[patch 0/3] speakup: simplify relation between line disc and synth

2020-11-30 Thread Samuel Thibault
This series reworks the relation between the speakup line discipline and the
speakup synthesizers. This is probably fixing a few minor issues, but since it
is invasive it'll better wait for 5.11.


[PATCH] speakup: Reject setting the speakup line discipline outside of speakup

2020-11-29 Thread Samuel Thibault
Speakup exposing a line discipline allows userland to try to use it,
while it is deemed to be useless, and thus uselessly exposes potential
bugs. One of them is simply that in such a case if the line sends data,
spk_ttyio_receive_buf2 is called and crashes since spk_ttyio_synth
is NULL.

This change restricts the use of the speakup line discipline to
speakup drivers, thus avoiding such kind of issues altogether.

Cc: sta...@vger.kernel.org
Reported-by: Shisong Qin 
Signed-off-by: Samuel Thibault 
Tested-by: Shisong Qin 

Index: linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-5.9/drivers/accessibility/speakup/spk_ttyio.c
@@ -47,27 +47,20 @@ static int spk_ttyio_ldisc_open(struct t
 {
struct spk_ldisc_data *ldisc_data;
 
+   if (tty != speakup_tty)
+   /* Somebody tried to use this line discipline outside speakup */
+   return -ENODEV;
+
if (!tty->ops->write)
return -EOPNOTSUPP;
 
-   mutex_lock(_tty_mutex);
-   if (speakup_tty) {
-   mutex_unlock(_tty_mutex);
-   return -EBUSY;
-   }
-   speakup_tty = tty;
-
ldisc_data = kmalloc(sizeof(*ldisc_data), GFP_KERNEL);
-   if (!ldisc_data) {
-   speakup_tty = NULL;
-   mutex_unlock(_tty_mutex);
+   if (!ldisc_data)
return -ENOMEM;
-   }
 
init_completion(_data->completion);
ldisc_data->buf_free = true;
-   speakup_tty->disc_data = ldisc_data;
-   mutex_unlock(_tty_mutex);
+   tty->disc_data = ldisc_data;
 
return 0;
 }
@@ -191,9 +184,25 @@ static int spk_ttyio_initialise_ldisc(st
 
tty_unlock(tty);
 
+   mutex_lock(_tty_mutex);
+   speakup_tty = tty;
ret = tty_set_ldisc(tty, N_SPEAKUP);
if (ret)
-   pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
+   speakup_tty = NULL;
+   mutex_unlock(_tty_mutex);
+
+   if (!ret)
+   /* Success */
+   return 0;
+
+   pr_err("speakup: Failed to set N_SPEAKUP on tty\n");
+
+   tty_lock(tty);
+   if (tty->ops->close)
+   tty->ops->close(tty, NULL);
+   tty_unlock(tty);
+
+   tty_kclose(tty);
 
return ret;
 }


Re: [PATCH] speakup: fix uninitialized flush_lock

2020-11-16 Thread Samuel Thibault
Yang Yingliang, le mar. 17 nov. 2020 09:22:29 +0800, a ecrit:
> The flush_lock is uninitialized, use DEFINE_SPINLOCK
> to define and initialize flush_lock.
> 
> Fixes: c6e3fd22cd53 ("Staging: add speakup to the staging directory")
> Reported-by: Hulk Robot 
> Signed-off-by: Yang Yingliang 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/accessibility/speakup/speakup_dectlk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/accessibility/speakup/speakup_dectlk.c 
> b/drivers/accessibility/speakup/speakup_dectlk.c
> index 780214b5ca16..ab6d61e80b1c 100644
> --- a/drivers/accessibility/speakup/speakup_dectlk.c
> +++ b/drivers/accessibility/speakup/speakup_dectlk.c
> @@ -37,7 +37,7 @@ static unsigned char get_index(struct spk_synth *synth);
>  static int in_escape;
>  static int is_flushing;
>  
> -static spinlock_t flush_lock;
> +static DEFINE_SPINLOCK(flush_lock);
>  static DECLARE_WAIT_QUEUE_HEAD(flush);
>  
>  static struct var_t vars[] = {
> -- 
> 2.25.1
> 


Re: drivers/accessibility/speakup/serialio.c:48:19: warning: variable 'quot' set but not used

2020-11-16 Thread Samuel Thibault
Ben Hutchings, le lun. 16 nov. 2020 19:51:23 +, a ecrit:
> On Mon, 2020-11-16 at 20:01 +0100, Samuel Thibault wrote:
> > Perhaps we should rather use
> > 
> > depends on ISA || (X86 && COMPILE_TEST)
> > 
> > ?
> > so that we have compile testing on x86 only (where the inb/outb macros
> > always behave fine) to avoid such issues on other archs?
> 
> That seems reasonable though unusual.
> 
> > Or we tell the architecture maintainers to fix their out macros into
> > consuming their parameters?
> [...]
> 
> It does seem odd for parisc to define the I/O functions this way.  I
> don't know if it's really a bug.

Sorry I wasn't clear: the problem here is when CONFIG_EISA is disabled,
the eisa_in/out calls are replaced by BUG() stubs, and the stubs do not
consume their input:

arch/parisc/include/asm/io.h

#if defined(CONFIG_PCI)
extern void outb(unsigned char b, int addr);
#elif defined(CONFIG_EISA)
#define outb eisa_out8
#else
#define outb(x, y)  BUG()
#endif

Samuel


Re: drivers/accessibility/speakup/serialio.c:48:19: warning: variable 'quot' set but not used

2020-11-16 Thread Samuel Thibault
Hello Ben,

A long time ago you added a dependency for speakup drivers on
CONFIG_ISA, and you also added || COMPILE_TEST as an alternative.

It seems that some platform portability tests then think they should
be able to build it, even if they don't enable ISA, but then we are
getting warnings, or even errors, depending on the compatibility macros
in  in the !ISA case (here, the parisc compatibility macros do
not consume their parameter).

Perhaps we should rather use

depends on ISA || (X86 && COMPILE_TEST)

?
so that we have compile testing on x86 only (where the inb/outb macros
always behave fine) to avoid such issues on other archs?

Or we tell the architecture maintainers to fix their out macros into
consuming their parameters?

Samuel

kernel test robot, le lun. 16 nov. 2020 09:54:50 +0800, a ecrit:
> First bad commit (maybe != root cause):
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   a6af8718b98e1cd37a9ea9a02269c79577fc9138
> commit: 2067fd92d75b6d9085a43caf050bca5d88c491b8 staging/speakup: Move out of 
> staging
> date:   4 months ago
> config: parisc-randconfig-r023-20201116 (attached as .config)
> compiler: hppa-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2067fd92d75b6d9085a43caf050bca5d88c491b8
> git remote add linus 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 2067fd92d75b6d9085a43caf050bca5d88c491b8
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
> ARCH=parisc 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> All warnings (new ones prefixed by >>):
> 
>drivers/accessibility/speakup/serialio.c: In function 'spk_serial_init':
> >> drivers/accessibility/speakup/serialio.c:48:19: warning: variable 'quot' 
> >> set but not used [-Wunused-but-set-variable]
>   48 |  int baud = 9600, quot = 0;
>  |   ^~~~
>drivers/accessibility/speakup/serialio.c: In function 
> 'spk_serial_tiocmset':
>drivers/accessibility/speakup/serialio.c:165:6: warning: unused variable 
> 'old' [-Wunused-variable]
>  165 |  int old = inb(speakup_info.port_tts + UART_MCR);
>  |  ^~~
> 
> vim +/quot +48 drivers/accessibility/speakup/serialio.c
> 
> 1e441594e509c3 drivers/staging/speakup/serialio.c Okash Khawaja  
> 2017-03-14   45  
> 3ee0017e03cd79 drivers/staging/speakup/serialio.c Jiri Slaby 
> 2012-03-05   46  const struct old_serial_port *spk_serial_init(int index)
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07   47  {
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07  @48  int baud = 9600, quot = 0;
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07   49  unsigned int cval = 0;
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07   50  int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   51  const struct old_serial_port *ser;
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs      
> 2010-10-07   52  int err;
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07   53  
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   54  if (index >= ARRAY_SIZE(rs_table)) {
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   55      pr_info("no port info for ttyS%d\n", index);
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   56  return NULL;
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   57  }
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   58  ser = rs_table + index;
> 327b882d3bcc1f drivers/staging/speakup/serialio.c Samuel Thibault
> 2016-01-15   59  
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07   60  /*  Divisor, bytesize and parity */
> c6e3fd22cd5383 drivers/staging/speakup/serialio.c William Hubbs  
> 2010-10-07   61  quot = 

[PATCH] speakup: Document read_all_doc shortcut

2020-11-08 Thread Samuel Thibault
This was implemented a long time ago, but never actually added to the
documentation.

Signed-off-by: Samuel Thibault 
---
 Documentation/admin-guide/spkguide.txt |1 +
 1 file changed, 1 insertion(+)

--- a/Documentation/admin-guide/spkguide.txt
+++ b/Documentation/admin-guide/spkguide.txt
@@ -344,6 +344,7 @@ spk key_slash = say_attributes
 spk key_8 = speakup_paste
 shift spk key_m = say_first_char
  ctrl spk key_semicolon = say_last_char
+spk key_r = read_all_doc
 
 5.  The Speakup Sys System
 


[PATCH] speakup ttyio: Do not schedule() in ttyio_in_nowait

2020-11-08 Thread Samuel Thibault
With the ltlk and spkout drivers, the index read function, i.e.
in_nowait, is getting called from the read_all_doc mechanism, from
the timer softirq:

Call Trace:
 
 dump_stack+0x71/0x98
 dequeue_task_idle+0x1f/0x28
 __schedule+0x167/0x5d6
 ? trace_hardirqs_on+0x2e/0x3a
 ? usleep_range+0x7f/0x7f
 schedule+0x8a/0xae
 schedule_timeout+0xb1/0xea
 ? del_timer_sync+0x31/0x31
 do_wait_for_common+0xba/0x12b
 ? wake_up_q+0x45/0x45
 wait_for_common+0x37/0x50
 ttyio_in+0x2a/0x6b
 spk_ttyio_in_nowait+0xc/0x13
 spk_get_index_count+0x20/0x93
 cursor_done+0x1c6/0x4c6
 ? read_all_doc+0xb1/0xb1
 call_timer_fn+0x89/0x140
 run_timer_softirq+0x164/0x1a5
 ? read_all_doc+0xb1/0xb1
 ? hrtimer_forward+0x7b/0x87
 ? timerqueue_add+0x62/0x68
 ? enqueue_hrtimer+0x95/0x9f
 __do_softirq+0x181/0x31f
 irq_exit+0x6a/0x86
smp_apic_timer_interrupt+0x15e/0x183
 apic_timer_interrupt+0xf/0x20
 

We thus should not schedule() at all, even with timeout == 0, this
crashes the kernel.  We can however use try_wait_for_completion()
instead of wait_for_completion_timeout(0).

Cc: sta...@vger.kernel.org
Signed-off-by: Samuel Thibault 
Reported-by: John Covici 
Tested-by: John Covici 

---
 drivers/accessibility/speakup/spk_ttyio.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -298,11 +298,13 @@ static unsigned char ttyio_in(int timeou
struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
char rv;
 
-   if (wait_for_completion_timeout(_data->completion,
+   if (!timeout) {
+   if (!try_wait_for_completion(_data->completion))
+   return 0xff;
+   } else if (wait_for_completion_timeout(_data->completion,
usecs_to_jiffies(timeout)) == 0) {
-   if (timeout)
-   pr_warn("spk_ttyio: timeout (%d)  while waiting for 
input\n",
-   timeout);
+   pr_warn("spk_ttyio: timeout (%d)  while waiting for input\n",
+   timeout);
return 0xff;
}
 


[PATCH] speakup: Fix clearing selection in safe context

2020-11-07 Thread Samuel Thibault
speakup_cut() calls speakup_clear_selection() which calls console_lock.
Problem is: speakup_cut() is called from a keyboard interrupt
context. This would hang if speakup_cut is pressed while the console
lock is unfortunately already held.

We can however as well just defer calling clear_selection() until the
already-deferred set_selection_kernel() call.

This was spotted by the lock hardener:

 Possible unsafe locking scenario:\x0a
   CPU0
   
  lock(console_lock);
  
lock(console_lock);
\x0a *** DEADLOCK ***\x0a
[...]
Call Trace:
 
 dump_stack+0xc2/0x11a
 print_usage_bug.cold+0x3e0/0x4b1
 mark_lock+0xd95/0x1390
 ? print_irq_inversion_bug+0xa0/0xa0
 __lock_acquire+0x21eb/0x5730
 ? __kasan_check_read+0x11/0x20
 ? check_chain_key+0x215/0x5e0
 ? register_lock_class+0x1580/0x1580
 ? lock_downgrade+0x7a0/0x7a0
 ? __rwlock_init+0x140/0x140
 lock_acquire+0x13f/0x370
 ? speakup_clear_selection+0xe/0x20 [speakup]
 console_lock+0x33/0x50
 ? speakup_clear_selection+0xe/0x20 [speakup]
 speakup_clear_selection+0xe/0x20 [speakup]
 speakup_cut+0x19e/0x4b0 [speakup]
 keyboard_notifier_call+0x1f04/0x4a40 [speakup]
 ? read_all_doc+0x240/0x240 [speakup]
 notifier_call_chain+0xbf/0x130
 __atomic_notifier_call_chain+0x80/0x130
 atomic_notifier_call_chain+0x16/0x20
 kbd_event+0x7d7/0x3b20
 ? k_pad+0x850/0x850
 ? sysrq_filter+0x450/0xd40
 input_to_handler+0x362/0x4b0
 ? rcu_read_lock_sched_held+0xe0/0xe0
 input_pass_values+0x408/0x5a0
 ? __rwlock_init+0x140/0x140
 ? lock_acquire+0x13f/0x370
 input_handle_event+0x70e/0x1380
 input_event+0x67/0x90
 atkbd_interrupt+0xe62/0x1d4e [atkbd]
 ? __kasan_check_write+0x14/0x20
 ? atkbd_event_work+0x130/0x130 [atkbd]
 ? _raw_spin_lock_irqsave+0x26/0x70
 serio_interrupt+0x93/0x120 [serio]
 i8042_interrupt+0x232/0x510 [i8042]
 ? rcu_read_lock_bh_held+0xd0/0xd0
 ? handle_irq_event+0xa5/0x13a
 ? i8042_remove+0x1f0/0x1f0 [i8042]
 __handle_irq_event_percpu+0xe6/0x6c0
 handle_irq_event_percpu+0x71/0x150
 ? __handle_irq_event_percpu+0x6c0/0x6c0
 ? __kasan_check_read+0x11/0x20
 ? do_raw_spin_unlock+0x5c/0x240
 handle_irq_event+0xad/0x13a
 handle_edge_irq+0x233/0xa90
 do_IRQ+0x10b/0x310
 common_interrupt+0xf/0xf
 

Cc: sta...@vger.kernel.org
Signed-off-by: Samuel Thibault 
Reported-by: Jookia 

---
Note for stable: this driver was previously in drivers/staging/speakup

 drivers/accessibility/speakup/main.c  |1 -
 drivers/accessibility/speakup/selection.c |   11 ---
 drivers/accessibility/speakup/speakup.h   |1 -
 3 files changed, 4 insertions(+), 9 deletions(-)

--- a/drivers/accessibility/speakup/main.c
+++ b/drivers/accessibility/speakup/main.c
@@ -356,7 +356,6 @@ static void speakup_cut(struct vc_data *
mark_cut_flag = 0;
synth_printf("%s\n", spk_msg_get(MSG_CUT));
 
-   speakup_clear_selection();
ret = speakup_set_selection(tty);
 
switch (ret) {
--- a/drivers/accessibility/speakup/selection.c
+++ b/drivers/accessibility/speakup/selection.c
@@ -22,13 +22,6 @@ struct speakup_selection_work {
struct tty_struct *tty;
 };
 
-void speakup_clear_selection(void)
-{
-   console_lock();
-   clear_selection();
-   console_unlock();
-}
-
 static void __speakup_set_selection(struct work_struct *work)
 {
struct speakup_selection_work *ssw =
@@ -51,6 +44,10 @@ static void __speakup_set_selection(stru
goto unref;
}
 
+   console_lock();
+   clear_selection();
+   console_unlock();
+
set_selection_kernel(, tty);
 
 unref:
--- a/drivers/accessibility/speakup/speakup.h
+++ b/drivers/accessibility/speakup/speakup.h
@@ -70,7 +70,6 @@ void spk_do_flush(void);
 void speakup_start_ttys(void);
 void synth_buffer_add(u16 ch);
 void synth_buffer_clear(void);
-void speakup_clear_selection(void);
 int speakup_set_selection(struct tty_struct *tty);
 void speakup_cancel_selection(void);
 int speakup_paste_selection(struct tty_struct *tty);


Re: Crash when specifying non-existent serial port in speakup / tty_kopen

2020-11-04 Thread Samuel Thibault
Matthias Reichl, le mer. 04 nov. 2020 22:15:05 +0100, a ecrit:
> > This looks like only a warning, did it actually crash?
> 
> Yes, scroll down a bit, the null pointer oops followed almost
> immediately after that
> 
> [   49.979043] BUG: kernel NULL pointer dereference, address: 0090

Ah, [   50.102938]  tty_init_dev+0xb5/0x1d0

probably the trailing release_tty call that does

tty->port->itty = NULL;
(itty is after a struct tty_bufhead + the tty pointer, that looks
plausible).

so probably an if (tty->port) in release_tty could help?

Samuel


Re: Crash when specifying non-existent serial port in speakup / tty_kopen

2020-11-04 Thread Samuel Thibault
Hello,

Matthias Reichl, le mer. 04 nov. 2020 15:57:37 +0100, a ecrit:
> I initially noticed this oops on x86_64 running kernel 5.4.59 when
> I accidentally mistyped "ttyS0" as "ttyS9":
> 
> modprobe speakup_dummy dev=ttyS9

> [   49.978481] tty_init_dev: ttyS driver does not set tty->port. This would 
> crash the kernel. Fix the driver!

This looks like only a warning, did it actually crash?

> the missing tty->port is quite fatal.

It is fatal for module insertion yes (EINVAL) but IIRC that should be
getting handled properly, making modprobe return the error?

> It looks like spk_ttyio or tty_dev_name_to_number() / tty_kopen()
> should perform some additional validation,

spk_ttyio_initialise_ldisc only has a dev_t so can't do much beyond
calling tty_kopen.

tty_kopen is getting the index from the tty_lookup_driver call (actually
get_tty_driver which uses p->minor_start and p->num) and passes it to
tty_driver_lookup_tty. Perhaps in addition of p->num the driver should
have another field to set, that tty_init_dev could use to reject with
ENODEV indexes beyond what the driver actually provides?

> I couldn't make the kernel warn/crash yet by specifying non-existent
> ttyUSB ports yet though.

That's probably because in the ttyUSB case the device allocation is
dynamic and made exactly according to the number of actual devices,
while for ttyS* there is a large overcommit of minor values.

Samuel


Re: [PATCH] speakup: Fix var_id_t values and thus keymap

2020-11-03 Thread Samuel Thibault
Greg KH, le mar. 03 nov. 2020 15:41:19 +0100, a ecrit:
> On Tue, Nov 03, 2020 at 03:31:42PM +0100, Samuel Thibault wrote:
> > This is a change that should got into 5.10, in the meanwhile the bug
> > (appeared in 5.8) is very inconvenient for users.
> 
> It's in my to-apply queue, sorry, it's really long at the moment.

Ok, np, juste making sure!

Thanks,
Samuel


Re: [PATCH] speakup: Fix var_id_t values and thus keymap

2020-11-03 Thread Samuel Thibault
Ping?

This is a change that should got into 5.10, in the meanwhile the bug
(appeared in 5.8) is very inconvenient for users.

Samuel

Samuel Thibault, le lun. 12 oct. 2020 18:06:46 +0200, a ecrit:
> commit d97a9d7aea04 ("staging/speakup: Add inflection synth parameter")
> introduced a new "inflection" speakup parameter next to "pitch", but
> the values of the var_id_t enum are actually used by the keymap tables
> so we must not renumber them. The effect was that notably the volume
> control shortcut (speakup-1 or 2) was actually changing the inflection.
> 
> This moves the INFLECTION value at the end of the var_id_t enum to
> fix back the enum values. This also adds a warning about it.
> 
> Cc: sta...@vger.kernel.org
> Reported-by: Kirk Reiser 
> Reported-by: Gregory Nowak 
> Signed-off-by: Samuel Thibault 
> Tested-by: Gregory Nowak 
> Fixes: d97a9d7aea04 ("staging/speakup: Add inflection synth parameter")
> ---
>  drivers/accessibility/speakup/spk_types.h | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/accessibility/speakup/spk_types.h 
> b/drivers/accessibility/speakup/spk_types.h
> index 7398f1196e10..91fca3033a45 100644
> --- a/drivers/accessibility/speakup/spk_types.h
> +++ b/drivers/accessibility/speakup/spk_types.h
> @@ -32,6 +32,10 @@ enum {
>   E_NEW_DEFAULT,
>  };
>  
> +/*
> + * Note: add new members at the end, speakupmap.h depends on the values of 
> the
> + * enum starting from SPELL_DELAY (see inc_dec_var)
> + */
>  enum var_id_t {
>   VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT,
>   KEYMAP, CHARS,
> @@ -42,9 +46,9 @@ enum var_id_t {
>   SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO,
>   SPELL_DELAY, PUNC_LEVEL, READING_PUNC,
>   ATTRIB_BLEEP, BLEEPS,
> - RATE, PITCH, INFLECTION, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
> + RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
>   DIRECT, PAUSE,
> - CAPS_START, CAPS_STOP, CHARTAB,
> + CAPS_START, CAPS_STOP, CHARTAB, INFLECTION,
>   MAXVARS
>  };
>  
> -- 
> 2.20.1


[PATCH] speakup: document the usage of enum values

2020-11-02 Thread Samuel Thibault
The cursor tracking modes enum, the edge enum, and the read_all commands
enum should be used as such in the source code, to make it more readable
and make gcc catch missing values in switches.

Also, some values of enums are coupled with others, we at least need to
document these.

Signed-off-by: Samuel Thibault 

---
 drivers/accessibility/speakup/i18n.h |6 +++
 drivers/accessibility/speakup/main.c |   64 ++-
 2 files changed, 39 insertions(+), 31 deletions(-)

--- a/drivers/accessibility/speakup/i18n.h
+++ b/drivers/accessibility/speakup/i18n.h
@@ -23,12 +23,15 @@ enum msg_index_t {
MSG_OFF = MSG_STATUS_START,
MSG_ON,
MSG_NO_WINDOW,
+
+   /* These must be ordered the same as enum cursor_track */
MSG_CURSOR_MSGS_START,
MSG_CURSORING_OFF = MSG_CURSOR_MSGS_START,
MSG_CURSORING_ON,
MSG_HIGHLIGHT_TRACKING,
MSG_READ_WINDOW,
MSG_READ_ALL,
+
MSG_EDIT_DONE,
MSG_WINDOW_ALREADY_SET,
MSG_END_BEFORE_START,
@@ -41,11 +44,14 @@ enum msg_index_t {
MSG_LEAVING_HELP,
MSG_IS_UNASSIGNED,
MSG_HELP_INFO,
+
+   /* These must be ordered the same as enum edge */
MSG_EDGE_MSGS_START,
MSG_EDGE_TOP  = MSG_EDGE_MSGS_START,
MSG_EDGE_BOTTOM,
MSG_EDGE_LEFT,
MSG_EDGE_RIGHT,
+
MSG_NUMBER,
MSG_SPACE,
MSG_START, /* A little confusing, given our convention. */
--- a/drivers/accessibility/speakup/main.c
+++ b/drivers/accessibility/speakup/main.c
@@ -90,19 +90,18 @@ const u_char spk_key_defaults[] = {
 #include "speakupmap.h"
 };
 
-/* Speakup Cursor Track Variables */
-static int cursor_track = 1, prev_cursor_track = 1;
-
-/* cursor track modes, must be ordered same as cursor_msgs */
-enum {
+/* cursor track modes, must be ordered same as cursor_msgs in enum msg_index_t 
*/
+enum cursor_track {
CT_Off = 0,
CT_On,
CT_Highlight,
CT_Window,
-   CT_Max
+   CT_Max,
+   read_all_mode = CT_Max,
 };
 
-#define read_all_mode CT_Max
+/* Speakup Cursor Track Variables */
+static enum cursor_track cursor_track = 1, prev_cursor_track = 1;
 
 static struct tty_struct *tty;
 
@@ -405,15 +404,17 @@ static void say_attributes(struct vc_dat
synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg));
 }
 
-enum {
-   edge_top = 1,
+/* must be ordered same as edge_msgs in enum msg_index_t */
+enum edge {
+   edge_none = 0,
+   edge_top,
edge_bottom,
edge_left,
edge_right,
edge_quiet
 };
 
-static void announce_edge(struct vc_data *vc, int msg_id)
+static void announce_edge(struct vc_data *vc, enum edge msg_id)
 {
if (spk_bleeps & 1)
bleep(spk_y);
@@ -608,7 +609,8 @@ static void say_prev_word(struct vc_data
 {
u_char temp;
u16 ch;
-   u_short edge_said = 0, last_state = 0, state = 0;
+   enum edge edge_said = edge_none;
+   u_short last_state = 0, state = 0;
 
spk_parked |= 0x01;
 
@@ -653,7 +655,7 @@ static void say_prev_word(struct vc_data
}
if (spk_x == 0 && edge_said == edge_quiet)
edge_said = edge_left;
-   if (edge_said > 0 && edge_said < edge_quiet)
+   if (edge_said > edge_none && edge_said < edge_quiet)
announce_edge(vc, edge_said);
say_word(vc);
 }
@@ -662,7 +664,8 @@ static void say_next_word(struct vc_data
 {
u_char temp;
u16 ch;
-   u_short edge_said = 0, last_state = 2, state = 0;
+   enum edge edge_said = edge_none;
+   u_short last_state = 2, state = 0;
 
spk_parked |= 0x01;
if (spk_x == vc->vc_cols - 1 && spk_y == vc->vc_rows - 1) {
@@ -694,7 +697,7 @@ static void say_next_word(struct vc_data
spk_pos += 2;
last_state = state;
}
-   if (edge_said > 0)
+   if (edge_said > edge_none)
announce_edge(vc, edge_said);
say_word(vc);
 }
@@ -1366,31 +1369,30 @@ static void speakup_deallocate(struct vc
speakup_console[vc_num] = NULL;
 }
 
+enum read_all_command {
+   RA_NEXT_SENT = KVAL(K_DOWN)+1,
+   RA_PREV_LINE = KVAL(K_LEFT)+1,
+   RA_NEXT_LINE = KVAL(K_RIGHT)+1,
+   RA_PREV_SENT = KVAL(K_UP)+1,
+   RA_DOWN_ARROW,
+   RA_TIMER,
+   RA_FIND_NEXT_SENT,
+   RA_FIND_PREV_SENT,
+};
+
 static u_char is_cursor;
 static u_long old_cursor_pos, old_cursor_x, old_cursor_y;
 static int cursor_con;
 
 static void reset_highlight_buffers(struct vc_data *);
 
-static int read_all_key;
+static enum read_all_command read_all_key;
 
 static int in_keyboard_notifier;
 
-static void start_read_all_timer(struct vc_data *vc, int command);
-
-enum {
-   RA_NOTHING,
-   RA_NEXT_SENT,
-   RA_PREV_LINE,
-   RA_NEXT_LINE,
-   RA_PREV_SENT,
-   RA_DOWN_ARROW,
-   

[PATCH] speakup_dummy: log about characters received by the dummy driver

2020-11-01 Thread Samuel Thibault
The dummy speakup driver is used to check that speakup is working
properly, without the need for actually owning the hardware. Some
drivers require receiving characters, so we need a way to check that
this is working properly.

Signed-off-by: Samuel Thibault 

Index: linux-5.9/drivers/accessibility/speakup/speakup_dummy.c
===
--- linux-5.9.orig/drivers/accessibility/speakup/speakup_dummy.c
+++ linux-5.9/drivers/accessibility/speakup/speakup_dummy.c
@@ -80,6 +80,11 @@ static struct attribute *synth_attrs[] =
NULL,   /* need to NULL terminate the list of attributes */
 };
 
+static void read_buff_add(u_char c)
+{
+   pr_info("speakup_dummy: got character %02x\n", c);
+}
+
 static struct spk_synth synth_dummy = {
.name = "dummy",
.version = DRV_VERSION,
@@ -103,7 +108,7 @@ static struct spk_synth synth_dummy = {
.flush = spk_synth_flush,
.is_alive = spk_synth_is_alive_restart,
.synth_adjust = NULL,
-   .read_buff_add = NULL,
+   .read_buff_add = read_buff_add,
.get_index = NULL,
.indexing = {
.command = NULL,


[PATCH] speakup: Fix var_id_t values and thus keymap

2020-10-12 Thread Samuel Thibault
commit d97a9d7aea04 ("staging/speakup: Add inflection synth parameter")
introduced a new "inflection" speakup parameter next to "pitch", but
the values of the var_id_t enum are actually used by the keymap tables
so we must not renumber them. The effect was that notably the volume
control shortcut (speakup-1 or 2) was actually changing the inflection.

This moves the INFLECTION value at the end of the var_id_t enum to
fix back the enum values. This also adds a warning about it.

Cc: sta...@vger.kernel.org
Reported-by: Kirk Reiser 
Reported-by: Gregory Nowak 
Signed-off-by: Samuel Thibault 
Tested-by: Gregory Nowak 
Fixes: d97a9d7aea04 ("staging/speakup: Add inflection synth parameter")
---
 drivers/accessibility/speakup/spk_types.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/accessibility/speakup/spk_types.h 
b/drivers/accessibility/speakup/spk_types.h
index 7398f1196e10..91fca3033a45 100644
--- a/drivers/accessibility/speakup/spk_types.h
+++ b/drivers/accessibility/speakup/spk_types.h
@@ -32,6 +32,10 @@ enum {
E_NEW_DEFAULT,
 };
 
+/*
+ * Note: add new members at the end, speakupmap.h depends on the values of the
+ * enum starting from SPELL_DELAY (see inc_dec_var)
+ */
 enum var_id_t {
VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT,
KEYMAP, CHARS,
@@ -42,9 +46,9 @@ enum var_id_t {
SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO,
SPELL_DELAY, PUNC_LEVEL, READING_PUNC,
ATTRIB_BLEEP, BLEEPS,
-   RATE, PITCH, INFLECTION, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
+   RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
DIRECT, PAUSE,
-   CAPS_START, CAPS_STOP, CHARTAB,
+   CAPS_START, CAPS_STOP, CHARTAB, INFLECTION,
MAXVARS
 };
 
-- 
2.20.1



Re: drivers/accessibility/speakup/serialio.c:139:9: sparse: sparse: cast removes address space '__iomem' of expression

2020-08-16 Thread Samuel Thibault
kernel test robot, le dim. 16 août 2020 19:25:17 +0800, a ecrit:
> First bad commit (maybe != root cause):

> >> drivers/accessibility/speakup/serialio.c:139:9: sparse: sparse: cast 
> >> removes address space '__iomem' of expression

This will also be fixed by the patches I already sent to gregkh for
after rc1.

Samuel


Re: [PATCH 2/2] speakup: only build serialio when ISA is enabled

2020-08-04 Thread Samuel Thibault
Greg KH, le mar. 04 août 2020 17:49:52 +0200, a ecrit:
> > #define inb(c)  ({ u8  __v; __io_pbr(); __v = 
> > readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
> > 
> > and thus yes it's arithmetic over a (void*) pointer, the caller cannot
> > do anything about it.
> 
> And that's fine, math with pointers, even void ones, is ok.

C++ doesn't like it, but in general compilers provide some semantic for
it, yes.

> I wonder why riscv was complaining about that.  It's not nice, but it is
> valid C.

Strictly C speaking, no, but GNU C yes.

> Let's see if any of their developers care about it :)

Ok :) In the meanwhile I sent a v2 series that should fix the different
link cases, just not the particular riscv warning.

Samuel


[PATCHv2 2/2] speakup: only build serialio when ISA is enabled

2020-08-04 Thread Samuel Thibault
Drivers using serialio were already made available in Kconfig only under
the ISA condition.

Signed-off-by: Samuel Thibault 

Index: linux-2.6/drivers/accessibility/speakup/Makefile
===
--- linux-2.6.orig/drivers/accessibility/speakup/Makefile
+++ linux-2.6/drivers/accessibility/speakup/Makefile
@@ -25,8 +25,8 @@ speakup-y := \
keyhelp.o \
kobjects.o \
selection.o \
-   serialio.o \
spk_ttyio.o \
synth.o \
thread.o \
varhandlers.o
+speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o
Index: linux-2.6/drivers/accessibility/speakup/Kconfig
===
--- linux-2.6.orig/drivers/accessibility/speakup/Kconfig
+++ linux-2.6/drivers/accessibility/speakup/Kconfig
@@ -42,6 +42,11 @@ config SPEAKUP
one of the listed synthesizers, you should say n.
 
 if SPEAKUP
+
+config SPEAKUP_SERIALIO
+   def_bool y
+   depends on ISA || COMPILE_TEST
+
 config SPEAKUP_SYNTH_ACNTSA
tristate "Accent SA synthesizer support"
help
@@ -52,7 +57,7 @@ config SPEAKUP_SYNTH_ACNTSA
 
 config SPEAKUP_SYNTH_ACNTPC
tristate "Accent PC synthesizer support"
-   depends on ISA || COMPILE_TEST
+   depends on SPEAKUP_SERIALIO
help
This is the Speakup driver for the accent pc
synthesizer.  You can say y to build it into the kernel,
@@ -104,7 +109,7 @@ config SPEAKUP_SYNTH_DECEXT
 
 config SPEAKUP_SYNTH_DECPC
depends on m
-   depends on ISA || COMPILE_TEST
+   depends on SPEAKUP_SERIALIO
tristate "DECtalk PC (big ISA card) synthesizer support"
help
 
@@ -127,7 +132,7 @@ config SPEAKUP_SYNTH_DECPC
 
 config SPEAKUP_SYNTH_DTLK
tristate "DoubleTalk PC synthesizer support"
-   depends on ISA || COMPILE_TEST
+   depends on SPEAKUP_SERIALIO
help
 
This is the Speakup driver for the internal DoubleTalk
@@ -138,7 +143,7 @@ config SPEAKUP_SYNTH_DTLK
 
 config SPEAKUP_SYNTH_KEYPC
tristate "Keynote Gold PC synthesizer support"
-   depends on ISA || COMPILE_TEST
+   depends on SPEAKUP_SERIALIO
help
 
This is the Speakup driver for the Keynote Gold


[PATCHv2 1/2] speakup: Fix wait_for_xmitr for ttyio case

2020-08-04 Thread Samuel Thibault
This was missed while introducing the tty-based serial access.

The only remaining use of wait_for_xmitr with tty-based access is in
spk_synth_is_alive_restart to check whether the synth can be restarted.
With tty-based this is up to the tty layer to cope with the buffering
etc. so we can just say yes.

Signed-off-by: Samuel Thibault 

Index: linux-2.6/drivers/accessibility/speakup/serialio.c
===
--- linux-2.6.orig/drivers/accessibility/speakup/serialio.c
+++ linux-2.6/drivers/accessibility/speakup/serialio.c
@@ -32,6 +32,7 @@ static void spk_serial_tiocmset(unsigned
 static unsigned char spk_serial_in(void);
 static unsigned char spk_serial_in_nowait(void);
 static void spk_serial_flush_buffer(void);
+static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_serial_io_ops = {
.synth_out = spk_serial_out,
@@ -40,6 +41,7 @@ struct spk_io_ops spk_serial_io_ops = {
.synth_in = spk_serial_in,
.synth_in_nowait = spk_serial_in_nowait,
.flush_buffer = spk_serial_flush_buffer,
+   .wait_for_xmitr = spk_serial_wait_for_xmitr,
 };
 EXPORT_SYMBOL_GPL(spk_serial_io_ops);
 
@@ -211,7 +213,7 @@ void spk_stop_serial_interrupt(void)
 }
 EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt);
 
-int spk_wait_for_xmitr(struct spk_synth *in_synth)
+static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth)
 {
int tmout = SPK_XMITR_TIMEOUT;
 
@@ -280,7 +282,7 @@ static void spk_serial_flush_buffer(void
 
 static int spk_serial_out(struct spk_synth *in_synth, const char ch)
 {
-   if (in_synth->alive && spk_wait_for_xmitr(in_synth)) {
+   if (in_synth->alive && spk_serial_wait_for_xmitr(in_synth)) {
outb_p(ch, speakup_info.port_tts);
return 1;
}
@@ -295,7 +297,7 @@ const char *spk_serial_synth_immediate(s
while ((ch = *buff)) {
if (ch == '\n')
ch = synth->procspeech;
-   if (spk_wait_for_xmitr(synth))
+   if (spk_serial_wait_for_xmitr(synth))
outb(ch, speakup_info.port_tts);
else
return buff;
Index: linux-2.6/drivers/accessibility/speakup/spk_priv.h
===
--- linux-2.6.orig/drivers/accessibility/speakup/spk_priv.h
+++ linux-2.6/drivers/accessibility/speakup/spk_priv.h
@@ -34,7 +34,6 @@
 
 const struct old_serial_port *spk_serial_init(int index);
 void spk_stop_serial_interrupt(void);
-int spk_wait_for_xmitr(struct spk_synth *in_synth);
 void spk_serial_release(void);
 void spk_ttyio_release(void);
 void spk_ttyio_register_ldisc(void);
Index: linux-2.6/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-2.6.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-2.6/drivers/accessibility/speakup/spk_ttyio.c
@@ -116,6 +116,7 @@ static void spk_ttyio_tiocmset(unsigned
 static unsigned char spk_ttyio_in(void);
 static unsigned char spk_ttyio_in_nowait(void);
 static void spk_ttyio_flush_buffer(void);
+static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_ttyio_ops = {
.synth_out = spk_ttyio_out,
@@ -125,6 +126,7 @@ struct spk_io_ops spk_ttyio_ops = {
.synth_in = spk_ttyio_in,
.synth_in_nowait = spk_ttyio_in_nowait,
.flush_buffer = spk_ttyio_flush_buffer,
+   .wait_for_xmitr = spk_ttyio_wait_for_xmitr,
 };
 EXPORT_SYMBOL_GPL(spk_ttyio_ops);
 
@@ -286,6 +288,11 @@ static void spk_ttyio_tiocmset(unsigned
mutex_unlock(_tty_mutex);
 }
 
+static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth)
+{
+   return 1;
+}
+
 static unsigned char ttyio_in(int timeout)
 {
struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
Index: linux-2.6/drivers/accessibility/speakup/spk_types.h
===
--- linux-2.6.orig/drivers/accessibility/speakup/spk_types.h
+++ linux-2.6/drivers/accessibility/speakup/spk_types.h
@@ -158,6 +158,7 @@ struct spk_io_ops {
unsigned char (*synth_in)(void);
unsigned char (*synth_in_nowait)(void);
void (*flush_buffer)(void);
+   int (*wait_for_xmitr)(struct spk_synth *synth);
 };
 
 struct spk_synth {
Index: linux-2.6/drivers/accessibility/speakup/synth.c
===
--- linux-2.6.orig/drivers/accessibility/speakup/synth.c
+++ linux-2.6/drivers/accessibility/speakup/synth.c
@@ -159,7 +159,7 @@ int spk_synth_is_alive_restart(struct sp
 {
if (synth->alive)
return 1;
-   if (spk_wait_for_xmitr(synth) > 0) {
+   if (synth->io_ops->wait_for_xmitr(synth) > 0) {
/* restart */
synth->alive = 1;
synth_printf("%s", synth->init);


Re: [PATCH 2/2] speakup: only build serialio when ISA is enabled

2020-08-04 Thread Samuel Thibault
Greg KH, le mar. 04 août 2020 13:58:17 +0200, a ecrit:
>   ERROR: modpost: "spk_serial_io_ops" 
> [drivers/accessibility/speakup/speakup_keypc.ko] undefined!
>   ERROR: modpost: "spk_stop_serial_interrupt" 
> [drivers/accessibility/speakup/speakup_keypc.ko] undefined!

Oh, indeed, these are not covered by the first patch.

I realize that KEYPC depends on ISA, but with COMPILE_TEST as
alternative. We can build serialio in the COMPILE_TEST case too, I'll
update the patches.

But then we'll still have:

> the riscv build issues.

Actually I was surprised by the riscv build issue: the issue is within
riscv's inb() implementation, serialio.c is only calling it.
arch/riscv/include/asm/io.h says:

#define PCI_IOBASE  ((void __iomem *)PCI_IO_START)
[...]
#define inb(c)  ({ u8  __v; __io_pbr(); __v = 
readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })

and thus yes it's arithmetic over a (void*) pointer, the caller cannot
do anything about it.

8250_port.c itself uses inb(), doesn't it get a warning as well? Or is
it getting compiled-out on riscv because of some Kconfig condition?  I
see that the whole drivers/tty/serial is under HAS_IOMEM, and that's the
only condition I can see for 8250_port.c (except SERIAL_8250 of course),
is that it, or is SERIAL_8250 just not enabled in the riscv bot?

Actually the warning seems new, when looking at the Debian build log:

https://buildd.debian.org/status/fetch.php?pkg=linux=riscv64=5.7.10-1=1595803499=0

and looking for serialio.c, I do not see a warning, and its code hasn't
changed. Is the build bot compiler just more talkative?

Samuel


Re: [PATCH 2/2] speakup: only build serialio when ISA is enabled

2020-08-04 Thread Samuel Thibault
Greg KH, le mar. 04 août 2020 13:34:13 +0200, a ecrit:
> On Tue, Aug 04, 2020 at 01:13:32PM +0200, Samuel Thibault wrote:
> > Drivers using serialio are already made available in Kconfig only under
> > the ISA condition.
> > 
> > This solves warnings in inb/outb macros on platform that do not have 
> > support for ISA.
> > 
> > Signed-off-by: Samuel Thibault 
> > 
> > Index: linux-2.6/drivers/accessibility/speakup/Makefile
> > ===
> > --- linux-2.6.orig/drivers/accessibility/speakup/Makefile
> > +++ linux-2.6/drivers/accessibility/speakup/Makefile
> > @@ -16,6 +16,7 @@ obj-$(CONFIG_SPEAKUP_SYNTH_TXPRT) += spe
> >  obj-$(CONFIG_SPEAKUP_SYNTH_DUMMY) += speakup_dummy.o
> >  
> >  obj-$(CONFIG_SPEAKUP) += speakup.o
> > +obj-$(CONFIG_ISA) += serialio.o
> >  speakup-y := \
> > buffers.o \
> > devsynth.o \
> > @@ -25,7 +26,6 @@ speakup-y := \
> > keyhelp.o \
> > kobjects.o \
> > selection.o \
> > -   serialio.o \
> > spk_ttyio.o \
> > synth.o \
> > thread.o \
> 
> Oops, no, I get the following build errors with this patch:
> 
> ERROR: modpost: "spk_wait_for_xmitr" 
> [drivers/accessibility/speakup/speakup.ko] undefined!

Yes, it depends on the first of the queue.

Samuel


[PATCH 1/2] speakup: Fix wait_for_xmitr for ttyio case

2020-08-04 Thread Samuel Thibault
This was missed while introducing the tty-based serial access.

The only remaining use of wait_for_xmitr with tty-based access is in
spk_synth_is_alive_restart to check whether the synth can be restarted.
With tty-based this is up to the tty layer to cope with the buffering
etc. so we can just say yes.

Signed-off-by: Samuel Thibault 

Index: linux-2.6/drivers/accessibility/speakup/serialio.c
===
--- linux-2.6.orig/drivers/accessibility/speakup/serialio.c
+++ linux-2.6/drivers/accessibility/speakup/serialio.c
@@ -32,6 +32,7 @@ static void spk_serial_tiocmset(unsigned
 static unsigned char spk_serial_in(void);
 static unsigned char spk_serial_in_nowait(void);
 static void spk_serial_flush_buffer(void);
+static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_serial_io_ops = {
.synth_out = spk_serial_out,
@@ -40,6 +41,7 @@ struct spk_io_ops spk_serial_io_ops = {
.synth_in = spk_serial_in,
.synth_in_nowait = spk_serial_in_nowait,
.flush_buffer = spk_serial_flush_buffer,
+   .wait_for_xmitr = spk_serial_wait_for_xmitr,
 };
 EXPORT_SYMBOL_GPL(spk_serial_io_ops);
 
@@ -211,7 +213,7 @@ void spk_stop_serial_interrupt(void)
 }
 EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt);
 
-int spk_wait_for_xmitr(struct spk_synth *in_synth)
+static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth)
 {
int tmout = SPK_XMITR_TIMEOUT;
 
Index: linux-2.6/drivers/accessibility/speakup/spk_priv.h
===
--- linux-2.6.orig/drivers/accessibility/speakup/spk_priv.h
+++ linux-2.6/drivers/accessibility/speakup/spk_priv.h
@@ -34,7 +34,6 @@
 
 const struct old_serial_port *spk_serial_init(int index);
 void spk_stop_serial_interrupt(void);
-int spk_wait_for_xmitr(struct spk_synth *in_synth);
 void spk_serial_release(void);
 void spk_ttyio_release(void);
 void spk_ttyio_register_ldisc(void);
Index: linux-2.6/drivers/accessibility/speakup/spk_ttyio.c
===
--- linux-2.6.orig/drivers/accessibility/speakup/spk_ttyio.c
+++ linux-2.6/drivers/accessibility/speakup/spk_ttyio.c
@@ -116,6 +116,7 @@ static void spk_ttyio_tiocmset(unsigned
 static unsigned char spk_ttyio_in(void);
 static unsigned char spk_ttyio_in_nowait(void);
 static void spk_ttyio_flush_buffer(void);
+static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_ttyio_ops = {
.synth_out = spk_ttyio_out,
@@ -125,6 +126,7 @@ struct spk_io_ops spk_ttyio_ops = {
.synth_in = spk_ttyio_in,
.synth_in_nowait = spk_ttyio_in_nowait,
.flush_buffer = spk_ttyio_flush_buffer,
+   .wait_for_xmitr = spk_ttyio_wait_for_xmitr,
 };
 EXPORT_SYMBOL_GPL(spk_ttyio_ops);
 
@@ -286,6 +288,11 @@ static void spk_ttyio_tiocmset(unsigned
mutex_unlock(_tty_mutex);
 }
 
+static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth)
+{
+   return 1;
+}
+
 static unsigned char ttyio_in(int timeout)
 {
struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
Index: linux-2.6/drivers/accessibility/speakup/spk_types.h
===
--- linux-2.6.orig/drivers/accessibility/speakup/spk_types.h
+++ linux-2.6/drivers/accessibility/speakup/spk_types.h
@@ -158,6 +158,7 @@ struct spk_io_ops {
unsigned char (*synth_in)(void);
unsigned char (*synth_in_nowait)(void);
void (*flush_buffer)(void);
+   int (*wait_for_xmitr)(struct spk_synth *synth);
 };
 
 struct spk_synth {
Index: linux-2.6/drivers/accessibility/speakup/synth.c
===
--- linux-2.6.orig/drivers/accessibility/speakup/synth.c
+++ linux-2.6/drivers/accessibility/speakup/synth.c
@@ -159,7 +159,7 @@ int spk_synth_is_alive_restart(struct sp
 {
if (synth->alive)
return 1;
-   if (spk_wait_for_xmitr(synth) > 0) {
+   if (synth->io_ops->wait_for_xmitr(synth) > 0) {
/* restart */
synth->alive = 1;
synth_printf("%s", synth->init);


[PATCH 2/2] speakup: only build serialio when ISA is enabled

2020-08-04 Thread Samuel Thibault
Drivers using serialio are already made available in Kconfig only under
the ISA condition.

This solves warnings in inb/outb macros on platform that do not have 
support for ISA.

Signed-off-by: Samuel Thibault 

Index: linux-2.6/drivers/accessibility/speakup/Makefile
===
--- linux-2.6.orig/drivers/accessibility/speakup/Makefile
+++ linux-2.6/drivers/accessibility/speakup/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_SPEAKUP_SYNTH_TXPRT) += spe
 obj-$(CONFIG_SPEAKUP_SYNTH_DUMMY) += speakup_dummy.o
 
 obj-$(CONFIG_SPEAKUP) += speakup.o
+obj-$(CONFIG_ISA) += serialio.o
 speakup-y := \
buffers.o \
devsynth.o \
@@ -25,7 +26,6 @@ speakup-y := \
keyhelp.o \
kobjects.o \
selection.o \
-   serialio.o \
spk_ttyio.o \
synth.o \
thread.o \


Re: [PATCHv2] staging/speakup: Move out of staging

2020-07-29 Thread Samuel Thibault
Greg KH, le mer. 29 juil. 2020 14:05:33 +0200, a ecrit:
> On Wed, Jul 29, 2020 at 02:35:31AM +0200, Samuel Thibault wrote:
> > The nasty TODO items are done.
> > 
> > Signed-off-by: Samuel Thibault 
> 
> Now applied, thanks for all of the work so far.
> 
> I will be glad to merge patches for this subsystem to Linus if you want
> me to collect them.  If so, feel free to forward them on to me, or send
> me a pull request.

Ok!

Thanks,
Samuel


Re: [PATCH] staging/speakup: Move out of staging

2020-07-28 Thread Samuel Thibault
Joe Perches, le mar. 28 juil. 2020 17:24:47 -0700, a ecrit:
> On Tue, 2020-07-28 at 23:12 +0200, Samuel Thibault wrote:
> > diff --git a/MAINTAINERS b/MAINTAINERS
> []
> > @@ -16077,6 +16077,15 @@ Q: 
> > https://patchwork.kernel.org/project/linux-sparse/list/
> >  B: https://bugzilla.kernel.org/enter_bug.cgi?component=Sparse=Tools
> >  F: include/linux/compiler.h
> >  
> > +SPEAKUP CONSOLE SPEECH DRIVER
> > +M: William Hubbs 
> > +M: Chris Brannon 
> > +M: Kirk Reiser 
> > +M: Samuel Thibault 
> > +L: spea...@linux-speakup.org
> > +W: http://www.linux-speakup.org/
> > +F: drivers/accessibility/speakup/
> 
> S:?   Supported / Maintained / Odd Fixes ?

Ah, yes.  I should have read the documentation at the top, instead of
assuming that "S:" standed for the reason for being in "S"taging.

Submitted a v2.

Samuel


[PATCHv2] staging/speakup: Move out of staging

2020-07-28 Thread Samuel Thibault
The nasty TODO items are done.

Signed-off-by: Samuel Thibault 
---
v2: keep S: line in MAINTAINERS

 .../ABI/stable}/sysfs-driver-speakup  |  0
 .../admin-guide}/spkguide.txt |  0
 MAINTAINERS   | 20 +--
 drivers/accessibility/Kconfig |  2 ++
 drivers/accessibility/Makefile|  1 +
 .../speakup/DefaultKeyAssignments |  0
 .../speakup/Kconfig   |  0
 .../speakup/Makefile  |  0
 .../{staging => accessibility}/speakup/TODO   |  0
 .../speakup/buffers.c |  0
 .../speakup/devsynth.c|  0
 .../speakup/fakekey.c |  0
 .../{staging => accessibility}/speakup/i18n.c |  0
 .../{staging => accessibility}/speakup/i18n.h |  0
 .../speakup/keyhelp.c |  0
 .../speakup/kobjects.c|  0
 .../{staging => accessibility}/speakup/main.c |  0
 .../speakup/selection.c   |  0
 .../speakup/serialio.c|  0
 .../speakup/serialio.h|  0
 .../speakup/speakup.h |  0
 .../speakup/speakup_acnt.h|  0
 .../speakup/speakup_acntpc.c  |  0
 .../speakup/speakup_acntsa.c  |  0
 .../speakup/speakup_apollo.c  |  0
 .../speakup/speakup_audptr.c  |  0
 .../speakup/speakup_bns.c |  0
 .../speakup/speakup_decext.c  |  0
 .../speakup/speakup_decpc.c   |  0
 .../speakup/speakup_dectlk.c  |  0
 .../speakup/speakup_dtlk.c|  0
 .../speakup/speakup_dtlk.h|  0
 .../speakup/speakup_dummy.c   |  0
 .../speakup/speakup_keypc.c   |  0
 .../speakup/speakup_ltlk.c|  0
 .../speakup/speakup_soft.c|  0
 .../speakup/speakup_spkout.c  |  0
 .../speakup/speakup_txprt.c   |  0
 .../speakup/speakupmap.h  |  0
 .../speakup/speakupmap.map|  0
 .../speakup/spk_priv.h|  0
 .../speakup/spk_priv_keyinfo.h|  0
 .../speakup/spk_ttyio.c   |  0
 .../speakup/spk_types.h   |  0
 .../speakup/synth.c   |  0
 .../speakup/thread.c  |  0
 .../speakup/varhandlers.c |  0
 drivers/staging/Kconfig   |  2 --
 drivers/staging/Makefile  |  1 -
 49 files changed, 13 insertions(+), 13 deletions(-)
 rename {drivers/staging/speakup => 
Documentation/ABI/stable}/sysfs-driver-speakup (100%)
 rename {drivers/staging/speakup => Documentation/admin-guide}/spkguide.txt 
(100%)
 rename drivers/{staging => accessibility}/speakup/DefaultKeyAssignments (100%)
 rename drivers/{staging => accessibility}/speakup/Kconfig (100%)
 rename drivers/{staging => accessibility}/speakup/Makefile (100%)
 rename drivers/{staging => accessibility}/speakup/TODO (100%)
 rename drivers/{staging => accessibility}/speakup/buffers.c (100%)
 rename drivers/{staging => accessibility}/speakup/devsynth.c (100%)
 rename drivers/{staging => accessibility}/speakup/fakekey.c (100%)
 rename drivers/{staging => accessibility}/speakup/i18n.c (100%)
 rename drivers/{staging => accessibility}/speakup/i18n.h (100%)
 rename drivers/{staging => accessibility}/speakup/keyhelp.c (100%)
 rename drivers/{staging => accessibility}/speakup/kobjects.c (100%)
 rename drivers/{staging => accessibility}/speakup/main.c (100%)
 rename drivers/{staging => accessibility}/speakup/selection.c (100%)
 rename drivers/{staging => accessibility}/speakup/serialio.c (100%)
 rename drivers/{staging => accessibility}/speakup/serialio.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_acnt.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_acntpc.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_acntsa.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_apollo.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_audptr.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_bns.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_decext.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_decpc.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dectlk.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dtlk.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dtlk.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dummy.c (10

Re: [PATCH] staging/speakup: Update TODO list

2020-07-28 Thread Samuel Thibault
Greg KH, le mar. 28 juil. 2020 10:18:42 +0200, a ecrit:
> On Sun, Jul 26, 2020 at 06:54:52PM +0200, Samuel Thibault wrote:
> > Thanks to Okash's latest work, the TODO list is essentially empty, so
> > the way out from staging now seems open.
> > 
> > The status of the remaining issue mentioned in TODO is not clear, we
> > asked the speakup user mailing list for reproducer cases, but didn't get
> > a really specific scenario. One serious bug was fixed by 9d32c0cde4e2
> > ("staging/speakup: fix get_word non-space look-ahead"), which does not
> > seem to really be related to the bug mentioned in TODO. Possibly the bug
> > mentioned in TODO has been fixed long ago and people have been thinking
> > that it was not because they can not distinguish the symptoms mentioned
> > in TODO from the symptoms of the bug fixed by 9d32c0cde4e2.
> 
> I think it's time we move speakup out of staging.  Care to submit a
> patch series that does this?

Yes!

Done so.

Samuel


[PATCH] staging/speakup: Move out of staging

2020-07-28 Thread Samuel Thibault
The nasty TODO items are done.

Signed-off-by: Samuel Thibault 
---
 .../ABI/stable}/sysfs-driver-speakup  |  0
 .../admin-guide}/spkguide.txt |  0
 MAINTAINERS   | 19 +--
 drivers/accessibility/Kconfig |  2 ++
 drivers/accessibility/Makefile|  1 +
 .../speakup/DefaultKeyAssignments |  0
 .../speakup/Kconfig   |  0
 .../speakup/Makefile  |  0
 .../{staging => accessibility}/speakup/TODO   |  0
 .../speakup/buffers.c |  0
 .../speakup/devsynth.c|  0
 .../speakup/fakekey.c |  0
 .../{staging => accessibility}/speakup/i18n.c |  0
 .../{staging => accessibility}/speakup/i18n.h |  0
 .../speakup/keyhelp.c |  0
 .../speakup/kobjects.c|  0
 .../{staging => accessibility}/speakup/main.c |  0
 .../speakup/selection.c   |  0
 .../speakup/serialio.c|  0
 .../speakup/serialio.h|  0
 .../speakup/speakup.h |  0
 .../speakup/speakup_acnt.h|  0
 .../speakup/speakup_acntpc.c  |  0
 .../speakup/speakup_acntsa.c  |  0
 .../speakup/speakup_apollo.c  |  0
 .../speakup/speakup_audptr.c  |  0
 .../speakup/speakup_bns.c |  0
 .../speakup/speakup_decext.c  |  0
 .../speakup/speakup_decpc.c   |  0
 .../speakup/speakup_dectlk.c  |  0
 .../speakup/speakup_dtlk.c|  0
 .../speakup/speakup_dtlk.h|  0
 .../speakup/speakup_dummy.c   |  0
 .../speakup/speakup_keypc.c   |  0
 .../speakup/speakup_ltlk.c|  0
 .../speakup/speakup_soft.c|  0
 .../speakup/speakup_spkout.c  |  0
 .../speakup/speakup_txprt.c   |  0
 .../speakup/speakupmap.h  |  0
 .../speakup/speakupmap.map|  0
 .../speakup/spk_priv.h|  0
 .../speakup/spk_priv_keyinfo.h|  0
 .../speakup/spk_ttyio.c   |  0
 .../speakup/spk_types.h   |  0
 .../speakup/synth.c   |  0
 .../speakup/thread.c  |  0
 .../speakup/varhandlers.c |  0
 drivers/staging/Kconfig   |  2 --
 drivers/staging/Makefile  |  1 -
 49 files changed, 12 insertions(+), 13 deletions(-)
 rename {drivers/staging/speakup => 
Documentation/ABI/stable}/sysfs-driver-speakup (100%)
 rename {drivers/staging/speakup => Documentation/admin-guide}/spkguide.txt 
(100%)
 rename drivers/{staging => accessibility}/speakup/DefaultKeyAssignments (100%)
 rename drivers/{staging => accessibility}/speakup/Kconfig (100%)
 rename drivers/{staging => accessibility}/speakup/Makefile (100%)
 rename drivers/{staging => accessibility}/speakup/TODO (100%)
 rename drivers/{staging => accessibility}/speakup/buffers.c (100%)
 rename drivers/{staging => accessibility}/speakup/devsynth.c (100%)
 rename drivers/{staging => accessibility}/speakup/fakekey.c (100%)
 rename drivers/{staging => accessibility}/speakup/i18n.c (100%)
 rename drivers/{staging => accessibility}/speakup/i18n.h (100%)
 rename drivers/{staging => accessibility}/speakup/keyhelp.c (100%)
 rename drivers/{staging => accessibility}/speakup/kobjects.c (100%)
 rename drivers/{staging => accessibility}/speakup/main.c (100%)
 rename drivers/{staging => accessibility}/speakup/selection.c (100%)
 rename drivers/{staging => accessibility}/speakup/serialio.c (100%)
 rename drivers/{staging => accessibility}/speakup/serialio.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_acnt.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_acntpc.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_acntsa.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_apollo.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_audptr.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_bns.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_decext.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_decpc.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dectlk.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dtlk.c (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dtlk.h (100%)
 rename drivers/{staging => accessibility}/speakup/speakup_dummy.c (100%)
 rename drivers/{staging => accessibili

[PATCH] staging/speakup: Update TODO list

2020-07-26 Thread Samuel Thibault
Thanks to Okash's latest work, the TODO list is essentially empty, so
the way out from staging now seems open.

The status of the remaining issue mentioned in TODO is not clear, we
asked the speakup user mailing list for reproducer cases, but didn't get
a really specific scenario. One serious bug was fixed by 9d32c0cde4e2
("staging/speakup: fix get_word non-space look-ahead"), which does not
seem to really be related to the bug mentioned in TODO. Possibly the bug
mentioned in TODO has been fixed long ago and people have been thinking
that it was not because they can not distinguish the symptoms mentioned
in TODO from the symptoms of the bug fixed by 9d32c0cde4e2.

Signed-off-by: Samuel Thibault 

diff --git a/drivers/staging/speakup/TODO b/drivers/staging/speakup/TODO
index 993410c3e531..d4ca093bf0bd 100644
--- a/drivers/staging/speakup/TODO
+++ b/drivers/staging/speakup/TODO
@@ -6,35 +6,11 @@ Speakup is a kernel based screen review package for the linux 
operating
 system.  It allows blind users to interact with applications on the
 linux console by means of synthetic speech.
 
-Currently, speakup has several issues we know of.
+Currently, speakup has one issue we know of.
 
-The first issue has to do with the way speakup communicates with serial
-ports.  Currently, we communicate directly with the hardware
-ports. This however conflicts with the standard serial port drivers,
-which poses various problems. This is also not working for modern hardware
-such as PCI-based serial ports.  Also, there is not a way we can
-communicate with USB devices.  The current serial port handling code is
-in serialio.c in this directory.
-
-Some places are currently using in_atomic() because speakup functions
-are called in various contexts, and a couple of things can't happen
-in these cases. Pushing work to some worker thread would probably help,
-as was already done for the serial port driving part.
-
-There is a duplication of the selection functions in selections.c. These
-functions should get exported from drivers/char/selection.c (clear_selection
-notably) and used from there instead.
-
-The kobjects may have to move to a more proper place in /sys. The
-discussion on lkml resulted to putting speech synthesizers in the
-"speech" class, and the speakup screen reader itself into
-/sys/class/vtconsole/vtcon0/speakup, the nasty path being handled by
-userland tools.
-
-Another issue seems to only happen on SMP systems.  It seems
-that text in the output buffer gets garbled because a lock is not set.
-This bug happens regularly, but no one has been able to find a situation
-which produces it consistently.
+It seems to only happen on SMP systems. It seems that text in the output buffer
+gets garbled because a lock is not set. This bug happens regularly, but no one
+has been able to find a situation which produces it consistently.
 
 Patches, suggestions, corrections, etc, are definitely welcome.
 
@@ -42,6 +18,5 @@ We prefer that you contact us on the mailing list; however, 
if you do
 not want to subscribe to a mailing list, send your email to all of the
 following:
 
-w.d.hu...@gmail.com, ch...@the-brannons.com, k...@reisers.ca and
-samuel.thiba...@ens-lyon.org.
-
+okash.khaw...@gmail.com, w.d.hu...@gmail.com, ch...@the-brannons.com,
+k...@reisers.ca and samuel.thiba...@ens-lyon.org.


Re: [PATCH] Staging: speakup: Replace HTTP links with HTTPS ones

2020-07-15 Thread Samuel Thibault
Alexander A. Klimov, le lun. 13 juil. 2020 11:13:05 +0200, a ecrit:
> Rationale:
> Reduces attack surface on kernel devs opening the links for MITM
> as HTTPS traffic is much harder to manipulate.
> 
> Deterministic algorithm:
> For each file:
>   If not .svg:
> For each line:
>   If doesn't contain `\bxmlns\b`:
> For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
> If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
> If both the HTTP and HTTPS versions
> return 200 OK and serve the same content:
>   Replace HTTP with HTTPS.
> 
> Signed-off-by: Alexander A. Klimov 

Reviewed-by: Samuel Thibault 

Thanks!

> ---
>  Continuing my work started at 93431e0607e5.
>  See also: git log --oneline '--author=Alexander A. Klimov 
> ' v5.7..master
>  (Actually letting a shell for loop submit all this stuff for me.)
> 
>  If there are any URLs to be removed completely or at least not just 
> HTTPSified:
>  Just clearly say so and I'll *undo my change*.
>  See also: https://lkml.org/lkml/2020/6/27/64
> 
>  If there are any valid, but yet not changed URLs:
>  See: https://lkml.org/lkml/2020/6/26/837
> 
>  If you apply the patch, please let me know.
> 
>  Sorry again to all maintainers who complained about subject lines.
>  Now I realized that you want an actually perfect prefixes,
>  not just subsystem ones.
>  I tried my best...
>  And yes, *I could* (at least half-)automate it.
>  Impossible is nothing! :)
> 
> 
>  drivers/staging/speakup/spkguide.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/speakup/spkguide.txt 
> b/drivers/staging/speakup/spkguide.txt
> index 1e622cd34363..3782f6a09e97 100644
> --- a/drivers/staging/speakup/spkguide.txt
> +++ b/drivers/staging/speakup/spkguide.txt
> @@ -1531,7 +1531,7 @@ The Free Software Foundation may publish new, revised 
> versions
>  of the GNU Free Documentation License from time to time.  Such new
>  versions will be similar in spirit to the present version, but may
>  differ in detail to address new problems or concerns.  See
> -http://www.gnu.org/copyleft/.
> +https://www.gnu.org/copyleft/.
>  
>  Each version of the License is given a distinguishing version number.
>  If the Document specifies that a particular numbered version of this
> -- 
> 2.27.0
> 

-- 
Samuel
 J'ai un gros problème: j'ai cet exercice à rendre demain lundi, mais ma
 TI 89 ne sait pas le faire...
 Est-ce que quelqu'un pourrait m'aider??
 -+- OD In Guide du Neuneu Usenet : Comment ça ! Il faut réfléchir ?-+-


Re: [PATCH] taging: speakup: remove volatile

2020-05-22 Thread Samuel Thibault
Joe Perches, le ven. 22 mai 2020 10:22:03 -0700, a ecrit:
> > Put another way: I don't think putting any hint here would help, on the
> > contrary, somebody has to really look at what protection is needed,
> > without getting influenced by rules-of-thumb.
> 
> checkpatch newbies/robots will submit this change again otherwise.

Ah, ok, right.

I don't think removing volatiles is a thing for newbies, 

> Comment wording can always be improved.

I'd then suggest

/* TODO: determine what proper synchronization "volatile" should be
 * replaced with.  */

Samuel


Re: [PATCH] taging: speakup: remove volatile

2020-05-22 Thread Samuel Thibault
Joe Perches, le ven. 22 mai 2020 09:36:05 -0700, a ecrit:
> On Fri, 2020-05-22 at 13:34 +0300, Dan Carpenter wrote:
> > On Fri, May 22, 2020 at 02:46:28PM +0530, MugilRaj wrote:
> > > fix checkpatch.pl warning, which is Use of volatile is usually wrong: see
> > > Documentation/process/volatile-considered-harmful.rst
> > > Signed-off-by: MugilRaj 
> > 
> > Please put a blank before the Signed-off-by line.
> > 
> > Probably there should be a space between your first and last name.  It's
> > supposed to your legal name like for signing a legal document so use
> > whatever is appropriate legal documents in your country.
> > 
> > Also the Documentation/process/volatile-considered-harmful.rst explains
> > that people often use "volatile" when they should be using locking for
> > synchronization.  That seems to be the case here.  So the correct fix is
> > to add locking.  That's a little bit complicated to do and requires
> > testing.
> > 
> > If we apply this patch, then we have silenced the warning so now someone
> > will have to look for the bug.  But if we leave it as-is, then everyone
> > will know that the code is buggy.  So let's leave it as-is until we are
> > able to fix the bug.
> > 
> > It's always better to have easy to find bugs, than hidden bugs.
> 
> And better still to comment known opportunities to
> improve the code so the next time someone tries to
> remove this volatile, there's a comment right there
> showing what's necessary instead.

Actually I don't think adding the suggestion is a good thing if it's
only a "rule-of-thumb-replace-volatile-with-lock".

Actually possibly volatile might not even be needed because there could
be already a lock protecting this.

Put another way: I don't think putting any hint here would help, on the
contrary, somebody has to really look at what protection is needed,
without getting influenced by rules-of-thumb.

Samuel


Re: [PATCH] taging: speakup: remove volatile

2020-05-22 Thread Samuel Thibault
Hello,

MugilRaj, le ven. 22 mai 2020 14:46:28 +0530, a ecrit:
> fix checkpatch.pl warning, which is Use of volatile is usually wrong: see
> Documentation/process/volatile-considered-harmful.rst

Yes, but the proper fix is usually not to just remove the volatile
qualifier, which will not fix anything and potentially break things.

Fixing this requires really understanding what is at stake here, between
the read_buff_add function and the use of synth_full(). That goes
through interrupt handlers, tty disciplines, and the actual behavior
expected by speakup. Not a simple task, henceforth :)

> Signed-off-by: MugilRaj 
> ---
>  drivers/staging/speakup/speakup_decext.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/speakup/speakup_decext.c 
> b/drivers/staging/speakup/speakup_decext.c
> index ddbb7e9..22baaeb 100644
> --- a/drivers/staging/speakup/speakup_decext.c
> +++ b/drivers/staging/speakup/speakup_decext.c
> @@ -21,7 +21,7 @@
>  #define SYNTH_CLEAR 0x03
>  #define PROCSPEECH 0x0b
>  
> -static volatile unsigned char last_char;
> +static unsigned char last_char;
>  
>  static void read_buff_add(u_char ch)
>  {
> -- 
> 2.7.4
> 


Re: [HELP REQUESTED from the community] Was: Staging status of speakup

2019-09-16 Thread Samuel Thibault
Okash Khawaja, le dim. 15 sept. 2019 19:41:30 +0100, a ecrit:
> I have attached the descriptions.

Attachment is missing :)

Samuel


Re: [HELP REQUESTED from the community] Was: Staging status of speakup

2019-09-14 Thread Samuel Thibault
Hello,

Okash Khawaja, le sam. 14 sept. 2019 22:08:35 +0100, a ecrit:
> 2. We are still missing descriptions for i18n/ directory. I have added
> filenames below. can someone can add description please:

There are some descriptions in the "14.1.  Files Under the i18n
Subdirectory" section of spkguide.txt

Samuel


[PATCHv2] hda: Fix 1-minute detection delay when i915 module is not available

2019-07-26 Thread Samuel Thibault
Distribution installation images such as Debian include different sets
of modules which can be downloaded dynamically.  Such images may notably
include the hda sound modules but not the i915 DRM module, even if the
latter was enabled at build time, as reported on
https://bugs.debian.org/931507

In such a case hdac_i915 would be linked in and try to load the i915
module, fail since it is not there, but still wait for a whole minute
before giving up binding with it.

This fixes such as case by only waiting for the binding if the module
was properly loaded (or module support is disabled, in which case i915
is already compiled-in anyway).

Signed-off-by: Samuel Thibault 
---
 sound/hda/hdac_i915.c |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

--- a/sound/hda/hdac_i915.c
+++ b/sound/hda/hdac_i915.c
@@ -136,10 +136,13 @@ int snd_hdac_i915_init(struct hdac_bus *
if (!acomp)
return -ENODEV;
if (!acomp->ops) {
-   request_module("i915");
-   /* 60s timeout */
-   wait_for_completion_timeout(_complete,
-   msecs_to_jiffies(60 * 1000));
+   if (!IS_ENABLED(CONFIG_MODULES) ||
+   !request_module("i915"))
+   {
+   /* 60s timeout */
+   wait_for_completion_timeout(_complete,
+  msecs_to_jiffies(60 * 1000));
+   }
}
if (!acomp->ops) {
dev_info(bus->dev, "couldn't bind with audio component\n");


hda: Fix 1-minute detection delay when i915 module is not available

2019-07-26 Thread Samuel Thibault
Distribution installation images such as Debian include different sets
of modules which can be downloaded dynamically.  Such images may notably
include the hda sound modules but not the i915 DRM module, even if the
latter was enabled at build time, as reported on
https://bugs.debian.org/931507

In such a case hdac_i915 would be linked in and try to load the i915
module, fail since it is not there, but still wait for a whole minute
before giving up binding with it.

This fixes such as case by only waiting for the binding if the module
was properly loaded (or module support is disabled, in which case i915
is already compiled-in anyway).

Signed-off-by: Samuel Thibault 
---
 sound/hda/hdac_i915.c |   12 
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/sound/hda/hdac_i915.c
+++ b/sound/hda/hdac_i915.c
@@ -143,10 +143,14 @@ int snd_hdac_i915_init(struct hdac_bus *
if (!acomp)
return -ENODEV;
if (!acomp->ops) {
-   request_module("i915");
-   /* 60s timeout */
-   wait_for_completion_timeout(_complete,
-   msecs_to_jiffies(60 * 1000));
+#ifdef CONFIG_MODULES
+   if (request_module("i915") == 0)
+#endif
+   {
+   /* 60s timeout */
+   wait_for_completion_timeout(_complete,
+  msecs_to_jiffies(60 * 1000));
+   }
}
if (!acomp->ops) {
dev_info(bus->dev, "couldn't bind with audio component\n");


[HELP REQUESTED from the community] Was: Staging status of speakup

2019-07-12 Thread Samuel Thibault
Hello,

To readers of the linux-speakup: could you help on this so we can get
Speakup in mainline?  Neither Okash or I completely know what user
consequences the files in /sys/accessibility/speakup/ have, so could
people give brief explanations for each file (something like 3-6 lines
of explanation)?

The i18n/ files have been already documented in section 14.1 of the
spkguide.txt, so we do not need help for them.

Thanks!
Samuel

Greg KH, le ven. 12 juil. 2019 10:38:19 +0200, a ecrit:
> Can you make up a patch to create a
> drivers/staging/speakup/sysfs-speakup file with the needed information?
> That way it will be much easier to determine exactly what these sysfs
> files do and my review can be easier, and perhaps not needed at all :)


Re: [PATCH] staging: speakup: One function call less in speakup_win_enable()

2019-07-06 Thread Samuel Thibault
Markus Elfring, le sam. 06 juil. 2019 10:15:30 +0200, a ecrit:
> From: Markus Elfring 
> Date: Sat, 6 Jul 2019 10:03:56 +0200
> 
> Avoid an extra function call by using a ternary operator instead of
> a conditional statement.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/main.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index 488f2539aa9a..03bbc9a4dbb3 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -1917,10 +1917,9 @@ static void speakup_win_enable(struct vc_data *vc)
>   return;
>   }
>   win_enabled ^= 1;
> - if (win_enabled)
> - synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCED));
> - else
> - synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCE_DISABLED));
> + synth_printf("%s\n", spk_msg_get(win_enabled
> +  ? MSG_WINDOW_SILENCED
> +  : MSG_WINDOW_SILENCE_DISABLED));
>  }
> 
>  static void speakup_bits(struct vc_data *vc)
> --
> 2.22.0
> 

-- 
Samuel
--- christ gives channel operator status to Dieu
 -+- #ens-mim and hell -+-


Re: [PATCH] drivers: staging: speakup: serialio: fix warning linux/serial.h is included more than once

2019-05-27 Thread Samuel Thibault
Hariprasad Kelam, le dim. 26 mai 2019 12:43:22 +0530, a ecrit:
> fix below warning reported by  includecheck
> 
> ./drivers/staging/speakup/serialio.h: linux/serial.h is included more
> than once.
> 
> Signed-off-by: Hariprasad Kelam 

That was indeed the result of f79b0d9c223ca09cefffc72304a7bcbc401a1c6f
("staging: speakup: Fixed warning  instead of
") which didn't take care of the inclusion above.
I believe  only is fine, the important part is in
drivers/staging/speakup/serialio.c which really needs to include
asm/serial.h to get SERIAL_PORT_DFNS

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/serialio.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/staging/speakup/serialio.h 
> b/drivers/staging/speakup/serialio.h
> index aa691e4..6f8f86f 100644
> --- a/drivers/staging/speakup/serialio.h
> +++ b/drivers/staging/speakup/serialio.h
> @@ -4,9 +4,6 @@
>  
>  #include /* for rs_table, serial constants */
>  #include /* for more serial constants */
> -#ifndef __sparc__
> -#include 
> -#endif
>  #include 
>  
>  #include "spk_priv.h"
> -- 
> 2.7.4
> 

-- 
Samuel
> No manual is ever necessary.
May I politely interject here: BULLSHIT.  That's the biggest Apple lie of all!
(Discussion in comp.os.linux.misc on the intuitiveness of interfaces.)


Re: [PATCH] Staging: speakup: Replace return type

2019-05-05 Thread Samuel Thibault
Hello,

Madhumitha Prabakaran, le dim. 05 mai 2019 02:26:45 -0500, a ecrit:
> Replace return type and remove the respective assignment.

I prefer to keep it the way it was, it looks more straightforward for
the reader.

Samuel

> Issue found by Coccinelle.
> 
> Signed-off-by: Madhumitha Prabakaran 
> ---
>  drivers/staging/speakup/i18n.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c
> index ee240d36f947..a748eb8052d1 100644
> --- a/drivers/staging/speakup/i18n.c
> +++ b/drivers/staging/speakup/i18n.c
> @@ -470,8 +470,7 @@ static char *find_specifier_end(char *input)
>   input++;/* Advance over %. */
>   input = skip_flags(input);
>   input = skip_width(input);
> - input = skip_conversion(input);
> - return input;
> + return skip_conversion(input);
>  }
>  
>  /*
> -- 
> 2.17.1
> 

-- 
Samuel
Progress (n.): The process through which the Internet has evolved from
smart people in front of dumb terminals to dumb people in front of smart
terminals.


Re: [PATCH 1/2] vt: selection: allow functions to be called from inside kernel

2019-04-04 Thread Samuel Thibault
Greg KH, le jeu. 04 avril 2019 22:35:49 +0200, a ecrit:
> On Thu, Apr 04, 2019 at 08:45:29PM +0100, Okash Khawaja wrote:
> > diff --git a/include/linux/selection.h b/include/linux/selection.h
> > index a8f5b97b216f..171d77dfc825 100644
> > --- a/include/linux/selection.h
> > +++ b/include/linux/selection.h
> > @@ -11,13 +11,12 @@
> >  #include 
> >  #include 
> >  
> > -struct tty_struct;
> > -
> 
> Nit, why remove these lines?

The same line shows up already just a couple of lines below, so it's
just a clean-up along the way.

Samuel


Re: Staging status of speakup

2019-03-19 Thread Samuel Thibault
Alan Cox, le mar. 19 mars 2019 16:31:21 +, a ecrit:
> On Sat, 16 Mar 2019 10:35:43 +0100
> Samuel Thibault  wrote:
> > Chris Brannon, le ven. 15 mars 2019 18:19:39 -0700, a ecrit:
> > > Okash Khawaja  writes:  
> > > > Finally there is an issue where text in output buffer sometimes gets
> > > > garbled on SMP systems, but we can continue working on it after the
> > > > driver is moved out of staging, if that's okay. Basically we need a
> > > > reproducer of this issue.  
> > > 
> > > What kind of reproducer do you need here?  It's straightforward to
> > > reproduce in casual use, at least with a software synthesizer.  
> > 
> > The problem is that neither Okash nor I are even casual users of
> > speakup, so we need a walk-through of the kind of operation that
> > produces the issue. It does not have to be reproducible each time it is
> > done. Perhaps (I really don't know what that bug is about actually) it
> > is a matter of putting text in the selection buffer, and try to paste it
> > 100 times, and once every 10 times it will be garbled, for instance.
> 
> paste_selection still says

The issue is not actually with pasting a selection, just plain text
output from applications.

Samuel


Re: Staging status of speakup

2019-03-16 Thread Samuel Thibault
Hello,

Please keep the lists in Cc, so that not only I have the information
(in particular since I will probably *not* have the time to investigate
myself).

Samuel Thibault, le sam. 16 mars 2019 10:35:43 +0100, a ecrit:
> The problem is that neither Okash nor I are even casual users of
> speakup, so we need a walk-through of the kind of operation that
> produces the issue.

deedra Waters  wrote:
> it's dead simple

For a user, perhaps, but again, neither Okash or I are actual users of
speakup, so we have just no idea what casual use is.

> just lead the screenreader read large blocks of text i guarantee it's
> reproduceable.

Which shortcut do you use to make the screen reader read it?  What is
"large"? Is that only one 80x25 complete output screen? Is that cat-ing
a long text? How is it garbled: is that right from the beginning of the
text? or at some point during it? or is that just a piece of it and then
it's Ok again?

Samuel


Re: Staging status of speakup

2019-03-16 Thread Samuel Thibault
Chris Brannon, le ven. 15 mars 2019 18:19:39 -0700, a ecrit:
> Okash Khawaja  writes:
> > Finally there is an issue where text in output buffer sometimes gets
> > garbled on SMP systems, but we can continue working on it after the
> > driver is moved out of staging, if that's okay. Basically we need a
> > reproducer of this issue.
> 
> What kind of reproducer do you need here?  It's straightforward to
> reproduce in casual use, at least with a software synthesizer.

The problem is that neither Okash nor I are even casual users of
speakup, so we need a walk-through of the kind of operation that
produces the issue. It does not have to be reproducible each time it is
done. Perhaps (I really don't know what that bug is about actually) it
is a matter of putting text in the selection buffer, and try to paste it
100 times, and once every 10 times it will be garbled, for instance.

Samuel


staging/speakup_soft: Fix alternate speech with other synths

2019-03-07 Thread Samuel Thibault
When switching from speakup_soft to another synth, speakup_soft would
keep calling synth_buffer_getc() from softsynthx_read.

Let's thus make synth.c export the knowledge of the current synth, so
that speakup_soft can determine whether it should be running.

speakup_soft also needs to set itself alive, otherwise the switch would
let it remain silent.

Signed-off-by: Samuel Thibault 
---
 drivers/staging/speakup/speakup_soft.c |   16 +++-
 drivers/staging/speakup/spk_priv.h |1 +
 drivers/staging/speakup/synth.c|6 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct fi
return -EINVAL;
 
spin_lock_irqsave(_info.spinlock, flags);
+   synth_soft.alive = 1;
while (1) {
prepare_to_wait(_event, , TASK_INTERRUPTIBLE);
-   if (!unicode)
-   synth_buffer_skip_nonlatin1();
-   if (!synth_buffer_empty() || speakup_info.flushing)
-   break;
+   if (synth_current() == _soft) {
+   if (!unicode)
+   synth_buffer_skip_nonlatin1();
+   if (!synth_buffer_empty() || speakup_info.flushing)
+   break;
+   }
spin_unlock_irqrestore(_info.spinlock, flags);
if (fp->f_flags & O_NONBLOCK) {
finish_wait(_event, );
@@ -233,6 +236,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() != _soft)
+   break;
if (speakup_info.flushing) {
speakup_info.flushing = 0;
ch = '\x18';
@@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct fi
poll_wait(fp, _event, wait);
 
spin_lock_irqsave(_info.spinlock, flags);
-   if (!synth_buffer_empty() || speakup_info.flushing)
+   if (synth_current() == _soft &&
+   (!synth_buffer_empty() || speakup_info.flushing))
ret = EPOLLIN | EPOLLRDNORM;
spin_unlock_irqrestore(_info.spinlock, flags);
return ret;
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -72,6 +72,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;
 
--- a/drivers/staging/speakup/synth.c
+++ b/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 };


Re: [PATCH] staging: speakup: i18n: fix spelling mistake "phoneticly" -> "phonetically"

2019-03-02 Thread Samuel Thibault
Hello,

Colin King, le mer. 28 nov. 2018 16:12:32 +, a ecrit:
> From: Colin Ian King 
> 
> There is a spelling mistake in array speakup_default_msgs at index
> MSG_FUNCNAME_SPELL_WORD_PHONETICALLY, fix this.
> 
> Signed-off-by: Colin Ian King 

We never got any feedback from the speakup mailing list, I guess fixing
the typo is fine.

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/i18n.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c
> index cea8707653f5..ee240d36f947 100644
> --- a/drivers/staging/speakup/i18n.c
> +++ b/drivers/staging/speakup/i18n.c
> @@ -336,7 +336,7 @@ static char *speakup_default_msgs[MSG_LAST_INDEX] = {
>   [MSG_FUNCNAME_SPELL_DELAY_DEC] = "spell delay decrement",
>   [MSG_FUNCNAME_SPELL_DELAY_INC] = "spell delay increment",
>   [MSG_FUNCNAME_SPELL_WORD] = "spell word",
> - [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phoneticly",
> + [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically",
>   [MSG_FUNCNAME_TONE_DEC] = "tone decrement",
>   [MSG_FUNCNAME_TONE_INC] = "tone increment",
>   [MSG_FUNCNAME_VOICE_DEC] = "voice decrement",
> -- 
> 2.19.1
> 



Re: [PATCH v2] staging : speakup: Fix format issues in Kconfig

2019-02-24 Thread Samuel Thibault
Bharath Vedartham, le dim. 24 févr. 2019 18:41:42 +0530, a ecrit:
> Fix the checkpatch.pl warning to replace ---help--- with help in
> Kconfig.
> 
> Signed-off-by: Bharath Vedartham 

Reviewed-by: Samuel Thibault 

Thanks!

> ---
> Changes since v1:
>   - Allign help and removed redundant spaces.
> ---
>  drivers/staging/speakup/Kconfig | 42 
> -
>  1 file changed, 16 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/staging/speakup/Kconfig b/drivers/staging/speakup/Kconfig
> index efd6f45..4a78ab1 100644
> --- a/drivers/staging/speakup/Kconfig
> +++ b/drivers/staging/speakup/Kconfig
> @@ -3,7 +3,7 @@ menu "Speakup console speech"
>  config SPEAKUP
>   depends on VT
>   tristate "Speakup core"
> - ---help---
> + help
>   This is the Speakup screen reader.  Think of it as a
>   video console for blind people.  If built in to the
>   kernel, it can speak everything on the text console from
> @@ -43,7 +43,7 @@ config SPEAKUP
>  if SPEAKUP
>  config SPEAKUP_SYNTH_ACNTSA
>   tristate "Accent SA synthesizer support"
> - ---help---
> + help
>   This is the Speakup driver for the Accent SA
>   synthesizer.  You can say y to build it into the kernel,
>   or m to build it as a module.  See the configuration
> @@ -52,7 +52,7 @@ config SPEAKUP_SYNTH_ACNTSA
>  config SPEAKUP_SYNTH_ACNTPC
>   tristate "Accent PC synthesizer support"
>   depends on ISA || COMPILE_TEST
> - ---help---
> + help
>   This is the Speakup driver for the accent pc
>   synthesizer.  You can say y to build it into the kernel,
>   or m to build it as a module.  See the configuration
> @@ -60,7 +60,7 @@ config SPEAKUP_SYNTH_ACNTPC
>  
>  config SPEAKUP_SYNTH_APOLLO
>   tristate "Apollo II synthesizer support"
> - ---help---
> + help
>   This is the Speakup driver for the Apollo II
>   synthesizer.  You can say y to build it into the kernel,
>   or m to build it as a module.  See the configuration
> @@ -68,7 +68,7 @@ config SPEAKUP_SYNTH_APOLLO
>  
>  config SPEAKUP_SYNTH_AUDPTR
>   tristate "Audapter synthesizer support"
> - ---help---
> + help
>   This is the Speakup driver for the Audapter synthesizer.
>You can say y to build it into the kernel, or m to
>   build it as a module.  See the configuration help on the
> @@ -76,7 +76,7 @@ config SPEAKUP_SYNTH_AUDPTR
>  
>  config SPEAKUP_SYNTH_BNS
>   tristate "Braille 'n' Speak synthesizer support"
> - ---help---
> + help
>   This is the Speakup driver for the Braille 'n' Speak
>   synthesizer.  You can say y to build it into the kernel,
>   or m to build it as a module.  See the configuration
> @@ -84,8 +84,7 @@ config SPEAKUP_SYNTH_BNS
>  
>  config SPEAKUP_SYNTH_DECTLK
>   tristate "DECtalk Express synthesizer support"
> - ---help---
> -
> + help
>   This is the Speakup driver for the DecTalk Express
>   synthesizer.  You can say y to build it into the kernel,
>   or m to build it as a module.  See the configuration
> @@ -93,8 +92,7 @@ config SPEAKUP_SYNTH_DECTLK
>  
>  config SPEAKUP_SYNTH_DECEXT
>   tristate "DECtalk External (old) synthesizer support"
> - ---help---
> -
> + help
>   This is the Speakup driver for the DecTalk External
>   (old) synthesizer.  You can say y to build it into the
>   kernel, or m to build it as a module.  See the
> @@ -105,8 +103,7 @@ config SPEAKUP_SYNTH_DECPC
>   depends on m
>   depends on ISA || COMPILE_TEST
>   tristate "DECtalk PC (big ISA card) synthesizer support"
> - ---help---
> -
> + help
>   This is the Speakup driver for the DecTalk PC (full
>   length ISA) synthesizer.  You can say m to build it as
>   a module.  See the configuration help on the Speakup
> @@ -127,8 +124,7 @@ config SPEAKUP_SYNTH_DECPC
>  config SPEAKUP_SYNTH_DTLK
>   tristate "DoubleTalk PC synthesizer support"
>   depends on ISA || COMPILE_TEST
> - ---help---
> -
> + help
>   This is the Speakup driver for the internal DoubleTalk
>   PC synthesizer.  You can say y to build it into the
>   kernel, or m to build it as a module.  See the
> @@ -138,8 +134,7 @@ config SPEAKUP_SYNTH_DTLK
>  config SPEAKUP_S

Re: [PATCH] staging: Note that simple_strtoul can't simply be replaced by kstrtoul

2019-02-24 Thread Samuel Thibault
Greg KH, le dim. 24 févr. 2019 08:59:21 +0100, a ecrit:
> On Sat, Feb 23, 2019 at 08:42:19PM +0100, Samuel Thibault wrote:
> > We often receive patches which erroneously try to use kstrtoul in these
> > places.
> > 
> > Signed-off-by: Samuel Thibault 
> 
> Awe, it's fun to try to see people do this and not really think about
> the consequences :)

Sure :)
But I have to say I'm a bit scared one of these could pass through :)

> Anyway, seriously, thanks for this, I'll go queue it up later today...

Thanks!

Samuel


Re: [PATCH] staging : speakup: replace ---help--- with help in Kconfig

2019-02-23 Thread Samuel Thibault
Hello, and thanks for your patch,

Bharath Vedartham, le dim. 24 févr. 2019 01:51:17 +0530, a ecrit:
> @@ -148,7 +148,7 @@ config SPEAKUP_SYNTH_KEYPC
>  
>  config SPEAKUP_SYNTH_LTLK
>   tristate "DoubleTalk LT/LiteTalk synthesizer support"
> help---
> +help

I'd say while at it, align it with tristate?

Samuel


Re: [PATCH] staging: speakup: Replace simple_strtoul with kstrtoul

2019-02-23 Thread Samuel Thibault
Bharath Vedartham, le dim. 24 févr. 2019 01:01:21 +0530, a ecrit:
> simple_strtoul is obsolete. Change it to kstrtoul. Kernel is building
> and booting successfully.

Please recheck your patch, temp is used after the simple_strtoul call.

Samuel


[PATCH] staging: Note that simple_strtoul can't simply be replaced by kstrtoul

2019-02-23 Thread Samuel Thibault
We often receive patches which erroneously try to use kstrtoul in these
places.

Signed-off-by: Samuel Thibault 
---
 drivers/staging/speakup/kobjects.c|2 ++
 drivers/staging/speakup/main.c|1 +
 drivers/staging/speakup/varhandlers.c |1 +
 3 files changed, 4 insertions(+)

--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -154,6 +154,7 @@ static ssize_t chars_chartab_store(struc
continue;
}
 
+   /* Do not replace with kstrtoul: here we need temp to be 
updated */
index = simple_strtoul(cp, , 10);
if (index > 255) {
rejected++;
@@ -787,6 +788,7 @@ static ssize_t message_store_helper(cons
continue;
}
 
+   /* Do not replace with kstrtoul: here we need temp to be 
updated */
index = simple_strtoul(cp, , 10);
 
while ((temp < linefeed) && (*temp == ' ' || *temp == '\t'))
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1979,6 +1979,7 @@ oops:
return 1;
}
 
+   /* Do not replace with kstrtoul: here we need cp to be updated */
goto_pos = simple_strtoul(goto_buf, , 10);
 
if (*cp == 'x') {
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -328,6 +328,7 @@ char *spk_s2uchar(char *start, char *des
 {
int val;
 
+   /* Do not replace with kstrtoul: here we need start to be updated */
val = simple_strtoul(skip_spaces(start), , 10);
if (*start == ',')
start++;


Re: [PATCH] staging: speakup: fix tty-operation NULL derefs

2019-01-30 Thread Samuel Thibault
Johan Hovold, le mer. 30 janv. 2019 10:49:34 +0100, a ecrit:
> The send_xchar() and tiocmset() tty operations are optional. Add the
> missing sanity checks to prevent user-space triggerable NULL-pointer
> dereferences.
> 
> Fixes: 6b9ad1c742bf ("staging: speakup: add send_xchar, tiocmset and input 
> functionality for tty")
> Cc: stable  # 4.13
> Cc: Okash Khawaja 
> Cc: Samuel Thibault 
> Signed-off-by: Johan Hovold 

Indeed.

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/spk_ttyio.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/speakup/spk_ttyio.c 
> b/drivers/staging/speakup/spk_ttyio.c
> index c92bbd05516e..005de0024dd4 100644
> --- a/drivers/staging/speakup/spk_ttyio.c
> +++ b/drivers/staging/speakup/spk_ttyio.c
> @@ -265,7 +265,8 @@ static void spk_ttyio_send_xchar(char ch)
>   return;
>   }
>  
> - speakup_tty->ops->send_xchar(speakup_tty, ch);
> + if (speakup_tty->ops->send_xchar)
> + speakup_tty->ops->send_xchar(speakup_tty, ch);
>   mutex_unlock(_tty_mutex);
>  }
>  
> @@ -277,7 +278,8 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned 
> int clear)
>   return;
>   }
>  
> - speakup_tty->ops->tiocmset(speakup_tty, set, clear);
> + if (speakup_tty->ops->tiocmset)
> + speakup_tty->ops->tiocmset(speakup_tty, set, clear);
>   mutex_unlock(_tty_mutex);
>  }
>  
> -- 
> 2.20.1
> 

-- 
Samuel
R: Parce que ça renverse bêtement l'ordre naturel de lecture!
Q: Mais pourquoi citer en fin d'article est-il si effroyable?
R: Citer en fin d'article
Q: Quelle est la chose la plus désagréable sur les groupes de news?


Re: general protection fault in spk_ttyio_ldisc_close

2019-01-08 Thread Samuel Thibault
Greg KH, le mar. 08 janv. 2019 15:25:07 +0100, a ecrit:
> On Tue, Jan 08, 2019 at 09:15:02AM -0500, Kyungtae Kim wrote:
> > On Tue, Jan 8, 2019 at 8:50 AM Greg KH  wrote:
> > >
> > > On Tue, Jan 08, 2019 at 08:37:37AM -0500, Kyungtae Kim wrote:
> > > > We report a bug in linux-4.20: "general protection fault in
> > > > spk_ttyio_ldisc_close"
> > > >
> > > > kernel config: https://kt0755.github.io/etc/config_v4.20_stable
> > > > repro: https://kt0755.github.io/etc/repro.a670e.c
> > > >
> > > > This occurs when the function kfree is about to execute
> > > > (driver/staging/speakup/spk_ttyio.c:68).
> > > > Particularly, kfree takes the argument like speakup_tty->disc_data.
> > > > But speakup_tty is invalid, so the pointer dereference causes GPF.
> > > > At a glance, it seems that speakup_tty was deallocated somewhere ahead 
> > > > of kfree.
> > >
> > > How did you trigger this?  Did you shut down and close the device
> > > already somehow?  Do you have a real tty device that is driven by the
> > > device?
> > >
> > > thanks,
> > >
> > > greg k-h
> > 
> > For this crash, we did without real speakup tty device.
> 
> How did you bind a non-real speakup tty device to the driver?

One can tell any device name to the driver and it will attempt to
communicate with it.

Samuel


Re: [PATCH] staging: speakup: Fix coding style

2018-12-24 Thread Samuel Thibault
Daniel Smith, le lun. 24 déc. 2018 10:12:23 +, a ecrit:
> Replaced text ---help--- with help as per style check patch recommendation
> 
> Signed-off-by: Daniel 

Acked-by: Samuel Thibault 


Re: [PATCH] staging: speakup: change semaphore to completion

2018-12-10 Thread Samuel Thibault
Arnd Bergmann, le lun. 10 déc. 2018 22:41:50 +0100, a ecrit:
> In this driver, both function the same way, but we want to eventually
> kill off semaphores, so a completion is the better choice here.
> 
> Signed-off-by: Arnd Bergmann 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/spk_ttyio.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/speakup/spk_ttyio.c 
> b/drivers/staging/speakup/spk_ttyio.c
> index 979e3ae249c1..c92bbd05516e 100644
> --- a/drivers/staging/speakup/spk_ttyio.c
> +++ b/drivers/staging/speakup/spk_ttyio.c
> @@ -10,7 +10,7 @@
>  
>  struct spk_ldisc_data {
>   char buf;
> - struct semaphore sem;
> + struct completion completion;
>   bool buf_free;
>  };
>  
> @@ -55,7 +55,7 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty)
>   if (!ldisc_data)
>   return -ENOMEM;
>  
> - sema_init(_data->sem, 0);
> + init_completion(_data->completion);
>   ldisc_data->buf_free = true;
>   speakup_tty->disc_data = ldisc_data;
>  
> @@ -95,7 +95,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty,
>  
>   ldisc_data->buf = cp[0];
>   ldisc_data->buf_free = false;
> - up(_data->sem);
> + complete(_data->completion);
>  
>   return 1;
>  }
> @@ -286,7 +286,8 @@ static unsigned char ttyio_in(int timeout)
>   struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
>   char rv;
>  
> - if (down_timeout(_data->sem, usecs_to_jiffies(timeout)) == 
> -ETIME) {
> + if (wait_for_completion_timeout(_data->completion,
> + usecs_to_jiffies(timeout)) == 0) {
>   if (timeout)
>   pr_warn("spk_ttyio: timeout (%d)  while waiting for 
> input\n",
>   timeout);
> -- 
> 2.20.0
> 

-- 
Samuel
Progress (n.): The process through which the Internet has evolved from
smart people in front of dumb terminals to dumb people in front of smart
terminals.


Re: [PATCH] staging: speakup: i18n: fix spelling mistake "phoneticly" -> "phonetically"

2018-11-28 Thread Samuel Thibault
Hello,

Colin King, le mer. 28 nov. 2018 16:12:32 +, a ecrit:
> - [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phoneticly",
> + [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically",

Mmm, clearly an english typo. Speakup people, do you think there might
be any downside here?  Could it be that it was done on purpose for e.g.
syntheses to pronounce it right?

Samuel


Re: [PATCH] staging: speakup: i18n: fix spelling mistake "phoneticly" -> "phonetically"

2018-11-28 Thread Samuel Thibault
Hello,

Colin King, le mer. 28 nov. 2018 16:12:32 +, a ecrit:
> - [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phoneticly",
> + [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically",

Mmm, clearly an english typo. Speakup people, do you think there might
be any downside here?  Could it be that it was done on purpose for e.g.
syntheses to pronounce it right?

Samuel


staging/speakup_soft: Fix alternate speech with other synths

2018-11-20 Thread Samuel Thibault
When switching from speakup_soft to another synth, speakup_soft would
keep calling synth_buffer_getc() from softsynthx_read.

Let's thus make synth.c export the knowledge of the current synth, so
that speakup_soft can determine whether it should be running.

speakup_soft also needs to set itself alive, otherwise the switch would
let it remain silent.

Signed-off-by: Samuel Thibault 
---
 drivers/staging/speakup/speakup_soft.c |   16 +++-
 drivers/staging/speakup/spk_priv.h |1 +
 drivers/staging/speakup/synth.c|6 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct fi
return -EINVAL;
 
spin_lock_irqsave(_info.spinlock, flags);
+   synth_soft.alive = 1;
while (1) {
prepare_to_wait(_event, , TASK_INTERRUPTIBLE);
-   if (!unicode)
-   synth_buffer_skip_nonlatin1();
-   if (!synth_buffer_empty() || speakup_info.flushing)
-   break;
+   if (synth_current() == _soft) {
+   if (!unicode)
+   synth_buffer_skip_nonlatin1();
+   if (!synth_buffer_empty() || speakup_info.flushing)
+   break;
+   }
spin_unlock_irqrestore(_info.spinlock, flags);
if (fp->f_flags & O_NONBLOCK) {
finish_wait(_event, );
@@ -233,6 +236,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() != _soft)
+   break;
if (speakup_info.flushing) {
speakup_info.flushing = 0;
ch = '\x18';
@@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct fi
poll_wait(fp, _event, wait);
 
spin_lock_irqsave(_info.spinlock, flags);
-   if (!synth_buffer_empty() || speakup_info.flushing)
+   if (synth_current() == _soft &&
+   (!synth_buffer_empty() || speakup_info.flushing))
ret = EPOLLIN | EPOLLRDNORM;
spin_unlock_irqrestore(_info.spinlock, flags);
return ret;
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -72,6 +72,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;
 
--- a/drivers/staging/speakup/synth.c
+++ b/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 };



staging/speakup_soft: Fix alternate speech with other synths

2018-11-20 Thread Samuel Thibault
When switching from speakup_soft to another synth, speakup_soft would
keep calling synth_buffer_getc() from softsynthx_read.

Let's thus make synth.c export the knowledge of the current synth, so
that speakup_soft can determine whether it should be running.

speakup_soft also needs to set itself alive, otherwise the switch would
let it remain silent.

Signed-off-by: Samuel Thibault 
---
 drivers/staging/speakup/speakup_soft.c |   16 +++-
 drivers/staging/speakup/spk_priv.h |1 +
 drivers/staging/speakup/synth.c|6 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct fi
return -EINVAL;
 
spin_lock_irqsave(_info.spinlock, flags);
+   synth_soft.alive = 1;
while (1) {
prepare_to_wait(_event, , TASK_INTERRUPTIBLE);
-   if (!unicode)
-   synth_buffer_skip_nonlatin1();
-   if (!synth_buffer_empty() || speakup_info.flushing)
-   break;
+   if (synth_current() == _soft) {
+   if (!unicode)
+   synth_buffer_skip_nonlatin1();
+   if (!synth_buffer_empty() || speakup_info.flushing)
+   break;
+   }
spin_unlock_irqrestore(_info.spinlock, flags);
if (fp->f_flags & O_NONBLOCK) {
finish_wait(_event, );
@@ -233,6 +236,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() != _soft)
+   break;
if (speakup_info.flushing) {
speakup_info.flushing = 0;
ch = '\x18';
@@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct fi
poll_wait(fp, _event, wait);
 
spin_lock_irqsave(_info.spinlock, flags);
-   if (!synth_buffer_empty() || speakup_info.flushing)
+   if (synth_current() == _soft &&
+   (!synth_buffer_empty() || speakup_info.flushing))
ret = EPOLLIN | EPOLLRDNORM;
spin_unlock_irqrestore(_info.spinlock, flags);
return ret;
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -72,6 +72,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;
 
--- a/drivers/staging/speakup/synth.c
+++ b/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 };



Re: [PATCH] staging: speakup: clean up few indentation issues

2018-10-30 Thread Samuel Thibault
Colin King, le mar. 30 oct. 2018 11:09:59 +, a ecrit:
> From: Colin Ian King 
> 
> Trivial fix to clean up indentation issues across the driver
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/kobjects.c  | 2 +-
>  drivers/staging/speakup/speakup_decpc.c | 6 +++---
>  drivers/staging/speakup/speakup_keypc.c | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/speakup/kobjects.c 
> b/drivers/staging/speakup/kobjects.c
> index 08f11cc17371..2e36d872662c 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -545,7 +545,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct 
> kobj_attribute *attr,
>   int rv = 0;
>   struct st_var_header *param;
>   struct var_t *var;
> - char *cp1;
> + char *cp1;
>   char *cp;
>   char ch;
>   unsigned long flags;
> diff --git a/drivers/staging/speakup/speakup_decpc.c 
> b/drivers/staging/speakup/speakup_decpc.c
> index 6649309e0342..459ee0c0bd57 100644
> --- a/drivers/staging/speakup/speakup_decpc.c
> +++ b/drivers/staging/speakup/speakup_decpc.c
> @@ -302,12 +302,12 @@ static void synth_flush(struct spk_synth *synth)
>   while (dt_ctrl(CTRL_flush)) {
>   if (--timeout == 0)
>   break;
> -udelay(50);
> + udelay(50);
>   }
>   for (timeout = 0; timeout < 10; timeout++) {
>   if (dt_waitbit(STAT_dma_ready))
>   break;
> -udelay(50);
> + udelay(50);
>   }
>   outb_p(DMA_sync, speakup_info.port_tts + 4);
>   outb_p(0, speakup_info.port_tts + 4);
> @@ -315,7 +315,7 @@ udelay(50);
>   for (timeout = 0; timeout < 10; timeout++) {
>   if (!(dt_getstatus() & STAT_flushing))
>   break;
> -udelay(50);
> + udelay(50);
>   }
>   dma_state = dt_getstatus() & STAT_dma_state;
>   dma_state ^= STAT_dma_state;
> diff --git a/drivers/staging/speakup/speakup_keypc.c 
> b/drivers/staging/speakup/speakup_keypc.c
> index 3901734982a4..b788272da4f9 100644
> --- a/drivers/staging/speakup/speakup_keypc.c
> +++ b/drivers/staging/speakup/speakup_keypc.c
> @@ -177,7 +177,7 @@ static void do_catch_up(struct spk_synth *synth)
>   jiffy_delta = spk_get_var(JIFFY);
>   delay_time = spk_get_var(DELAY);
>   full_time = spk_get_var(FULL);
> -spin_lock_irqsave(_info.spinlock, flags);
> + spin_lock_irqsave(_info.spinlock, flags);
>   jiffy_delta_val = jiffy_delta->u.n.value;
>   spin_unlock_irqrestore(_info.spinlock, flags);
>  
> -- 
> 2.19.1
> 

-- 
Samuel
 je sens venir la fonte 14 pour le rapport
 -+- #ens-mim -+-


Re: [PATCH] staging: speakup: clean up few indentation issues

2018-10-30 Thread Samuel Thibault
Colin King, le mar. 30 oct. 2018 11:09:59 +, a ecrit:
> From: Colin Ian King 
> 
> Trivial fix to clean up indentation issues across the driver
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/kobjects.c  | 2 +-
>  drivers/staging/speakup/speakup_decpc.c | 6 +++---
>  drivers/staging/speakup/speakup_keypc.c | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/speakup/kobjects.c 
> b/drivers/staging/speakup/kobjects.c
> index 08f11cc17371..2e36d872662c 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -545,7 +545,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct 
> kobj_attribute *attr,
>   int rv = 0;
>   struct st_var_header *param;
>   struct var_t *var;
> - char *cp1;
> + char *cp1;
>   char *cp;
>   char ch;
>   unsigned long flags;
> diff --git a/drivers/staging/speakup/speakup_decpc.c 
> b/drivers/staging/speakup/speakup_decpc.c
> index 6649309e0342..459ee0c0bd57 100644
> --- a/drivers/staging/speakup/speakup_decpc.c
> +++ b/drivers/staging/speakup/speakup_decpc.c
> @@ -302,12 +302,12 @@ static void synth_flush(struct spk_synth *synth)
>   while (dt_ctrl(CTRL_flush)) {
>   if (--timeout == 0)
>   break;
> -udelay(50);
> + udelay(50);
>   }
>   for (timeout = 0; timeout < 10; timeout++) {
>   if (dt_waitbit(STAT_dma_ready))
>   break;
> -udelay(50);
> + udelay(50);
>   }
>   outb_p(DMA_sync, speakup_info.port_tts + 4);
>   outb_p(0, speakup_info.port_tts + 4);
> @@ -315,7 +315,7 @@ udelay(50);
>   for (timeout = 0; timeout < 10; timeout++) {
>   if (!(dt_getstatus() & STAT_flushing))
>   break;
> -udelay(50);
> + udelay(50);
>   }
>   dma_state = dt_getstatus() & STAT_dma_state;
>   dma_state ^= STAT_dma_state;
> diff --git a/drivers/staging/speakup/speakup_keypc.c 
> b/drivers/staging/speakup/speakup_keypc.c
> index 3901734982a4..b788272da4f9 100644
> --- a/drivers/staging/speakup/speakup_keypc.c
> +++ b/drivers/staging/speakup/speakup_keypc.c
> @@ -177,7 +177,7 @@ static void do_catch_up(struct spk_synth *synth)
>   jiffy_delta = spk_get_var(JIFFY);
>   delay_time = spk_get_var(DELAY);
>   full_time = spk_get_var(FULL);
> -spin_lock_irqsave(_info.spinlock, flags);
> + spin_lock_irqsave(_info.spinlock, flags);
>   jiffy_delta_val = jiffy_delta->u.n.value;
>   spin_unlock_irqrestore(_info.spinlock, flags);
>  
> -- 
> 2.19.1
> 

-- 
Samuel
 je sens venir la fonte 14 pour le rapport
 -+- #ens-mim -+-


staging/speakup_soft: Fix alternate speech with other synths

2018-10-23 Thread Samuel Thibault
When switching from speakup_soft to another synth, speakup_soft would
keep calling synth_buffer_getc() from softsynthx_read.

Let's thus make synth.c export the knowledge of the current synth, so
that speakup_soft can determine whether it should be running.

speakup_soft also needs to set itself alive, otherwise the switch would
let it remain silent.

Signed-off-by: Samuel Thibault 
---
 drivers/staging/speakup/speakup_soft.c |   16 +++-
 drivers/staging/speakup/spk_priv.h |1 +
 drivers/staging/speakup/synth.c|6 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct fi
return -EINVAL;
 
spin_lock_irqsave(_info.spinlock, flags);
+   synth_soft.alive = 1;
while (1) {
prepare_to_wait(_event, , TASK_INTERRUPTIBLE);
-   if (!unicode)
-   synth_buffer_skip_nonlatin1();
-   if (!synth_buffer_empty() || speakup_info.flushing)
-   break;
+   if (synth_current() == _soft) {
+   if (!unicode)
+   synth_buffer_skip_nonlatin1();
+   if (!synth_buffer_empty() || speakup_info.flushing)
+   break;
+   }
spin_unlock_irqrestore(_info.spinlock, flags);
if (fp->f_flags & O_NONBLOCK) {
finish_wait(_event, );
@@ -233,6 +236,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() != _soft)
+   break;
if (speakup_info.flushing) {
speakup_info.flushing = 0;
ch = '\x18';
@@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct fi
poll_wait(fp, _event, wait);
 
spin_lock_irqsave(_info.spinlock, flags);
-   if (!synth_buffer_empty() || speakup_info.flushing)
+   if (synth_current() == _soft &&
+   (!synth_buffer_empty() || speakup_info.flushing))
ret = EPOLLIN | EPOLLRDNORM;
spin_unlock_irqrestore(_info.spinlock, flags);
return ret;
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -72,6 +72,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;
 
--- a/drivers/staging/speakup/synth.c
+++ b/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 };


staging/speakup_soft: Fix alternate speech with other synths

2018-10-23 Thread Samuel Thibault
When switching from speakup_soft to another synth, speakup_soft would
keep calling synth_buffer_getc() from softsynthx_read.

Let's thus make synth.c export the knowledge of the current synth, so
that speakup_soft can determine whether it should be running.

speakup_soft also needs to set itself alive, otherwise the switch would
let it remain silent.

Signed-off-by: Samuel Thibault 
---
 drivers/staging/speakup/speakup_soft.c |   16 +++-
 drivers/staging/speakup/spk_priv.h |1 +
 drivers/staging/speakup/synth.c|6 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct fi
return -EINVAL;
 
spin_lock_irqsave(_info.spinlock, flags);
+   synth_soft.alive = 1;
while (1) {
prepare_to_wait(_event, , TASK_INTERRUPTIBLE);
-   if (!unicode)
-   synth_buffer_skip_nonlatin1();
-   if (!synth_buffer_empty() || speakup_info.flushing)
-   break;
+   if (synth_current() == _soft) {
+   if (!unicode)
+   synth_buffer_skip_nonlatin1();
+   if (!synth_buffer_empty() || speakup_info.flushing)
+   break;
+   }
spin_unlock_irqrestore(_info.spinlock, flags);
if (fp->f_flags & O_NONBLOCK) {
finish_wait(_event, );
@@ -233,6 +236,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() != _soft)
+   break;
if (speakup_info.flushing) {
speakup_info.flushing = 0;
ch = '\x18';
@@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct fi
poll_wait(fp, _event, wait);
 
spin_lock_irqsave(_info.spinlock, flags);
-   if (!synth_buffer_empty() || speakup_info.flushing)
+   if (synth_current() == _soft &&
+   (!synth_buffer_empty() || speakup_info.flushing))
ret = EPOLLIN | EPOLLRDNORM;
spin_unlock_irqrestore(_info.spinlock, flags);
return ret;
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -72,6 +72,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;
 
--- a/drivers/staging/speakup/synth.c
+++ b/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 };


Re: [PATCH] staging: speakup: remove redundant variable l

2018-07-11 Thread Samuel Thibault
Colin King, le mer. 11 juil. 2018 12:26:07 +0100, a ecrit:
> From: Colin Ian King 
> 
> Variable l is being assigned but is never used hence it is redundant
> and can be removed.
> 
> Cleans up clang warning:
> warning: variable 'l' set but not used [-Wunused-but-set-variable
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/varhandlers.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/speakup/varhandlers.c 
> b/drivers/staging/speakup/varhandlers.c
> index 54a76b6752ad..1b545152cc49 100644
> --- a/drivers/staging/speakup/varhandlers.c
> +++ b/drivers/staging/speakup/varhandlers.c
> @@ -179,7 +179,6 @@ int spk_set_num_var(int input, struct st_var_header *var, 
> int how)
>  {
>   int val;
>   int *p_val = var->p_val;
> - int l;
>   char buf[32];
>   char *cp;
>   struct var_t *var_data = var->data;
> @@ -237,9 +236,9 @@ int spk_set_num_var(int input, struct st_var_header *var, 
> int how)
>   else
>   cp = buf;
>   if (!var_data->u.n.out_str)
> - l = sprintf(cp, var_data->u.n.synth_fmt, (int)val);
> + sprintf(cp, var_data->u.n.synth_fmt, (int)val);
>   else
> - l = sprintf(cp, var_data->u.n.synth_fmt, 
> var_data->u.n.out_str[val]);
> + sprintf(cp, var_data->u.n.synth_fmt, 
> var_data->u.n.out_str[val]);
>   synth_printf("%s", cp);
>   return 0;
>  }
> -- 
> 2.17.1
> 

-- 
Samuel
> Allez, soyez sympa ... traduisez-lui "linux"
Linux, c'est comme le miel : c'est vachement bon mais ça attire les
mouches. En plus, ça colle aux doigts et on a du mal à s'en défaire.
-+- TP in: Guide du linuxien pervers - "Barrez vous les mouches !"


Re: [PATCH] staging: speakup: remove redundant variable l

2018-07-11 Thread Samuel Thibault
Colin King, le mer. 11 juil. 2018 12:26:07 +0100, a ecrit:
> From: Colin Ian King 
> 
> Variable l is being assigned but is never used hence it is redundant
> and can be removed.
> 
> Cleans up clang warning:
> warning: variable 'l' set but not used [-Wunused-but-set-variable
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/varhandlers.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/speakup/varhandlers.c 
> b/drivers/staging/speakup/varhandlers.c
> index 54a76b6752ad..1b545152cc49 100644
> --- a/drivers/staging/speakup/varhandlers.c
> +++ b/drivers/staging/speakup/varhandlers.c
> @@ -179,7 +179,6 @@ int spk_set_num_var(int input, struct st_var_header *var, 
> int how)
>  {
>   int val;
>   int *p_val = var->p_val;
> - int l;
>   char buf[32];
>   char *cp;
>   struct var_t *var_data = var->data;
> @@ -237,9 +236,9 @@ int spk_set_num_var(int input, struct st_var_header *var, 
> int how)
>   else
>   cp = buf;
>   if (!var_data->u.n.out_str)
> - l = sprintf(cp, var_data->u.n.synth_fmt, (int)val);
> + sprintf(cp, var_data->u.n.synth_fmt, (int)val);
>   else
> - l = sprintf(cp, var_data->u.n.synth_fmt, 
> var_data->u.n.out_str[val]);
> + sprintf(cp, var_data->u.n.synth_fmt, 
> var_data->u.n.out_str[val]);
>   synth_printf("%s", cp);
>   return 0;
>  }
> -- 
> 2.17.1
> 

-- 
Samuel
> Allez, soyez sympa ... traduisez-lui "linux"
Linux, c'est comme le miel : c'est vachement bon mais ça attire les
mouches. En plus, ça colle aux doigts et on a du mal à s'en défaire.
-+- TP in: Guide du linuxien pervers - "Barrez vous les mouches !"


Re: [PATCH] staging: speakup: fix wraparound in uaccess length check

2018-07-11 Thread Samuel Thibault
Hello,

Jann Horn, le mar. 10 juil. 2018 13:34:33 -0700, a ecrit:
> On Sat, Jul 7, 2018 at 1:29 AM Samuel Thibault
>  wrote:
> > Could you review, test, and resubmit the patch below instead?
> 
> Er... you mean, you want me to take your patch, add my Signed-off-by
> below yours, and then send that?

Yes, please.

> Some random thing I noticed, but I don't think it has anything to do
> with this issue: In some runs, when the console is repeatedly printing
> "Debian GNU/Linux 9 debian tty1\n\ndebian login: " in response to me
> pressing enter repeatedly, /dev/softsynthu (read in 1-byte steps)
> seems to return things like "Debian GNU slash Linux 9 debian tty1 \n
> debi login: ". I don't understand why it sometimes says "debi login"
> instead of "debian login".

It's odd indeed, but I agree it's unrelated.

Samuel


  1   2   3   4   5   6   7   8   >