From patchwork Sun Jul 10 15:03:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912555 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DD26C43334 for ; Sun, 10 Jul 2022 15:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NJpsQsuVvOO5FDrMB5S5kc9fMa0CJvrkn8V9nzaQ+Z0=; b=EPOxZHcBysh1mX xxadO747dlgco3C7qqTzW4J05Gzm6rKYJG+z4LHlGLuCD+pwrMKKsC/PREFc2Di6MFud1sjwNl4WE Gk7GSdp/+3LehgqC3/rgPcLaLRmA5+bFQQTw1XfR3uLlztdpZiPerRALs1dj+7w2Oqx2R4QcE0GLP th+cLjDjxPTWwPSLkQ2ifRKsznpTp1XHZSRpFgtFPpQ5LoYgdrglUAe134X0jsfvMF/NUgFV4S2OV EiNUR8zDmYOiGOl4Z/aWwc2rlZiIsPRYwR6nUIMzFUrm+dJgyZFZo5B9XhEoXG3hJGCZTyvWE3m34 a12TnEO9b2kEawD8LrNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTJ-00C8DA-AD; Sun, 10 Jul 2022 15:03:45 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTG-00C89V-0t for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465409; bh=hAdqGU4U+jT6aGvJmg4F8iA5nfZQBLISiVM3W5oMaNA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Kil0ihi8CLg1hcV0Bl0c1mDxb2dKaqNRKuE27ch/sIBtNMMhpbYDIn4qMFG63ssip Pr66aA3J5hVV7P+361zFUUhhxJ+wUBuYDisn2e4MXCBQGJwXlO3MR2GiQbuu3E7nbi guDRiovY02jPKO8mWMKhX4UsP0ZwR7BTe0I7LhS8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MSt8W-1nzzoN2Ps6-00UKK3; Sun, 10 Jul 2022 17:03:29 +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 v3 1/8] serial: ar933x: Fix check for RS485 support Date: Sun, 10 Jul 2022 17:03:15 +0200 Message-Id: <20220710150322.2846170-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/MJtYd9AOLMxStE6KfPlSbTQ5/sUlYRb1gizfNtMnSPE2eDXq1d AHprNBtSvZqtfdaik5Wo4jzS+CQRcd8sR0JrpZ2ximJ390D1vM7Ls4jxarMRh5bvIuIiJbG 5wh/GkBARbYtEY4oZEnnS8m+kH4ji1piOcMb2h3qtQEKRNruFc4b1EEG6oNZs608MabR3vQ RpBtHr6OKqkjKlf4hHAhA== X-UI-Out-Filterresults: notjunk:1;V03:K0:SMNcpCrW+ro=:D8ly5GJ6LkIiAGR6E2Lbb9 ZSZWX1ruKyu3mKj7vvd3iada97G+Ma+3yiq90E/pLcwm5DugFkiKMpDgIX6oxn0FYJO5dT//m 5rpuLCwfhJc7PCj9rEBRAdiNYdW/oAyMte2v7S21COWiZCJX5OJBUHBWjk/hl8uJe7SH+jgb2 f0uO7yHOY5Nc70GaBQlYrP+c6vLYYcknHFkd4mrYONjFxRM9NiZE1LQKxSB76SrgL6MEGSpu+ fegmOTBzMfdAAeDPG9zpG8kiv/kzqG8k9+D4PiIFhmjyWBCSTz/837ZdrbAkKlbikNOvUN/Lo T7/Ld7tXLaO7JhLy8N9wUJKg9kty5Dn3uR1ImgH18Lzc6RLiTn++gkDcZJTVdrkYw/QxkGzQZ LVTa+UkrOF8tWiFiLw6bkag1wvPSbazoVMK/wKQogRWXdjfiegUseUlHvMfpjDIcBWT29I0kc CstLM9/uGo43sVNKRj643WT0JEY+YQIQK4VBqYNji2IE/HMFnJZFDn+Lf18QFZXrp9p2WXEwU 3HZ8XLfUXRqXOOoMTcmA5H0NIVKts2m+aeEItZ17Wrrm2DdcqNVXXq6GRaNjFNCjDHaCorr0U ZaQu2t7JeV8gHLzDPLcdQ1WSDjKMg1O7CQhyqoEeby/xatCLTUVakeQitNLbBNnq2SjXgjyoc pXPlZPecumjoeRux+teq6CHAsX3cHPe7ddc1NqWKOtnIYvbJUK3asHL3xbnVvPu8lCE6CIytA 6ocdCPBXRrsNPSh0F7AN6B1Nswtb6313oVH1WNWoJophntkCsGHtaareel161m/cMKuYL8bWv M5J06TFDUCEvOQSvz4ZnAyfbfGW46RxF/NGeYBU5sk9ooUSMX2xOWiTwY62ogYXKEAXzjHJ7Z qB2K7ENeKPXZqMGriOXoR1gQpKYQ2f60HGb/wEtssSH5Q7JjLVrNn4nlcflSp43y9G62Ty3Ab B5YJ0fgSPSWcTxziQJa92TXC1gHvWzmTLbjLij6ZWBvJGERLeGPW2AiUNr+s126b6hm32P41i gvJVdqTWg7SlvhtUP/xtrl3IaT5KVp2+pPD9rfsdw33dko9Ps8vatENNU6KGwWTX8wz69eYKk 0DC0ZmjnA4ZLep2WXeO2gBKxlZtTE69CReGIiK9TfOmj1M4S0pb6Ik6vA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080342_535455_F85B6536 X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 15:03:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912559 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EC3AC433EF for ; Sun, 10 Jul 2022 15:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3J7MlngULEfB4r5UPfYTDeC9sa8qtdRCfwXMVbzJlMM=; b=NKqa/YKAWu/iiL Vb1yOcWwQqaLai6MCHlT4IvM/xOd0zTG8zrGUMneM1fujp48E1rJjPNFotk45Z3TMYvUTooQjBtOM hxDe7ivyoCBiEG9uevVSx029DK85fmXb/FA3tw/S71L6Mw4+dIrSUxDHFtT6QncdiMGLjbWJykayR wzO3bZ45DCmOBK2OJtoz/2sK9e6+46x5hiuxUsIsg490r9sNADii5f1sBz8hgW9pBCnaLcDd3tt5b gbnfWjHj4ruAX0ss7ynn5u8nRiNZR9clot1sxKPmMDmw1L1m91iZWfJxrTXsgnqZOhJr1IvX+hcbf wvteUi2fwPQp+0fr3Fqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYU2-00C8V5-C0; Sun, 10 Jul 2022 15:04:30 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTG-00C89R-9r for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465410; bh=ZCtUUJ2Kv6ZjMvVyjn9DfppbcpxqyAsK7G92RHDx1TY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jw6XYssfLAglNQGipFi5jLqgdiiMnJ8TdSA/TbmLrPe8j8L88EeCgfX/211cpKG9o 8Mg8/kyqpcQTVsftNZUCF0EYVIF07y88+W3UdQ73qM+ror61c2hvGkBqnp3E3b7Y/u 6f6oyDA5R8SFcTjvH+9zWPqFGpCLkDAUh3wQP9VM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M9o1v-1oGLtk43TZ-005pJ2; Sun, 10 Jul 2022 17:03:30 +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 v3 2/8] serial: ar933x: Remove superfluous code in ar933x_config_rs485() Date: Sun, 10 Jul 2022 17:03:16 +0200 Message-Id: <20220710150322.2846170-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:5+Dw2l9RAjF2laNlcFk/awBskO8xgbsTtkjwp1p4X1ML/yUYLsC uYpA5UA9E/xyAWxjOhpkVLgrmHBBbK800tPqkHHZWFAl4NPI3aifM0R34o9PONbwnJWOTn8 XPwJqHpvgmWfa67n+dTla0usEBzOoMcgSHR6lIjnvchK/47CbWjW4t2rO8+YHxNdGajjl/s KO5b3VUol/StOq67lcOKQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:XU3LuT5bwyE=:oPva1eHjwj68X7wuD47dF6 pF2kEzoKom312Ga/WZCT/tOkg2HMHNiNo4pt6IFcT/XRQ0pwt1ufsuFwqjuvpm+q5xnmPHrYZ 5VGbiveauePGnxs9OUpqxo81tyGpgJTlz2gvOa5Y/V1XgG9YRZCom/BNRu5pq5fGRlMF+pY6x Gcv+dRCaIsTlNYMmE/ua9Giku/StUmCIT5nVwm+6aXA4fM9jPlWGHsJ5yVYWLRaGSoAgxHnuE pYDZNrKpOf37Qwn+fIVViFjmr9uHM7O0UKSBSwtfrQ74aAtA1whsjzq7iOG4Pkpc+dRAIfK2P IlKIlKx1TS7jYyLm90NuCTN4Gz5SxMxO3SEDhB6eA4c2hEZeXw3xUH2RHywQ4eYDMXJ7rigJi OBGrTdQFUGfhFogcoIdZvDLNLe1PmGjbSiirhHOjV6aJqyjNubgjezlanljAREBkqq8apFTcP ZRu+303xgDdwkziojov1l3Di9m9xKQ5uEdT/1dS2xNmyBBturUTi/xmwDDImo2psYtNxexIhS pl8Opjubh/W/tLZp0HUBVXbqzc+wGEPY/8ftcs7jWrzAuWqVCwrV0jH1w1IQrB6a9E5rRkvKY MF3vi5/0+v1RglZH7YPBhgYEOqdP7UQGtdq9IdzpTsHkmxkCfb4nxMXgjLRiDIINDqxiw+Kqq CuhW/n6OrnjarJQVYki3DMOD5SvfvjaxXXBEJth6FsBgTl1+uyh/5ma8u/Yvrdghy428yhArp ybvHmYsYJ8aouDhiuBsgr69TMceuX9Hj81OOhkmgdI+yIUBnMbAvrEoyLN81CANnQtAml6wB8 5DSfR+ODW5T5O3mi7O0TBPaX5r6CsFJ7OWWOQoXzPk7T59X/UcNXJx+bjcsybvAY75uR1SH3N 2eC6Wk1VhKa4+et+PT8Z+aPZlRngZ8Mb0YVn6ToqYZHyHU/MVVyuyLY9KXddMaFCoZYVVLcsF eVt7DGJByLC4zuMd9gnd75gFEV6qVFCSz1y0NHwnyicy6faRs7uXzDgdqb8UBeqg/wgBDhwcs 5i1/w9DA9WNzfQJ63yeFVHXvj/ZRo645wHZQGjnVGzin5BxsArOv7Tinkv50syZ0SMdj8sHzl X1sVZ4KcDYnlaM7HSKZc5O6BB0TDuA00O/vRWFFDA3OvgBFUi7wJHe69g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080342_685797_9B8AEB85 X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 15:03:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912560 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6E35C43334 for ; Sun, 10 Jul 2022 15:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HUSFJ+L52n+HHRb/yfJQI/oGBeB5Ug0AHr2ffG9YXeo=; b=PvDwRlbgaG46OR pNQfmq5pNTZs3M0DNSlxMbLFgIGWTK8fz7mnviPw/BNMS/lNK489vR7Af5ZlbGEnza21JO3IuGOrE eJYsKFxDR5XOV6NqfGHevvG+P0vb0P5nyKOmk7ZN9L6ehaAnJjwbQ1szk3fpUe5iz9jZR89RPtDLH Y9hVjVh5MZykVSbSDcjqBWW3yV90TpKNw+oVPxhaafjNEZvjRvYhnKEYFd54f01EQuliOc16ttzf8 0BMqojZEaBA6e23Hv3r+9wVBOSxBQNLkkaTZ6fZ2IxALOZf3WfYOXiwEooLZO8KDfrGgqcyuhF/a0 eohGpqiQfs9+K6FFt8RA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYUJ-00C8dl-Bu; Sun, 10 Jul 2022 15:04:47 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTG-00C89U-S3 for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465410; bh=8FT0ij9jO2V6dVyym1DjOHi++3Z/BUIKRaGKBNPBHZ8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=j1NDK0qIJSgyoyQmV338pTIYOvQ6MoHZmvrGTE4EmRaq0EK0k6hXp0LR16Bu2iYFa NlRG+VpcQyy9QdG0yM+yAxjerCCYcqE2VR6f2HxcHq5zflGY7Dmpc32tCuR2Eropbv 9JQlLewzSIKnl8HgsfkLjQr5N/+mU7Q2P5zA5+RE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N33Il-1nRUPH1Vxl-013O1Y; Sun, 10 Jul 2022 17:03:30 +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 v3 3/8] serial: core, 8250: set RS485 termination gpio in serial core Date: Sun, 10 Jul 2022 17:03:17 +0200 Message-Id: <20220710150322.2846170-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qrz8l9nuTB/MvdivY3E4Gq67uW4qo5owht5uptPokpBMWVbqBdB gu79o5AcnqycxmjkNIKQ7S4LsmUbyZg0DR1jcf8ASWKU4xy2r0Z34N37xrO1xtwNHVtNCpO 5/3cWtbSvTusl5UvUGeJ2dq/6MjrMTFxul+nqgyegdAI5EhLQDhe8TKqXlGlM34GADCSjOX 59bKhFgdWc150BauLLcWQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:99l66P87yug=:6330KW07YlG0wPh3HArFB7 ngV5mGsIwIlZWOuQ5XA8irS1dxOvPVwy4p4conwKbGjEnGU9jns8Yj4PsCcHjgvdSXayXGZRc nxm5ih3cQ1AYXJ3C7VaU2SiBEPb9hgZxU+O/gbHJMRlPeyE2zKI0iEciSpEpM8DQAG9YzwvLk xj4MOnU98TII/DFm4CrxkjJVYQACaAh4OvF5ypzds1x1KzI7O5516h9L7Z07Uo58flqy7gff7 rJx20LCmauC1CfNo5NDKCkJj67JS189scZ8lmrwaW6hsRAoBGzLHwq4IfbLGvZH8BprP8Czjr scka1uAaYtagPpgKsDSEThMKcEp05iDMtI1zcVaotDV+Wdthmb96MmxUxxB9ZAdr41eHFjuz8 xui4L9YDcE2oWDazNYJs0YDDI0RH5ZipHVbFPqmJJ3EtzvxNh6oy0G0TBDoMS3GSmGuptcR4d qaky/u15vTKjmFven38P16tlFp3dKWnjo/XArpMX3goCVyKa/It9JO7kNvG089mxAsDQXvGxP E8fKdK/76OeHW2stu3WI6oFKzym4kTSXVT2l+CbzWaVtMwTkNFhQhHzBzcZSYCzb7jdU6auQ/ 5b7WmZp/FpM62xFuGgaeCM8hvrGATdzxj0l97EZwpOwazIRqAAWwiBckAkwR6peW9VLsB2tDD M7smwAKv4OFbNh/exRard+fOzanyNdda5jbJru714p3KAmOngnGZwWARgS+pVBBCd9ZKYOIw9 TT4p3PckA2Sfpc5GHFEjdaUt0D1AsXNgtDOZyAGW/Ra4puDZ4LM9EQZmF7LgEMxP5R8rf/DYZ io2LgEqrXKGp4GYzwzz3sVPVjmzpuWWyhfLTmUUVL+5oAIrJwj/V2HAHJmRmH7D4qz8nrnEpO cd+lQOLL7+0QNxpfAH0CDzC5O/MAy97u4t2r2Pnf2mBb6Xp+eYsk4J0gipTGQsr0mvhvPlO8O 5l2p++rKCCshWslRnYXXTgWi75y+hrjgug9Ln6FI2lIChqYzZ5SB+uhHMVGHjgLjEL/2zuUEo soqIFti6fPLEvnSG/NXFWF/f//kThn142/mVisrYHANovIOXkzZW5Bt7RmPV7kEVksjw52oHC uNPDYG+bTFlGSJwHemoOqdreYjEC/i/QfRyZzVdrtcemMNacv0wpXpvvA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080343_226874_AF1A6315 X-CRM114-Status: GOOD ( 14.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reported-by: kernel test robot --- 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..612a97788341 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 15:03:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912557 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C54C5C43334 for ; Sun, 10 Jul 2022 15:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uMTC8IcOVHqIcatbNrlMNAtxvaOXKe1Dzw6uUgRYgfA=; b=j2n4hoTuXUzZpj mdKyOEBzHBeCn9TENp3g6BZd6coTmsGJ/5e/bb5/5u3wvr3vhoP8FG+vaqMimrPT4vMuizcklXOeQ NHtXtmlwrez5qxXkslY9T+BTUIx7yv2YN00ECXvGED64AhmR2dxSRMUGUQLuI6qskzS7LTNfL8ldl WoBvyklpxx2HoHK44Y+Pbsa/DMTumbvMUew6XAuDUPEVDYfjeognO68QIDrHzOI1kGZNyEVBlTOk4 8zq/b1YBNe92f0u6V0fg1rmKBRPkx62sgYYd7LUKG0dymGA7qEcIX+nh5FV//YiR+tVdfvG+vHWja fVG5CjR/SvgUVk3VDJFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTj-00C8K9-RP; Sun, 10 Jul 2022 15:04:11 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTG-00C89S-2P for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465411; bh=0pVEiaSU9V9cl2GANnDMVx6RJaK7jU5KH3ahskRO4Gg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Zg56N7v3dhgcT2JpchdQkdecj9PKXc9rVXqdeHJds1yeeAS+qP3YbY2KJHs6lzBdL Gfi6qM2KJCC7657SAEqTEihuWVjXxaLIZ5RoLdS+YkaSfxaIwSZjj7s+0SgP/K7rO2 y/FCXHTI8+EXglTRSC8Dpvys0/f5EZjIFHkdtmso= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbzyP-1nZq8r4Apj-00dVRC; Sun, 10 Jul 2022 17:03:31 +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 v3 4/8] serial: core: move sanitizing of RS485 delays into own function Date: Sun, 10 Jul 2022 17:03:18 +0200 Message-Id: <20220710150322.2846170-5-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:1s9YVDSEdiONONi+fKcJr5fa2mYHrQpCwIex2wcxL5QhRWNh9Dj v6BNo3hqd4hRMMWwckcjWVyu4iWGISgsYuhFjAug3MImXW81A8zdMgaNReO+7OY4XK1RY6D 6Y7jQyc2XnLYT7FOostwqpX92OFT227XOylsUi9bxbZ6Kn1yIh9slqv3OVf+yuE7GMdzg9i MK+5sOCGffhmQqSvWcpmA== X-UI-Out-Filterresults: notjunk:1;V03:K0:+0u/mHrmuAo=:LwO3azg2BUo2EFtcw4L69N OvRGnUSXza4kT9XoPiQfCGpXQApGKPmCyNI7d1vN8Dvb6U29wgFJenNrK+JkwXJil3jSA3nU6 iaon84x9/RYh+DyLv1SbecD5BtIoHSzP2OinW3QqbSciBpbIU/hB80TeU8lhPzAQFGubw8d0d ouV3CMXiD2J4SAi2QWs2B+vvmMTMRTNimHQDbNuOcdvW6g0k0y9lTA4JzuKIf/bFJh6xhiCPo likMLQO5nvVLkFTJhVdaiSxv5H+mAGd7zHesPVqghNVomHAx4TqHvILPpQqG9EBjQj7YKqjXF bLZNY6qePBJSR8Md/nhUcbUWxokiKoi+0UwVcxwOxkfdFAUQr60hxNj0rLPC9A6fPzEoqiNvW Mo3aZMBK4OK7X258NUF5Ezc47i34QXqcDDVKbOj/XPs2iNdP9uGBezZNZvf30A2AxHwkSpDLa 4jPFh1i36Aj/znr38oRhgzIxDW6wxa4oJgrS0aAYrTKP/eDR1A4L2qPzO+Pvw6aCvgvbU/Nde epBXZ0YF9ZmFzNOZZsVyTmqaRuxzHgVyXopL88MFFqdxHmPP5csP4DnfpnbSTU2ZXh4lHErs9 opfKOejVkuF5T7rV4TdN32zqbAIlBUl1OZpImkAOc2n5Hgw2AgzvMQbHhDmHmSO5qxHDdp9Nx L+UW0iRR+0+09zgA/eQhKK2U1UK1CYAWlic1Q8JtF/CrI+FcZfyTjaWqs1qvqdB7icvOgj6rB Lp9CWasqEykZchIJOFi0M3y1CLP7PCdYovhCVYHWnQ/GvTJNoRqkbv27gfCgCvLBWHqutnSio JlHTyCgM0vT7PQ0K0ZRCf/x5cn0sfN9N6PWFDoYk5g7ScKpxKrruKiUURT5bi/rzaaOkzE2zB jk44TtY78+uDL37WV4w0ZI4/PvERV53ZtQ5HZ2haBkNIPt/SaAmUo66/pU+q5aVmWwbHz3qcj fxejD3w6A4F/3maTuRKbZ14hLvE/F74WEwO9FF3YUH2bKiOpqe2vq36GegBdY8WtRX7zwVOd5 8gE2Bo1+GzvDyzVBbvHw8Fgkqmj1BmG3/kLbdBkdKEEMRXmPEBFOw4Tz6+Oq8m4fyp+2jGFgY 9awCYiftoZNuj2Lt6PzhYCtP+Dm+s1FvTZZzRECbBJazDgRgJOdQ7rPzg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080342_535459_0AC54686 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 612a97788341..5943cb35556f 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 15:03:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912554 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4EADC433EF for ; Sun, 10 Jul 2022 15:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jmhVMnGL0syRmpEf3ST5flj5TGuu7aM411slt3bQ6WQ=; b=1dpoRRFjP2mHEJ lN0iAD7fZm4rf/6qDUY/U9DwicAaccn1AyyUNC2nQMsRdbB+sbEYASuBC+SpRnaBCbW1L/c/MjmBI 0Ow+vlFgVD7eYj9QNEES2vz4z8HwSE6jFd72BmTs/HRQo7l7uvOcM3TcbjfGlcCBA0XWlZR3RaEzX 7RlwrCaFxVa8VK03mEcbqbu34JjDFFQVb0auItJbjwrQmHml9jyc5022xl748whFXf82vo7pVyQfd G2SA5LnkUaXx8POLnzh/FaE/lhGOisjed626B9CpKu5Jv8S6Ubx2bACRksO341MjlUCioiFVWaISi +esqIbk7hTcB29T3GaKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTS-00C8FH-Jn; Sun, 10 Jul 2022 15:03:54 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTF-00C89T-Uc for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465411; bh=+fmYvZVXamDwJB1kParFdNMn3bLBWfn1dkqM/yC5mIQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=f9oarPSz50faR9fqgIqFdwEidGXgoWiiLKWRC8ZULN3yoLiaufw6nG5kbt+oUY5my ernFkTEptbd0oqiSAuky8iZkJ6Qjh86ns1mtZcbN/XELLhzUfBH8NTExnKhkXY/xmf oE/9MejjkU+jrQl8GsTTUCTPNPl+TKpFruPAZYH4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M4s4r-1oBNoa1hUV-001xh4; Sun, 10 Jul 2022 17:03:31 +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 v3 5/8] serial: core: sanitize RS485 delays read from device tree Date: Sun, 10 Jul 2022 17:03:19 +0200 Message-Id: <20220710150322.2846170-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:2ZsPcOiZ5Mc/6S7zDjUbGiEU3WBBNjfP8QdAjZZG7E/rqnT/FJa vIYzeakLH3ICKvf5VHkJEPkjnoYSn66Pi0rvxgOUtCRfjSzmukj4YcewZSbPIckLL7BDzqB AN3HuyAfZF7sVMCnW0EOVrYsyswLNxDj7HxMkgRtovGkKvRmcsEQwY9FrOf/60baCc7sWRz N8Vq7yJeJ+2A/TpWYwrQA== X-UI-Out-Filterresults: notjunk:1;V03:K0:6j6GiID7VR0=:p7QB+QX/zyq23lxlxhIM3Z RIg6TG4+oAUUv1saM4BNFwtW93qiPJkDIU10hl8XkFKiBF9qNcPPHywvBSeI4jxpGMxt+UQ5o Ha2Z1qD1FTtercN0Npu8BJTJ9Fns2/uYDEiYxip5b3qCDw5Z05T0p6ruyHcoZjRZWBZEqcOos PiliK6ncvMDJCJ1MaqYTdGZr9X9pwCe4vPXe+Ilwp0/PQDhLyht3vAbZc8V5Jd1Uxr6DegM4+ Ox6o8CKYAXPtcEasa+GxhvPnnqwxaEi7n4YuAoBRliG8cLlSTqqk40gMaCvujkg61os6PPLrU NxR6dPA/aF81TtKrSZmMcRH6G0i4tvJavlZBohGLdAVmRlWvpeoZJHv0wXV7awQJQT1sFvotY NSUrOBpf/TiaSZsF0b/afdGaaN5g5CTIFwhacgfoTiDJ6EPY5Y1V6+FJLEzl0qqhnIrnVgo8b LNa8CG4aHbFfHta6NRVL6/7NNxP8n/UZzz6pj/GfLRqe/rq5jE1gKaGh7AsNUmgQZAcqmdtVX ANIXU8Mt8pkPiIcxk5prLHw2Kn9GYN69p5q+kLlfSmIg6x/skPXZQDInjZJJQYfaDSLeoWsMd 72Qh82yMJEExhLIT7nkW1xwpYWkWFNcvMNQvWWMXTXXq+ALBBI5VqC16lXkD6/VyBiG1c1Mod iNmYvwhf7jZ1ekH8JhEDJKJ4WtLYZxTkTP/OL9eKk5ZPS2M4jc2tga+MOVEAQ3Q/KPLDZFEYV ZCgOGwM34r4u4dLvkVJIAvv4KvZYrExz9Se+QTIQyuwNdG2KCgl9dLMcQ0E54Z7833OF0addm +HZ+unJ3aBN4JwK0bbNyWdiVJeKOFuQtJg4cYUgMlMixszlj7QyWOI/hWw97ecSkz2s9g5moR IF1BZ8Bz4C3RnpPbShCN2ITZdf4XbEPtdzpLN+EtbWyw/xHfRJdWgTdfrdkC7MOBbtwpGUQv3 EHz477JHLFq9991NlTGBWBpD0nsV/S7Z5IjD/0eIdAo++v/vBU+JI7d8G9oCXzXRRGLf/ceKt jy43ZKwSWX/FvD9ZpfQzKIcKf7PejunyIniEwWMwMhuwH22VnNG0o29v7VHqSQ5voVHWRkLo0 QsGYqT7FG3ROLCNFyUAzuWjl50V6qTEGzJhXrQtzDYVl7F/FvOwC1yY9g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080342_535631_A1DAFB78 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 5943cb35556f..2c4d52b37596 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 15:03:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912562 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 793C6C43334 for ; Sun, 10 Jul 2022 15:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=30efDz6OjI5qR9cd/qyEYpIWZ3m7rcI/q5kq+Mj1wSI=; b=IAvvO33PsoHrNY 2XYtyIGhtz/8NdgDH7Qh9FN9XcKW6TOkXN/HpHliYwYc3Z0cEswSbEdp0A230/WRaLd+2OMcaRWhU H34gnzhyzPuFplLCAnpjmo57ZYUoa3tNJDGhJr7bSgGPPQEWxsNXdokCTsIzpHl0TOAeogV5hX++B iPCdCmWNVDkoCzXdPUYvPIPMNwyExRDCfp/Bb/51Pj7OoF0BtylB1H/Hy18atyUkKTCTH9lRed9ND wJ0QBTjD3CwfLDLtumQt7BxMY4Q0COvqIiwl+7Eax9PyPfYeJuAZZLWeflwTd0/Y9a7k7pCUNY3tZ 9OwrIgpGqdag2ZZw34yA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYUw-00C91W-SK; Sun, 10 Jul 2022 15:05:27 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTH-00C89i-81 for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465412; bh=AdWDe6Q5QpRDiXyrdxp/60gdvK8IQ697veYdYB+5CPw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=RpDQmP9YpKA3kZJbp2nBYOA8WtEtCb+ZCafnb3qhJttYtVM1UlLmyID40TdkH8BhM FOS78SiPO674Vz7f9FQvUBtc+hGE56XwCU++wYVYY3kjdnWW2vHCnWhvPmWv7YnIq4 5hYhtjHJTHlYF4z+5XQPFj/cGCEFnggMxAnBO9iM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MSt8W-1nzzoL3KHO-00UKK3; Sun, 10 Jul 2022 17:03:31 +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 v3 6/8] dt_bindings: rs485: Correct delay values Date: Sun, 10 Jul 2022 17:03:20 +0200 Message-Id: <20220710150322.2846170-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:yJi8p2NgxKQ8FKq06j2HKJzfUCvFcCx+6G4JpaRdHQrk8vklqVq lFC1SiKRhr7xeyGLdAfLc95ybCifFXnM+72ScdGZueBY1rmd4DIkdfMnqTq3Ep+uFMD586X YFLV2NbYXbQBRPPbLheiHCyZ/PVjeAJ9eCY7DkrYv6rreMlnlqII/fEBlwM04Jkh+GtFbJk wtI3rzaRYGOMrHTr8l8yw== X-UI-Out-Filterresults: notjunk:1;V03:K0:5SmAIpv7yMk=:tEAeLMKY7NmT+XfzJj9Hu5 hwBVsIRn2eI7//D+ZOZ6ZmDO0dssPPpv3Phy8hEPIBdFquyv/ecR/zCZXRXFb7SyfkEyKoGV2 bLKE6X1YZxPCLi88ON/dituSvUjsN8yq48FJr5Q6ZXMYcpE41FYD0IWdhuLzDLQkTu0GrUYvF +qRV3nf0pYInsGbRVrbiuixWtck76W0VZmfeuF7nFARhr9r7k69pHQRT23CqYSzemJXEJdN+3 AOy3NCie05wzoLQlEPsBq17pIHRh1GeHwoB8wTsymb6EUGkYmFv9R8a6wO2RJemScdSmtOPfr S5BTzpeMCG5NCovFq9Ginr55mgvcn9qzZjV2XoI+zMBkB2/Y2PQYiqKkLX4cxEVyFyucXt2+z VVZI42+kzORSW01iCrW9mLgqKoO37lMjkbi6Fssq46Y9zStDFNHxowPHuy3dsctxBWw28YEHU tsAlO1UDSpwiTVyyq8oCb0xBa4ODtqfIB3XePu76Mgu8eq59ytDJiIK+O0K16xyi4bXH/nED9 10/3/eHmmCdUAUL5XGq9jbbpt8SsOTi1mYZsqVh7TISmOPNGqoFycm7CXO3RX5VBx2uwCUP1Y GMKbxzpwD/TySOUMe57zNsTZh/BwyhNGKcdYi19n203ZOo0TusIm70l3aANB1Vi6qguPwPQe9 JVg5dQ7JMjNp7U1Z/SLZmhsW1wiClEfRRwrrZNT1unfoOA1urKu6s6bdfKOkM+6LGqN7a5+ox P0eDRfDJwwk2wgdXxI5O7zP+dYAYJndD8Ym/eD/D/L8D6J/tsY9BKyF+Y5fAuBDQ3Ml6I33rX DMwUN9dhv24UvTH9oOLDtFCYPXdoYoFQZuSJr5soSdWSmkmd1VrVgw+HnHRa7DXjlRzcDmHU7 m2cBYrigKZy+cVEtDxjNCrW3GLlGhHCH8FxZHBwpZDm/9PEGOT99//9iRKt+Ik+hNxJBMfFHj KQ0lthjHs1O24SGddWAzqJhMtlBAVdXcbxOCpHs8FkZri2//ln5X0Pff2Fnvk8fpV32zibe9O WK1gKYj0CEz/GoN9pMWSSwiH0M4ig9QyNBIRl/Hi/UX0ygM/5cDOWpSHC9G+sPzVatYixPFa7 UGReiGg37X3D8DUx1HLKUKXT7Y3tbZS3Tagzxr1ivCHc1yC3z/2roAG+g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080343_618633_EB922C7F X-CRM114-Status: GOOD ( 13.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 15:03:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912556 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81223C43334 for ; Sun, 10 Jul 2022 15:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5KDB8B59F3SZtaKJtsmhoTEK+ikiZHz941jgkMJ6lNw=; b=zP+7h/E9R3s4DH BLrs1q3rxR44VWS3N3WZ083zIUuvWXf/d/0oi0DzAR1sn1nF0H/90GICKIVAd7sAQO6VEThGGSyOH n5I05mPdONmQrSxm56psQ+BoK22gGkJnds7FQ4BO3Db6PTyK8GN0aJFtYnYasHRvfn+b0pUPQH50J 3epOFmIhnlwwldCAxcpFRCXSBCoqHgmmcvsTlDw8BYQh2GIemVfgve79NKgBXyJ86XzlVu8qTWd1z KMPEH8KnqpHi8zwKMx7SHRSxwDUj1x3IbsdgtLUcGVqfkBqU85oI+eLnN5os/3v2fifzFykRUJ5v2 gaoatUoDokxc42B8ShFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTb-00C8Ho-3w; Sun, 10 Jul 2022 15:04:03 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTG-00C89g-DQ for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465412; bh=RTaQ8P1MotigS/r/NqnxH6+EynGn170u76xP3S9I5PA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=VYmgRHD9guwyTr685kbRDCBjTxEvllfCEKiU4vomDHEk0ZWjDSho4zlby82R9EouY e37GubREDnBIVqtKTwMivFON9fgTUvkj7nTpVzSdajq9b6lg/+4D/8CVdY/6QPv7cO 7V1WXAt0fg82zgiV4E5zlUdjfWz+Luu8B9NOmypc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MD9X9-1oJb1h0oxF-0094ya; Sun, 10 Jul 2022 17:03:32 +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 v3 7/8] serial: 8250_dwlib: remove redundant sanity check for RS485 flags Date: Sun, 10 Jul 2022 17:03:21 +0200 Message-Id: <20220710150322.2846170-8-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:EPdF0klEap6nJ86G0oJae4XIa8U0Q/ceU7Qt23QVOLeQ4UiT8uR dmCPatGoEK3YtJWoGzzLM7JIcd/t5f3BvzNKAKILdR3OorSjDYC5tvDkFipvefM2VULRyDj Hz06G7hptyBdRJ7TRci/EhuZIBz0V82nXM7ElZWo5Y++Z/K19LkJVCwnHg7kk2nG8h02ipj MiQJx0dmy4yEGHdL4zvSQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:iEZJw3xE6Ww=:l1Jp2MziPcH061eoQq1b2/ UgUcDDyGvGmWwVxjRdqKA9ncT58txCaqYd7D8x50IpXqm1qTzMXLrzMMyVKoa0lvcTXEZvTD7 9OGtMl9MwuPyejAl7dR+H0odkyIppM2QUYxyFPKnD2DznPkFBbeh29sUbRv5y9Lwx8o6JDFlK ZyjW8/R1IdvY4gWvqAP/uiDq3h6Z718quCceGQto1X+MpYJKk9/anSfbRI9gWy+S5L/cygngp 9UyjGbxr1N2bnvVrC7EF19oGr83yxTcJgKsjZaRYPjEZKilt1KsQyIGFjin/c6FPYBqpfkDPn Zw96lecNyHmzIiMrJAvCd/gPVD/flOoECr1P8prYl1rhqg6oNH/xv1Zp5t1sIbk2RaF6GT01o MKdCc+pDFcYDGPa+eVUEtZpU3Dl3Swz/pmixfW05JoYcH+HfDtQS1cbQgi4hK4vXLk0YHjWug j6r2DS6Xl3Qv4YzFh5PYm/qUQ1jIx6pwYueimMa2CSMeP9cC4fx7wb8lxAvh2kDRltm7OOmIY slejUngqIUvu7kGGxRIDFTT4J7EYheQ4COjlMmo3QN5O+KLM6aS2Tm6zcC0/qquea0NQWMcFQ i60sI5VlwOd6n7O1ggOBu7VQkiqTalqovGtTjGprJGt71jflvYSQGgcYRqVtWEW5vokj2LIne KIKZX1wzeCH45JE9wCN9f12rgbel+xa/xVApMe6sjHYmUpS0y0+5SZeR8xx9nB/hdTVBbZR31 zjMhLW1p5hmFLcUQn120b49GVlZCeSRy+R1njqAkWtJbWBLnx2E8yPYlJckLRL27udNBODn2w z5wirR/xGrgkfcmolIfILEWEsjTkNg0vQBeDC6cmTqBlItlt/ih8xNIi+ADeTSK84yvRscJZP Nx6ZzNrH/Uw8odj6uIbKO1dSXz6sseT0MA911MbR43kNtXJIApKpVfPHDQDDOIz75XmjcsKFZ 6cBYQejyIIFsXG3ANhzuoZl6RhlmBSDcpXZE4ksqrh3j3VtS7piAW27uCE/zNDyZa0VNURC6v K6Hacxu+bBExQphZoPC9j9etDejiOUBN9Sqh9v/Ez9HT614UBz1CKaaXox+rtT15GtqCZZGwg b6ClXKMqR6wWD9rchb8ragRm/25uyl9PTviFVobAmTmCYQTunH/+h9OvQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080342_796148_9004DB66 X-CRM114-Status: GOOD ( 12.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 15:03:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912558 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CD51C43334 for ; Sun, 10 Jul 2022 15:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Dh4jYdN7vLA6qnSilkwmL6xf2C5LxeVBWj8sFqkk9Z8=; b=aGOcDE3orRNAIP fZQ1pp6dzU++FXGwZ9EkmipP7m7yahDScga2Wmv95tsYpbZpoxKxLZ9D0kLFzyoAsBjnDD3Y8yQ86 aujYhmGBkUYZiNAM8f56k6atBddOTzcYLyWCp9Cn0J/djiQ0R/sye1RdC6F5eoy1arNk7KFBFPRp2 tRy7DWGHdoYitNNYt0F8vrfu+wCHlRSQTr15zcj3gWHNrMfZ3Mx1UPvKIyfApNTcnj9+Plc9Vljrv yIeUYeYX4DMkIP4NFOxRtb27NK8PL3JQ+YRGvaSTHtRhFFkOoUdw/D1wz8C+HdXxd1Bwd5kjJNGPa 7q3H5/PpvhgeU1ZI8j8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTs-00C8Oq-MI; Sun, 10 Jul 2022 15:04:20 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTG-00C89h-RL for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465413; bh=0HR3Zv5yqKQt68jtTzgddRrz6zgVoGHjCf/opyPjVSw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=C/G0Dw7qLGqe4pItHN7TBRQgbs/PiZ6WZmsjY77bzdOy8aRoex3cAlp/o+l8oDNKT 1VoTaZg65/UBaeghR3QT4R0ODfTiXEwtJfWQ3XRD3K+ziqk/l5Or7iBOKowu8TJlSL QeVgD/QnMuqu+ezRQdUkR2ylpQyLONjApqfcubFM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbzyP-1nZq8p3OYB-00dVRC; Sun, 10 Jul 2022 17:03:32 +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 v3 8/8] serial: 8250: lpc18xx: Remove redundant sanity check for RS485 flags Date: Sun, 10 Jul 2022 17:03:22 +0200 Message-Id: <20220710150322.2846170-9-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qzHu4PvDz5P895faBhT9BuPeJF1PRRW2iLbjX8PmLgdI3/snLgi OxgKGpRySgUOvEjEysXvo6BSJ+waB04FeaK9eEMhMcIphKa1UL3KezetcBHkQt8dhMZRqkh wE5d2J57eK7Q6oDU46JdGPpdgW+StgBq6HYTJkzdeTri8RZQS4Cxx6PG/iLTzyqz4qKuln9 uqZ3mslLu/zf1Nmp7t7ng== X-UI-Out-Filterresults: notjunk:1;V03:K0:8RXqQFDDp2Y=:h0kmsp5HdQeZBg5mCa/jYk nCEoVbztb6K5MOvE5NwHK/QFB/XXRNsHL/zRXpmg0+35ERHRPnM8IFB9OhDhqaZ1o5CDVrNXr t6jyVaSibtvBU67ujv+tZUxjHUc31nSN7+pymtbzwaujGoR6yU5oBZ0mlfBeGMWBt/bc2gLEa HmhRqedM40KDObOWJ6CjahS6gjlHmDqHcNmn1aIt/z8BJ8lza2lzVaqBvFg1AVrWwKeqLA9Rx Tu26xjmzAfYhCxB8JO1pvNC9QfQ+tsNGqgl+87jQqlavkanVSv2MI+k/NWme+hfTzJRFG+Plu GFL3uozPyYGZdR8zFjjWgfqoo4YSSO3JlcXCSE+xGeSdN7BbnYdhLccp8Ohkv8GKh2YBdy3uQ nLimuRhpRkk4QYUtE5rgdvoYC0zZZ1ap9WDiWqhcHLUYPNhIJlb+LSosWZHTl8eSf0RAokyrx y0zYRR9yfoSEAsWecSKdFlC+VzOyafpEhxJqcsOWQOJOVlJlRAeW5W31qXGj70PAKzMXMWu9R DTXiy4M8H+ckuIdF/KFunJlVQk0nzkPppR+wcq+4S4D12jps8joOxRfEBn/INlJgB5gXtDov8 JLrh0Nz0K64wD1XKuRdMoPHw0IMV+v92xaf4fjkCO8ZxOGlmw0kna/qD0sef022BQX/+tode9 LiU8gXHX7W+62xiFCZ8tF2bW/1bKzu9pf3wlW7XgaokQJ72NBP80GWKKoPdiuaN5KetdYHaId SLWkSWMbK5nGiyTONxoOa85SEIXx1OwBl16NffFXqGR6wQhOY6/RtR5CwlzC9DVxxS/5CHfRK 3CltWHs5mnqogsH/JeYG6tjJHZLY4w89+5fhxx7WcGaOvAL/tHCSTYqLfrIWwD/N20I53Uffy +B+17T9IBVkCt+m3jrOCr8dTj76yAgrTOEzKwxA/wADi9/mkjAq7TlOqqNYwFFPpwFml6pj6H eoMbfinI0tp37P5i/4Eat5Lf98sMFe8IvSOp+0XuGIeB4vIgaQ7d/mRWPExr/uidpKVIOITgH G4pa20OwDZa9sHuqd/Mc0lTOPviDIRoXQ/tFU82vdv8NZjt611UsHjPv+X4JlYoJSiNd3t1+G 6wTklg+guCEyxOfjUmdth6VCWnth1ZQtWpBWqnnJI3PiGlT4W7Bfy0LgA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080343_220790_D5E57CD2 X-CRM114-Status: GOOD ( 11.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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) {