Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp459316pxb; Wed, 27 Jan 2021 11:59:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIjfMhue0P+O/RDFjQm0urtY5IyNbwB1KCrNZ4hYHXGmbUrjQJ0nEzDPHOZXOvAHhmuC/O X-Received: by 2002:aa7:d98a:: with SMTP id u10mr10544215eds.275.1611777565821; Wed, 27 Jan 2021 11:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611777565; cv=none; d=google.com; s=arc-20160816; b=bY4DMcnhxS+jshHZXChNVuvaT5f459QcnRyYuTWAnCv8cC+hF8kokSgcyEAy7690f0 y50n2kj9/rJzMPLJW6OwOy0lTMT6CoFxJsioj6mzEQfetpfPS75AUV6JfEZX6t1DIyEM rbWua7qfp9jpY6u8wJKGzPxJ/oGDlRV1OAETybB9WDFV9aUd34bZ+EzGdt07qURNZ8BX rqjc1PPnp+WHKB7LZOXLGcpCb+vfS+0ZXIBOVKteMASx5vvHXh1NOlM6wqXEJd2kOmpg ch8jxN3xLzmXwafimBaZJW9eOcCtXfrqmUbWGjEcWm2DM8PnkAO4UIaFQ3SuFxBpbVMq 2zGw== 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=F7nWTu6t7s1hF3Hza0qrlJSFdiaIQ6NBtOE4BkKvElgl2x2Btw9ERUvcMCfg4yetgy e8ssBzDJpfz+MmFvqlLw/0ieANmoYMWA+YmhYB6NjgtpG43vv88FnjJF7movZh1xO8kl O7q+BYUSbAIGNbdBu91hTEcT4VwLWuAD/r3PF13t6ZWfMYk1NSH49KyDtN05Z935BZz7 aRPr6rypmiew+ykVu14K11+Y+/dANcwr7Nz5+10XsokQRfHdx23fuHqElC+9Ywf6mB9G h1vAeGPeHiYqYWt8TEEQOrrHXauhD6YmhIopGjimHPnbZm3UTvBf55mFzvzFyogaC9tf IMsg== 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 gw23si1255404ejb.145.2021.01.27.11.59.01; Wed, 27 Jan 2021 11:59:25 -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 S236889AbhA0Dn4 (ORCPT + 99 others); Tue, 26 Jan 2021 22:43:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728594AbhAZWXh (ORCPT ); Tue, 26 Jan 2021 17:23:37 -0500 Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F47DC061573 for ; Tue, 26 Jan 2021 14:21:54 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id A3E6A1F2; Tue, 26 Jan 2021 23:21:50 +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 H03Vn_blbOD4; Tue, 26 Jan 2021 23:21:49 +0100 (CET) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 3AD04312; Tue, 26 Jan 2021 23:21:48 +0100 (CET) Received: from samy by begin with local (Exim 4.94) (envelope-from ) id 1l4WiZ-00G98U-Te; Tue, 26 Jan 2021 23:21:47 +0100 From: Samuel Thibault To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, speakup@linux-speakup.org, Samuel Thibault Subject: [PATCH 3/4] speakup: Simplify spk_ttyio_out error handling. Date: Tue, 26 Jan 2021 23:21:46 +0100 Message-Id: <20210126222147.3848175-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210126222147.3848175-1-samuel.thibault@ens-lyon.org> References: <20210126222147.3848175-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: A3E6A1F2 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