From patchwork Sun Feb 13 22:27:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 542476 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 B54A0C433FE for ; Sun, 13 Feb 2022 22:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238716AbiBMWeJ (ORCPT ); Sun, 13 Feb 2022 17:34:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238652AbiBMWd6 (ORCPT ); Sun, 13 Feb 2022 17:33:58 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 192705468F; Sun, 13 Feb 2022 14:33:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644791630; bh=bZh7fD3BxcL0U4ga7XTlAYTEC0EPT7y619IUOjTzv7Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=fJ2J1ZE0XlMRdlW52TUFV8Rls4Wt+oe23eSYWj7DXJWajS3kefqY7OCtnrdOilFc7 +T37tZ8LTjRw72zk+aSv3KVno7C/iOCRieNKqGQ84DjZPXdaPjR6KYIBReP1lx6OSn BVRc9RvsMGN77rACYFoIg6aiL+c+u2qWoXGV4770= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.68]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N9Mtg-1oORt22z8W-015L7F; Sun, 13 Feb 2022 23:28:05 +0100 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, Lino Sanfilippo Subject: [PATCH 1/9] serial: core: move RS485 configuration tasks from drivers into core Date: Sun, 13 Feb 2022 23:27:29 +0100 Message-Id: <20220213222737.15709-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220213222737.15709-1-LinoSanfilippo@gmx.de> References: <20220213222737.15709-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:a70uNS3aT4SFE/6OuZPcmU57hS9z6lw3Arpt/2q+1Rn1DqngY4I cqop7d/eCjPhLHz9sZAYXp8ibRRdjqeKMEGk6i8ckZI+xCeYiAixStK8vfEAdAWCt5bZW84 pGb79r9pJC9KWgmT7d2YGAKs5egMFgBpJUZOpsIxXRwVf4VSjo2bXW3br64Ayb/nGyae5pI kWJYGVzKhf3TfZQ3c5gGQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:WISNCh6R/yA=:sVlZs0DWuHUGARQn/S3+aK zd59Brdk98FRPHtjNCIj67dB3yZj9E5b+LYZhLTpVVm0twqHHmcruORuTyLEZEEIRRfPbSSbW ZgqggRyclent0AWivDhkySKXNprFXcyH3sjtEBrcigV1Lmz26t8gT4qcdZSc0lZcJcMuaTqgQ TCjjF2z/7nkqoIG36h5kCM1pVZD46mRahcDLQemzyQT3r9ReH6XAk6YuFmz/kGZ7aDIkBgnlK HS6Ojs9BRDudMNxxIxF/yDHaqrRndvwVaqULS5tRHNbdlfG9SbXd8tHGevNhezmL4Jtq+22x+ Dtdb8txG5ry5CPfofYwKG+LGlN1R6/KiJ6EgeMDhhswThOVX6F7+LhOmUFSDJedLpU7IaxpJH HdLqydKblOr5ZACttW1UnusNsgc5Gnr80DtWXT49puMknGy6iCRksJZEWyqyhAnYX5wAPYSq4 RyacO4M4BMjQXvYBBRDajYH7U7nd7VAlSYqlsl80iKFwAiaf+s1VFA0sfawi9xQPMeFvkCAti kt4UvBK7tM1t8MlR+9OZtik7l40ThCct043pcnXvAq2WpN+og438rjTrUYrmqGtq8VGLLcR8H Qg4HjdVwTdEgwiZVzITuneRLiNaVPRcEKDXu54DVxBi3SxZsXrtb2e79Lo1KXQdnIZ4UT/x8p BhuYIgllQmuBRgcIGcCbvZiwyjEiDaSZT3IiavF8R6RDxfvHUrfihiO4I8jDCSc/JU1f+XFXf 6Fnhy6JJTGgVL1v6FMMAHDvUAJTBJAm8weKDLboi2GFitZa1Zyc/X/fCwrIyJJvkFBJ+iB+4e nbfKOvPuyXTLdoP+9NouO4eysr9Y4gNIOU97iYqsLA7rna1Y+m+0/yTgQ8KIPclkVBVB6fdUN aLSDn/P0xP9X/g/kE3ach3bLknEpqGm37qAba4/7DADSUErhSDtOLAjjLehqaNiOASPsDGBl4 Q+TOG+WUz7dVNdm1BbOtuwtVyZSDxdk6IgLfFhoEL3cjlMaH59anz4lqxik39gcDMlDvoJl3l f/meXFdtKSzjdPzHC5rM8JVDEwdSoM6/LQicSYaQu3oNCJEvL6ph5lP0xusLD6BBW09KGKxTo jUS2wR4UmLz2wo= Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Several drivers that support setting the RS485 configuration via userspace implement on or more of the following tasks: - in case of an invalid RTS configuration (both RTS after send and RTS on send set or both unset) fall back to enable RTS on send and disable RTS after send - nullify the padding field of the returned serial_rs485 struct - copy the configuration into the uart port struct - limit RTS delays to 100 ms Move these tasks into the serial core to make them generic and to provide a consistent beheviour among all drivers. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) base-commit: ad30d108a5135af584ff47f5ff81be971b6c26f1 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 846192a7b4bf..3fab4070359c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1282,8 +1282,21 @@ static int uart_set_rs485_config(struct uart_port *port, if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) return -EFAULT; + /* pick sane settings if the user hasn't */ + if (!(rs485.flags & SER_RS485_RTS_ON_SEND) == + !(rs485.flags & SER_RS485_RTS_AFTER_SEND)) { + rs485.flags |= SER_RS485_RTS_ON_SEND; + rs485.flags &= ~SER_RS485_RTS_AFTER_SEND; + } + /* clamp the delays to [0, 100ms] */ + rs485.delay_rts_before_send = min(rs485.delay_rts_before_send, 100U); + rs485.delay_rts_after_send = min(rs485.delay_rts_after_send, 100U); + memset(rs485.padding, 0, sizeof(rs485.padding)); + spin_lock_irqsave(&port->lock, flags); ret = port->rs485_config(port, &rs485); + if (!ret) + port->rs485 = rs485; spin_unlock_irqrestore(&port->lock, flags); if (ret) return ret; From patchwork Sun Feb 13 22:27:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 542479 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 BA456C433F5 for ; Sun, 13 Feb 2022 22:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238588AbiBMW2h (ORCPT ); Sun, 13 Feb 2022 17:28:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238583AbiBMW2g (ORCPT ); Sun, 13 Feb 2022 17:28:36 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B9D354693; Sun, 13 Feb 2022 14:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644791286; bh=8vbc9twoUnggUtV10g7Mb1U2iiUeZXUFcj4fWWaxiwc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KzjfhcAZczeP42Kc+7eSyADZ3vwREiZGBp9roVilY9ewt2ksqSuI/JvJg2j5kMVxa mJDR7n9ljR6OFNZ3KdB8vhU++9m8WQ/rMSzQELa4K0OgzDUbYM/bDEcT2TBNAGaquk vUaRBtGXKbKYyVlN/aGhNYikGke8j2X9kjaga7M4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.68]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mz9Ux-1oEnO23kPb-00wEQc; Sun, 13 Feb 2022 23:28:06 +0100 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, Lino Sanfilippo Subject: [PATCH 2/9] serial: amba-pl011: remove redundant code in rs485_config Date: Sun, 13 Feb 2022 23:27:30 +0100 Message-Id: <20220213222737.15709-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220213222737.15709-1-LinoSanfilippo@gmx.de> References: <20220213222737.15709-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:c6+Ys0/CKTSgWjVeoHGhXE+C7sk8b465AsFJvqvT7hz8+wtDILI NE3k60+XHiuNHEj2TtJpphtCYkCMo4QEpfjehlyIIi44xqXykt7VEWB7Quwjm++QSW9C1ok c0kE/CShtmVL3c5kTMdNm8WfIiYMVLwau6yNXOYtsq7yd9HvNp4HA/7w2J5S5dvZYxf5XwA zu8cffo7aTS44giQMVBbg== X-UI-Out-Filterresults: notjunk:1;V03:K0:akt+BNB8rAE=:Bij2tUiEnDYYUcmCI8CH+u A4X+QoGrJhbTtvO81tUsSGH35FOJ9hYG/4EkmBjBWlUTdmgiDY90LejjQ1T1DOWbbD9nPP9ho 0kMwdXf83JZ07EDk9e8rEFIEUkPTA5YQ76+KUyd2PTsk+krztvyEZUgIl8tVw+OvZ5aGXGPkU WEeyn5ENHzR6Bl7wDAz0XqLz9huU49AAUcCqUG3RQn39totfHr338TqD0HRJD6MLpPpw50xUO fn+H19tJ7/L7XojyykiBUoxb0U/CkH6b4AdUkcx27iN/sOPuy3CmMM+EOb22PlE3+A2cy8m5f jRjbW5XYBz1LWtjetZSfMhldFJUenIkLCIcxl9HfNEKPJIjwt6IaNatq3AxzvD/W6qGqbJPoj fc/0DDAQYcghgn32ByxAcVQcxr+ygvkbAdKHTHzjJ+fwHfHDv/a/SeK+YNVagaXmRqlPk810V ziIOIamhRohN/Niu2k+n3mlxrwehLBKh9USfwKT8DfgrnOO2DEdT6srG1qzkARKlto1Qj36gS MJwcGmlPJ+tiIg50bibbbXG3ktSP3j6o142XKCAnGH5NYR8+T+fSrnjr6OtzTaEceQLoPXp88 CnO21q1/l3XdwCgOOF02PbPAl7TwNqP7ClB86ki+c4Ez7ExHt7eklnwxe0+JzA0mo+lFWUB2U ojqgyfDEpcLsZwSKvJ6Vg2e+HZuU0ok3DlnwiePXZhMekSJZW/8Oey4sUIAKrAGJVvcOlCxFQ I5ADBW0EPpxT4xG3XfUefQnfFfsfKiJ+GqdcIXuJ0EBkQ9bzrGmDF77fzKr9qKQh6cd8l1fTy tcs79czwiFw9j6JZ1RP5Z5HaOjUvPf5MrHyAPKDV2MBf5XvyxdPH3XEejYXsYbkz3xqqL6+Cy CNRj5KfoxNsrUxk9G1Ir3wQkCoJc7mhJWP5bcNN97Y/dvxrkBwUKvJnKnSBGvbC8ybIYMy1Nb CAfcQ1+KoVarO2W2L1P5VZPyIucsCrCP3n8UaUAIZW3R8ra41iTBKZ4uuIgPZ/BrMy2TEbjUT spGalwnWvT8DIdqumYaFRpCpAjvrGbx/KtUvYOJ1h1Fn/KT1JUI0yW6PLNFfXWaNJilrNcEtI S8gqQvcwhLJ36g= Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When RS485 is configured by userspace the serial core already - checks for valid RTS settings - nullifies the padding field of the passed serial_rs485 struct - clamps the RTS delays - assigns the passed configuration to the uart port struct So remove these tasks from the code of the rs485_config function to avoid redundancy. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/amba-pl011.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index ba053a68529f..35c633739975 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2170,25 +2170,11 @@ static int pl011_rs485_config(struct uart_port *port, struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port); - /* pick sane settings if the user hasn't */ - if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { - rs485->flags |= SER_RS485_RTS_ON_SEND; - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - } - /* clamp the delays to [0, 100ms] */ - rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); - rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); - memset(rs485->padding, 0, sizeof(rs485->padding)); - if (port->rs485.flags & SER_RS485_ENABLED) pl011_rs485_tx_stop(uap); - /* Set new configuration */ - port->rs485 = *rs485; - /* Make sure auto RTS is disabled */ - if (port->rs485.flags & SER_RS485_ENABLED) { + if (rs485->flags & SER_RS485_ENABLED) { u32 cr = pl011_read(uap, REG_CR); cr &= ~UART011_CR_RTSEN; From patchwork Sun Feb 13 22:27:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 542477 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 18D1EC433EF for ; Sun, 13 Feb 2022 22:33:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238676AbiBMWeD (ORCPT ); Sun, 13 Feb 2022 17:34:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238641AbiBMWd5 (ORCPT ); Sun, 13 Feb 2022 17:33:57 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AAFF546B7; Sun, 13 Feb 2022 14:33:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644791629; bh=e4EzhSBd05ZEK5ajCopJGbJXFDfnsrEfcW+jvd6E+EY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=YxwTNWkLhFD03TT5KQxsIOnM0JLeOn4PRCCayDr7YnHyEZlDRAJpwIbswgGQTasW3 qofz2TAe1ncgIlMRz5EWMvvsA7TNoDjjAQ8zeUlqSBLPFPNWGZCCx1f6nKeD0+7r0h bt4cwdEJx+CZfEwGMXEv1ypOYkQcUyStCXePIHWg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.68]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MhD6g-1nxP7t2Zs2-00eI2N; Sun, 13 Feb 2022 23:28:07 +0100 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, Lino Sanfilippo Subject: [PATCH 4/9] serial: sc16is7xx: remove redundant code in rs485_config Date: Sun, 13 Feb 2022 23:27:32 +0100 Message-Id: <20220213222737.15709-5-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220213222737.15709-1-LinoSanfilippo@gmx.de> References: <20220213222737.15709-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dCybVK/xN3+Sufq+aIz+9f9d8QRQ5K5pMV3gwc6qC9O0NCSdf1D cunb/0Yy49nK2WJiwnG/+2iYNACFAlKyWdWsfvp1naKMMsRuUqdzTZzl+xqlpHZPw3EmPHH cibXWxB0zOOjR1LwlupJz/gBg3u2f9jFJ6mj2wZ/7+fxaGmahcpW28UDocXGZCRFeRNrbCQ 4yjiBCc3/e+QF/Ah5zyTA== X-UI-Out-Filterresults: notjunk:1;V03:K0:/8qhBW/HGNs=:3NOa0RH3JyLBfCAaVitQ78 srakgitfNsLlkOTwdZvSIhlA6qBJVExc2i6J+HJTQXSZ00+R6hBHLgIEjZ3b3JOGXLw7yIyDP z/dLWf6XMf9Xy/tgVwJWH0r43OamjCRnCY5s6gsUkOtQdZnE2EF/xuQEDTU8K8KH/63sb7bHg VvE8gPftT0XqE3wU6rI7lRWclM932FYJ+xVWpCDSQ+pFBJDLk/Fx4T62MTf7CwfPWLbTgQE3b 8ycmQrzmHg3mvjWvQWOttwgJAI5FcdhF5VsOuDVxH2zaSE0DR056l8nKOEyfdaNW5V8qc55Vu +ZK3o4hNFCDti/nzXkX+aqh0XdAN1lanUK3rxGQAW9gscjYtSxbECIeYLNmht+k/ZDKMPWVxy jSDelmDv9Th6qVDrel4ZPV/Pu23oVd8Do1zTCehvJ2u+Z5Wv1wclXMIArEsm1A4aRchCvARZt Z2gOUxgGpXNyvgG+pjdEPI00MglHymbGWo/rdqAsKKItAYxUVeamYdgyPHPziR4DbUrIkjano kYMLqaYGnUcXmR1dNjfgRfLSv/WZzRU7D+diTdq6CYXfE0C4janJIiDJrarfqeswheioi2t5X VTPGvXRr51Sn6sP2MN76T09MuSeOlQauVqXw/AZkM58zB58i5nLnrkcgtFGZCWOTRzsR6BOv0 AJyXSCVrBGbNYhNuyppLETMfdhNkAIGKpYeJk7TpOHs1xksm3d8d0tpAo83/DkWnGAem2xoZa 53P6IVk6fq1pP+lS5wKSufHCmKDOoVLUQ8+UKCa7upjhuXnKYuPHeeCQrUncBEDPgVnMXv11U VoO3EBYBAfdD0yOK7e0zD8smvGHbd4rUvDMcgrWtQAdXCWuCAV7Zs1A56cYy5gpoBAk2CHD6M n+qIwuVE9GaSuosY5gK1CakukvSIgeXzKh/jf8y3sfaVanXy9ydXhvb18MNzw0Lci9x2nmlDR 2OSmNZSiuZLpXr8nMZcQ/HNgWYKXqqUJKEBYv/ugC8s7C/oceyK2nlV/lDN+LPHstugZZe0I1 Oqyl0UUYvuFanmA3mcrnAKCCjKY49OsjH/QMoRcQDQLWi5sZphn7s5qA4P0yhCLjPSHHoyFsC HM/vL9J+qwIFjU= Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When RS485 is configured by userspace the serial core already checks for valid RTS settings. So remove the check from the implementation of the sc16is7xx drivers rs485_config function to avoid redundancy. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/sc16is7xx.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 64e7e6c8145f..730f697bb517 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -959,16 +959,6 @@ static int sc16is7xx_config_rs485(struct uart_port *port, struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); if (rs485->flags & SER_RS485_ENABLED) { - bool rts_during_rx, rts_during_tx; - - rts_during_rx = rs485->flags & SER_RS485_RTS_AFTER_SEND; - rts_during_tx = rs485->flags & SER_RS485_RTS_ON_SEND; - - if (rts_during_rx == rts_during_tx) - dev_err(port->dev, - "unsupported RTS signalling on_send:%d after_send:%d - exactly one of RS485 RTS flags should be set\n", - rts_during_tx, rts_during_rx); - /* * RTS signal is handled by HW, it's timing can't be influenced. * However, it's sometimes useful to delay TX even without RTS From patchwork Sun Feb 13 22:27:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 542475 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 835E3C433EF for ; Sun, 13 Feb 2022 22:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238695AbiBMWeM (ORCPT ); Sun, 13 Feb 2022 17:34:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238693AbiBMWeJ (ORCPT ); Sun, 13 Feb 2022 17:34:09 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D54A54BE0; Sun, 13 Feb 2022 14:33:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644791634; bh=qLYG3ShC2H3ubPzsSwJCdlMrSsl/GQcb1NMteyXFxUQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=A4tA82OppBmIjt8/B6k4xEFGXfP9PH82xsLuWBrRi0yxA6c+IDNGtwsu/oymvy2kb eggeK0lbLBZRmRCLJL1+fLAxmogiNEtbNQ3M011n4zwE/rkIoMmjynjvqFW4WmGLI1 SafSW2vu3AdeTvYCNwCXfG+mCRMZ5cy5FM9CdKgU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.68]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MHGCu-1nWcsj2aye-00DExV; Sun, 13 Feb 2022 23:28:09 +0100 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, Lino Sanfilippo Subject: [PATCH 6/9] serial: max310: remove redundant code in rs485_config Date: Sun, 13 Feb 2022 23:27:34 +0100 Message-Id: <20220213222737.15709-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220213222737.15709-1-LinoSanfilippo@gmx.de> References: <20220213222737.15709-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:pNx+oEQyE87SI8SUhuYE/49GQx6eFVSP9sCHmwT/ditRcv0ylZN rkC/z0D7Q2MUrIrRUkpVmA71yNbDTddrfPtrt8KCP/4yOZ2GPb61Nh3ULguiKqL0WQstrUN QGKtvqxZref4S6azX7N1AacR+IVk1yMV8IHdwiZZEUXR+W4Bo/HkFSxPoooN5TYo9XQpjMZ K15CBILg6Irsn1kmnCbgg== X-UI-Out-Filterresults: notjunk:1;V03:K0:KFVBimZyooQ=:g3yHkv5cYs/FUFqcfKZs9z Y2pq5lZjKOPHeUVnvVOrp7UzHqauIgGU7WkACWjIK4T8qR56umvUiZlccERTv1k2vNeSLxdX/ TwA3p9aA/vIOBYe5ThqRFsQfYRLvhgnjSVQzS6u/RkKlrps4E2pSejrk10GdfADWqGeK10H7t +K4lkkGJX++AyPaL4/QQasQFUUJi+ZbYBOIoVDtmIyjhjGiQ93TK8P34L/BQDA12umb3YK1fM nqbMwgeTmxb9MNObQ9miQjCXbr/8svARONA17eiK8Lbht+8R05lzzUKMdJub0/8QnKhw7qDfu CYwx2vW9kg3UFs+TPcQ34Nx5m0Wwe5ck+T3YwdIH/GvooJ5wNW2+coeCNAvvpbYHCz8AYPBNR offq2ubqRZ/ZMvJxOxbRbnf9nM5sn50HYj16dbQvwu696yGaM2r2hHUXjlEODdk9xQYVvZIZY cmTeTU/dg7/h+8JwVlZa/3bSMJl67gcjK5i70kqxO4tiphTEz7tXLDM2s48P1WATNJaJjkDNs 8N6Taq0UhJC6w2BieAft9CuEwvlJGu6lDbiprc8c1mAmZ6Df4nNlF+M6LAcAUjmeBdkgcpHwi /QRBdMrnk3l+PPlzonwSpZI4hLtVgcEIPJcsFHVHpJ9DgI12d/TLqVd96zd6jG5La721fnpv7 DMWMobnWqVOmjKpOgGA6EEzadU4IKD8cOr6TD770H15C5ZIyXeO3N+nLZKrQMjxeHhnF5n47e FhpJI5rXqr+C2QtPbLVTTNIHYiqyj8IO5XE340lw+5RoKBrhPKuAMbgD+Am9SCmB8nY5KnMYA umV4MCeNhrHXyqIZGj6zg5ygckJyL/N/QTNkZTIjK9tnu4o7eLa7MmftSpvp3xlZL77Wnltnd zuD4rIOZunWSPHJtYWpzw+JoLDAzXMwaT9tRdAr/p76ZS1xg9myQzVRXtE6goJJgvbyBcsxr4 /1jj/uw+hlDZXXoglf87akB8Lzo9KdNIKPWa5MBVUz44DwqXT86iAnJoUpccAU2JmgXg+UTUK oBr1iBcqofPTLF3NDQilGRN7hBcWLyeFUgNfxY9iP0xfN37jM8OFXf5oJcSiUMfu7xOddXAVW UnK0ShGsRhg6VU= Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When RS485 is configured by userspace the serial core already nullifies the padding field of the returned configuration struct. Doing the same in the drivers rs485_config function is redundant, so remove the concerning code in this function. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/max310x.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index dde0824b2fa5..2ecc5f66deaf 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1037,7 +1037,6 @@ static int max310x_rs485_config(struct uart_port *port, rs485->flags &= SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX | SER_RS485_ENABLED; - memset(rs485->padding, 0, sizeof(rs485->padding)); port->rs485 = *rs485; schedule_work(&one->rs_work); From patchwork Sun Feb 13 22:27: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: 542478 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 A0FFAC433FE for ; Sun, 13 Feb 2022 22:33:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238638AbiBMWd5 (ORCPT ); Sun, 13 Feb 2022 17:33:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238628AbiBMWd4 (ORCPT ); Sun, 13 Feb 2022 17:33:56 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA9954BC0; Sun, 13 Feb 2022 14:33:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644791628; bh=n1QSAdLWsAQBxZRJC/gnWpm6+lTx/Zgz/1kXnTeWbTk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Euvc0QJs5qieCLnv9C6/YUVPLjBNeYOTXTteefGmLXgCboPOrB8Nc0N2t5d99rahC sQi58eRP3vSQ7RSFe7zZLFnRDEJuGzgk5Onds7fSrTPgUV8Dj5anXTZYQPgtd16kQf 1bQUxA1+wejOhYged7FtqMi8wWKqNq+AzcsophYI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.68]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mk0NU-1nz4sc49Zg-00kOyf; Sun, 13 Feb 2022 23:28:11 +0100 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, Lino Sanfilippo Subject: [PATCH 8/9] serial: fsl_lpuart: remove redundant code in rs485_config functions Date: Sun, 13 Feb 2022 23:27:36 +0100 Message-Id: <20220213222737.15709-9-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220213222737.15709-1-LinoSanfilippo@gmx.de> References: <20220213222737.15709-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:C/eQLJontq2RLt02NobbFgS16JscCgWH9ptxRkHS5Z0m9OOZox8 QJGSADIVHCm1oXdpAIolH0IZm4dSg8gHv3aQgY5IRT0JMcQLYAzrw6FPiw1+XnQmDkw/xGA W1WYjAcv3FUh6R5QieabywvgR65jtD6wAJRB1A7LCgqcjvv7kUdIfMTyYwJm6rwuRAh/fiw 3G7H1DWGTLFL4eHAtVtHw== X-UI-Out-Filterresults: notjunk:1;V03:K0:U16uzVtWgXY=:tZVo3I7KjrLD55/IVEQz9A i0uiAt7g6CbjcxV7+YCGedN6AYeKUSm43jNjorEj8neySgcdg2sVwwxduc2CQQC70PmccQ5tq XrOW027kGd/ArvGgTfP6tgcddHDalQjca+c0/qe9SdRge7vq2sTvtBl6XrYXAD4+L361S+OfO rAAxjOb75fpa97uFUEzubcYPbPLH3MLqBR+n8ns0xJPGJHzugbHimrRC8vy3YxlumiJQ30j+d pIjoZjojcfUNkITgJJ21dm146N02KV7RwgnSROLHZ5jdsZRid1HKYYry+JvWhXGtKbrsYA7Ds E1aXunqXLQtroV/II3YKhT3DPvBVz/5VU6NT1CNIPoK2wMY2KRDlg2MIzKPr0rh+BMyiEDLPo E7D8I7POIZAj+N4/1NLTcBYr3QJ0zRDUmwLOhN4Q8+iMtsYzGcmEBi+kVepLJXYbowMTrdHzx xl3I2BCmGsMyW9iLeoQQYPOMDsdJmDOZ0TTZcLNYW3HTnX0H7KiwJoxqunqLnlR3z6tWS/VVo lRp7xMt+DqhD80CM2ga2SnUTwj03EVL40FwAlYzBJxFA4VcPhefsrI0Nq9rP1bTwkp6b7bHoj 7OjkX/pcn6/A8qphaA3jLWajFBLhAw+FivtuQl3aNjxW1NLRGE9QNCxl8n/eHwEm3av1i5rEv yBp01gmQMIH8erJH8PfN/9a+kkMsx3AHOpKmq5DKhNct+nyFdmPs5QJ0vwsHMuxSYp22hDWz4 rRnXE8gf7cfgOl1WNAXcUfjFPfJXev0K7WPKPB0UOGLUh7CFBV8QQ3TuYwYwRBJd+XbdtFxBz CmQo5IrTfu0aBLIm5KTgI3ZXmI5xjQeK8OPHp+Pj6tBN4g1Pg4qyu5BNJoNoZ2HMDxgRD/QwS IJU4wXn1V5tUjpxC/EtFLuTPvApg8swNJfKoIl8GDfVAGZidy6ZmlCWBaqftmBC6o5XSM8cwU ix3r4gTyaQ4kXmnFHcY7Pspvk9t7d4QSyXSvEI1gv29Vz0lijy0DWLnR0Y/SLaJOYv2NexX8r 1e0Wnraa0NTxvBYc5MsuzaJiMDQ/PCNr9sRuVidg8qGK3pt/gmlJwkclrDThrsoszVJINsdrW 3fHqSgh8a/wqHM= Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When RS485 is configured by userspace the serial core already checks for valid RTS settings and assigns the configuration to the uart port. So remove both tasks from the code of the lpuart_config_rs485 and the lpuart32_config_rs485 function to avoid redundancy. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/fsl_lpuart.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 7d90c5a530ee..a201be44d68a 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1377,19 +1377,6 @@ static int lpuart_config_rs485(struct uart_port *port, /* Enable auto RS-485 RTS mode */ modem |= UARTMODEM_TXRTSE; - /* - * RTS needs to be logic HIGH either during transfer _or_ after - * transfer, other variants are not supported by the hardware. - */ - - if (!(rs485->flags & (SER_RS485_RTS_ON_SEND | - SER_RS485_RTS_AFTER_SEND))) - rs485->flags |= SER_RS485_RTS_ON_SEND; - - if (rs485->flags & SER_RS485_RTS_ON_SEND && - rs485->flags & SER_RS485_RTS_AFTER_SEND) - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - /* * The hardware defaults to RTS logic HIGH while transfer. * Switch polarity in case RTS shall be logic HIGH @@ -1402,9 +1389,6 @@ static int lpuart_config_rs485(struct uart_port *port, modem |= UARTMODEM_TXRTSPOL; } - /* Store the new configuration */ - sport->port.rs485 = *rs485; - writeb(modem, sport->port.membase + UARTMODEM); return 0; } @@ -1428,19 +1412,6 @@ static int lpuart32_config_rs485(struct uart_port *port, /* Enable auto RS-485 RTS mode */ modem |= UARTMODEM_TXRTSE; - /* - * RTS needs to be logic HIGH either during transfer _or_ after - * transfer, other variants are not supported by the hardware. - */ - - if (!(rs485->flags & (SER_RS485_RTS_ON_SEND | - SER_RS485_RTS_AFTER_SEND))) - rs485->flags |= SER_RS485_RTS_ON_SEND; - - if (rs485->flags & SER_RS485_RTS_ON_SEND && - rs485->flags & SER_RS485_RTS_AFTER_SEND) - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - /* * The hardware defaults to RTS logic HIGH while transfer. * Switch polarity in case RTS shall be logic HIGH @@ -1453,9 +1424,6 @@ static int lpuart32_config_rs485(struct uart_port *port, modem |= UARTMODEM_TXRTSPOL; } - /* Store the new configuration */ - sport->port.rs485 = *rs485; - lpuart32_write(&sport->port, modem, UARTMODIR); return 0; }