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: 589238 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 C97D9C43334 for ; Sun, 10 Jul 2022 15:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbiGJPEE (ORCPT ); Sun, 10 Jul 2022 11:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiGJPDy (ORCPT ); Sun, 10 Jul 2022 11:03:54 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B4B164DB; Sun, 10 Jul 2022 08:03:51 -0700 (PDT) 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== Precedence: bulk List-ID: X-Mailing-List: devicetree@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 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: 589239 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 8E2DDC43334 for ; Sun, 10 Jul 2022 15:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbiGJPDx (ORCPT ); Sun, 10 Jul 2022 11:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiGJPDw (ORCPT ); Sun, 10 Jul 2022 11:03:52 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB78664C9; Sun, 10 Jul 2022 08:03:50 -0700 (PDT) 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+oAUUv1saM4BNFwtW93qi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29v7VHqSQ5voVHWRkLo0 QsGYqT7FG3ROLCNFyUAzuWjl50V6qTEGzJhXrQtzDYVl7F/FvOwC1yY9g== Precedence: bulk List-ID: X-Mailing-List: devicetree@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 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: 589236 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 C6A07C43334 for ; Sun, 10 Jul 2022 15:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbiGJPEI (ORCPT ); Sun, 10 Jul 2022 11:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbiGJPDz (ORCPT ); Sun, 10 Jul 2022 11:03:55 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694206552; Sun, 10 Jul 2022 08:03:52 -0700 (PDT) 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:yJi8p2Ng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Ml6I33rX DMwUN9dhv24UvTH9oOLDtFCYPXdoYoFQZuSJr5soSdWSmkmd1VrVgw+HnHRa7DXjlRzcDmHU7 m2cBYrigKZy+cVEtDxjNCrW3GLlGhHCH8FxZHBwpZDm/9PEGOT99//9iRKt+Ik+hNxJBMfFHj KQ0lthjHs1O24SGddWAzqJhMtlBAVdXcbxOCpHs8FkZri2//ln5X0Pff2Fnvk8fpV32zibe9O WK1gKYj0CEz/GoN9pMWSSwiH0M4ig9QyNBIRl/Hi/UX0ygM/5cDOWpSHC9G+sPzVatYixPFa7 UGReiGg37X3D8DUx1HLKUKXT7Y3tbZS3Tagzxr1ivCHc1yC3z/2roAG+g== Precedence: bulk List-ID: X-Mailing-List: devicetree@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 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: 589237 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 1BE92C43334 for ; Sun, 10 Jul 2022 15:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbiGJPEG (ORCPT ); Sun, 10 Jul 2022 11:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbiGJPDy (ORCPT ); Sun, 10 Jul 2022 11:03:54 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 392D1654F; Sun, 10 Jul 2022 08:03:51 -0700 (PDT) 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== Precedence: bulk List-ID: X-Mailing-List: devicetree@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_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) {