From patchwork Sun Jul 3 17:00:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 587079 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 D3007C43334 for ; Sun, 3 Jul 2022 17:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbiGCRBy (ORCPT ); Sun, 3 Jul 2022 13:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229730AbiGCRBy (ORCPT ); Sun, 3 Jul 2022 13:01:54 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BFD7615B; Sun, 3 Jul 2022 10:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867690; bh=C3f07IvyTVhB+y3Q1h44bhbt9vRcIn4vLfeS+jIHjl4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UWg1iEGo6CeHvfMMIMMD9CoHT0jbVNvQN+at0B7mf3usRzdY1V7YQN10p7whaduf4 Td0bpGFkBiZCRpROiY5W9x73UZkSpbeA/t5AzYKFhrP1WuM814C9xzxTtXsZBNGIlP dB6pbCgMy25/R0iizdNEA/ic2poIFkzPTjOdMz2Y= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.210]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxlzI-1nPIwu0lH4-00zFlf; Sun, 03 Jul 2022 19:01: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 v2 1/9] serial: core: only get RS485 termination GPIO if supported Date: Sun, 3 Jul 2022 19:00:31 +0200 Message-Id: <20220703170039.2058202-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:BNqEbx/9a7Pb1HYT5WcqGew1ocBgpWVPz7NMEroLwpfbbZWgiNG 7ZgXhoo1Tbtpsx0c8O/Tr7rLINJO3+WiwvgZ5cKUVeGOXXxz6vLlB91Yvab8Z6dDulISFZ6 RfJC5I4LfCOMl/2DuNx+yaeO7/pq2+uU/u0zO8R+liIAANAkdguZPE15z1YR4h8rGHuzPXC wR8nYf3FTb9S5SFa1lbdQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:oOHxaRj80UE=:FXzyBpuwcy/JGOnS5aO/lW Okq6c/8RULC3/s31QGDvwKmhxXuCI+RpcZwuJvTwctvF0AkUGt2H/sUiUM2lzAiJsvsHlkxft VbGjpoU77eMPiC9WXsHYImHUVXkXc7qPNDoCUvrt0Nc95/GHz/AczY1apx29If1P6fxQtdC2x GKJDPf2Wiui5VVaXfQj7v1OUpc/U2buXnJjUwrrgh6aL2ClzrH0RGPVYcNs99WXjLGcTo6lM1 ehuJ0jBbEQ6RRBQUOH3DbEMn1C9HNBDyAURLhjIydo6YhemOIm/ejEiQyryXB5dTikblqLSEb KQmjaOk1g4EXtdi4g9bp7o7lKjWB1TQTXBoNKbDpDhMjb0LxBLWhxNJpQ8RXKqJy84DiXUiJ8 7kJbXw00qPN5v5V9C11hRDi5Ayw6rZkVB87DVS+35ydmMm6LA+eGpasU5BSeuSQvvNQs/tRh2 x2nSNm3i4z+O1QpSYoJjrm4Wkdh2H93IyMzORhYGWnFR/aVea8+pBfdTVe6nQ6WKor86v9R+Z u+zsH6NKK/4U9e8660hA9kUhXOy/8R8iDxhObv2TUgTWR686vcqc3YqCr8xRM7OqHPtYeMLKJ bnzR9/dm5vl3pvisfYe3YBGdT4dmgxCa+t/9JilOIdjkiOI5d7WDw1ebIaamCIZ8+grGUfGM1 ivFitghN1blZXsYJncEElXX+YxMn630Tun5QABH1RsklORACj5tJWEKQaBgCZVMC9ZmKsDnBh Ht7Ux5vWBssGUHiiFbvIXtIjXANGBuKKR3JQThK4EKpyEHyvBXHmYHbBQ4QFmrWFx/HB+hWf9 VooZW9sgqranC7d3CHKIJ6IBt9HA+ydMKIq3+u0mPzFYpkTdvhKJqih3OaIZkZANrEYjs3Xr2 zd7aPMjN3lQs7ttcS+cemVL5/cx9y/LJP5E/g/9CVfMM8AhBdJP4CLr+PxKss/ytWIlCqii5E EDNU0mxEcx5tReyg3e4RgSrdRGbbaa5HXY63IXXyVxSzzist7x5o7vBAo6+lj2HWffuBFWOwB fFo9DUBgMHR2hBERTyicsUi/ugli6rcL9njTgY6kT+7WAY6X5l5nhNYoKyG7cTe6R2et0jLTK txuTm8H+E62W532aldkf+I/PVpgRHLb3mFLe5nGofHYGJQXaamKq3z1DQ== 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. This prevents from allocating and holding a GPIO descriptor for the drivers lifetimg that will never be used. Signed-off-by: Lino Sanfilippo --- NOTE: This patch follows the design decision that "rs485_supported" is set by the driver at initialization and cannot be modified afterwards. However the better approach would be to let the serial core modify the termination GPIO support setting based on the existence of a termination GPIO. If "rs485_supported" is not a read-only value any more in future the logic implemented in this patch should be adjusted accordingly. drivers/tty/serial/serial_core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 85ef7ef00b82..3768663dfa4d 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3404,6 +3404,16 @@ int uart_get_rs485_mode(struct uart_port *port) */ port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term", GPIOD_OUT_LOW); + + if (port->rs485_term_gpio && + !(port->rs485_supported->flags & SER_RS485_TERMINATE_BUS)) { + dev_warn(port->dev, + "%s (%d): RS485 termination gpio not supported by driver\n", + port->name, port->line); + devm_gpiod_put(dev, port->rs485_term_gpio); + port->rs485_term_gpio = NULL; + } + if (IS_ERR(port->rs485_term_gpio)) { ret = PTR_ERR(port->rs485_term_gpio); port->rs485_term_gpio = NULL; From patchwork Sun Jul 3 17:00:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 587075 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 E559BCCA47F for ; Sun, 3 Jul 2022 17:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232443AbiGCRCQ (ORCPT ); Sun, 3 Jul 2022 13:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbiGCRB6 (ORCPT ); Sun, 3 Jul 2022 13:01:58 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7936E624F; Sun, 3 Jul 2022 10:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867691; bh=jkKzvX9K2yUOdQWW1Ju0XywTrAt4odrCEHF4kNehvBc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UsQY0Eai123tThH18I4L+xXnQcNKmJgvkHWxF8zb4fdxOkrVUwgCizd6xALGqoQq5 1spIcHUfMHUlCcc30Axgx7q+OxCdmdaDt14Z1Pp3DQ9bPq6sh8jxy7nD/GQSOUoKcv DmyjNLzs403GFvdxsFfK8t1JpRu9sBolhFuI5kb8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.210]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MTAFh-1o2mQ805Dr-00Uduo; Sun, 03 Jul 2022 19:01: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 v2 3/9] serial: core: move sanitizing of RS485 delays into own function Date: Sun, 3 Jul 2022 19:00:33 +0200 Message-Id: <20220703170039.2058202-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qyH35UB6OgK9aAsVjM0R4uFEO6UXYWIXW/DoeHKNA3Jzn0ON7NF HlAakeLXfnswVxGUTkH0ckJFuTnc+GsUF8aIYaQ7io/vr3twlSjDNY3Wx4d4v+TQn45uEER ZEHHM141I6Px3YC7/bZyXYZp/b4YwMH6iPkrbwd52ZGMdVAg3c5tthynG4o1aSqjAWElLtz AB0lmeed15siiWjKhy3zg== X-UI-Out-Filterresults: notjunk:1;V03:K0:BTn1/O5BXtw=:l42TZAJHEvnFUeUpI7Ge7Q hrCdO5OC+J2dpYG9om6hc2QquHWMenwZyiETFBSuH+hlir4rmNazsfv8ni7W8Oadc2FGfioLk 2kFzGyusvkL6DGEPyv1mMUWqYji3MQBMBTt8iqPQIRoZgfaocUuZMPrWFAH+7HDyBaGV/QqkF 1gwF6KAg39pz7GXcQlM16Z0VXvPf+UMOg5Dc3xjWeBhn/YwW8K2CmrVzGOyvYfSLeGfcetQiF yl5O2NjXCUqz1UaaA13uNAZRa7dcMbrHA3qA5tPWrw7ZRGzvsklRW6A7CHsxgIywIhEpSf8fu Qj9nOTbNqFghDSxg+10vFYndBtImo2XnVQHmtlhylF8k9rF4QdOcRKNgj/wRvLfE78SrEFqY4 mwh5qOpcCfYARxPg9veH+ClBMnH8oukL5ZYIN1ga2+K+q7M/zrtC6EwMVYk3KOkfDxCXErEon BpelQo/l+MQH9FXHULf3f/BwdGT6vy0nbhYUwel3IjjF0GuFuivgO0R9YWS/knYXk3e6DbncK K6570yZiW4t3lW+ZN3xqxSiw/OvuTwtVgQds/V+ru9mFfb6WNduBxB8iGMGtdt9RffC/7unRf +y925rk5IXM1xmjZ8rXwlwckvFGNypCmhktkulKzjaqwj+uOgdD7+2lNhhoyw18gUccC37PqB 60ncuGo4B2ymiQsSa0pE5Ld5ddqz/g0ss9e4X8e3D0KQhGJQe1uBPvpA6uqA83Ujv1UOI0zqs kEnwPo9SXeRecy2j7lTm9K39f6IVUB2dZ+6Sa01/X6y4jwk0e2TSNuuKQaAF7G/dF6mhPBo9S b0/u1M2qPPzWorvxHYU/u4VkBmx3AGXJDAhkTU5nyt3BZ0TimWcKrUq0foNksNwHzhY6vGDC8 l1tHudumo7mx88Chc4dbxNO1o9ogoEvH87HnoKvZ8/qg/iz3ccrHjEzQpBfHg3y4Dt/Y24YxJ +6bCos7IRBbKlgrXReSLDRbXRkENHLoG/a6blFNyh8Kcs2Nhd4IQqVy3bNyGdsyIFqgK4422F 0wA36G1RHePgcNP86hn6/QEQziIrGbx/i+IaKTJ59qU6BrIe6MBZ56vjbu6ll3bDU4lyDW6aV h7Ua8nDsH1H19zG06xBk2LDhaGL5he2BflcVjwwrf+jPZ0WsImSZ4JgsQ== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Move the sanitizing of RS485 delays out of uart_sanitize_serial_rs485() into the new function uart_sanitize_serial_rs485_delays(). Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/serial_core.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 9c29d031b404..05ed3acad09a 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 3 17:00:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 587078 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 5B989CCA473 for ; Sun, 3 Jul 2022 17:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbiGCRB4 (ORCPT ); Sun, 3 Jul 2022 13:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbiGCRBz (ORCPT ); Sun, 3 Jul 2022 13:01:55 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 427DC6255; Sun, 3 Jul 2022 10:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867692; bh=EM1zIbFY/PJTPZZLlKcGTkRY1PczN69X+ZbPoyUQEKE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=G3bWZbl2JaB90fUHC1g/izQgwL/3d0qlV6v3tSQBsHpG78BysBo4wC25NtNBrx7+w g8NIK7REGsDgO86K+v/Ja/wZBFFAh30H0gcqz8QZbdrFEj+0ajdJ618Pq4/bsHa+Fw DZ/8GBvzVjXF6R/mXyx70WHaNLXWwRBI9YBfofyQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.210]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MhU9Z-1ndOvI3izr-00eZYA; Sun, 03 Jul 2022 19:01: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 v2 5/9] dt_bindings: rs485: Correct delay values Date: Sun, 3 Jul 2022 19:00:35 +0200 Message-Id: <20220703170039.2058202-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bHhKUQrpvxEfQLDnA/B6qLNzCXgXuk8x5oOAJ9OM/fcBNvvd46G VxPFhxseBHLy1gfuNFr2susLgd2MviSP9QUS25CF/wjFGsoA8rBUkedVWueukBPXDSfTJKV 30UFURnT7zuEzfu5WGVu9zv6a5/c4MAAM7wSNDzZKIHfx+Jlv2wFCVQSle/Cis61j0aJcW+ eQ0cFQFwBIlPzZncLsjWQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:YCM95pyK50M=:PE9osGNTq6W4U2Rh6hQkj5 gNeGezDhq2uT853atR4YjVF+lv2LA0J0RCzAqLNcaa/tr29AFLMfMGUGb6scYWaaDZTC5MGR9 MBqqK5GZuMpJaORxsL7w9bKvUc6R3jAhUkPFKMaGNiYGLgE00OvJuPaKKOGQJWNeQrQtSCdwK 0mR3m6uFg2KXC5OLBgL23mBJTbN9/cE5aB67jmC/Iko8Dqwzb7ObAST6WYEozpYbOfVNJJzNv 7HZA7kwOZPNEYuWk1CxVPd6xFV67PQ7e2Cmy2Z96JLxixZGSbOQgNTzN8w7WroxnJWXKYbs2P wofIXXgBvl8LxvRg13h+ShDPOovMAD8tRhOuSugkws7LgGNQW/czWYxtjsfQ08YrVoZ/SCmNr 6LvjijvBuk2jgVg2jCnpWIzeBcdC9LMzBiKC4SF/YcJFnuFA+zkyRzQ+W5fvrsMNbIZb2Un3E CZ33kuJnxTp63hoevF41AQ1AkkmRMkLvd5gLJUW3Ujxeplqny8ZBiBwK/ScGmGDr+kyku8r21 ylmHYjYy3nmZAHI4MeGVUqb2W1aMYCDLd7qdLy2CM/fKRYdpGJpPz9VmNp7uOPILrKdymBBeM yI4ZOomHeR/Gev3rTSDICjpWVxmByA2c1B1Q/CQHTfWgMowtOetUVpHY/Oq5JZDjdq9OcXd+t txPq4f8xjdLll2cXy0PvgVuhLYaWyWCQVztT7QeikkK8aIR73oZ8XBDeu+V6dTG8nIh18rYCq DSvQ3pjORN/QMOZ0vv9o+D8Blp3VWUG8rBgeJJ+g3H00BXAp9mopGo/KB6CvbGK1QlzrU3+GW +yoRh19pkwRyHhOqKd39upyBQsLBz/X3FKVcErxHiBMUPFCEfweBvYQQ0bJuF7RtUfdyCmBfE yjwm5ggGIj0oXt2znPXEvi0rhFAXh4mvqlcW1QhNQVcKzcYa8g/4j9xPa/alKiAVp3NRBQg/Q +6ur7alcw3lfjAINLmzPIrSckkYVwSQ27LGrXX/qC+VlyYfW7FuLSdFAxMyhjI4crtsHIN57q 7TBQX/Uez5KYyhSCiCd/CfTXd40cGVOBnN9mBRyLS+1Hn/FQspBp2iTlgYPtQeFCnP/HTlZ8A Ee9+4Z7cqNEMN4uoghE9Q/8p7abMwgTsXcCjgtIIEKh+2blSXRya4zjhA== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Currently the documentation claims that a maximum of 1000 msecs is allowed for RTS delays. However nothing actually checks the values read from device tree/ACPI and so it is possible to set much higher values. There is already a maximum of 100 ms enforced for RTS delays that are set via the uart TIOCSRS485 ioctl. To be consistent with that use the same limit for DT/ACPI values. Although this change is visible to userspace the risk of breaking anything when reducing the max delays from 1000 to 100 ms should be very low, since 100 ms is already a very high maximum for delays that are usually rather in the usecs range. Signed-off-by: Lino Sanfilippo --- 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 3 17:00:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 587076 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 A9887CCA483 for ; Sun, 3 Jul 2022 17:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbiGCRCO (ORCPT ); Sun, 3 Jul 2022 13:02:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232564AbiGCRB5 (ORCPT ); Sun, 3 Jul 2022 13:01:57 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DFC3615B; Sun, 3 Jul 2022 10:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867693; bh=nviYHbsk7MUrNRrU2LChICEnd9k2yAJfBhTih4EkRFU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=bfdg9Q49+9fanC418tQVocQrYkJukV2m2YyGouT3Gtfn9930Ay67FU8PMbEX2Ncvo VASUlpgLNTfF+bQC6ikmKXX10KopUCt0Dpfe42ofDYkYRLW9G3C++1NiUUo0TRFi04 4LUemO34zsS9GxuSSISO8GiX5ZjkuAinkZmPgM7o= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.210]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtfNl-1nKbyt39up-00v91q; Sun, 03 Jul 2022 19:01: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 v2 7/9] serial: ar933x: Fix check for RS485 support Date: Sun, 3 Jul 2022 19:00:37 +0200 Message-Id: <20220703170039.2058202-8-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VoZAD9Dbxt7x089Nyq0L5L28YRZ0OXJkTCsDYq8757Tu1x7ijrb 1s3UwQ7BRlBMhPG9SvgbwyjHMfPBn5G7Zc9ba0MC107DvPp1VJqChWY2oeiFtO6WtuVxNA3 UaZ7cGMKvIj9AXKhn2DsI/eQhmBIbFeXjMP+TrR2OySjsUSb35l2VTPBip44TNBWdNK5MBE VLqQ1oI1j6MzoLicOuncA== X-UI-Out-Filterresults: notjunk:1;V03:K0:fI0Hk2c+rTM=:1XyIzL8b6fUbwwxLVUcz2o tl9xpNLJF40NPd6lue0eD5eU/48Xii+Y0WhsQrWxTkjg+37M/Hj9EX81+NeD35yfIbqVMfaMI +/NStccZRRwhwqcwQZ4MxTtZRvGsf4YzGc6k5TQGoHfsbmUEabln34I2k0AHsT7L9o3VRkhWX tpIL2xiSlRF6Zn4XpDq9BCdcdRcINuROys9s0+g4SuRYxsYBPbgVfPguLuwM6Gtxeya7d/47P 5waOEkawMoQOSmL3BGogEhtL+YcFyJMKprrZ9iT88igOY2kqQ95ycbe4SURJ7wQWWs5nO+umM N0b1+UOK33mxlbiwubQWA37GpmbUhHmulsdr3ytTdV9xq5TbuktW6OPly92PgH0XApi82Myiq B/aTfI3cbiMne4rb0B3+qw7kdh+FUUp81yUhtZKaryT24NkyvckG/9NpZPRa8CldQVNcPv4tC q8ZugZY7MexU+AlZdGNcdhwsqMxyQ5UVnGIlDhikXFnPelqtCKRwsQXXEdoY6pvD8rU2x3Apf dGySC+FR1dc1iVmIATkQOKhAX4C0pdxgHOe3EN5GFnFq7iHYQAdncuhOzh6NOgNLj/JFfzjhJ FywHCMR6UzahErs67Boudc+LR+XVaQt3GshuhixTk+Qt9D5I5PyXwuWON1iwMJ+ouh1btTKYb gjUBd5L3W8rFf7UkCw2yJlpNundDpnTRFEl/ti+gYMzYyebTXIrocGy0Ojmker/fWdBMXckxT PRFt5wYgzS1P5xUO+uKLK8Zu5sTW5t4/QQhbnUeTyoXFhUUHQJKhhXlelEB2yf8Sz1kn5SiPn g8OvF0Hosp3M+9ZfW5qs5Y5kVmjWq/WQFKZLcrG5ZVDYzz/KnS3o9N3c9mYU4xDeAI/NpLAYo RZ5A4n8I5sXCxWZGNP2VdzpS1Va8Qz/Q0l4yifOV3jsrj8sY6WQg0VFLTeYInQ9YyqiuWpcZv gcPEDVJllns4/zpaeayYvNIJ9YzMN/e749djGIpm7wCZotQefi2xB2c7gdfFKSWm/hB106m4q Mn/gw9P4T/zl6OMY91B84wkxb0zX65tAhnLV5VMXNCNQkbbRKzxJsVzbBIeQXD3TJihR5aap/ Qh7ZIf3nhmME+JwVeyDt/XxwVbZOwJ1VCI0JXFtqeKYo4JnbSzuUnF+Mw== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Without an RTS GPIO RS485 is not possible so disable the support regardless of whether RS485 is enabled at boottime or not. Also remove the now superfluous check for the RTS GPIO in ar933x_config_rs485(). Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/ar933x_uart.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index b73ce13683db..dac48a330db6 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -583,14 +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; } @@ -798,11 +790,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 3 17:00:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 587077 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 212DBC43334 for ; Sun, 3 Jul 2022 17:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232782AbiGCRCM (ORCPT ); Sun, 3 Jul 2022 13:02:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232312AbiGCRBz (ORCPT ); Sun, 3 Jul 2022 13:01:55 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C905E627B; Sun, 3 Jul 2022 10:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867693; bh=r3dNDUDIuUE3Q0qRG27sRGL8QSUVi1dKmu2o/TP38+o=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=IrAd30hI+KUcO22l6V3kbwW5xHgsijSs1p/i71c27LXUsdMOpa0ypTKskAHkDFHpj JE/09dEVOj9gGtf7+J2t/ZqJyOpZUjJpM5FA1195w5TIH9wL6esbljwXYQL4PRcvLB WQyMBuSrwWdviCLV4NsgrRp/f5h69xVNUikzLV18= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.210]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5QJD-1o8sJs2ocP-001Oya; Sun, 03 Jul 2022 19:01:33 +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 v2 9/9] serial: 8250: lpc18xx: Remove redundant sanity check for RS485 flags Date: Sun, 3 Jul 2022 19:00:39 +0200 Message-Id: <20220703170039.2058202-10-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:KjAB4TazV/OvuLGClQIL62mGEv/0G6rRtTs5pe+N09lU9C9u8xm 81tPPKgUO4gFQ/640DbtwTghVkeUew/lXZ132Zx7lpMa7HbYuUo6nPX3HNBwTFf8pgXyXUR 1nuiwWq2ftAkbP7ADU8L6aiMNKMOe6wQAf0wbvKqGxPKe1TKDE8k2BjTm+ExZ1L9ivWvJKN o6I+B9izQFtUuVJ8eR+sw== X-UI-Out-Filterresults: notjunk:1;V03:K0:t+3L/KYJQ68=:Idxt9qmFJMRusII+8L49Aa zSEABMSFoylvJHtAm0y/CS9YVujhvonXNXu1GJTkyShWG1tLqw89/VpBtdaF2c66TTiJUgOwm KI6+f5TGj7Sjd7B0mmIFPwRVrJWSrHO3vM7edcNHpTa0JM3+RmZ3sNi8pjTpNCDuCgE5XlD2h mrm9uXPMIPy8tph8lpaYpiRBVaP7a6QTnNpWFOzQYCGe/8F6UbvMQX2oRT7BDQPOVytP02UVY YOVbhq3oqeAgMAptgRoq5CzPBVEWcvg9atN6dkcRD0mbqILD/eTf1NngAiLdn3xOlCKC4CxpV b7K0AZG7oKsqqmBarzoMIxTIObjF7JGsVyFewDGrLmOHu6UvXrKKD+M5xniRFzQaIu0378Ayn l9OH3QXdyePodceFWxarQrhf9GjXbzyVfh+YUILaK66fCx3LQft7Fhs95ccWKhpSY8Lms/RjF oRaGf0tZRFvnWA0rG4FoyI/tfd2Gb1iXqJkvC5VU1XQvcLDHmSDGo2fucc75oMYg9mD+zgu0b zoUGA4hSinXPuCh9TNIZOO6FVjA2Tw1dpnedxUfdcoSFziSRa8ZSYbVHGb1h3gGHx2TvXwoRr 4punAqCmgyhw/2/ug6fo7J4XW1Rqnp/nObBb3v3Mj0XfDN73Mcu5BvDuzpcne86IAjsKaX8km j3s4M96Mn72DBI+KiGyZS7wbiTLx/3dHJO4TZwLGMVOq7DuH6kfDfoah10cmEL4rEvPiX9Jph cPuQp1f4KdPpcu3jlt2m8Mc4P1hzY7bF924o6/Q6V5kSX5os8/S5uygtT/O8NjWCrfpSHIYvA ttZh7Kuiuasvf5BU3ZwBriZXY+oPOYCSO/aNB9B/BmmFpdJYcSVZTYKxqcbM2qY/sbazuHT94 uKvBfT88apH4yV1gcuhKhapJfubzTZl0DF46zvBeH89MH7ohbCBE/8tAJDUi5lkPNEYBboYuP IkUAB7IH7MJFUvrbj7S7wI4HGgW2TNPi+IvwqXAwfbJbuyw4/fXty4WBMHthI46HvQnULV1l4 N617UjZIHNOtqa1OkMSiAlUb3GPobKsTfHmbGXaziwEo8xCgHURaTxPLbz8vaAfpZ4Jyr7OFm 7yElBeI/pR2ocJKJx826lpW4oRhiwYe0BsN/13CYajy+gHb9xgBdcVngw== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_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 d7cb3bb52069..fba0bb17e536 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) {