From patchwork Sun Jul 10 16:44:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 590017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D27EC43334 for ; Sun, 10 Jul 2022 16:45:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiGJQp2 (ORCPT ); Sun, 10 Jul 2022 12:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiGJQpT (ORCPT ); Sun, 10 Jul 2022 12:45:19 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB7C11C2D; Sun, 10 Jul 2022 09:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471495; bh=hAdqGU4U+jT6aGvJmg4F8iA5nfZQBLISiVM3W5oMaNA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=OydU4uFMRVmBaBd5ZGwffSMy5f4n+68pgkh7Iiqjos30Zn3ncHGuPs0ndyTNMT3aG sUb7lDfPRJs7yqFGGMUUl/CAbigg5OvLoZO86+8/pSnndhjWjmzS1WoiSsmjuQte1D cqPGIZrV3TUun3qbtv0tC3ckcDqYr1v4ko43weno= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdNY8-1nbWLf2Mwi-00ZLAi; Sun, 10 Jul 2022 18:44:55 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 1/8] serial: ar933x: Fix check for RS485 support Date: Sun, 10 Jul 2022 18:44:35 +0200 Message-Id: <20220710164442.2958979-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZxsMwkh/sJADzwFan2bdA9wzNHS6P+rSo+WssaVRYFj38vGWgMf wVi4wI0mpq9PNuOMR76MsXg2GaYhfAJ/BJ6w4brCMstaprAQrglDqlnfDMgU+rTS5NU+fTr v9Ya3YqcILGefrM0xiq9v9LufwgIo5SIGd9Wtr2NbWsXFOrQj8ejkfcS+r6uXqjSiM6cqQG S9xQzRcpM/PmSDM0XsKag== X-UI-Out-Filterresults: notjunk:1;V03:K0:8guffhWWUw8=:GZ+9TKPh6447V7e/IdCQKx QKHA56c6YekXHaCsl5+F4uBa0nI3RhzQn9VbpMtHimASFnU1BdamhtMSu73ek04baiBexwtr+ EWWQtdyfYLmL5T1xIKQoipZDQb2YDtTK8LXe0b0eIH+sf0DWLGgKKZ0K82K8WT4r3ScFRLhIg u3YDYQjGelsBZFt5+BQwpVgRzk45TOJBeK83X6FmlwK4oViAuA8NiMUPhHd6bX/W8QMiTfeu5 YdgKlATDxQQwIBudiO/SaQqD13yFL3xT2z/A/YoUszLrZUE4lgq2aCX+MjWdpH9ES1nZ+kZBf 0GaSGy9SISLcdUvkJPXgqTCCGhbB3CKvAwaXbNAmynW/SQNijdiPUeypynukdULSIjLFG+eox RyZL1Vhwsg/ycB973Cj0qWjOh65xEz5IHidq1NnmmRT5pePJKFan3vw41uFFq12F6twBW/TmK s+8czWivVkj6COdhKynfLwi03TQBvs3XTbkHkU3mQRBeWaXdhwsT4++xVFVbCN1AuT+0c4o1E wZ1cZr3ORDIR4vK0IRMapz6iRX1cLWDSA+fzpUzIG51YYRH3eocMGLZ1eS1IbZyeZ1ZGI8fBj xN0Rx76lVo4mRKWX4lwd0XbieSi9hDkzZ7kB0ViAHMv1p/g0FG3dcDAXdCa8JHnQcER1QHuta dMrKRNJTa3Ns/ZdopV4tYkEhGYraChwqTk1zvxgdZsVTtdcl+NLb2Mo2xsBC+ANk5kyfGsW6s HfDGgfuZS4wz3eGFiXVm6sMr5QDeTK9G6wS05WGx5vcuFFlkUU7zWwQhINz4TNWQvPhUkSJab Kvy+bM5vP2yEZG0yVOa0cdHyuf3UHyLJs1hkd/oeaHw1VrTag+D3SLAU+Yy5werv8k/iSyHBn 7BEIzlujnlPFyxx4lqAeJorhQ2PajoavjjtXC1XHqEBTi6mlksMRMIucKXSXDQkBjUXV2MN6N Feu/M+ACjvY1eNwCcyu2O0hwLh59ZrV0dPHb+SZAUFzIRdADC6EUpoAcxISoZFFyrud8nmb6p tumKGMo/L/7baxD6MAlVEFx7MgQVeqD8UvQxG4UwozsiMUcA02pA9KXqO0i4K5C6VnLfCvu8Z L/mF0qSbKIV37YndJpNVkBex/CtwfRPwZ1dMyhvbacRqK+1tFrnSJZILA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo RS485 is not possible without an RTS GPIO regardless of whether RS485 is enabled at boot time or not. So correct the concerning check in the probe() function. Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/ar933x_uart.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index f931ecbc0bc0..f7b4638d69e5 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -798,11 +798,12 @@ static int ar933x_uart_probe(struct platform_device *pdev) up->rts_gpiod = mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS); - if ((port->rs485.flags & SER_RS485_ENABLED) && - !up->rts_gpiod) { - dev_err(&pdev->dev, "lacking rts-gpio, disabling RS485\n"); - port->rs485.flags &= ~SER_RS485_ENABLED; + if (!up->rts_gpiod) { port->rs485_supported = ar933x_no_rs485; + if (port->rs485.flags & SER_RS485_ENABLED) { + dev_err(&pdev->dev, "lacking rts-gpio, disabling RS485\n"); + port->rs485.flags &= ~SER_RS485_ENABLED; + } } #ifdef CONFIG_SERIAL_AR933X_CONSOLE From patchwork Sun Jul 10 16:44:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 589331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42F46CCA485 for ; Sun, 10 Jul 2022 16:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbiGJQpT (ORCPT ); Sun, 10 Jul 2022 12:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiGJQpR (ORCPT ); Sun, 10 Jul 2022 12:45:17 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F3F213D47; Sun, 10 Jul 2022 09:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471496; bh=ZCtUUJ2Kv6ZjMvVyjn9DfppbcpxqyAsK7G92RHDx1TY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JGGkWd/jM0pG0LWxjd7k9w7t5glUGXZzlhWE9RRWZZyaFgLTnxEDEP8vU+2dh3MHf ZdmE1R1joGkfVkyy2argi/BCJD9nHxat/2pquIoNGhq/f1/V3zhXOvJDefFMSi79sZ WNQnHNW53ZheDKXVac4lpxPUyY1iRAmXJvKBYNcU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MVNB1-1o2A9Q49I7-00SQZn; Sun, 10 Jul 2022 18:44:56 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 2/8] serial: ar933x: Remove superfluous code in ar933x_config_rs485() Date: Sun, 10 Jul 2022 18:44:36 +0200 Message-Id: <20220710164442.2958979-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:r71Y1Fa5+bqyqmrpIVp46cCXbjgLbualWjO7kFiDHpXTHV4AgxL y9UmxiUFpQ1S2+KC9WGMkyl8taGMpgAC5JRJ6p6U61xQF3DRerAUoyF68q/NFSmDsToCm7j dtI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xqIJd+wKrC4GCGmhe4XZSDW81S4 dWXC0v35YUA+0dxMGB875LZP/du92xWEer9Z5OYGixv8ya1v5eMGMTQq4NkfJDxXSGqiF80rX fPV3K8/F33g5rhjbLxdyjqTQOd2rxqVdVnlpOz9C7O0hyyySR1tLwtMwz5kGFFOvm3/8MFbVW dNQ/hKHHmZWWwPY+eSw3kGiizegQ+nBikhchkziCuZKwYIisNxCl+zjeA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo In ar933x_config_rs485() the check for the RTS GPIO is not needed since in case the GPIO is not available at driver init ar933x_no_rs485 is assigned to port->rs485_supported and this function is never called. So remove the check. Also in uart_set_rs485_config() the serial core already assigns the passed serial_rs485 struct to the uart port. So remove the assignment in the drivers rs485_config() function to avoid redundancy. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/ar933x_uart.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index f7b4638d69e5..32caeac12985 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -583,15 +583,6 @@ static const struct uart_ops ar933x_uart_ops = { static int ar933x_config_rs485(struct uart_port *port, struct ktermios *termios, struct serial_rs485 *rs485conf) { - struct ar933x_uart_port *up = - container_of(port, struct ar933x_uart_port, port); - - if ((rs485conf->flags & SER_RS485_ENABLED) && - !up->rts_gpiod) { - dev_err(port->dev, "RS485 needs rts-gpio\n"); - return 1; - } - port->rs485 = *rs485conf; return 0; } From patchwork Sun Jul 10 16:44:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 590016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D91DEC43334 for ; Sun, 10 Jul 2022 16:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbiGJQpb (ORCPT ); Sun, 10 Jul 2022 12:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbiGJQpU (ORCPT ); Sun, 10 Jul 2022 12:45:20 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E281513E25; Sun, 10 Jul 2022 09:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471496; bh=r9kQ+eb8XdjZm2Ia2YL2lmH1Q4foW6xhwQY0wLK1kO0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Q+2VyhytvwOF/Ho43AS3sCGevrGN3OZMunGLb3xBpMl48zX/xQiNocBP1h11IBHbr YMO0M2doffF0EYPv5dn5oyXeWdmwpLpmNthrkyUlP6J0cEetzyz2xQZ97rpOMd6LAU d2n/dFbopqmN093Ux//1k2vRYZlLKtCm8NtjNvGo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MHoNC-1oONqA1uYY-00Eu3u; Sun, 10 Jul 2022 18:44:56 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 3/8] serial: core, 8250: set RS485 termination GPIO in serial core Date: Sun, 10 Jul 2022 18:44:37 +0200 Message-Id: <20220710164442.2958979-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:XurQd/pVhRtOn7OmlHi3+KPTToa5xwcFYC++6/bubt0RdZdvo6J gmhM2JkWta63OpaxAP0Y5e6LXwH/H+snbwgl/zqf7OOq/96WMEAQyPzh8pQjnhHb3+bpzVx OZpc/Wp308+PIBJipIYUqLakfsKJol2RctIFXlpPQEL348z1F+Oz/jCVQua1+k0ADNKzVe/ sfU9Z5eXrYB5e5OdxZ/kg== X-UI-Out-Filterresults: notjunk:1;V03:K0:XwqQq1X6clI=:DCwiGFcWHsjQeAfaCMj/Om TJnm0UR2TQiVt23i/ofuM4uMhE930cIXqxxoXhAai6QyLQ8qgvqUOFV0fY20XVS//qlSHaSAw e0AFhnqvHSgMVy9bjEhROTVXw7yIpXrblxc/TZd54aGJgP2llafFsm9qPzVYkBH85xxQ6+rsz pMW4sWfVaSOqTmWNfmrxWmfVDZoZW2VQVKhbsouUBQWPHnu7RWjV0foRfOYOevu+OEVoU+jxc cvX/2oWrYZph54eYD89xHu8Bxi1Frv885AbW/ay9Zzt+MSghCEAR65bNSz69khSJOKDKeviUi mC3gFOTXdbYjVtJ67GRisuYz7Go6+I8S+WlrQ31TMpN4EVhi4m4we0B63zGDRrRzm2EwTWbBD EG82W9iu5GCqBpqnYumwNXhadNKIrOhaJ+MKGNSOA3vI8n2YY+y0CfNEQDjgMoD9y4umvdoC+ Fo9VGh9mTSM7IGH44JUZMQv54ER0Fc4mgXdxFzUTRZ8PXwdAQQHojsx8yKmiI9J5JLl/Lx3W/ pBLsfqiWcoHyXxAlpY8pUB/ySNU1pMIe44cJU60G8ygVxyzJcnsEE4L+qqViYAlqr7aB7PNHY CYFbTSntQbuPDMAe0l2eLLLscber3pmCq06MZht4Xks9zWLBKYiDkQROtGKYRuIDq08hcUSik MTVpcyy6nXsk7xeswcs9UfuOt7DJq+rrCqSB0yCKAB8zPKQDgHbCH/CGud4LmOv46iEmT2gEn 9sQu0NIfwiyK7UcGpreZA3uRl8GZItODXlI9+6RrzKccLDwAqkw3Vq9v3o3CEytAtkT2xe6+j Ni1HrE8dbHrrA7ts7whPh0AbK8i9uwu6zgpnYhM2OJKqMPUSZ8xbp4GWV0SeDTcRhOIziOiuY dnH8PgTurz8tyI4TeyXgHDWiB2pMerIKmiZpLVeyIYhVBCesXCO7XjeD0LOeyvlsYzcQW78gc JUVUsyQQmO6BZiUtlbkabCvyoR5i1rUaC8oVhcIkOyJJnuAPAyneU9zzaYZboGtpZDHCWlemM hhKY6RO4OJ2ez5iwS6GvqQ9wiylSkfSgfYz/f3dU9NzTZKy1ICjqWm3HZHYh3gvl1wqoD35Ba 9LJM8Xiv1CXhoO2Ls8FDpMyvX+A7wDcNfDRy23pWQO0rIcaBrQYEItUdA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo In serial8250_em485_config() the termination GPIO is set with the uart_port spinlock held. This is an issue if setting the GPIO line can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Fix this by setting the termination line outside of the uart_port spinlock in the serial core and using gpiod_set_value_cansleep() which instead of gpiod_set_value() allows it to sleep. Beside fixing the termination GPIO line setting for the 8250 driver this change also makes setting the termination GPIO generic for all UART drivers. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/8250/8250_port.c | 3 --- drivers/tty/serial/serial_core.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index ed2a606f2da7..72252d956f17 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -676,9 +676,6 @@ int serial8250_em485_config(struct uart_port *port, struct ktermios *termios, rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; } - gpiod_set_value(port->rs485_term_gpio, - rs485->flags & SER_RS485_TERMINATE_BUS); - /* * Both serial8250_em485_init() and serial8250_em485_destroy() * are idempotent. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 1db44cde76f6..047ec51dbd41 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1358,12 +1358,23 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 memset(rs485->padding1, 0, sizeof(rs485->padding1)); } +static void uart_set_rs485_termination(struct uart_port *port, + const struct serial_rs485 *rs485) +{ + if (!(rs485->flags & SER_RS485_ENABLED)) + return; + + gpiod_set_value_cansleep(port->rs485_term_gpio, + !!(rs485->flags & SER_RS485_TERMINATE_BUS)); +} + int uart_rs485_config(struct uart_port *port) { struct serial_rs485 *rs485 = &port->rs485; int ret; uart_sanitize_serial_rs485(port, rs485); + uart_set_rs485_termination(port, rs485); ret = port->rs485_config(port, NULL, rs485); if (ret) @@ -1406,6 +1417,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, if (ret) return ret; uart_sanitize_serial_rs485(port, &rs485); + uart_set_rs485_termination(port, &rs485); spin_lock_irqsave(&port->lock, flags); ret = port->rs485_config(port, &tty->termios, &rs485); From patchwork Sun Jul 10 16:44:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 589328 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF3CDC433EF for ; Sun, 10 Jul 2022 16:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiGJQp6 (ORCPT ); Sun, 10 Jul 2022 12:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiGJQpa (ORCPT ); Sun, 10 Jul 2022 12:45:30 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7CF413E89; Sun, 10 Jul 2022 09:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471497; bh=+8xtH88YOOLsZPGBk+8MayK28Z9P5RAmhj5fFk999no=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jfm793oRyRcXyfwlGzzOSIU31lMCstduoZgtZd0UDoy0z+B5C3QRzOLGIlORDil6b qvxegme7Ka1Hv3wlD93nO6+bUBtCavSHMobIl9rHPyFhkliQWVwxDw1gR/6MqZJZf8 uH1e/HXkrx20TgZODby3FbHz4LW+Oom5bjieN/ag= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mz9Z5-1nNa8Z3urr-00wFbb; Sun, 10 Jul 2022 18:44:57 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 4/8] serial: core: move sanitizing of RS485 delays into own function Date: Sun, 10 Jul 2022 18:44:38 +0200 Message-Id: <20220710164442.2958979-5-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/B4QTguHrmwHQ+n+io6jRV1yTm9GIglViqwMlUnseveP4s/0FGJ YhcgE0zBR36vqgdwY71AnhhcetsI6YPnFolco3+Dj9YsbfJ06w/3ihOZPLvvrAyK90ilfAg OHkxi+xJqlgXlApudIfuir6Ja+uv1y1YvLCWFUMkaKPi0CE+37rYz4c7UQwMlnP3kAMTHgp 9l0lzRsfN0qa1Pqkmx6gw== X-UI-Out-Filterresults: notjunk:1;V03:K0:AMXfJa/0vG0=:VlvViT77U1oKOJG19IuxGQ AGz6OUxHm27Lcg2N7oS9RUGSgs1kX9+p6+gsuEQxXDCkw/QTvqUplQRdNPHBZSt5mP5e+WwsZ x+NsaH25xoXM1WsRIYZdNUJLxfqWxEoS59lSaqXtRK/3bBF8gdjKG4KWvfotsABrM5iSE0C1q MkmbtLQUMVnaBuOa9Hoglv9N/xfzLI37Cfg5hIxdG+MbO9blic1qAXog0cWBCRPK/W+x66duB 2jT/+Odd8Ft5twBvffNQSQGQmSyl4S5DsrSDdZ9BXqdMSPC/8CBkyaYLcHksXcEMZmBdRhDi+ gLEiP4f69GalR5U5xt61fsYq/HUm/c4D+DvvlxSvhXeLpXSs7wHQq5DnFConnW/uwnd12PQxQ CD3bKEsf9/7LwysRiy9zL2dYrjj/VkPWdxfhBbB/SO6LRxAj8mv39l+mdAb927kpAyxd2p+/V MNPo95t2yt8kwP/iYX6/SvFlInubnZUS59DmWVXFDvKoC4zFtTO4c1XJLor7cbPZe4BPRBLR5 L1h/X0BML9eeH4Q+OsegGEQdYXXdtebCUpYrLAZZ+GuxhOh3atUYHlRjgjf1gATfN+6U9dfP+ mhFo0l1S2cKpzS5zqr0Psgwf4wsDand6JEB6cr6eXIMEzly3VQmAL2QQbdCfNJOgRAmbdMm4i VfyhUnzY6I8PWxP9GkAeMscM0PDzwidgTwaFaT986uh2+7QMIUUeUlIwBjTb6Y3BaTOm4kRBG wxLsQGjxv609NKiYlB+em/agJ3s4J6rF0eAAeL4ERC5YGItU110r0lUOCOZwDShvL/CZ+2aau DvD3Ln93fvmxv6OEoIizJNlefXJNDQKQ9rbwo/fbygUkoNMtcfgfoB0Lj0NbK6hsIRIkbKlpc 6Eldz5GWPruXZU2J+aMhFvqN7q0/cD7eqzzXffUNIsGRZDEw+ISlxPzzR5Oa6PuOFbR/wB6CX hgwiYyABhy3VHow6zpXdW4YmGB+zv7Rm+UY6vM+oeYwm3AVHePtD7JQrdSQLFgdm81gsMvtc3 R/w5KKj39M0ugXlmLQSxat7A+GJ1LuvQI3Fgl1F9gl8pIubr8smD8P+UazWx4b8aDb6e6Su9u 7WJQCHZ7ukMVMMRMLpRKvwBzayiaRuBNhQQkjMzPkNMYppidAAGf7+ebg== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Move the sanitizing of RS485 delays out of uart_sanitize_serial_rs485() into the new function uart_sanitize_serial_rs485_delays(). Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/serial_core.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 047ec51dbd41..3158f05a328c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1302,27 +1302,9 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *r return 0; } -static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs485 *rs485) +static void uart_sanitize_serial_rs485_delays(struct uart_port *port, + struct serial_rs485 *rs485) { - u32 supported_flags = port->rs485_supported.flags; - - if (!(rs485->flags & SER_RS485_ENABLED)) { - memset(rs485, 0, sizeof(*rs485)); - return; - } - - /* pick sane settings if the user hasn't */ - if ((supported_flags & (SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND)) && - !(rs485->flags & SER_RS485_RTS_ON_SEND) == - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { - dev_warn_ratelimited(port->dev, - "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", - port->name, port->line); - rs485->flags |= SER_RS485_RTS_ON_SEND; - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - supported_flags |= SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND; - } - if (!port->rs485_supported.delay_rts_before_send) { if (rs485->delay_rts_before_send) { dev_warn_ratelimited(port->dev, @@ -1350,9 +1332,33 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 "%s (%d): RTS delay after sending clamped to %u ms\n", port->name, port->line, rs485->delay_rts_after_send); } +} + +static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs485 *rs485) +{ + u32 supported_flags = port->rs485_supported.flags; + + if (!(rs485->flags & SER_RS485_ENABLED)) { + memset(rs485, 0, sizeof(*rs485)); + return; + } + + /* Pick sane settings if the user hasn't */ + if ((supported_flags & (SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND)) && + !(rs485->flags & SER_RS485_RTS_ON_SEND) == + !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", + port->name, port->line); + rs485->flags |= SER_RS485_RTS_ON_SEND; + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; + supported_flags |= SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND; + } rs485->flags &= supported_flags; + uart_sanitize_serial_rs485_delays(port, rs485); + /* Return clean padding area to userspace */ memset(rs485->padding0, 0, sizeof(rs485->padding0)); memset(rs485->padding1, 0, sizeof(rs485->padding1)); From patchwork Sun Jul 10 16:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 590018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70224CCA479 for ; Sun, 10 Jul 2022 16:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiGJQp1 (ORCPT ); Sun, 10 Jul 2022 12:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbiGJQpT (ORCPT ); Sun, 10 Jul 2022 12:45:19 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7AA13E13; Sun, 10 Jul 2022 09:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471497; bh=o+W8ytMepE42gQF0QexTyH8iX1o8DL+6k2p2ZnfEFk0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JMIVFwwesErimfQUonJfmRcoSxOfdrl41iOeYkn1BO35NjjxibV44eIAl+tb1Y5bY LJuzI8zHM8jg9R4z0aodSebEWWHLeJrZk8XBaCzAJVJxtDoh64f9fr+b9VBrLflTdH dJkWplFgOKHx2InAIcKn0m1Jm2ILT4/4u5iVDg38= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MMGNC-1ntbQt1ba2-00JJtC; Sun, 10 Jul 2022 18:44:57 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 5/8] serial: core: sanitize RS485 delays read from device tree Date: Sun, 10 Jul 2022 18:44:39 +0200 Message-Id: <20220710164442.2958979-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:BmyX5I0qt+OesHVxffLQ/vKe7NwrSCOmcs5z8TkhMlNjqTio3Bg dJfSZy76tfO6/ooi+mv9cEpVLH/02a+wL9nR+oItjKClHXcbrg8mr8PiXXxtLjOyHG4Qf5l 0NnfIwpYhzISa8MTQuKj4S3IwUTKH2eLM6S6FiIQnHsMg2/88jkKTdititWojJvdn36qsx9 nBOLgWTbbAbxF71M5YAiw== X-UI-Out-Filterresults: notjunk:1;V03:K0:Ya4pN4diymI=:kl+/LelUjlM4BTT4Ugt+LO rKUM5oSNJeLUqW19kw36LgNFqbF85JGwHMo8cfxcGMJ2AGY92gz9hvLumPqy7PqkcB6uJ1RnM mGpDxTMqUDpD5MsmjliyF8HCuZyuHzXgN/oTK6qkauG25KTJrSBZu1ShGbwWJfBsW+rtGItC0 STM+tphrmp0Ylj6MvQ/soJyQl7wDdgjf5d7OE5Lm5rxUnWhHxiHL+KWb+rzxaS4xQfU2C5hk/ E5kC6No2zl281vgmMnBM7WzB2TWvkzRA1Uf7Wat6lhvaQ27+ZE+8Qd+cS5zsG5OSwAB4sDm7X k8HQIF3c4Sw22Kqq6G/1L/Ms8IHRG+ES3gTM3h+GprixZWS7C0qGCpgvHLrVa+f7uhxahS8r6 2jSt/9d1Ozw7GLhDDlGv9dIXHx+nl8ccWKoOv3vzbFw30fsjk8y/XQ17Fj24jlKjHVxc+dedk aCNt9d3mENQZRaPwfT5xG7Ir2FHFcJEru+ZK8J/LcptFHiF6Eh7V/ySFyRL0RkvsUg6usho3v DipBL3fcDqAz6bSjYwbvLDoifAXbCFKlEoBQUPDezPunmIHiduv2xEl/yruwPo1Mu2cVTWq12 ACmYxPzyVps9f/ab+38WsDpWb1BVcZaLJiznX0e3sWVG9Lh6zHQ9J/DrnV3LlK39YtgehytPp /Ilmo4n6ZHcmLctHk+wpysz4dvxztCbzgfcIey8D9VyRdycNRz/Xvv9mhJ+fbKOuc67CRgqfQ OjfH7wNyaAMz55GyuNFqCRI62h5dRcBoBSFi94kEz9K4DVvMy28kfZ1sg5Ft6kkn6CjiHNETI g3LTaj7pWWYnPevaVcOSmNgRAqhQjBri7fBHZT3vgW0jMNZjxKw7ukXsAHaAE2KhEaobt6WTk Sat3kz9IS4RDtj8WbfM9VvA2xpMFPAyN43rHWoV9Mw8J0ZT1xKAWWZfxLJoI9iub/Vu3c5Y/H yLWB/+FZpXkoSA3V/Ni4rwrpv2o4WpygYcVCYM1UiPfvW8mdeTmYEsUuy2N9PlP2dXGD/mZV8 nQw3qgPKB6cvDOP6qie8cAsdpHVSbF8BMoHeZqGkXIx2RxfYuJ0SlSzP+4V4u3u51K9GKMbiu Ot3zsSWaB68U3UUyfKuLXNV/Oannn//xMk1IGYC/5u+ShCNmFd4Yt6B8Q== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Currently the RTS delays set via device tree are not clamped to a maximum value although the device tree bindings documentation for RS485 claims that only a maximum of 1000 msecs is allowed. So clamp the values to avoid arbitrary high delay settings. However clamp the values to 100 instead of 1000 msecs to be consistent which the maximum that is allowed when setting the delays from userspace via the UART ioctl TIOCSRS485. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 3158f05a328c..ac198d0d4c80 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3395,6 +3395,8 @@ int uart_get_rs485_mode(struct uart_port *port) rs485conf->delay_rts_after_send = 0; } + uart_sanitize_serial_rs485_delays(port, rs485conf); + /* * Clear full-duplex and enabled flags, set RTS polarity to active high * to get to a defined state with the following properties: From patchwork Sun Jul 10 16:44:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 589330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3F57CCA47F for ; Sun, 10 Jul 2022 16:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbiGJQp2 (ORCPT ); Sun, 10 Jul 2022 12:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbiGJQpT (ORCPT ); Sun, 10 Jul 2022 12:45:19 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA2013E14; Sun, 10 Jul 2022 09:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471498; bh=MsWxBaLlxA4ELwYXkzuPt+y1986U/Jbrt8tDYt6WPtU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ePqk3UCYbWhcEREOfn2BmyXgqSXhiA4giff//b8To8GFdDdl7w/8Li5xm6UorodsM WlGlY+UqoPiVpp9pASd3SI4y9ppyA/WhYgXpc+9y/iytVZMA+EzP3dYDENd9IGK0Eq NSP43hhHPlV+8Pi2JsQDoauZC/n6QVP8S5Tz2RHM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MvbBu-1nKXjL3YcY-00sehu; Sun, 10 Jul 2022 18:44:57 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , Rob Herring Subject: [PATCH v4 6/8] dt_bindings: rs485: Correct delay values Date: Sun, 10 Jul 2022 18:44:40 +0200 Message-Id: <20220710164442.2958979-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:pS2amxHgDU+Wqa33aIo1OuacztgWxkio2F8l4JrUK1VzOdgcVA5 BHIxYGcVgBkD1j9QSuzO8Bi31IPuzNtlAVefpXKX1EgGeJXT/bcOEGRlCj3cXDs49oRryx2 +5EzF50w7rfGvw1ROEgQuRQZw9Ib9VsG/pOeOP063V4EEZtBlCqh5znEI1XfyhzByllDv0r oA0HfvHlEePKUN8Q8YXlg== X-UI-Out-Filterresults: notjunk:1;V03:K0:3JcwZC3pljw=:ia63mV8swlzNczAFBk8Rbt Wj3umSjlDASFbqh4PJMZtDocY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HHh01Z D/TlArsNIXMrLY8BKMumZfi84Aj+7zzY1Ql4rtOoMfVENeOwg2WK7shFQ== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Currently the documentation claims that a maximum of 1000 msecs is allowed for RTS delays. However nothing actually checks the values read from device tree/ACPI and so it is possible to set much higher values. There is already a maximum of 100 ms enforced for RTS delays that are set via the UART TIOCSRS485 ioctl. To be consistent with that use the same limit for DT/ACPI values. Although this change is visible to userspace the risk of breaking anything when reducing the max delays from 1000 to 100 ms should be very low, since 100 ms is already a very high maximum for delays that are usually rather in the usecs range. Signed-off-by: Lino Sanfilippo Acked-by: Rob Herring --- Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml index f2c9c9fe6aa7..90a1bab40f05 100644 --- a/Documentation/devicetree/bindings/serial/rs485.yaml +++ b/Documentation/devicetree/bindings/serial/rs485.yaml @@ -22,12 +22,12 @@ properties: - description: Delay between rts signal and beginning of data sent in milliseconds. It corresponds to the delay before sending data. default: 0 - maximum: 1000 + maximum: 100 - description: Delay between end of data sent and rts signal in milliseconds. It corresponds to the delay after sending data and actual release of the line. default: 0 - maximum: 1000 + maximum: 100 rs485-rts-active-low: description: drive RTS low when sending (default is high). From patchwork Sun Jul 10 16:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 590019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1574CCA479 for ; Sun, 10 Jul 2022 16:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbiGJQpS (ORCPT ); Sun, 10 Jul 2022 12:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiGJQpR (ORCPT ); Sun, 10 Jul 2022 12:45:17 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EFEA11C30; Sun, 10 Jul 2022 09:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471498; bh=RTaQ8P1MotigS/r/NqnxH6+EynGn170u76xP3S9I5PA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JxeSvcSdkqv3BaJH4LQDBCT/fwR0ffuhsG6H+xYLXBynkukG8JsFoH8x0T2x48uR3 HUC1ebF5Qjtr2BTZIqzOqi1BrT+HhJgYPYGwNl/DaDT6Hn3SISZBDJyxLhCBQH/zSX Rq9qBS61DGAHMVVjueTDJYDXdGJjdOq9/6sbi1w8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Md6R1-1nah8T17MR-00aANz; Sun, 10 Jul 2022 18:44:58 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 7/8] serial: 8250_dwlib: remove redundant sanity check for RS485 flags Date: Sun, 10 Jul 2022 18:44:41 +0200 Message-Id: <20220710164442.2958979-8-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:PnpKOWOjc/EdccU37ZkkrSh+yct+U+f+NYjM3bA6D95h50QRPz8 KAZA7zSJojNMW/TCRQ1rgGfTyETfN1kOG5xTYltHvR0AaQWYWuEvsJCo4Tfupd8k2nV1Zy+ mpBhByN4WkFO1MW/QcRyqUwy+/lNcVcTCDIe2p4LbZGIniyQQ5EjSBldI+SpDZLuRc7hQRU mOMoY+aobdAJ3om9Mgvtg== X-UI-Out-Filterresults: notjunk:1;V03:K0:1A5lePXI1Rc=:GEmAi2PBZUQK5JyVPMBAhY bY2LYMVfEqN+KcqXJRhvV72aA7F17Oa5AD8a24WAqoS0UVzKkmrGO7ED+GgnESL9Il4TeZIaT ARE9srLaL8xzAd5j6s+fJffPhm2jnocTvj7SvLuW8/aTIHJbYJXq9pstH8F3o4fkuulqu+Pmt rh+FTilyW+Lb8p+jB8BM0qA61//N1wM0pHV8VKEwh/xVzXTvnOnjXEKjRToBhjlrPo6VsRUTh qDxzwRFOey5prMfxFuSEi7xBm/mlMUL5zk5o4DtPG+isETwgSPLUZEt3/vrdV5vuUWF2ZhwcQ D/d2OknbmtKPYRvA8SlEyEH2ElRx4zTzLVKowI2m0EGNCDE0PJkxJBukTo3UbXNEWgPtfIUF/ gEjKRE2/XxvFq8Epd5wuJ9s3LTMmLXkNK9zWruDkfUQvVbVRUQ8Z1hwkN9lZW9Wve0Y2/deJm Ux57IYWdGS/D8f+Q6GP6F9iWjqEEZaIDCppFJX32cLVidn+r2a85r78gECpgtgBzMq2TF8Q2l DVw6xFAX7MFwZpGiv5zK2LG3hh5uMHtThYt3koH18SPgJjLcpgfpLtlYNxC6MemrqAScbkFrj x7WsFtXDispnw83tWZUs5SlcuDcSlkUw920Zbu5oGQR/ZcCwtsUqkVXFtnQ/M28tFQQfwHr/o 5dIJysy03QMldHKVXXh947CQ6lsEAhI8rvymQSQTey3QNLs9IAoVOmaQiObRNnlWNnx+YSNW/ FgYoaN18DPUtkDV8APCgVwn4Lf15zQB86Iniehx68QHn+vwTME4NnoJc1DcRl7HaLbDvtG+vV PTi0rWed9UGIKEiQSNp8r2n4J4Cos9OGXgHBnn5zj75Kf5oKqMZ/YTdCrAokiB49YJE/CBLT9 y2IZxraJ83kDHN8aOHF1LrkH2WbTJF5+AsYGHZcklN+3XdYMP6dy4LOheIlRIm+YlwPskAJXJ /09tbze74OP9vRymiRX+DZAUX+Pfjb366grrcCAt97FysnPnvW22uZDLz0ildP46DWt1Ukv8M 0WDI6jsAxV3K9aoVW5h9+BnJzKOGPgiYFdr0CY2qDurPLeSt3SU/5PWwPY/enuSgyDFUptANK 8IXP1W3Nd6m8Q6HUdkqHRDawtPzSYOHkgMjHrxqYe1NW1EM2Ko5fNzMfQ== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_dwlib.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c index 2c3b1468bd88..dbe4d44f60d4 100644 --- a/drivers/tty/serial/8250/8250_dwlib.c +++ b/drivers/tty/serial/8250/8250_dwlib.c @@ -187,16 +187,10 @@ static int dw8250_rs485_config(struct uart_port *p, struct ktermios *termios, if (rs485->flags & SER_RS485_ENABLED) { tcr |= DW_UART_TCR_RS485_EN; - if (rs485->flags & SER_RS485_RX_DURING_TX) { + if (rs485->flags & SER_RS485_RX_DURING_TX) tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE; - } else { - /* HW does not support same DE level for tx and rx */ - if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) - return -EINVAL; - + else tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE; - } dw8250_writel_ext(p, DW_UART_DE_EN, 1); dw8250_writel_ext(p, DW_UART_RE_EN, 1); } else { From patchwork Sun Jul 10 16:44:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 589332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 121C4C433EF for ; Sun, 10 Jul 2022 16:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229513AbiGJQpS (ORCPT ); Sun, 10 Jul 2022 12:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiGJQpR (ORCPT ); Sun, 10 Jul 2022 12:45:17 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EE6511C2D; Sun, 10 Jul 2022 09:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471498; bh=0HR3Zv5yqKQt68jtTzgddRrz6zgVoGHjCf/opyPjVSw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=igYmmq57v09yY5TCm/EEXRWHE2BDQ0q2qoXUJuwBy5/Fa23GX3Wd3aFauWp+nL5JO jg8RO1c4w/lPru6wVhYj0YqUprMmCb0hZvjmTRzcTUUV4QLRu7ZDopd38tHCEL1hyj qfyiwhta6G3m2H7MIs5Pi+nm20hFVnFqVNoZpFi0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mk0JM-1niAC230BM-00kNno; Sun, 10 Jul 2022 18:44:58 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 8/8] serial: 8250: lpc18xx: Remove redundant sanity check for RS485 flags Date: Sun, 10 Jul 2022 18:44:42 +0200 Message-Id: <20220710164442.2958979-9-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:utoOmTsnfe/Q24WFmaru+XmVgFVIdOtiXrB3erIIRDRENkVZzm7 edqUoy/EUeaB5WiZx42ILFdtsA8P6fdMkjzqTlE+ty6zC7Qc400H/KX/VG1jcXahq/0+kLr LbDOcrdcpuzoYpQD728PIsNmo7C4mSAefduXs+mpLQFyTn7on/Lc8EAuisOXTobz5/DwKyC 693B854VYP0yoFVDWZMow== X-UI-Out-Filterresults: notjunk:1;V03:K0:KkTfvqotrcM=:GhmoW+RnNyay85NkMwVp11 /izaJC+pMyDx8YtkIu3hzLuTxuZSarXmbIc764KoMtKCvEyX4efCiX2W/N6dRJsNJj8Y+z5Fq LJNDo+bCn+hnY+WOabNKXE9VJeAxDKrGJot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kernel.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_lpc18xx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_lpc18xx.c b/drivers/tty/serial/8250/8250_lpc18xx.c index d6ca0d47e9d5..6dc85aaba5d0 100644 --- a/drivers/tty/serial/8250/8250_lpc18xx.c +++ b/drivers/tty/serial/8250/8250_lpc18xx.c @@ -44,12 +44,8 @@ static int lpc18xx_rs485_config(struct uart_port *port, struct ktermios *termios rs485_ctrl_reg |= LPC18XX_UART_RS485CTRL_NMMEN | LPC18XX_UART_RS485CTRL_DCTRL; - if (rs485->flags & SER_RS485_RTS_ON_SEND) { + if (rs485->flags & SER_RS485_RTS_ON_SEND) rs485_ctrl_reg |= LPC18XX_UART_RS485CTRL_OINV; - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - } else { - rs485->flags |= SER_RS485_RTS_AFTER_SEND; - } } if (rs485->delay_rts_after_send) {