Commit 11742252 authored by Samuel Thibault's avatar Samuel Thibault Committed by Greg Kroah-Hartman

speakup: Simplify spk_ttyio_out error handling.

This avoids most code indentation
Signed-off-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Link: https://lore.kernel.org/r/20210126222147.3848175-4-samuel.thibault@ens-lyon.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4f2a81f3
...@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void) ...@@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void)
static int spk_ttyio_out(struct spk_synth *in_synth, const char ch) static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
{ {
struct tty_struct *tty = in_synth->dev; 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) { ret = tty->ops->write(tty, &ch, 1);
int ret = tty->ops->write(tty, &ch, 1);
if (ret == 0)
if (ret == 0) /* No room */
/* No room */ return 0;
return 0;
if (ret < 0) { if (ret > 0)
pr_warn("%s: I/O error, deactivating speakup\n", /* Success */
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;
}
return 1; 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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment