From patchwork Wed Jun 22 15:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584560 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 6B35DCCA485 for ; Wed, 22 Jun 2022 15:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359564AbiFVPr4 (ORCPT ); Wed, 22 Jun 2022 11:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359501AbiFVPrp (ORCPT ); Wed, 22 Jun 2022 11:47:45 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854893A5DF; Wed, 22 Jun 2022 08:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912840; bh=8IFGxVS1vl5JLWh0yU8Lv5GqvKfBZ2iqkV27iNYuWh0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UVO+cw9CkqDJWgg8c2KKc/7SdSzueQAlaGe6XDfOE7FC4NpxX7octk2+fWE+Kr2RX cXHgaBmUuvmXdJx+w7v9FLCByTAcz+j6Yhz/pu7eulb/7qLAnvZjBr/6B1CPSkw417 /1Z97pBU0JgW3m9r3Okn0lI2i6SCiLlp4KgDKFWc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MV67o-1oDQn33Qnu-00S3PO; Wed, 22 Jun 2022 17:47:19 +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 1/8] serial: core: only get RS485 termination gpio if supported Date: Wed, 22 Jun 2022 17:46:52 +0200 Message-Id: <20220622154659.8710-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Wzux1oUdzW1pI7nfCPbfxqcmfleiTwvPyv2n9VmmFzCZ2/Dzw4V a9Sc1f4YAFcUhRs4jBHdjixFcdb4xPhKK3ZFyjOXGeX5mUGXETzXZFsgQollNQX2ZipkO0Q FLHbM5HCIlp9mdDiEjp6G0/1hrXNMpyVW3d/PTsBFcRH7g4mKyZo2oehzc2ZOQqK4PLZzvI b8zkGeTTbxKpW3/DZSMkQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ObLfviULXH8=:BUFD+zu2z8GYzeCsOjHWqD TyrqkX/lOCzkMy+RY/45i+3vUB7nd6K/wkPEAO5Rk6LnO1Two+tFsknemhrIkMUslMU2HJjrB AngOpKEV9nuDk4BvfIxTxtla/g8Xijq4dLm7dOBTpkM0vIoyxl8Xq81UYsuvSf1GLMBLjMRCx POAfAQyBT4leaA9Bt10Qw3FdewKrpRIC3mu6MM7VBZV6ymYjH3Q8NEC6J3U5hDAEu9ikf4hRr Rxi+VwJAACFftmCWGdZYiLO4Ywl7rSxNg6JRkeRcazh3LGy63GZ8puI6a5BjdMkOCe+MivsyH BMyiNZNEpSRZ1TvxKQu/6xacUAARfzOQ07LAKGj33rOHWUkL/o0K5RzidoBT3z/Ljox+cWwJq KCSaiCBIayfV7PUypWK5DCRHcYUPn0xH7PTKEJnSTgeLebkRxX0nQPmDuYV1ZIiMH7U8G2esi THgibLABCTPmhUBirAKgG8Vayb7V98jM91f8fC2FGtWLhHCS9OuJJ/+VAMi9IXKsEPTTLTfqy P8Bi80biXYRow0sXFmCOuGVrFtgYvnqkeawk4d+3IthSwfWTwquTZQ8XjLtjRUmycFKAbPtaP DSO8EISdXnralXN46F/wan3dwQJEXupLfpYykI6eomP2X7REeSh3/lJUD430R61RKpJlbcaXD uaIxC6SGMNq8zA/yqTfR6B8wcj8sD7XrOTkao0xOd6ldEMh9Hl+oOYmEdayJ+xTOA4ac1NQoa W/tGmX7kBrfUHa1boVKgWXmqP0zRCVqR3/+b24Tipat2p4JQeCO2DNHEKhY8Zez9COqjyGM42 qLig8Ymt1r+N9gMWHIxgJwW6mlOzTGio/8FARtTR2KY9r1BfawuJj4TXXzNajc581Bq29gAPk JhIj2P1x796luk+pvaaGkX3uh3/LuWAkwwaJjEyRgqH7H2/wvl0kAHuyOkAofTgWl8ci1Eb3i c+IG9X+SYsAf8blcz1YMB3S11J3zwf10zEW47ITQcZIMi6izTpz1k89LO0gNX9cMplBDP5m2o 0SpSlWnxKqbKppyHljPuit5XaqaXHlfpjINBRzqy9EX2Fa6fcBu7KezCLqryGeDqp1yfaiDLG AYKzEY6JlRtf5fj5HJRUwih4kjk0ham0LorujXrvE96jqR1uj0cfWOknw== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo In uart_get_rs485_mode() only try to get a termination GPIO if RS485 bus termination is supported by the driver. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 1368b0ef7d7f..015f4e1da647 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3384,17 +3384,20 @@ int uart_get_rs485_mode(struct uart_port *port) rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; } - /* - * Disabling termination by default is the safe choice: Else if many - * bus participants enable it, no communication is possible at all. - * Works fine for short cables and users may enable for longer cables. - */ - port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term", - GPIOD_OUT_LOW); - if (IS_ERR(port->rs485_term_gpio)) { - ret = PTR_ERR(port->rs485_term_gpio); - port->rs485_term_gpio = NULL; - return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n"); + if (port->rs485_supported->flags & SER_RS485_TERMINATE_BUS) { + /* + * Disabling termination by default is the safe choice: Else if + * many bus participants enable it, no communication is possible + * at all. Works fine for short cables and users may enable for + * longer cables. + */ + port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term", + GPIOD_OUT_LOW); + if (IS_ERR(port->rs485_term_gpio)) { + ret = PTR_ERR(port->rs485_term_gpio); + port->rs485_term_gpio = NULL; + return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n"); + } } return 0; From patchwork Wed Jun 22 15:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584137 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 28414CCA486 for ; Wed, 22 Jun 2022 15:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359573AbiFVPr5 (ORCPT ); Wed, 22 Jun 2022 11:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359503AbiFVPrq (ORCPT ); Wed, 22 Jun 2022 11:47:46 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91E933C4AE; Wed, 22 Jun 2022 08:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912840; bh=ng3CY5sBLo9HzL9eQ6cr+vyMggjXbLYmrX0EBHYnCIE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=hxE6QMAWXz8YpSwjcicr3QOu28G1YDOM0vvGeIpeGDRQ3TkpGCJZxqvrLmOX8oIEU DIzVsoSlu+uP/XDoIeMqVIcm0kWq31QAngdg8EPZPRSOgSE4mVE6pPjVgWHeFTAbvP +pWdS4EK36cll96Ze7Z3lbTmVJBDmYN5NcCU44Us= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MpDJd-1nKCVr0uzP-00qlEB; Wed, 22 Jun 2022 17:47:20 +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 2/8] serial: core, 8250: set RS485 termination gpio in serial core Date: Wed, 22 Jun 2022 17:46:53 +0200 Message-Id: <20220622154659.8710-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.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zvewym1favEUzIhRoghqogGZGZLpUpTJ5vFPYhCvoe8mDkS ooRxFwqhOUlcGVuAen+l8Vxf+dt9BTUvikMEm52fpxPyjLvlPiYyMV0AtRCxAbYfZkMTO41pr QwG7SpQ3aB4TuPnajfNAiluvHQSn8Gvea3gb+MYgqbpfSItXl3bFMJvXt5iuV9G5nob05an5P pi/OYt3fBIAKl1CTkqUBI+xh47Gz6upzAlhCHmnQyCh7+Lq6L3D7GuGd5rHpXJ6UpRZM8cTnN QhGlg2jQiU8AYRSzPf2xoaqiy+InRAJIdzszOlVDqwy7JLH1nM9AIXGtxiZzzmM0U4q1EU8Vr IQIF1RMxzhxtMkXToM02bxagV3Gu3G3Gv3G5He+4oisrrCu3MpUTSEmVA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo In serial8250_em485_config() the termination GPIO is set with the uart_port spinlock held. This is an issue if setting the GPIO line can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Fix this by setting the termination line outside of the uart_port spinlock in the serial core. This also makes setting the termination GPIO generic for all uart drivers. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/8250/8250_port.c | 3 --- drivers/tty/serial/serial_core.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 3e3d784aa628..5245c179cc51 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -675,9 +675,6 @@ int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485) 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 015f4e1da647..b387376e6fa2 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1352,12 +1352,23 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 memset(rs485->padding, 0, sizeof(rs485->padding)); } +static void uart_set_rs485_termination(struct uart_port *port, + const struct serial_rs485 *rs485) +{ + if (!port->rs485_term_gpio || !(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, rs485); if (ret) @@ -1400,6 +1411,7 @@ static int uart_set_rs485_config(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, &rs485); From patchwork Wed Jun 22 15:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584138 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 39B57C43334 for ; Wed, 22 Jun 2022 15:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359557AbiFVPrz (ORCPT ); Wed, 22 Jun 2022 11:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359515AbiFVPrs (ORCPT ); Wed, 22 Jun 2022 11:47:48 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAAF13DDFA; Wed, 22 Jun 2022 08:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912840; bh=Rq3KFvxDtHALFh/DnfsS+evHIUI8vMe3n1/DQWqfHUk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=XZgcm2aBHskXKxiq1sdoU/43+QwTkbYSXsznvKnZHkWP4CKG+g7l3NCchoiBEIASO B8/Vby+1wlyuEGZz+T0B7DidPFM+D4hvQg39WtlLzGMjgcqMhcv+coNCt8+hT7tYXT e2fKbQAEGRU5lD+ltxxhFJqOb2QaYQCPFtxuIE5w= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MpUZ4-1nL1am2Tt6-00pvse; Wed, 22 Jun 2022 17:47:20 +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 3/8] serial: core: move sanitizing of RS485 delays into own function Date: Wed, 22 Jun 2022 17:46:54 +0200 Message-Id: <20220622154659.8710-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dCXH7+GWeAl4LLMvcxAw/fQZwalG9+Q0N9n2K5X3mltot8aufOr a8QPrBg2BcpkehxEVEfYsj+RupRw8ld0OVbpgqKeJ81S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Q/2NiWJSkR8tyQO15jhvuSKgje8Wxd2+DQzFpkCo9YOcvLNJ66QVlzxQqFfGHkxC XHVxcJ2MWX631NOaGQk1PXbnuc9zv89L1FgFl6T2c2iahVicWl7Ep916xuHV/6WjskNvb+GG0 Y+58/8YDEY9jPkSWX5rYiGo6anGAb7fnSHbL05m3OCP5YgmajBDo2nYnc098DMtvnUd7qykqZ TSJWhF3uQgRTZqa/BJVBTHXcpsYcEv7CH/aXxXGNR46g9o/q1lYYJ+nlw== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Move the sanitizing of RS485 delays out of uart_sanitize_serial_rs485() into the new function uart_sanitize_serial_rs485_delays(). Signed-off-by: Lino Sanfilippo --- 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 b387376e6fa2..fa6acadd7d0c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1297,27 +1297,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, @@ -1345,9 +1327,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->padding, 0, sizeof(rs485->padding)); } From patchwork Wed Jun 22 15:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584561 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 B7A95C433EF for ; Wed, 22 Jun 2022 15:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359499AbiFVPrz (ORCPT ); Wed, 22 Jun 2022 11:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359516AbiFVPrs (ORCPT ); Wed, 22 Jun 2022 11:47:48 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E0243DDEA; Wed, 22 Jun 2022 08:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912841; bh=USV3fl+twKeaglXK8ND9rNj7pBUi2D1D0ABm0cxEvko=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UUswrZCOZwnVPIrtWkrISAJD5rAj5sXkVJ6a2FK4S7ogLnKGOE7AB6uoJONiZvpZy GFcYDw2xLOxfQkf6yxGc88/IOu6Az36J/NmES+kIhCRG3ueISlyh961UR0LU3Jxyzu CIOdMM1emnxbSaDDjVOHd5xtT69vpJ8k7X06qKKo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mwfai-1njsGI44rK-00y96s; Wed, 22 Jun 2022 17:47:21 +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 4/8] serial: core: sanitize RS485 delays read from device tree Date: Wed, 22 Jun 2022 17:46:55 +0200 Message-Id: <20220622154659.8710-5-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:e/jK6Z9VQvfhmbL4/RIZnEERZwYLu9YwLTfCCrPInSYYBm2ZMlu CdYKgEWHWZyP0DyZUusPmYZ7dOqtX0318268vHy0EiQ9da2TtNeALxihcGNyb2GVCKq6WIf K1WN8b7AtCjRUKa0B50guV58p7oloY6sGrhWQiJMpkUMsqd8nZGzppNMBusaPxFoaPa/iU6 3Vi/pHI8FXMt1veuMQuNQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:prhJy9QMOTc=:QgaCgmiMiRr/jtLsmjd/QX yOO5BLgh+6c5I/D7ExYmUEkszGqa1iFGUtVzTEnmdWuI59UKmXPEKEL/opxgHpdFhHpev67aU Re+56rDXQXyzgqWoxT84lFFYoC3w1j2lzNs4PI3b4ADpwW9k8/9AMW327z5l8PbA4DLIfE/Wo gXMjFaiSHBCYAy6oGKOkB1ptHnnGndgCixavf0/NnnCkhN4mNz74SKDLCxgU/5XDWkh1heBUi m9FBLUj2gLKu9SBsySl1JoS9f84CZXUZ7Bi0pX3UovOF9AAADsTx5g++ZODJNbkzF6rT5SNIy mwlZLenjF1gX8rOtaHYpImziRBJHVLMK/wQkRo42cZNrnLjk88oikKfgCDRwI1ypWRj+UJiub TkCE572PllH+X/tZVTSqAmIbuZe7ZyaYrwjCcy/QnIf7c3aH1e3Q3NyjQApcKEdLdQi8feRQH Bql9UIwvcpbgtTVSFY7kNKZGe+FvS1AcNZnsq6O27u+SlkeNMHd5i4K/QJoYr/HdITiTIVs1T 1bg/ffXjDgG0suzrzvgBY1ZzIgaNav8XYzRRY/VrEl6Tr7lYiVfCpN5i23thYtWe3xV2O7oEW HToPEpqarAtMdVh9wJPLCwtQX3SHyJdX/Zhc9Hq1whcHK7Urkydu0RHYEOHAL04/ksZmviQbX 4I5g8hFtDgWyVAcE4GkW7wLhsO8vFwVXAKMnFsMw6icgrFmAj5h0VXcodH9i3MUk9HKGdEef8 DBskoAa3Pcc6XcVIqJwQy7cdqBZ5H9xkhIG8D0mdfwI9hz360zB7mJ6oMq9I+s4b3xqTMM0p/ 0xJzzxWLVnOKuTZIlVvzjUOdXXVUJAdmlGqCalkfPMEyLR990t5LKFXkAbiLr9WfM3KQM2mem I3HTTWY4nSskMIUdlIpAnyxCDQVHgf307hrkz6giYUj+nuX1M/Gl6HkJVh8OZLVAce6BsGogs 0iySkke9+0e6N26x5iWAvq3QKOOzHQsvWZBaMY0C4/5x9Ur8yYoe+l5rVubK3ETUHRqvaOn9H 3zXdUNjM7pJBe39Z555W7asmxuDquQQEQjBpVeSqGSda/ad7MmWQ5/pBSjWzpP416PveRUMZl I/BDunea9pML9crCdcYZdMlt4ErDobXSqD0fYFJHPU7zBG8v/ozpNOwPg== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo When setting the RS485 configuration from userspace via TIOCSRS485 the delays are clamped to 100ms. Make this consistent with the values passed in by means of device tree parameters. 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 fa6acadd7d0c..2e9f90e73e62 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3382,6 +3382,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 Wed Jun 22 15:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584139 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 49B31C43334 for ; Wed, 22 Jun 2022 15:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359535AbiFVPrx (ORCPT ); Wed, 22 Jun 2022 11:47:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359512AbiFVPrs (ORCPT ); Wed, 22 Jun 2022 11:47:48 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E52D03DDE2; Wed, 22 Jun 2022 08:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912841; bh=qz3RPS0BDICfMwamW1svnc7WnNORF05BoX0V9U034PY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Q9rqsXtaMHi1YlwEa4O0LljiLQt7E7eGVDzXCe1m3Yy3wLBQ7vFYdpRI7fJyZL1bQ 5Cxs6jYX/4aBEwGVeAPTeZgRaLf0XPC6ZNTOpJelWV3dscEzdqDkJkX5or4q2LcKbw dhbwwV6XNVM/14EiK85yEoNrnQ3brzR8MaIAfye4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MeCpR-1nVGBi1rNf-00bN23; Wed, 22 Jun 2022 17:47:21 +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 5/8] dt_bindings: rs485: Correct delay values Date: Wed, 22 Jun 2022 17:46:56 +0200 Message-Id: <20220622154659.8710-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:prpxpsnL+vHyU31JlXHFy4JJMQnzLkmjydzLnz0hdCESo10CyX1 BvFe2Ef67UDIzefsCrVEOhPDaCAtKR4JHdmHsOz67qK/B8uxQAFJ82e8iG8FmwlSZAUNKUe vuPmKM2UUf/cR8cMFcG4JVy+cwZ04tp2Pgj9ww0tWhodpEEcBDqcmbOLBm/jifd9EocrflE sq/FpHGFY0ugxgYIfmoxg== X-UI-Out-Filterresults: notjunk:1;V03:K0:jd8EvS36E6A=:+4D6ILjoBJaOwLyGtJ7GPE EIj2y5rNKJk0IVlrWHMTCPYRxfEQd/eIRDbQfitfnXM91yzFq3TFivv9LzEfzjX+692TvAKOL iYfbf1uLMGtEiZ04idQ+T7J44UmljX57MdOVO7jqOpdjEp009EjD/A/mk04s0BZ+Eaz/WtVO4 B8Op82x6RrWmcAsDim1UXbmJMYiu6GkdkL9zp8ZHhZ7V4uVIzkXTJoDLC9fyP52/IbWhqf2sE srcFDsTgsJDnl62pwdq07j2DJDgMROQSy3h8+XWOi1btlYNRqqzYIjB10zjCpoP0lsH3YhnvA cARGw+jWzL/1u4W3NQGs8DMIRRLY1QqeW0NypF77SVxokB9M2W3XYJW1vR4lIe9StdeZzdpyj qisg0AH0ToqAtwd02qCgkQnUb21RRGcxKd1q7Uq6RwQaIwT6xMfHn8DRO/gSsimapaRaQcNM+ MKkQk/7/OTdLQPl4qfZH6xw084uD7NBvYodqI2WjOpmsWqljgaJhz9kP5LBLWwqWgyT4e3fAx Wm4hJwrUw6cqoZ0iqvT+/GL0TQfWlbaWj2vx3q/IiyWfunOorZJY4a9eVVF+fTf2CiazJBfgC BNwj/pTN/TKNYfNF9SNqEa465zZKkH/cCbtcvAHfboAgOAfGNWnXZ/P9No4+SOISVg67grzSz j/YNNolTGeA26jLX2VYynCcTijz3FCGzPtwh54IaM6AzG8VTP5z3v7GyoMF6Hdl0zP559Fdyn Gjc7Z7s/D1gcIZOD8lD1VnHgVJuuBzWNkhOR614GTmB8yQosBZ4sP8wZ7GAX1G7uhRVQil9WI N4UIRDtX+Kjf2aeXmm8VGlaTdX1c/dAhhZrdTXEHN4C2GfNAnOtJNXdOhHdbw4iWcg/CiX6fv tskcnHOfj3o+gXBpCHSIHuNFKHJzoaT6PgdxYGfRm6vTF/xQalqqMGsvRhcmcX6wlmrpu6dy3 x7vn9ZcyM7PgdgPbdR8pHqA9b8twRGmqveMDrg4kJReMVjI/U9TXROVnTqlQP6P+VehdacfO0 lV3aWZFLLQGHF+ogy4RJTxHdcUmuRS/boTzuGblmPqFoGVYQh6V+IAgVmvKb/SV5Y1Vox9hmZ UnAsPjOizVJmcZNXtRf6IRM8FONJO9KD5uKT48zVLpuhyIM2RBWX2CbZA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo The maximum allowed delay for RTS before and RTS after send is 100 ms. Adjust the documentation accordingly. Signed-off-by: Lino Sanfilippo --- 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 Wed Jun 22 15:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584563 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 B14BCC43334 for ; Wed, 22 Jun 2022 15:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359520AbiFVPrs (ORCPT ); Wed, 22 Jun 2022 11:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359494AbiFVPro (ORCPT ); Wed, 22 Jun 2022 11:47:44 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10EB3D4A3; Wed, 22 Jun 2022 08:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912842; bh=HDosJRHefTht65c4ercr1KFDzqhI1YXcq1slYta5z4A=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=gByAjzYHwj4ZyQkpGUFpq2uQ5SMSXICPzeymxulNVo0O4C2dKCaiIZi+rG6f4KwBZ kqX9CZuqhn2odbA+UDyazL6ZKDn+XGECwtULsCVXgMoCVyyxPSIyLVV4eci29hsS2l vsDTHqA+3i07RXKqBrZkCwywtnlFiqHr24HR/9Cw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MYNNo-1o7uUF3WbK-00VMn8; Wed, 22 Jun 2022 17:47:21 +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 6/8] serial: 8250_dwlib: remove redundant sanity check for RS485 flags Date: Wed, 22 Jun 2022 17:46:57 +0200 Message-Id: <20220622154659.8710-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Hhv7t15Eh6FTG+Idf1JKlreiNJd1OLyuJVNyAobctRorPGG09eB UhUhe6n7MDFCBmzjH7Cn5SP/HmdAMOH/OZ48WDsdTRdcLnINiFwqpzfo1IvmwwAFDVNMqq1 8mh7tVmlaIn7JlvTneV+7JF90o0FRhA/oAKgU7uDQpr5zY3vEok4j2ldH0YchU0Awq0Gpyp olizn3mofXHuiEJpSRiiA== X-UI-Out-Filterresults: notjunk:1;V03:K0:uV4EiirzX/k=:tzUAkIh9Yxc0fagdAnUphy iyaTAnKFLbOzbmLlEZMC0tV3E93zqEGVbaASD1I4ZH0m1QsQDiFesL00LqnzCyeLugbm2g/1H tOS/+Aka+/QDu7leK5WD1gZI6mgoe0nNEghrJAPMDpvLjd3keHMDQzkDQDtxEyIBBP+OQtmuw kSfmXSIHM5wWOSUgLxGZVW0lBmr8ykW6pF+kpdttijmUJPCaPaYIAvzN/rTZ5bYrgl7NnU98p mfRS5H1bUEyjqRb6dP4slqACQMjl1Q4HvoZSpxFjrbcUg70UHcQSwpIO8Kj2izhJim65/NDWt UNLLRb8JAdB5XHPMjT8EO/sk0HpML0kc7O+72dZcaweHgXuHnoQq5+rUMy5pn9l7VEiIFKibr Nz5YezbJ+9F5/ek6CmlruMTZLOpgsdzlxokuHdoitPYZcET0W06Jc3oh4Ln5j8ZLelfj3sa5v s3T52RxQoreKAv457PzxBqHDag6x6XaYmbdekh/2VCGWZxr6Yn7u6cwL+r6zCdmLEInKjwZgt 3wNKFk7zdrUvuee/pJuACL+8OKh4iqOXHQEJcpPCQwY+WDaUwDRCVL4vD6ur14g3mD6nWZDBQ cqbo9flzA50PSNa76khoJDVkY81Kp4jrG6ZbSh/bV7JCd5bVWkkMG+9oxbljiePGNWfeRcvvv Zl8gvYDBDvu2aqsb5EEDkSUxV0MFRKYZNLIDc1VtrW158GV/2n4qj4RPHZar8MIKm83O5/I9o OTT0lQameMWIJBov8gOiExgBdAtkMq8YJyYU0nl+I+HG7ie7Rrq4LIKr5d6vzUe+c2Ed93mWA 7Oxod68SqB45ZoPjV/L9gxeqR3WI25yCKQLDkBJjd1kwFolF05IoTnBhH0KzaA/Cc2c+Mp/UG uDnAh3X0RZQM10qrvvbQEr2M/6egoYmTH7/0hnC4hhQE9QcwmP0nfvHOy3sMzXnACEDOmpZT/ UjrVtaJVSTjits3L3l4OUGLh5DbqJ+92Zi9zbpB9HrFrLr6fr6Cq0/aKEi/6Pm7mr2qh/HIOa UmguVQgCt4MwKaM156/5A1fwj9oSZG5N18PP0EqheOLR8dmCTMLE0C0WWsuHjJ9StVIBH1k9z CuzzlNJmuYJrV5zGK15YzazLzGfOYNscI8n4BHV3/Jl3AA73UpkweZg8w== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo --- 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 c83e7eaf3877..bed2bd6b7a01 100644 --- a/drivers/tty/serial/8250/8250_dwlib.c +++ b/drivers/tty/serial/8250/8250_dwlib.c @@ -95,16 +95,10 @@ static int dw8250_rs485_config(struct uart_port *p, struct serial_rs485 *rs485) 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 Wed Jun 22 15:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584140 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 EC440CCA481 for ; Wed, 22 Jun 2022 15:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359524AbiFVPru (ORCPT ); Wed, 22 Jun 2022 11:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359161AbiFVPro (ORCPT ); Wed, 22 Jun 2022 11:47:44 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 176633C4AE; Wed, 22 Jun 2022 08:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912842; bh=5KTQXMZiT6D7UTxVVBqbL5j7igCB2KvHxvl0c3jIThM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=b23P5kRcBPxk+Mh5R0DyccQRxSN7ul5bW/3joQlL/4IfG4g8lESitm603XuYPUY/f Dd2ogve+eR32enNs0eKYopEsm+U5PPTw7YMi0xSzSganBpDv7zYOeV45mXoLLqALam n4JeecrWhfRdQsxMaM8pRNkPK9vx+4uWTai5ekuc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M3DJv-1o73mJ0v0f-003guP; Wed, 22 Jun 2022 17:47:22 +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 7/8] serial: ar933x: Remove redundant assignment in rs485_config Date: Wed, 22 Jun 2022 17:46:58 +0200 Message-Id: <20220622154659.8710-8-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:+/P+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h8LIbsNjoa4K7/7er+hTS7S 44w069ud3GUhSzqAJ8Y3jv16/l2Q8V2gZBwHGgUoM9P1uxKube94aNwZ/8qcg5bxfJoMKsjYX GcF3ZcCSY0m5Wl/T/TVFpDjVHtIzp0p3PLFenz6faEh/L/zFqcCW9NZU24dRENv5qQVMTV7j4 b7gNO9KpVIs1B4kE9KFI+o4XChCyyIwufrlFmsGwLpTleKf8Tw5Hmiyxralvy7OI0sS2TGnL3 eNYWHv4EOA9ExM7oNqqdAg7oMKnbbQoT7hhs9ezO1NwFZFlei01nyhL968OoSrPz1Us36N9bS GHnB++5ZabW3zKc8DfQwk+lyLZpckBrq7vlLlUC7pMrelUlIgqMCwCFcQ== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo 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 | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index ab2c5b2a1ce8..857e010d01dc 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -591,7 +591,6 @@ static int ar933x_config_rs485(struct uart_port *port, dev_err(port->dev, "RS485 needs rts-gpio\n"); return 1; } - port->rs485 = *rs485conf; return 0; } From patchwork Wed Jun 22 15:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584141 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 E4682C433EF for ; Wed, 22 Jun 2022 15:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359484AbiFVPro (ORCPT ); Wed, 22 Jun 2022 11:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359075AbiFVPrn (ORCPT ); Wed, 22 Jun 2022 11:47:43 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208553A5DF; Wed, 22 Jun 2022 08:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912842; bh=P76JCAoBEwYxagrCxqz0x5UalaF1hec9VzDLAcDAK90=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=gI1K62Ac1Y8Zx3itipz4l03G0B4VpHAqQssoOhMy45OJHJ7d6vl6R48KWA23w5wHX lLpcQtAu5Z9rWcNJ3tME5m7Xum9Y/CA553ucU33xukIAk0a0rh5Ww1jYD9CkfhF0xb OHrcXkxYHMChG59WJajHANGnes5KYp99xt9wn8f8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N9Mta-1naV942eE0-015Fq4; Wed, 22 Jun 2022 17:47:22 +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 8/8] serial: 8250: lpc18xx: Remove redundant sanity check for RS485 flags Date: Wed, 22 Jun 2022 17:46:59 +0200 Message-Id: <20220622154659.8710-9-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:WKHLwSJiQn/lE+w+iwlvUVlY+hSjpvhwDHxzI/x8AFxyiTj4QCk GTI2fk9fSpQP3EnqiPKgLA/I98tb8vKF0Q4dwXlGNBk+RnRJLkvLOrJCT6JkraJYyX6hvfP vss2kjip1uOIBclB0Issx6scJCOIPxFsNJAMk229SIDjibTBwNB7AZyWoVlB4lRWToVKN2K d8myOgdT/Z2X1ICVbHXYw== X-UI-Out-Filterresults: notjunk:1;V03:K0:iVH+DtPsNl4=:I3yIIZMg6ftu/BPmnCuV47 yr8woBxBq0n/NEkF8Th+CcdZiXC7vlGyp/DN5B2FPGur7o6AD7/UwSCwFC2WWldf3HpK6OraY evL1IQ3wIeTMr5JCtM40+ZHdHTLlcvRwcuCWeGoM/CiQsWG88IrqJofXafcbYofa+QKC/oI9L pmXngFqXuXxjkbJ2PKUg5Rp3Zo85K16r1yP1QghTo1I2xmvY3m/T/Lc3GvKS7J6XIhHHZdYBF 9OzaTIur2dtfwY+Lbl+QGrlsb3ktTV7vodgPnuegX53RClh4IZrvTgmXSM/Y/mQNwLz+zfhBC eMr0c5O1pwibXgELsJcJ8RTCFDQpSuxV2rOXjS+95feRbXLicHC7fFIKDquNnvkH+mwAcnmxz neQzO8FAVdvlwHRC7xyGO0GXMnGK1x9JTDvsnLZ98nCC2K1/myWxTM2FPPOeOTB1ULtIkXbKM hW8k66Tj2b6vHr9QVzNB0AEipTEf64Aeq+MCMfty+xgj9TPu+WeIgn4OjD53jQ0M3cnjCLFSR BMvhayoW0tLe7ByS8THdHvKlVD9cRasuODbeO3jEHj52xUUtXiegDK50ZGp+FQ4qHqCfQenLW iV4Xi9E7umRJQ9hs5pugWESRDR8jSDF9DcM38ZNfaTQaNtG+QAequSopBEmdNawhDl52X8AiD fKbSe3wwSvJ0Z2TwwaZqR3/vjsVEy1WJhkYXgJwO8m2lrcLdAMI17nC6k/qL10m4kyEsyV+u4 IpQbpuAybwIOQ9O3yM2e6m+xfO+r1tAOUxlkzv1ZrRsvrcx00oPNPJrq4zgObvsu/zi76iQZd TeGcZY8stRdVkgGhiDln3yQ5LxmqSWr4i9zIcJFz0zfsobOVbHPx2Wo3c+zp4Qo3d2WvKMC9S qKHcZngglEppklaE/EDJIX83T9lPMDdg2yI9oWCHxLYDvguUFYIg8xcVE0mWIkEQcRILkVxvV k5Ualh/6T56zYez6mbthhUVMnCfMtJCkdAq2PxJbyJYovtnPZpa8Ce8vYjLUKWppwDmK5FHDv JXG7eX2lcdFtWpaHT7R5y6uoXJBngAj48KDaqlLvRd9d+h+2xy63+q/HpgurFGdhAmyCayLSR bDyfDbXYqaQ1UyRrhTcSQwcbo0ELvbYfNOLdMgV/G0PN2Ko6+H/mfLWcA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo --- 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 3a1cb51cbc91..21896adeb172 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, 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) {