All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, speakup@linux-speakup.org,
	Samuel Thibault <samuel.thibault@ens-lyon.org>
Subject: [patch 3/3] speakup: Simplify spk_ttyio_out error handling.
Date: Mon, 30 Nov 2020 23:26:57 +0100	[thread overview]
Message-ID: <20201130220719.298054871@ens-lyon.org> (raw)
In-Reply-To: 20201130220626.854574234@ens-lyon.org

[-- Attachment #1: spk_ttyio_clean --]
[-- Type: text/plain, Size: 1522 bytes --]

This avoids most code indentation

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

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, &ch, 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, &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;
 }
 




  parent reply	other threads:[~2020-11-30 22:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 22:25 [patch 0/3] speakup: simplify relation between line disc and synth Samuel Thibault
2020-11-30 22:26 ` [patch 1/3] speakup: Add synth parameter to io functions Samuel Thibault
2020-12-09 14:40   ` Greg KH
2020-12-09 21:14     ` Samuel Thibault
2020-11-30 22:26 ` [patch 2/3] speakup: Reference synth from tty and tty from synth Samuel Thibault
2020-11-30 22:26 ` Samuel Thibault [this message]
2020-12-09 20:58 [patch 0/3] speakup: simplify relation between line disc and synth samuel.thibault
2020-12-09 20:58 ` [patch 3/3] speakup: Simplify spk_ttyio_out error handling samuel.thibault
2020-12-10 20:01 [patch 0/3] speakup: simplify relation between line disc and synth samuel.thibault
2020-12-10 20:01 ` [patch 3/3] speakup: Simplify spk_ttyio_out error handling samuel.thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201130220719.298054871@ens-lyon.org \
    --to=samuel.thibault@ens-lyon.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=speakup@linux-speakup.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.