mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: samuel.thibault@ens-lyon.org
To: Greg KH <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: Thu, 10 Dec 2020 21:01:26 +0100	[thread overview]
Message-ID: <20201210200132.174722170@ens-lyon.org> (raw)
In-Reply-To: <20201210200123.451204785@ens-lyon.org>

[-- Attachment #1: spk_ttyio_clean --]
[-- Type: text/plain, Size: 1521 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-12-10 20:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 20:01 [patch 0/3] speakup: simplify relation between line disc and synth samuel.thibault
2020-12-10 20:01 ` [patch 1/3] speakup: Add synth parameter to io functions samuel.thibault
2020-12-10 20:01 ` [patch 2/3] speakup: Reference synth from tty and tty from synth samuel.thibault
2020-12-10 20:01 ` samuel.thibault [this message]
  -- strict thread matches above, loose matches on Subject: below --
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-11-30 22:25 [patch 0/3] speakup: simplify relation between line disc and synth Samuel Thibault
2020-11-30 22:26 ` [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=20201210200132.174722170@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®