[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210111223737.697336-4-samuel.thibault@ens-lyon.org>
Date: Mon, 11 Jan 2021 23:37:36 +0100
From: Samuel Thibault <samuel.thibault@...-lyon.org>
To: gregkh@...uxfoundation.org
Cc: Samuel Thibault <samuel.thibault@...-lyon.org>,
linux-kernel@...r.kernel.org, speakup@...ux-speakup.org
Subject: [PATCH 3/4] speakup: Simplify spk_ttyio_out error handling.
This avoids most code indentation
Signed-off-by: Samuel Thibault <samuel.thibault@...-lyon.org>
---
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, &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;
}
--
2.20.1
Powered by blists - more mailing lists