Skip to content

Commit

Permalink
speakup: Simplify spk_ttyio_out error handling.
Browse files Browse the repository at this point in the history
This avoids most code indentation

Signed-off-by: Samuel Thibault <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
sthibaul authored and gregkh committed Jan 27, 2021
1 parent 4f2a81f commit 1174225
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions drivers/accessibility/speakup/spk_ttyio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, &ch, 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, &ch, 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;
}

Expand Down

0 comments on commit 1174225

Please sign in to comment.