Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2612159pxb; Mon, 11 Jan 2021 14:39:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJCk5ZU28EdCmhGIRZx6gTi+QE40Rrp4qty+1Mc1ptwpIiBpri+HvOIq5wRdtnbjUqn+Um X-Received: by 2002:a05:6402:308b:: with SMTP id de11mr1058434edb.205.1610404785798; Mon, 11 Jan 2021 14:39:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610404785; cv=none; d=google.com; s=arc-20160816; b=0Tn9GqNDKa0hTvTfgxzstadAox0UYpOlQGkMK0BX4vvSBUMGOuyflCUIyE9jabhlqa jcKeFAHf07nLouUGtEAuELYv/9MLf6djKIq9FQ9lkn+W5AFum3s0g8o08lWuW+1t1UAg LRCRJnW8Jb/PiE1F9/maXhazk78Gpf4cb33PIbMHLMg1O7F6YIlPArPoL/1b+114oRbM 2WLUIAWYCWG9CjRaN7eI+9sboFleKvRRVlno6bimMssv62MMSHPowsc6kmwEgotCAqa+ doZpY9+MFK5N6e4DI+cBNbaERIEfvV092sI1z3XMDJmYIMFZfamggZGm6C780APJb1GE Kqfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RvuwyE+CJmOHvGiyNK+LttrbnXta+QIKxrKBxKGEM3g=; b=iDZNEfYAH6q7sO4WGbQzluosTIwnsns319o2MAdqeFax/y+uRS4koSPFOzQPtz5bMT bG419njc/XDUgNf9tA8NdX6YoqDF68CWZ4ah6KYwFHZCm4wEUuvmxMsnNbPEupLb3+9O NY4EJdAJyMOJ6lsBPVMsKl7FaclHxIPSG1Y3coetqMcMtvS3T2fCT/gYZb2EH/HDSekd ngd1ei7SfYq4QigvWXxY4ttTemPpLGMFg9ygMiwOZeFMzXINvm5BGk7cJFTeClRLhL6W 2aSLIeCF/lrzt1UN4iY/xSqeUU2tOR4EOs3Si2YkmqJWLqzzOH3tGHtj/fl16F0gA41t fYsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 18si256961eju.589.2021.01.11.14.39.21; Mon, 11 Jan 2021 14:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390298AbhAKWi3 (ORCPT + 99 others); Mon, 11 Jan 2021 17:38:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389720AbhAKWi2 (ORCPT ); Mon, 11 Jan 2021 17:38:28 -0500 Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187BDC06179F for ; Mon, 11 Jan 2021 14:37:48 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 7F60C68B; Mon, 11 Jan 2021 23:37:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gr-tPAs02lxc; Mon, 11 Jan 2021 23:37:41 +0100 (CET) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 18B025E2; Mon, 11 Jan 2021 23:37:40 +0100 (CET) Received: from samy by begin with local (Exim 4.94) (envelope-from ) id 1kz5og-002vQB-Ni; Mon, 11 Jan 2021 23:37:38 +0100 From: Samuel Thibault To: gregkh@linuxfoundation.org Cc: Samuel Thibault , linux-kernel@vger.kernel.org, speakup@linux-speakup.org Subject: [PATCH 3/4] speakup: Simplify spk_ttyio_out error handling. Date: Mon, 11 Jan 2021 23:37:36 +0100 Message-Id: <20210111223737.697336-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210111223737.697336-1-samuel.thibault@ens-lyon.org> References: <20210111223737.697336-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: +++++ X-Spam-Level: ***** X-Rspamd-Server: hera Authentication-Results: hera.aquilenet.fr X-Rspamd-Queue-Id: 7F60C68B X-Spamd-Result: default: False [5.00 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This avoids most code indentation Signed-off-by: Samuel Thibault --- 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