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/4] speakup: Simplify spk_ttyio_out error handling.
Date: Tue, 26 Jan 2021 23:21:46 +0100 [thread overview]
Message-ID: <20210126222147.3848175-4-samuel.thibault@ens-lyon.org> (raw)
In-Reply-To: <20210126222147.3848175-1-samuel.thibault@ens-lyon.org>
This avoids most code indentation
Signed-off-by: Samuel Thibault <samuel.thibault@ens-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
next prev parent reply other threads:[~2021-01-27 5:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 22:21 [PATCH 0/4] speakup update Samuel Thibault
2021-01-26 22:21 ` [PATCH 1/4] speakup: add the missing synth parameter to all io functions Samuel Thibault
2021-01-26 22:21 ` [PATCH 2/4] speakup: Reference synth from tty and tty from synth Samuel Thibault
2021-01-26 22:21 ` Samuel Thibault [this message]
2021-01-26 22:21 ` [PATCH 4/4] speakup: Add documentation on changing the speakup messages language Samuel Thibault
-- strict thread matches above, loose matches on Subject: below --
2021-01-11 22:37 [PATCH 0/4] speakup update Samuel Thibault
2021-01-11 22:37 ` [PATCH 3/4] 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=20210126222147.3848175-4-samuel.thibault@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;
as well as URLs for NNTP newsgroup(s).