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: 12904413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00BC9CCA473 for ; Sun, 3 Jul 2022 17:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4aOYTDE025Fb/Qj2ZQ5QgmtaniUm7u0EC7YyIVqXVCE=; b=mkvjJiUawxD6oI wBfjaFK58GdM+Pqa00LX3EH67UHWBKsvAOdgyr9I2/wv4NnFViCsiIT9rEazW3sTraf6ODlhgUhmp wO0N1KqBxFEcODlqtIX5zoLghxr49STB5Rckmoxk3q3RuOmyb0bT0U2vrVZOxELXel+wzDrQwgaF4 yCWHK9WpfBoAcZ30Q4G6LmHx0/MWZ1ORlUvrdmQ6MRO/gXb3QSVpEtGVbSQNtdZA6mmhQjc9rV9iQ IF20AtgEomnb8jj8obmtJ8vUAKpVig89p5KQ4BOvPrwhXxZxSSnLEdzN9KSFiBlHIjp5xU2Xwdl+Z MIIIHzz0mGf3AawtIETw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yi-00HMVH-ON; Sun, 03 Jul 2022 17:01:48 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82ye-00HMR6-Az for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:46 +0000 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100144_874238_4583C687 X-CRM114-Status: GOOD ( 14.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo In 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: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: 12904417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60C84C43334 for ; Sun, 3 Jul 2022 17:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vt/xzYp3fZGm463ujYvNaZ6WFNwOLVO2tua8Pla0n4M=; b=kU2mmmY57Z7J9u H24mXfmYr8eemr9ImplyUy6eKtUB5xq+FQqax/QLvg/5ofr5R03dm8rF/MGZBnazN9Vz0trGN8Kl9 sVorFRoy4DZjiz0yiFPZ8sEspG9ADZLYf3qZ8JbTHsX8RPvaNxu3gea04QIJGtpfjP6udLQje80xv d00iqZw1uPConar3NKWkxZ8cFWy8xkPAsTDQ3LqAzbXzFgbf80lTtTl997Jsj2wnwI9PmO+IXd0zu kckjowxCx2PO4GRJWpmTBmIgI4Qe4+s9mnHgb4Cj80yRE9+AyB3/8h6cDr24kCiKlOrDBlnZDMId0 hSRePMS9V21SqvK+PArw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82zd-00HMza-7y; Sun, 03 Jul 2022 17:02:45 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yf-00HMR0-Oe for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867690; bh=4T+L3fj2rIaDf0LyMh9vktfUXwU/37+/jmdujXAyxz0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=FEuqHqg0WG5nVktHv6xCd3W1Ld6jtB5zAnlm/hfeHGjRN6Yvx+WK7KZ0ix1XOe/KH Xz2o8FO+6xxwOB7ztgX+NX3bVE6WtFKxUf6wsoQHWizke8Wf4wPpYI5FKUGIAYl1RT z0BrGsQRBedJMDB5HbP8B4dl8XpeKYnXsLUIHS2c= 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 1N1wq3-1nRnF52VdB-012Kq0; 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 2/9] serial: core, 8250: set RS485 termination gpio in serial core Date: Sun, 3 Jul 2022 19:00:32 +0200 Message-Id: <20220703170039.2058202-3-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:R+T9lTd5QNKfU/UVz9Zl9hUp72gfyo/5kcqc7ITMzukGKBCRWX+ igQ4FnN+qs1jxL/Sq2SfxXLcA8lc6ToVFJuQMItUdRh04VQQ3nGqPGCdyhnnzDMSq/XxivC rcAB5CHDsNN986vE8DN8LcHJeuOAFeIBGDJw+OzV9XGU1yjia5dPB65u8RL3sDOxMA6b69B ajJNcwPkDzRq9vEzlvjMg== X-UI-Out-Filterresults: notjunk:1;V03:K0:VGcbVIfRMao=:/7A90dMhuM6exf6PSho3Rv +HmiAaN/vZ0khcOt75Ls70aICa8xr5x1aDIYtA5WX8oWL08fBYV/C8GZIOoBO5bBjy0ecgd/Z isKGaYxm1dVkZCYbIJ5fumRtuJ3qVaLqur1w2YWCeRLma81CJ7IJYiwEVJltmIHPRE+UfdKf5 UHXfTuE6BupZ247plxA8quuUymIpPsnywZdbCt1LNF087AHBwLsQr41FXXLeJXfnLN9WXp6or B0BTzTi7U1SodMU+/Q6C3wttYH766/ZT+OmCg1fjOZjbdtfYm62lC3SclIaBMbOnXcTjzst7l WzQ0KgDG8ukL2WTbGiMWt/4c/9le7Dg94H+BhuuFUkqW0oeMOIGDfi1nbWimUkFq8mPyI9yeD kkeTzsY3OaxfrlINafetA/H9AckDIXlmrU07XmMQ6bUfZEUJwFALkC1X1e62og0BDBss1wSR2 s7ZMqSUQ5EVK6SfUxYvJcg2c6iqGCSHa/AlTrmybJG94nCyY1DWkjFnDHLO/Ivjn6NalwdZfj Y5J1KcgLwGeKXLZp6cIXYispu+PEX9DGz98vWw1EbBUhd8mHuB/5ytv6ZusUz3LyRWxqrq2It gwJ+NBm0p81uKpAFdEU+cKpsnBjTx/lPW5nlZ2H2xcXZWk8u1x0khyT3VOt8xI6UjkGtGHPLU TiE0mGBmTPW9tkFhZa+Y0bLcpoLzzPlzqcTi61NNS/uGuOkw7VODOovMCz1khl+PFJVPqzB8s xQKpe1YgNFpYAaMiMtyml0B3YDINDsMKTxAFQSE3fnUWV8j+8BKiJIzG0iW3mkiMUi76M5eB/ AKrMnc6y2FDwGHcR/crZaU++34um5YhKei4KDIcxW2j+uJPzuPMfzFgawUh0OH5koJh36JpaZ 9S1pabv9aVkZBL6iAngcJK73Qw8pVAcbfcw9A1zf2azLRypkN5qGnq8XzED2UtQAch/WacOv/ bXJUkQn41u4O9BDyOqkJTNtBgJtFDE2PEzA+CmVKOUzaXeTsBFrqxTF4BzUyxoyX4iNZ5Yv3k v7jtFg4PdlSIOzm+5S70okhmX/J8BNd2TUPCeO2fL+cU15TaDlG7TDSel0eds6ysiClwqiR7G 9GgOI6ZkBqiabwN3VsqOED5hyBNiPpS8ulfrW1YenrA/d21STfPn1kAgg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100146_112324_96628C02 X-CRM114-Status: GOOD ( 14.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo In serial8250_em485_config() the termination GPIO is set with the uart_port spinlock held. This is an issue if setting the GPIO line can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Fix this by setting the termination line outside of the uart_port spinlock in the serial core and using gpiod_set_value_cansleep() which instead of gpiod_set_value() allows to sleep. Beside fixing the termination GPIO line setting for the 8250 driver this change also makes setting the termination GPIO generic for all UART drivers. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/8250/8250_port.c | 3 --- drivers/tty/serial/serial_core.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index ed2a606f2da7..72252d956f17 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -676,9 +676,6 @@ int serial8250_em485_config(struct uart_port *port, struct ktermios *termios, rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; } - gpiod_set_value(port->rs485_term_gpio, - rs485->flags & SER_RS485_TERMINATE_BUS); - /* * Both serial8250_em485_init() and serial8250_em485_destroy() * are idempotent. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 3768663dfa4d..9c29d031b404 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1358,12 +1358,23 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 memset(rs485->padding1, 0, sizeof(rs485->padding1)); } +static void uart_set_rs485_termination(struct uart_port *port, + const struct serial_rs485 *rs485) +{ + if (!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, NULL, rs485); if (ret) @@ -1406,6 +1417,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, if (ret) return ret; uart_sanitize_serial_rs485(port, &rs485); + uart_set_rs485_termination(port, &rs485); spin_lock_irqsave(&port->lock, flags); ret = port->rs485_config(port, &tty->termios, &rs485); From patchwork Sun Jul 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: 12904419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E7B8C433EF for ; Sun, 3 Jul 2022 17:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DZ53VkwIsv5HGG/0PH3KYx/GX0tqE2xeHXWSJZSsUxs=; b=Gt+7wdUQt1R5m2 hfxWHAi/V93LqaDcLF6s3JpulFD6i7bPSbEyajjoqCLauzvtqH3CUME3iZMuP+gUuiPQpQOvdKEQU 9NG2ldA876amSVckeq9hv4p8hSZ8a4RG8AScF7fSXIPwa4SSF7HpVV/5nXDg8dApa9ycJMBVWJvBb L3jxGYfFxlehI+JhBBNR16o4dmB3e5vzIa7gvH4YV5GmO5dVH2G2mKsKRCIQhq8MXP9AjAxqUcGUX /fsF6Lt2lCO1y8Z2MJgEghjMbN0+rvEV4w3wEsFTIr4oZNpn779o6IcBvACtQKV/r7/wqCn+la2t2 MU9QqhgRIj76eicEtQdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o830Z-00HNbA-EP; Sun, 03 Jul 2022 17:03:43 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yk-00HMVl-FX for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:52 +0000 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100150_880237_0F3C78E3 X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo Move the sanitizing of RS485 delays out of uart_sanitize_serial_rs485() into the new function uart_sanitize_serial_rs485_delays(). Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/serial_core.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 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: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: 12904411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C91D7C43334 for ; Sun, 3 Jul 2022 17:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tNaiF9x3jEgnufvGs8gG/P6Xu8PEkOgpLyTUA67W1HQ=; b=b5TTP+ZXaVfpCM AV6ZiBwKQGTK5I6um4aaxm/PZEUahRxgDKiO+BTiXJ7U8HndCyDzSgc8AmB1OONM1n/ovVBxXDmyq Wh6VXyrUMGwFWCcDFcgsS0eEQRaHEgznn+Q59GpcdtzeroHbo27R8R9mf0IIlOi7P2SoUsehssZAx zruyOfelhbOupcxKq6Y/r/8AqAZZ0B1ydYOQrJi2D998sIAumHXREkKqLmokAROr2cFiGFl3WpJYf S9i8b8gO2m/ACjeSwZ19bdfmfE/bU7yQrKvUXAAmrMBFZDxzqmRG7fXdvZdWiyaMQlewkHHI52o/n L6pXoYFgm0qCANGqXpNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82z0-00HMd9-Ez; Sun, 03 Jul 2022 17:02:06 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82ye-00HMQz-UH for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867691; bh=jKGdNVXp94SoOUgUewE1NIzx0yJCaYTRp187GnBOMW4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=IdYRVDSfnKdRTqfbijTq75loOiKhXz0iGBmFcIybPlhuEB7WCxUiL1tLQ0TW2/IqD RNmBrAQjtiISIkg1lmTQSpL0aaQAVKVedklnB46snDTMFxBXFjC5yBXImMXZCrxGqm 54SakHGE+SuOiiwOr0Giwy/V1J6YdgOI8L/9TZAc= 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 1N3bWr-1nQ9Lk1rL1-010gwU; 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 4/9] serial: core: sanitize RS485 delays read from device tree Date: Sun, 3 Jul 2022 19:00:34 +0200 Message-Id: <20220703170039.2058202-5-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:T7olYTqQ/ItpDdzzZ0sa8NhSXZigBDn8hZLyCYIVpVdN+Yl4A0l gKtUUNf/JIQZTpEoIvJ/aWKONaAqk9IYmx6b/2PjYRMG0GKIHWnQR9lFp7DmiBVkINSjXYO CKnfNclFkaQkOakE3eRkWU66rWPdchZ5ZcO1UeWB9Gof22isYI9fSAHVLBBJVjEhRBi1hvb jHGlOSc2Om9ie9jQwCsDw== X-UI-Out-Filterresults: notjunk:1;V03:K0:wKpdk3bch9s=:7wpOqGIdGZ0su1rFiDQoeA mHIWlXxqi0yyXausNIce6//3ZetYWu4UpJ1Pj9r0nl9FsO+dCSXf60Xk+qMcoiVQ8fMURbbxk Zz2e4BiefpIi9IIm2oZW4zSE6+kuL1NpRXBwDfFDm4DcvdarhO5v49vpdrqLauytBeJv4plhK 7twQ/0p+KcRciPUK5/Oh2rIKMzhEJTGtDIqWEOcpjmFj9jrji0Gb/f34NemHYiaOVrNxqyOfF 9pWVQotKcA1I9N0exCLBf+fD+lnewfyX7vMm2NYo4ya/O+T1Y9WW+izcLFlrLMQ+m8bF3XpZC WflnysQ+cR1jBYCxbXJEkS/TK8WB8bMduDT7VMuxPqaOfiOsF4ZZ0X97WPd7BworBzuhuVWDk yLbKZfwaGz8QAN451Ztzdmt8bW9XBnw0Asoj4KDl6hFj0bHVFs5GBLTFlO2RlBla5/VeGSqNQ D2df0ULrZ+BPG18z0nl25WCBgxNDrXndRB3WhUFmdAOBglWexZGl/ghE4wM/yJn9VW/Q4at1V EjQiEWjzh+QGsrdMV/Nh9+30sFeZqEmpcK3GVzJkzbXaOJf7kVbkw9nAVCKQ1wgGeWXjBZp/I qOJ/Y1kB/cEfZxF2yD+qykGcxSUbZ1R6P6dTntySgBJcUA+J2SYsUiIwkkOexZNrd6kkdOUYJ tbReqgxbj8X8ZCd2RVk0Sdi8mZnYCqHaneuRYzqGfpktbdihT8EkPw3kFT/Qn2CUZC0zJ7Ne5 j0BZY5Ygm9SVZnK1e70wsB0AKqgKClXe4C/6d5MFgt3bO8CTx34rrFpK6RhFzzH45FgnZm/SS zsrzKKwmJiDmTOXfYNiXH4C3XZiAts5ZewHammc4gdxbwnWNnlQa9H9KthRV2BlHh4ZQ0X4y8 NtQXXus2hZ0NwP/B42FKQk6QXJncDlR3LnjBQeDYmC9QQ+pi0VfQWftusGISxwlTPOpCK7Y5y dx9E/ZbSGvdjmYyWzwmd2VL45AU+NklDf7mNIniV7Wxch/WzdfN3QCByZ9VN+3YAv+7SbeP+8 KFstWGx7uocQzTGw8ty0x4KysRjmobl7U9fEVUefHLx5BKMQerJRgntApNIkorvX1Bmd8z6t7 tY1pvovH1gi0svjyZQdN0sF7sKm4Wr79g2/kM9IYxN0ggtGXbhsbrOAng== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100145_304597_E8802FEA X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo 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 05ed3acad09a..58cdad5f45dd 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3395,6 +3395,8 @@ int uart_get_rs485_mode(struct uart_port *port) rs485conf->delay_rts_after_send = 0; } + uart_sanitize_serial_rs485_delays(port, rs485conf); + /* * Clear full-duplex and enabled flags, set RTS polarity to active high * to get to a defined state with the following properties: From patchwork Sun Jul 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: 12904415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0E88C43334 for ; Sun, 3 Jul 2022 17:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JnsE5FJ8v5+dFgEZ+sPds8Az6Gglc8S9tgMstH/FsIg=; b=M+HgbtBcC2bedP PllAxJU/C+FSGtJfJObCokU1HJM/W/Rg4kQ7+XE40PVcDkKKDQr2Z8r57b6ddGSpwiol1eGw+vB5K fIBfJFotNJGEVtuY55M9Oa+w5rP1B3DwxuWhP2CQkoOC3aP8cTzKdV8QlKDaMlaqONEcqVvxDsj1b B98w+PlyCjGD6GeXHFbbxDLkYibeCreQ8LlrhImYAzo3mAEcfA4BNJW8UGII3Ned+SlO5DNzuOF4U UGXJhol/nDbcFfpq+3Xa2k7UQC9ifffruh6F6jH+Ju7JrpJiNRJWqmnKCKW2EJRZbY5AngFV/vtz3 9Db5482H+vfo9Jp03xwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82zI-00HMnz-AB; Sun, 03 Jul 2022 17:02:24 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yf-00HMRG-L9 for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:48 +0000 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100146_008955_60F5C8F1 X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo Currently the documentation claims that a maximum of 1000 msecs is allowed for RTS delays. However nothing actually checks the values read from device tree/ACPI and so it is possible to set much higher values. There is already a maximum of 100 ms enforced for RTS delays that are set via the uart TIOCSRS485 ioctl. To be consistent with that use the same limit for DT/ACPI values. Although this change is visible to userspace the risk of breaking anything when reducing the max delays from 1000 to 100 ms should be very low, since 100 ms is already a very high maximum for delays that are usually rather in the usecs range. Signed-off-by: Lino Sanfilippo Acked-by: Rob Herring --- Documentation/devicetree/bindings/serial/rs485.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/rs485.yaml b/Documentation/devicetree/bindings/serial/rs485.yaml index f2c9c9fe6aa7..90a1bab40f05 100644 --- a/Documentation/devicetree/bindings/serial/rs485.yaml +++ b/Documentation/devicetree/bindings/serial/rs485.yaml @@ -22,12 +22,12 @@ properties: - description: Delay between rts signal and beginning of data sent in milliseconds. It corresponds to the delay before sending data. default: 0 - maximum: 1000 + maximum: 100 - description: Delay between end of data sent and rts signal in milliseconds. It corresponds to the delay after sending data and actual release of the line. default: 0 - maximum: 1000 + maximum: 100 rs485-rts-active-low: description: drive RTS low when sending (default is high). From patchwork Sun Jul 3 17:00:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12904416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD3A7C433EF for ; Sun, 3 Jul 2022 17:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B+AY5DnSCrp3bfKxfO6zX56idmpUDdKGDbE6kJprDvA=; b=eirmfvHz4g28Ew kq0c9WrSWqUEC0z9YeRJPvKpk6EsBbbromNp9/gDtKDGE/9LvvMZKx4SvUomNBsoIdRS33ngIJ67V gbJwRsfWgVe+EPr4wXyveBEKIjxMh5nAvzzk6JhDGiLA2e2T7ee639XAcPOLVe8O9ss1n9NQ9oatc 5Lqxl2xcfKjz3zzOs0PhEHGsrqg8sfZEYzhPubN/1Qlq9MAm7S8bPw5qHtafpMIKChqfxxdYcmAvt OeLnJLyiFDsePmai+f4iw9N2MGYOBqE1I0FQaOLQV9YFCeY6KLPNZi0s1tkdQlbKu0OtCvTfBPR3f QYo9yAPMPoNfUw1ih52A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82zS-00HMtQ-D0; Sun, 03 Jul 2022 17:02:34 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yf-00HMR7-7D for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867692; bh=Gw9NEaUgWzJlqBYAtK80pixVAewS3QXQKW91nfrstD4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=BCHYoqoDyTIfRPQSP3pz0be+L6Y1yTs6mrMlhnaZnGTDscZFIVEkw8Ftu04175ys3 X3zc7nRc0Po0E5D37M+aS5FkWDUfPVkbhPftmLfWAY6+hApnEq1P2nxfn48dFJngCK J1vXAqZbjgSh0CFbemTj9mVXrrcvMhrEj20bVGow= 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 1MNswE-1nwzH21HTM-00OH3R; 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 6/9] serial: 8250_dwlib: remove redundant sanity check for RS485 flags Date: Sun, 3 Jul 2022 19:00:36 +0200 Message-Id: <20220703170039.2058202-7-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:AgTxFL7r7/KltmrTUlOEyF+V9kwKsTZye9xp8F5aWwyBq8ROOC2 EYKSeYZn/3j3mXtxqxwFZ1NysE7MZAMpa+L2/MmHtLd6P1vinXWmbw3YgzHVbqZyq5banr3 WOXMu+dT7Vuo/+aM4npJVetk6Nvg2fYMm6GVIh6cF5D8M8VM3xCdx2p6D9ARd33aeVhH1mN yehDL7OmHW3Q/UGXUAe3Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:nJntR4xGIIk=:Pls7E2ZPEwkgHAQsyIXXV4 u/ukUxSVSSvAi/N/kVlpce3DvTZp+9icN7FPaBVPfKmi6l596lpz2JO8VdYVzs3awEQaiYbO8 9FlJFEYC+ts9u1HkIfHBi0B7RF57Vt41b0za55P4otAB3vpJcyfT3PrspM0gJyz2f59iC4ML5 sCLZegmqe3LnoFdMfLJqEc3nwqzXlu7MUvxJxLOPhHLBCllnJsvxgohSe9wCTJcjyOoKHsVy1 qxO9KTm2/xqJudMglYBiQl0CHsNHk6pEwVSThsdyLGrTUsyq0ydEjZ8giwAbf2H0/Cjz6NSOs sumuhDhNmostSZeUCHixXw/q4PCHvN5gFzPhPwRpz8EOl7z/tQfBXTEPDZvHQRm+x/ypJT1G5 kN6FB/eMyJDIGGFxpxPScIQ3znmgSp/HNkCu1bjm76amVb5a3nThvi/MlK9g2yh8Dw1gumDmm v03p+ShkXtUU+dp5MxIur+rG0Y94UVG4nWZJO0+MPnFKAEE1WPepxCaAQVxPXhhhrcXeevURx huYdyiewGQNkfNR/ux7gIVnklM6vnrLtFfCa2I9XeJ1+T0NRSGt+/v6nu8V1IbK8G/wTdgC6d ziPX79u1eHaQWQrt58TiKkK/veuWUaIX+HF94oAy+AbcY5sTzmW019gQj01nsc/N61mAqA2vy W/ckBKonz8Vglm6q9yTZgh+FjsoWHNSjwX7Cfn35qhOIKS9STBx4lY6RP4OzsOt9dnzbHsgKg KgZHvGfwz81C2DrBOHHwelwPeiOO7tKGMhr/gdSgzVXzu6+DkK2HdhIj+UJm6A59CicVoy2Q/ Ive5KhtIyJThnK76lqX2UY8xhsPAsdFuyuAV30hux9LDfzD2uC7rUJPQKj9oB1q53PQadaiRk ajcrdDjXxoiCSVH7c01xD2YhIj6ZN4Gc99wA4SjQqKnnaRFkfDQSEV/JI693rI3K/IRWUU0C7 BvW0zP5MGwLrCSN+nu/plLr0Kja7ofBu+nfDfG59AehsFW8yQXowz/SK9MhOQs4Hxis6aMCFM JBE19nyxxniF0+LU9YIqvidZY6jbRkyAU8bWo2Uni8nhZHqeGw5u738Ful3ExGQOVKDoExlGx MeMPq+bgywM2dUWntvAqS7yBBgyHVIcW4iufZGSRwUhcCYHWMiA1eXf/A== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100145_610034_A927E2B6 X-CRM114-Status: GOOD ( 12.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_dwlib.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c index a8bbed74ea70..f4ae262d00fb 100644 --- a/drivers/tty/serial/8250/8250_dwlib.c +++ b/drivers/tty/serial/8250/8250_dwlib.c @@ -187,16 +187,10 @@ static int dw8250_rs485_config(struct uart_port *p, struct ktermios *termios, if (rs485->flags & SER_RS485_ENABLED) { tcr |= DW_UART_TCR_RS485_EN; - if (rs485->flags & SER_RS485_RX_DURING_TX) { + if (rs485->flags & SER_RS485_RX_DURING_TX) tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE; - } else { - /* HW does not support same DE level for tx and rx */ - if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) - return -EINVAL; - + else tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE; - } dw8250_writel_ext(p, DW_UART_DE_EN, 1); dw8250_writel_ext(p, DW_UART_RE_EN, 1); } else { From patchwork Sun Jul 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: 12904418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D12B7C43334 for ; Sun, 3 Jul 2022 17:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=St3alUPDYe3hTb36tM0z9A1NlAgGVZRoCPvqysBqiF0=; b=b///hBXkfI8OjB QJODcD4hGCS2Aev7pNxwHeA5g7yluzyLAqbIbRFhda8f+STe56cqykYPdC7DUgfhVt8kVFta1nHiD qI1sVmPFJfHyT60fBSXP/VWZ/W1kYNVgGRsL/pmJuT4BV1RO1AIPf0qGM0DUAgjHMHH2GwItz4Hs6 qUwW5q9UzCbIk+4104vx7aJm8FABAApr/1J0iWxg12uu1AEVHdTd+pAKZEu56vn4UH8rXY6I+2EWH zL5sTttx4aBRPh/YLIWiJJDfNxGKqxYZaHbmHpnZgjiSc+pyyjq4ZqJSqhsHPD79X/46HI5ozfMT7 6c/3pqsnVpa6ywF6520A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8302-00HNGS-WA; Sun, 03 Jul 2022 17:03:11 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yj-00HMVj-NW for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:51 +0000 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100150_124908_9A37DD1A X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo 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:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12904420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63DB7C433EF for ; Sun, 3 Jul 2022 17:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/qsr/AgcM3A7epBa5tqa5IXEGX1q+bMwyiU5EC8Iil0=; b=MMYul/NxNmxgsE 6l40396l5lxkSo65l3ee963dGpOcyh+vgAtN+RJUvJooAEm7XRCmuDn6ZbvJS7+27bl+V4ZIqwehP AkOMr0o4WbP4Ugi/6gTGGiM2e1t8uH+2GsGt40RAgX2P61W8kRHhTAgW4n3bAwj7xXadJi5LNQ8mo XGa91r7NrHqHZgJ8aJvPqt45fbjqgHDOxaa6mVb+tV9YgqP2Agkundwn4iEri5TuoetqV+f/0Dkrn IXUyfoj31xcocLDo20bD5pJ/+fCX7J0NUdunKLsS/HCBNYN/I7vVCurLtmYnJ8LyzGueu2NdJXIL1 qSBKJhd3LQRVRHEqghNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o830z-00HNsF-Em; Sun, 03 Jul 2022 17:04:09 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yl-00HMW8-5Q for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867693; bh=AAX50up9vrAlY/p/+wJUzVHbLcYBIrsT5uEQh7IkmNY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Y9+z4Autfh1ycKRvZkjfgTSyYoVnBehSUKpQ8YHzXjTP+yqmOGPmt0GFbxVbvKpqe XkIAowi8qE3JZEwhCE7X/bLrO10Vo3b9SXAGA7rtFyXahwCs0a77mdixtxQqgvxj+a KJsYPge8l7shau/QnBdFs/wZSWc1PSvKp29A9npo= 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 1MYvY2-1o3d6b0r2W-00Uutl; 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 8/9] serial: ar933x: Remove redundant assignment in rs485_config Date: Sun, 3 Jul 2022 19:00:38 +0200 Message-Id: <20220703170039.2058202-9-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:Qo0skloQF62CG0UUEStUQZSV1iogB+E/uMIFp0z7Lb6ONP5anEp cAtLLk6++A4T+0LnXbRMWpuYucEbODsNpcHSrTnjD0skN8KIuvvH64XyrcBetnCRBJ0nLBb oL9LGqWityudKugIPobY+XheImMQ8NuYWtBZ7ckB+YKAASuJ6n/zihekYWaoSnsFjL2ApkI y9hoTppvn+yMGVd4LSv/A== X-UI-Out-Filterresults: notjunk:1;V03:K0:GswIleH2Oq4=:qGXjT1EUAtBYScBPZcRc2g Kk7goyv98JI4EvKXTmuWK8gYvFCtvqB7gfVAQjg/GCoJHxxko7U1JnIIJ1K//Q9mbZEGRwtyy jkKJJBBA1PTi9wz0bCs6yzkL8bXyj13zorrSxDHAOfmzqhXBe5bi1cqr9tCvJUfBk/SUjYVEv 1GuVrsaaYZdXbVIM1o06XCrEzpbqYyQmVa9ba6PejIcOmzNa1oizwfubER32cjHVD5QdIWEIv YyleB7iSuq1hv7QRaKW0pAJH58RBlOSDr4FFNk/4sLhFrUYGt5YetjtsLJIoIhbmmRq0ECzWm aCBrzrE+JrbXZW+Ax0ULX4gUn/fs4TFuwbrjnDxE4PDzVYImiFBsMLUvKGzt5DPaeKXkgOaQR VRnx43HvqLp24aAuGz6dR54Om4bbQHZDmV4mgn3ku2XNatLu9HCl0Fo74lnF4cd/TpsqIXiEB 78/lKoljcMrCoSNLwqZOweUKlncmH1UADlwVY2AfDnkvbAT4LBIqqYklHSZ//XkqWWhJ8EJVY 4k/0bh+iergvKbyJfirXsmGo8RfJS0/AzPcJZXR/y+vBFY3JpIvW+1Bfy5Jd82qzFjioELvwB ydpEf3eKFX+aH05sUuK3SVZO8hZZSP9XF34MrOOJo9jDj1n6wYLoGMwqDIqAmlpqPmRsLC4TA Cmst+WRLIrBbOqR+60+ZlFOJD9mhIDO+1tkE/WMbMkTI6VMKHNbALvvok0Bv17J1imIRrTBaH sulpRyjQAOHQeEahqm6KBkctTw/7v03Lw9StHRpzmu7GEcdv2sU2ahwcWPzk/jEJpXlgeqyQr uPtbExaRnaK3ntacrQh1sPbyEfx8m7LeuPzMvPeqGed0mLAC/OPVeKzZRvwygG2x1frs47xnh /EMaStot/N9YFjRL++X/Jumd1w3mmSNI/3j4F2aNfi6f4C0YBATRjVWvFfwu8CwWcbkQPJWUG ngESaWIbYqHHDghMk/XwDr+3GQLA+hqivJdPp/ZaGsDn+xjyE3mkhX1UrFTwTEe17HWwW2nqm Lypwhq1CvInOJvto8vegRnQV3bpIf5qUgkLwZpkNrRT1NZlsO4aaNexrzYNxIr2nSe9IiQh4m 9pJLBpjNojGVWYPApshIRSBbG0M1+12EilhxIqGEUYzyYR9O5n1w7O6Xw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100151_575981_C2F0CE49 X-CRM114-Status: GOOD ( 11.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo In 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 dac48a330db6..e07d8a550a49 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -583,7 +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) { - port->rs485 = *rs485conf; return 0; } 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: 12904412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39687C433EF for ; Sun, 3 Jul 2022 17:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q7erC9Fk9nErO4Ss5RgLiHAOxs3BfnhG04dD6OQFrzc=; b=xaTuoyukQZUIcm NEEw1HGilanzI8tyyW0HCXoUalnWXQSDOfKVgJ4NMXewc0y81z+3dXRO0a8+HzIai5/XWc1jZyM8l 3M2jwuX9vuCWRSJUeQ1teYT8fJPmNAJzQVSsHkFnWNwD7XYiSMYQ9x3Eb3NDnAgdMuUS3hMTuLzX2 I+JXwaTdGjPJW65r4d4KQkx2KduGM9YiD4HiHS0PTEpOaoa9GLmERaqkmj2oPaGTAm7IqNu9J/7De 9fKMRWuqHhGs0iC7Iz4YQrgo9ZE2wHuJnPQaDpFXNMyQoYUUUyNpHUMxcGKxQRv8wN4otSneMjjtI Yf/96thIy1CsWflywNkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82z9-00HMim-7q; Sun, 03 Jul 2022 17:02:15 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yf-00HMRF-3I for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:47 +0000 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100145_473699_1A3DA0CB X-CRM114-Status: GOOD ( 11.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo Before the drivers rs485_config() function is called the serial core already ensures that only one of both options RTS on send or RTS after send is set. So remove the concerning sanity check in the driver function to avoid redundancy. Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_lpc18xx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_lpc18xx.c b/drivers/tty/serial/8250/8250_lpc18xx.c index 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) {