From patchwork Wed Oct 18 17:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 736150 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 18FEDCDB484 for ; Wed, 18 Oct 2023 17:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbjJRRtp (ORCPT ); Wed, 18 Oct 2023 13:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230132AbjJRRtn (ORCPT ); Wed, 18 Oct 2023 13:49:43 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CF6A112; Wed, 18 Oct 2023 10:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZJMFDHnUNSKyDjDufaULtC/PvwznpBvduHHHhBlZqGKkMRPIT3YpJY+hp+vEOnxMKkO8YUJdIUhLDtPAD6sESs7TkenWZmeYahhqNkpMvtMKrvJQqYqffSmyASxVwGtxCQQH5doYP6VBx4KwZpJ2Lo/jrDG0qGm7FQdNdBz+y3DdzrbHPWmRRfr2aZKt/kge9sNh/emzDEX8CgkWTglMHVGRHTZ9QAm38fwqQ2ZyxXdDe9ENJpy5mDQqFqjl32qA10k/IY9XtHlOC5Qhn8o05BR0kClYzU70MqgHUD5uP2GFCrN96pkm/ox/cYrM3Cn7/fxMdnw9XNY9r7lqONwk7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kig7DXAIM3jbV8RnY2R78WbZepJvDlAZxse7gk0wTaQ=; b=PTECnKq3pP1/XA5RRiKHUSFx2lMLOkm5T7kYxEXFmPuG3IUOzxurRWLQXMVP1a65WhbUX+gg9VtANJXSTMoNMbIhm62BACUEXpq34YDKw9iWGKc0GoKv4yHq5Kb/p0dBeX8pgC7YnO6DNl5KEev028J3AjD0LdsyvpIdzB6DWr18r5yLTQbYHcdwzFtLhBySQ+7TjemyGlp7fUo5InBPgAcND+4FGFrHzbIFOn1EjR/Rkskkx/fOaxvytErOL4PWWEhK/16oS+b7HqOHLoo+9O73CpcpaFkzOGyqSrQkAN/KwMKA5ZpFWxY7QpuWRXhbjMhl90svB48yfoK3rAJSTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kig7DXAIM3jbV8RnY2R78WbZepJvDlAZxse7gk0wTaQ=; b=GUD+rpoE3gNaAKX/aB0nTbYTdQ+IG/cdHb6jNJTtAMZs82d1KVxX+/nn7kwBx2wi9UeoqkWib1T1ODAdeq2aUzaGKyMpla05Ps/xA3Z0F85zX61/tuWe4VcbLHEwuO4dgq2wBwrh8nru2vRCSfciuWyjDl5+Ar61+04Q1+aPgaI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:37 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:37 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Wed, 18 Oct 2023 19:48:34 +0200 Message-Id: <20231018174840.28977-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: df67c3bb-bcd5-4e5d-4540-08dbd0029899 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zVuJrcLoriTOHM1JYrJky0Z5WHGN5rPnXGVQACkTIrIYvRUecpBsHpY2CI3ai5qLSEbDzIj8QWbOLxjnXg2xaCfqBGgsovT3OzhQohraoRFzuOpDg5+VANWny39G0ytw/1nQOaLY7bVPt5+H9Xhj4oQQb+CMbImsW3zsJb6v2b7V/3hB8HrAsc5GNbjQSg62kL6OeOJS8MOilXEtCkS0uEWMZ+IklIpr38HEpS3a18FuxF7s1nOCM2xUYIqGNsnZe/9JewHtZUIKqsgcd1F23ySj0O0Z+sIe0mo4cwdwzkiASBzJbCPRvS/Uk+FQX4b9h7rHimpWQCV2OVsR3xNQez31au9wXi81FdF9pYiosTFpNkMErJFHw1YpZ4ZPLeynNhE/iOZ3KjThyBeeEr3pqd87aSfXcv62GHK3EDGNvKK47D4/IgHmvEGElZa5h1qddUeYS2zqIhG/TgZU9I3YT6oXJ9kpX3V5UGMBNIlm1QWb38rnAXcxmHjd/IJWFs74pwFH8z1K6TzqneoT0+QCzLIpgrmHpZWahqYrqBlHFSQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6666004)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vBvekx8VX1rcwvvmhxBGQrT4TM8YbhB0Cm6Ka9lfPE5p6ojGn+ZPnO25BldsuKwQwquwLQ728F+L+znhwniiwSG8339uUh3fK5+/cWcAE2SiXvwSAKPG5+7IdB9DBWSveVmrCbAxzTjxMKWk/G1/xUgojTmn3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qj8aZzC3SBrEJ9RYaHA/bbVkQJNQhzv+Gf+HP/FjBj9EDD9wDG/1tizgqqYFaYd5voviV0bxeVPmpiBu1nSRLXX9ekOhj8SIJKyDe5Q8o/hy6pPSC8yedrEF+3fhMjXXs2txMn4+X5oruCvDJtyieq3ZBikrMW0T7iIZP2zgDMFdHtCEddG/bsY/NekDeDjwfA4gGyMdQYXqKwyhZbJTzqjMIUOOfDH1m/5tYHP+ix9XGDSpxYszVNx/z6LDLT6fhCYIiA57Dy95B+Rcb6Yvw8jN77m+GueRQEsqALCUHPpwNF487o6cCIbn42ZIhn4o3dJhKG5KPkQFKT/8JV9bt3lwBX185OfSmnbQ7eeLRbahffzdvgfP/0gGYnj0OsPUbS8KNSArxqJ1tDaAmcKDGXlL3uISQoCHG67vLOd X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: df67c3bb-bcd5-4e5d-4540-08dbd0029899 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:37.3227 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dwcD3vU1XL3VB/zRaSK5EE8tX9LeKWKLBmOzFAzMO1IYEcbM3poO9fpJvz5eVVMD0lT173xsiN1B6A53TG/pSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Both the imx and stm32 driver set the rx-during-tx GPIO in rs485_config(). Since this function is called with the port lock held, this can be an problem in case that setting the GPIO line can sleep (e.g. if a GPIO expander is used which is connected via SPI or I2C). Avoid this issue by moving the GPIO setting outside of the port lock into the serial core and thus making it a generic feature. Since both setting the term and the rx-during-tx GPIO is done at the same code place, move it into a common function. Fixes: c54d48543689 ("serial: stm32: Add support for rs485 RX_DURING_TX output GPIO") Fixes: ca530cfa968c ("serial: imx: Add support for RS485 RX_DURING_TX output GPIO") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 15 +++++++++++---- drivers/tty/serial/stm32-usart.c | 5 +---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 13cb78340709..edb2ec6a5567 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1947,10 +1947,6 @@ static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termio rs485conf->flags & SER_RS485_RX_DURING_TX) imx_uart_start_rx(port); - if (port->rs485_rx_during_tx_gpio) - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); - return 0; } diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index d5ba6e90bd95..35e014f83465 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1391,14 +1391,21 @@ 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) +/* + * Set optional RS485 GPIOs for bus termination and data reception during + * transmission. These GPIOs are controlled by the serial core independently + * from the UART driver. + */ +static void uart_set_rs485_gpios(struct uart_port *port, + const struct serial_rs485 *rs485) { if (!(rs485->flags & SER_RS485_ENABLED)) return; gpiod_set_value_cansleep(port->rs485_term_gpio, !!(rs485->flags & SER_RS485_TERMINATE_BUS)); + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, + !!(rs485->flags & SER_RS485_RX_DURING_TX)); } static int uart_rs485_config(struct uart_port *port) @@ -1411,7 +1418,7 @@ static int uart_rs485_config(struct uart_port *port) return 0; uart_sanitize_serial_rs485(port, rs485); - uart_set_rs485_termination(port, rs485); + uart_set_rs485_gpios(port, rs485); spin_lock_irqsave(&port->lock, flags); ret = port->rs485_config(port, NULL, rs485); @@ -1455,7 +1462,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); + uart_set_rs485_gpios(port, &rs485); spin_lock_irqsave(&port->lock, flags); ret = port->rs485_config(port, &tty->termios, &rs485); diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 5e9cf0c48813..8eb13bf055f2 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,10 +226,7 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); - if (port->rs485_rx_during_tx_gpio) - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); - else + if (!port->rs485_rx_during_tx_gpio) rs485conf->flags |= SER_RS485_RX_DURING_TX; if (rs485conf->flags & SER_RS485_ENABLED) { From patchwork Wed Oct 18 17:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 735437 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 D5CA7C41513 for ; Wed, 18 Oct 2023 17:49:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231480AbjJRRtx (ORCPT ); Wed, 18 Oct 2023 13:49:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjJRRto (ORCPT ); Wed, 18 Oct 2023 13:49:44 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C69B8; Wed, 18 Oct 2023 10:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nTdovfUV9LgZfPyETCwshmyT4G5MXBMWPB8GroxXedEznjWI/8bhfWebdMaaDIcfljSNaRUtT07l+2+jOEr7XVLdUTqSpBGbclT/4e1MoHHbH9YVXazjU2nOQe3lv1pJOo+v5Cxx0sfKkUC1E8jPIqNRhXAdQFy6SAYyY1+GNLEInKHnl+pBmgrOVvBzBUukin36FI/YiS3UaD1uo4/2ycENE6ILWRWRlkqDpsQNQk4A580R5KlUtwhqKqZPz3Srpcs5pJ+JgrUJWE72BCg+vPWX+40cVPtZByXBbkVX3migFCnHC/UiVT8nJHVkyDK4Pg8+4V40GNcBL6/ZsRYX6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dJ0aXBQC3DduVUO3LMOak7Vihfr1WaSMQA9Zk5Ski10=; b=nXmTgFvLZIHIuiNcShh44L/41ADMeqG6A7JbdxXICS5BpFmN9vThftEMkTqTr/GkJFTAfopYOqsvjjL36NXfmLm9r4guC45OjsduMYhZ/JFwLyIHvhC9kKVNrSN9dd+uPnXFYw4jJwD/vt+slV4b1aDVCftlRVi/o16gnm2ycx6q1/oFUBySChyJdWzSztY/yN448bF0p/U8agj4ldtpTHV4xe3VOd/ho06wzNZ/Yo+INdlgGqh9Ia9J/dCDLxuJoSqAn8S/C/B223c+J7NriXPrcAwMaNXqHWII+ROz1Bb938iGSWITtCIbVBFgkgMZsFpg9VBjLuCbSbNyd5lmtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dJ0aXBQC3DduVUO3LMOak7Vihfr1WaSMQA9Zk5Ski10=; b=N3IkT233IuCFcWwVhLskZ9j8inzLxwpOuutBhIZMVWzqCqUxwsLzYdU2ws80leLbXGzXlS0saeeK+G3uRu1pw2dyoCAJmEzL+F1+AACUV725qA8Jx1X3U2HNo4ayU3yFBUSCrg4KpqZ9GCQvWR3qd7KdqUXlh4S7GBIk/vDZ/tI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:38 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:38 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 2/7] serial: core: set missing supported flag for RX during TX GPIO Date: Wed, 18 Oct 2023 19:48:35 +0200 Message-Id: <20231018174840.28977-3-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f5d1cd6-6f42-4737-f170-08dbd0029906 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gD6bpCM/evei2bhCdZ7F7S2cX+acAS6jdVrtZ/yCNQqBdKY4q8FrlsGBBzDA/baqB0N+Av4jxwepLwTa9OcZHptcHQ8M52BYub7OoKjUOk28DzCqQ0W6emJXLMjSJfVbAH7eg/p85P8x1tb+6NF2awoxYF3LUXEp1nRPxBhQhWAttEkzTNKXDZbcMCZtQxzLHoWiFV3x/GLj5P2bgPzNQgwPnHCCMReauu7IHLbYZ83sTNNFYXNyRn/IIRmpre6nK4dbIzX9j8jKwxaPtLmLdKMavycowLOi+4pQhsx1dQrLnSNxDP+XMLCrMNGHhK6Xz+4UMWqrGSnLHadrMxHkhhnMDWLp1jc1ynHxJtNfRRsjH6718o61IkG7vmBO6E9CZvmS0vayqcoMiRwz5S9SUO+qYSiaAe92q1nEFEnCROEqO8Cn05TLx/VtEw7//GvnaDbavhS4ur//D/xs7yfjNiHbudMn71CQ8PeLijeHi4Nc5k8eU3Gi0SPMv0Ye4N5/txz/ZWZQWcJZgwQyd4aotbrvEVAvJ355ctGu2iJ+31m3F15e0IsJHvTx8e/sUpVC X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(6666004)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bbVuxL6ogjdrrz365fPYKfjbqPyyvuqLtYDvN3+DznTrwTx8YRhIc8wqI8GSlr+/AS+L1E2e0/dyY1w6P36wlIPzblmCKf285tjOjOOuKhzFqJkIhzb8H+B5sIqWC8N8IYHpG4vLFKeWiPsB2/Y3GksQsI9Y1exor5ODIvd2QQ6uHAB4seYmrQdD83AK0qNN9zfWBaF7LQlMRJRuelz+ZZK/JeYEkwHr/rd3Kq/UOx5kLdx1Cs6ejSGDqgbXVzGBrBagxrFbb7D2h3v4ZdEqpaVqbIs9bMNdhh5tS+Nx6K9jgXluF/y9rT6FN+qV4scMz8jfMwu8fzNiIkmz74xi3jinotJFjXwJ24XGX5TN6oYAF+f5nywGY7YqiEXN+nlHnaUqXZdHegBJrLjk9MCkd5xbpqQfeq7L34baWC/19o2YsOv1ynfAg1yJn6KSu35N/K30MBHebsSH0aAIib9Ib8RXDswTQ2Jo/9vTPF2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PX/QnfSyC2S/dk0Yi5NJAnstZGKy82tLx2pOi308pY9Xg8LrrZcuL/zpwAKg2qnGVdBnGqtoeVJPdq8rE2RF2fo+GhYnrjCkZe X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f5d1cd6-6f42-4737-f170-08dbd0029906 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:38.0434 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DhogkkMz2tk0H78vxdgDXmW5bdVXcvn5kX6Ku5icSHLJhcdIssMHw3DpyiJgbiI9jU6rBs/tKbRKLlq0xM14IA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org If the RS485 feature RX-during-TX is supported by means of a GPIO set the according supported flag. Otherwise setting this feature from userspace may not be possible, since in uart_sanitize_serial_rs485() the passed RS485 configuration is matched against the supported features and unsupported settings are thereby removed and thus take no effect. Cc: stable@vger.kernel.org Fixes: 163f080eb717 ("serial: core: Add option to output RS485 RX_DURING_TX state via GPIO") 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 35e014f83465..ef9e9014bfab 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3632,6 +3632,8 @@ int uart_get_rs485_mode(struct uart_port *port) port->rs485_rx_during_tx_gpio = NULL; return dev_err_probe(dev, ret, "Cannot get rs485-rx-during-tx-gpios\n"); } + if (port->rs485_rx_during_tx_gpio) + port->rs485_supported.flags |= SER_RS485_RX_DURING_TX; return 0; } From patchwork Wed Oct 18 17:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 735436 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 C1102CDB486 for ; Wed, 18 Oct 2023 17:49:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjJRRt4 (ORCPT ); Wed, 18 Oct 2023 13:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231375AbjJRRtr (ORCPT ); Wed, 18 Oct 2023 13:49:47 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2057.outbound.protection.outlook.com [40.107.6.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FEC9113; Wed, 18 Oct 2023 10:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nnMTf1S5RputoZxYOaUfCTKAc1Z7DRnT1hHLFzsYNOvdnHzMYVDFEDnbFHWp+TQbTuPHz4QllDMxF/GleRwOatqNR15lxm9ELvRnSeVqb7wDqGOiIDfoyaCGPpmIcH8AixE6wwMKBnKzpi2lbpJ3RVCEoNtxGjjb55N1+CR1ZHmVgOLi409b4xPeAWPH6XLhq6D6Sp+Gjljxz6waMrZ2VSW4pY1hZwsicgZmTn+gpqeTYT9VNc/lC498SifSjV8X30wZFiBNesCmuRmALhgu+k26RNn2vUBa7s3rMdwDJQUSugrfjh47ST15PEwZC3GOIbAOgTSMzt0VYpzvJvG1wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=em2W+/JhkP+uQxksZVkmIQVWa1dzHka/9yRLKurOJYg=; b=SCLUEMedgh8ITcQs6+f94GWm9JeMHShj6yVYkN/hr6QEbCZuxbPkUccXZsI8bj7jb1Gm4JM8PTzbpyXBGXpWKNj0CK4cko8JuHB04+x7p+yDAmRW+8QCYfMcEoi1S4uJ55t40dg+sLlWJ7RZmDGjd62Uq22KYV69S3FiypW28K31+g+xQB2iB9GCwn9pkYgHvhPb9ib8AqDDRoMm033NTRWCiDT5gcarhbTxNM5Ewi/rn7A2Q9GbjQkACozXjTUNR9GNyTrvjxGlW4S4ZlDK4jss4aeQdyqbg8yS7jwoAUUbpIckOW0jQKzrw8T5ROiiwkK4q2B+HGjcBtGpe5Bg2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=em2W+/JhkP+uQxksZVkmIQVWa1dzHka/9yRLKurOJYg=; b=w5hpAhrx/6l4oB8VdG+yWji52E3ShHriK3PFMwgWSytjzObqte2GokW/Gi41Yj3YVJ2p23ytHn0Oj6EpQYayBijG8fzj2jR3n5lJsQMhuwW9frP1KaNcAKOL26hoiq09urzVfg6TKFqKS6w2NCBCVsQp7PKfNfN/xIcAtNQ1Sz4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:38 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:38 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 3/7] serial: core: fix sanitizing check for RTS settings Date: Wed, 18 Oct 2023 19:48:36 +0200 Message-Id: <20231018174840.28977-4-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 542f69b7-d790-44c7-52b6-08dbd0029966 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OcaPmEYr4KqEbqe7Ba39nGmo5vOvDG5M74RJvTz/fktGDr4UD5BVhh0NwQ+98RIZilVflxKc6yiQZULi8Og37W9Eqq81ez/rTI0ygMEudNHIVDjhIKX2emmAEg5c1g7DpVBp4XWsRbp6XnQg0dGQ7FE+XtQ/7gcIl3P/brYt6fFRYzbRK4rrVuPdA1svatAxzIIMWM8Ogwaf0PMa6YmMmxywTgPENcdrSG49Tnpj4Am2usebTsWSWm0oCIDKQMShoPQYNzZtH+N5zojnIpremax1er/1qU5CKFxexC/uf8qNAYg/zLB6zuN5ART0VPtCpvBt7qBglOYEoGdSQyu8CC3zTum+NffeBdmfmOGNY/8YgKehpGLQNG76OWV0I+b2dII4ZdbyLpIrVgkyFkBtx9GG/xmbsJejspBxB0wxgfReCenthihkrOrb6i5yb1VA2SYeDift/tn3uqWhEqhwrh6BG5oqqQoJwLw4e18+QB6WNyv+Q6yLuUR94LSBEIp/ksRgwJeU5zmvoqpPaaB1vwTn6DZW4kw/l65DmXAnH8AtWEfpW89zbXlGV+a9sVzg X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hNwKmCMBvMDoCVUkoOiyfCg7dL8tW6RYJmJl1FWLZuBhwfiQqHJq8rhUvwM9MfoF/eTW/tzsufplUmZ8JXZaraceR34rCyzVfIbPNsSL+ESATyAc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Ay8yCCHG5bESceYDWMonyQSf5ftq68I3i2ZkDjrUOkAG7noCog6oXZteFLe1gNXEBV66jxdY7d91Eu29iGi5vfzLg5lDJ31tqDCIgLEStFR46LgtE16RLhIzF+NaDoW/a0z2ns64Ma2FGP67P2ee2MhxcruINTf2M7xIYhvG1TyB8TnvMTxxlDRBKht4DHZNhfC04QWBS4V1AztTLcMtUXZkNv6XwDPniIUEeb3f3uUJPaEZq2WHqMVEQSLNiPYPFkGlS9cC6kgsbvhP5fJuav9f0OPbmKJsCL7MSFiVvLqiyxxv3T9idUL90+cCa3oPP10pOsP0vZguLOliv/Rqh+GjBL6wafJ/LvxvsT8LVPTU3uRCAwGwjM7pwdZH/3HJichLQxFUbL9jd7mEglo7uFN/YpsoiFD4kRJhP3p/0AlwfMXlx0PJxZsU7QISvXeYq25i03M01ONR X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 542f69b7-d790-44c7-52b6-08dbd0029966 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:38.6334 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OM7QtnvcXYajBfi0J0JlPE+XIdVcqjnlaPZYEilAG6tWrsUVv77dZ0h18gNgTm8Ug79O7xtc3T6RyfCNcFp+/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Among other things uart_sanitize_serial_rs485() tests the sanity of the RTS settings in a RS485 configuration that has been passed by userspace. If RTS-on-send and RTS-after-send are both set or unset the configuration is adjusted and RTS-after-send is disabled and RTS-on-send enabled. This however makes only sense if both RTS modes are actually supported by the driver. With commit be2e2cb1d281 ("serial: Sanitize rs485_struct") the code does take the driver support into account but only checks if one of both RTS modes are supported. This may lead to the errorneous result of RTS-on-send being set even if only RTS-after-send is supported. Fix this by changing the implemented logic: First clear all unsupported flags in the RS485 configuration, then adjust an invalid RTS setting by taking into account which RTS mode is supported. Cc: stable@vger.kernel.org Fixes: be2e2cb1d281 ("serial: Sanitize rs485_struct") Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index ef9e9014bfab..f1d889f9fd6e 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1370,19 +1370,27 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 return; } + rs485->flags &= supported_flags; + /* 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) == + if (!(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 (supported_flags & SER_RS485_RTS_ON_SEND) { + rs485->flags |= SER_RS485_RTS_ON_SEND; + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - rs485->flags &= supported_flags; + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", + port->name, port->line); + } else { + rs485->flags |= SER_RS485_RTS_AFTER_SEND; + rs485->flags &= ~SER_RS485_RTS_ON_SEND; + + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_AFTER_SEND instead\n", + port->name, port->line); + } + } uart_sanitize_serial_rs485_delays(port, rs485); From patchwork Wed Oct 18 17:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 736149 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 0FF1DCDB47E for ; Wed, 18 Oct 2023 17:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbjJRRty (ORCPT ); Wed, 18 Oct 2023 13:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbjJRRtp (ORCPT ); Wed, 18 Oct 2023 13:49:45 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381C5111; Wed, 18 Oct 2023 10:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c2gQQChVxGzC6HUdhwdjwJLe92l0XLbgCSLxjXtcJowjFKwDi4x7E57tcMzl8TuQStOkDs/40o7eSsf3Q76rP3NxSXPCJ8mwsPiTPBdeOsZqyTCoN2tIiAZMX35rbO8lIHst+jN4PDYWmnMYX30UawCtwiWXddAUgsyx11JirNGw2oi7dANboY1xg40AEDzWehr+maV6m+V6lhK/z1AsQP8qZ5h78jTm9VvD/511FeO99cR45+20PYAQmGKekJIW39rj5pqWwyliJPoIUnCKYG27S8id4m0wd5xqt3hwFkUXOPmiO94ASYWr5ZpawCGsp9phnAJeGlPKhrQ4seOyOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w4GqqAu1YpbERiRD53HRt9O/SyEoX2/kmKWMxhgAsE8=; b=fU9VEmhv41xMBgB/IShPS6QFGJz2VfHdpc5ORnWlhsy8EWNreiAO4nmPJxij/2G7DTH/Y+KHUpbrwHhaqV/4H+GlOhOAV2eHbPa2dU1u9RC9OaXTZfOU4vk6abuu9aYzDjcbayN6ZHPveJ2ASByAO7NSBvUhyFE4sAx2kz3m9oNCwDwRPAjiXGwkwXjq1biCyO8wXdg2U8M/c3dns/uyxrUJt2VK2LmtrONL8uXMyEYCmV4SjRTN0QTUjPDmztaJ30PIdEBcY/1y1lLX7YwXNq9kXC7qhsrqrxgIIKp2JUvpU7itUz4tD0KVJHZd9RHSq7Ig05UVAE/L95Wu6Srn8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w4GqqAu1YpbERiRD53HRt9O/SyEoX2/kmKWMxhgAsE8=; b=VpQJ+1cXGAjHN/rUQW6HSGGQxPC0FrYAMAsXArNpCvjliGscg2SHW5Y3CemmpqdGMQBjnYRCdi87t0YdlmVzBRgqOHSM4efWyDsS/HeAxgKmboj54hdELSzTrioOy+z/F5S8VA6pEKyaVPMv8xoDm2eZE6uWBiMJuepqIS4hyg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:39 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:39 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Wed, 18 Oct 2023 19:48:37 +0200 Message-Id: <20231018174840.28977-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b4caad4-19ef-4727-e8b1-08dbd00299c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: svjy0K3wb7yzn5wApTnwDw5STDiJKfNnI73LjKOy73hMJlfYnAQZhbMP9j+6tX6KpCV9QbiDJrWVrJdSAnQtzPoaS3Leio5oaUctqpPOvGfXjpsYWR1exbIPzx16AWkuqnczbpw+kkkK8RY+x3vIgcBAvCZl4TdWTc+oRcysdVrZ9am7u31M+ztz3SjCIBUsrpGqWquy/RKbMdidoUYO+F5TiqSosePJeCkNlDiNwYDemH60ZC60vnEIA3U/bRdkqHSj6mOXmb4E3cxiyRvIbJpY/tlrHtg63cOfAl49DKkKc4PG5JdASyOw/mUU7aSOzrIcuJnGudFKLuMapLujcD52ZoVgDuoERwDWrP3R5bZeUtTSB6Vc8gKgiYnq7W4oUwgDmxl3ad/IJubkKHKEZtDyFE1jx0i+eUyYqn67IfvGmse2Wnl0zCCnO7tsXB7hIGEvS0h1BQeamNN9VyYIEOJyLSBjA0xiNll9J+zluKD5/VHtNZNWUmvlzzreyKiOj+pGlDBE8AqgXpkcOjyibDXDsA3hxv6+UdFljxdHTdUFFcv2NBCmxHFPn03uO7yl X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u2uscTQ6tODp/oVuSdzy5OPWtfbQLid62kem5zmpQoSzxx157DkkNC4Ef2iuX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Gx1Khm9Pi/DaN+1Uj4BOFySaUnj0JweI5N91xhFvnPq3s9hdwcNZGrEwIhiEWO333pPf06qbbbsAf4kIVc/bpep2QahrRknvwKwleo/WNY3FWUX5T5aQ31FInbUyct35rtnZboGs3s2vOcC0VW7/rx/kL6zGgCzw/x4abr+hXFcOK2gZ3CThsWGIh6nEea90cVCcxdGMGUmS4AOUYDEW9v8vlfPZ2yle1+yd6cVEKnBKuNkJFz/bn9UrDyhtdcCW8FcHA2L8nrEgK8+do/3zG1/o6P8e5K6qQli77X3Zo1UKlTdJwnCrLrE4ufsdiGaYoov1Z7elO+9D2trxSpKPj6r2cezpLuZJRnpxvpbfQUEN60cRB1ZiuSZLgeKZe5J6zYbjsBMH3eg9qCb88I8qCiOjVA7phNWb8SmIDsxZXC+pyXitgRaLLKzo8PCFj7M8kWsbHC8Kh5IWm6zm1c45qR7Rz/WzE5YBESWFdxszt697Rfs2xjOsPwuKV+/siR1aBv3/WFUIbtqdLE0dGU X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b4caad4-19ef-4727-e8b1-08dbd00299c0 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:39.2625 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uQaQsd7nbtBLqbD64cqci+u1b2lhwe6JQKcwQn3DTh1/d5pUYQIOWy0R+fPePTFK51lekSrsTWTpqrPPCi7Tgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Some uart drivers specify a rs485_config() function and then decide later to disable RS485 support for some reason (e.g. imx and ar933). In these cases userspace may be able to activate RS485 via TIOCSRS485 nevertheless, since in uart_set_rs485_config() an existing rs485_config() function indicates that RS485 is supported. Make sure that this is not longer possible by checking the uarts rs485_supported.flags instead and bailing out if SER_RS485_ENABLED is not set. Furthermore instead of returning an empty structure return -ENOTTY if the RS485 configuration is requested via TIOCGRS485 but RS485 is not supported. This has a small impact on userspace visibility but it is consistent with the -ENOTTY error for TIOCGRS485. Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") Fixes: 55e18c6b6d42 ("serial: imx: Remove serial_rs485 sanitization") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1d889f9fd6e..49dd5e864719 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1443,6 +1443,9 @@ static int uart_get_rs485_config(struct uart_port *port, unsigned long flags; struct serial_rs485 aux; + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) + return -ENOTTY; + spin_lock_irqsave(&port->lock, flags); aux = port->rs485; spin_unlock_irqrestore(&port->lock, flags); @@ -1460,7 +1463,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, int ret; unsigned long flags; - if (!port->rs485_config) + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) return -ENOTTY; if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) From patchwork Wed Oct 18 17:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 736148 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 10E5ECDB482 for ; Wed, 18 Oct 2023 17:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbjJRRt4 (ORCPT ); Wed, 18 Oct 2023 13:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjJRRtq (ORCPT ); Wed, 18 Oct 2023 13:49:46 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44AC5112; Wed, 18 Oct 2023 10:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Om64yqT6QtA9XIsqZl0GfdomHbPCvLmoyO5UJksiXefv+C7xZnz56ivs7UcSrPxufXZZfXYb9wYyUjO+ozf1qb7aeiA/4r0CDBmjkJ3pEMvBvPGQ2JUV6Mc1n3l8klSo6dzpBGE6oTk07tPLiynW15OjpdC7Hx/Is+phGPiXj9cRGayY8vrnh7cSLRgvBmF2/iTYbAtwyMOE35olNZIreaPr1CLSFrl6PgFPU/Hobhc2UH0LLj6ilLURX2BaV9ZjMUVfGcHMDDU9HpmgjqyualrwtjLtf4Tgv6alNaqF7dXzfQ0pyuUmKHafS5OVjJK8++1UH5CQ4dxpcqaTYJ5Etg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jty28h9E0xtb68sEWjbyY0P2pj9xkcJFJp53NmKQG+U=; b=ge58wig/MMVgy57YNCIPSYsFAllTU4SLFRV+d5CFrCMWvYzG0N/evARgUB5jZyR3IRKPbZV3EATXXYBkAHivr0mI99W7nmBhZ4y1xFwGHaJaR4KogI6MC+wESk9GjTGsfkM/NeGAlY9oM8wvbZeDQS0sTKZdBtL3n/UuNjVqJ7H24VjAYUONBQnmhkoPwJsCrtWZiBP5Lu7NrhFXGwV4sBHsHSIjYjxzpNqvAf8Z5fBi44swP7ceD0AJzYtRHmkEc0emccsc4dvGkvXmjKt8kejtHua6AY98IQ9zeznTClZYEyCTMlHJot+YjSPL/2hS+ccu8CUyCZeCEgVFnOs4jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jty28h9E0xtb68sEWjbyY0P2pj9xkcJFJp53NmKQG+U=; b=l+eAnmduG0YpjI7aCljrJG9ORqd+EBhRFaBNSFHsgMY/W3ifBygnYLNOyANpNWs2mIKB9stP2MMIr0ESYxoeyZcnB8RjkAmOvQkNcW6dGh9Pyb+PkM1aBWKC8dnyAtDXamoF8EiBXE9HDKqqggNKOf26pGtkMd7zdYEg32j1EzU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:40 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:40 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Wed, 18 Oct 2023 19:48:38 +0200 Message-Id: <20231018174840.28977-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 72b92e88-ba23-4c86-a918-08dbd0029a22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KDOMFT4bE62M04KLes3Y92TMGUbPgcsnfvRWdFlzkZIKiGR/fVnfZ+0HitHq3GBO2HL3/piUfbry6ujuwqEkTxtsKk76vNT2nVMF7ZUMi8rmjYciqRVr5VIlVAVoIDSOKX9KaSXo+XgWEyf5LOsyHf8/hGfmCSDqj93vfbk8amt1o3qcNSQgcEyKrkWsJnsTSqHwAlQMX610Dfw37vKTlnu3QN1v7qI1browjrcV0XNXTGTHOcmMgU3ipoBYI9uXqq8bx4YA0Z3jthW16zbCRvrXlvbqofeG/ad+5kdf0z473fRF6h/Bkj6RR0RDFZLbIJIKpvrdn9TJ3/yzW4grkK2KvjAB4SqFWFpQwv48K5s3mt2o9XkQQXAufLVpqFbJk4Z2eTrhrETJ8a1VKFg1E9jv2ToE4yDX9QCWROIXXGHj7HrRZ5maPPnq6t268dCS+Z+iKu9pd5uzuQxKcOlFdlWNFBT+2Bz5uiLVtPx5v/nLnEI6nm444GHJBdX6/0tHmxQdXLDr9PbV8tdxAPjVHzwknSZwuo/U1iaGIK9oAs0QvYV/HdEiZF+r/nuSzgdk X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?U+0r05znMH5+SvnOv9rbFGY+CteN?= =?utf-8?q?WN8afrDfeu4ZtU3mKZKT5Fn8qWVjlLchBYcLPfJQto7GPgR6wWKDuX9McgtHDHugo?= =?utf-8?q?IMNXju1Q6SHsNAT4z4joCsMfcgIT8xNRU/2ZNXJFHxIYzNHX9OkTGYCmukTAAXYEJ?= =?utf-8?q?YG6Md9dcopW+9brzJc9b8c5zm6tpuOOzsrT8MQ8ShIOsnFsqiWRHLmyhAenS+ZhEJ?= =?utf-8?q?KvsTzsi5pWXGRWWtb5tACDuO4IIcuNRgjPqNR8wm5RIAwsCEHOr1nXyCJD+3GZuLs?= =?utf-8?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L?= =?utf-8?q?kw3Oruwzgge0tySWDvVC4ZswN40urISCqw9P4+yYiqizZ12njRySMUNmrPLWWyhF2?= =?utf-8?q?YvJq4bCgmRx6uJ0p7FxmtVZSQlWjYYMdQqDCmLHP46EMtpycB2Uk/Se6QmHDLace8?= =?utf-8?q?B3Z6lhtMjcYtQ5TdXpfoOVvAMPmeR1fO5OS/ICZ4/V2vW9COu05Pnjliv2aaAqGtK?= =?utf-8?q?DqXwOQw1t7cR/RTCY84co7RBBHhIGPEXL4JcGepxNYmTmIg1sJACxlTQX9TBaN4oQ?= =?utf-8?q?q1i05vsqfnstpBM3vwzOLDo6sh2lj/BZTO5HU47T0Ia6L6x8G3BK63//bhXd8SxN5?= =?utf-8?q?4Z8x9VIZl/TRNRoMW11xN2up9bSdd6mMNir3Vfyo+FCOJcfrXDmucZqIJfdxz/td8?= =?utf-8?q?jUtcDRI5nFiFlFfUJNfnyzvJnnuBS0c0Ss2fZ1mAOp2osNHkhJsg6uMH7eOBqvZfj?= =?utf-8?q?MLOSxp62qo+?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b92e88-ba23-4c86-a918-08dbd0029a22 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:39.9162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0aP0OJ5xQjQtUKhP3as4G8AuHwhn8gk4iza0d9j7nnK2WyXfZ84qJSd01bT29XU1hDGVTaluT/FLHhM7pVfl+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org If the imx driver cannot support RS485 it sets the ports rs485_supported structure to NULL. But it still calls uart_get_rs485_mode() which may set the RS485_ENABLED flag nevertheless. This may lead to an attempt to configure RS485 even if it is not supported when the flag is evaluated in uart_configure_port() at port startup. Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED flag is not supported by the caller. With this fix a check for RTS availability is now obsolete in the imx driver, since it can not evaluate to true any more. Remove this check, too. Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Suggested-by: Uwe Kleine-König Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index edb2ec6a5567..c8c19bf8585d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2332,10 +2332,6 @@ static int imx_uart_probe(struct platform_device *pdev) return ret; } - if (sport->port.rs485.flags & SER_RS485_ENABLED && - (!sport->have_rtscts && !sport->have_rtsgpio)) - dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); - /* * If using the i.MX UART RTS/CTS control then the RTS (CTS_B) * signal cannot be set low during transmission in case the diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 49dd5e864719..c85275a573e3 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3586,6 +3586,9 @@ int uart_get_rs485_mode(struct uart_port *port) int ret; int rx_during_tx_gpio_flag; + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) + return 0; + ret = device_property_read_u32_array(dev, "rs485-rts-delay", rs485_delay, 2); if (!ret) { From patchwork Wed Oct 18 17:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 735435 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 F243DCDB487 for ; Wed, 18 Oct 2023 17:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbjJRRt5 (ORCPT ); Wed, 18 Oct 2023 13:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbjJRRtx (ORCPT ); Wed, 18 Oct 2023 13:49:53 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CBDD115; Wed, 18 Oct 2023 10:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ir/xu8jj/brKyr8EdoM/iyZl/ho1UERPFGAsXiJ88LqFkHlz5o2wjXe/OVyxAT3CluBoKXeMYqYpAWMZr3GjzMtPRCKzGw07cE28jgmZy7TEQSRdMl+IluNcXqAREYIxcrRCKyz/HgcVpRnRPAJesQcvnn6iwaTMci+a2t6huOLpjQamfwmR5k9+iQ7haj9JDezTS6OOTscJ3gEt1e3MVp9UJvXLExmnFoTWcsN7m5D32gtRDXjhqzs2sIRfQ9dbPRXRh9xEjSB+RebeScHNZKlssRHSzItTuN/qL+q2BTKUdWTp6zIKKFTMnoYHpU7Q9aqjTOtjW4QmYsNjU5qnKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7/vH9Q9jKs2GzlPx8DEoi1T0SBAlJ5DZXJzhZrsbsp4=; b=Y7dqoMSie3hYNki6v3NH0JcfTG2LLhojE2KGPhRVdx+BN+epFzYHYB/70FOJmxCpjRvYvoa4xYg5f+A646gloWWZWhMV1BxuM4FeuI7rS5rqpVNZ++dDL0bjHf+pys5KiPv6nR0ihEYWFGnkmJzbBFzaHS/nB5Fy6h/FaUJxxQglxnornDtIcxEfNgMk/m2vTx/gJQSTBbSlXNiQ2tPuLi8dd21hopL2CATCy+/HndWt0kIVX44WyoqMbUTs4RgQbhBFe11iml8SyR6SNU0oblTznxEPHK8hxhXhLYh33qaKoi/c4A0cAhPw02tKTSNkh4apEwRTdZXT3cbfWlcpUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7/vH9Q9jKs2GzlPx8DEoi1T0SBAlJ5DZXJzhZrsbsp4=; b=GYTZBziUvrEq5AnLQr0+QYDpXMfz27fmrhSSRAnHGzw1iglOkVbwooCNpNclsqZtOaqGuOKuxFmHudFBPLmHuYS2XsqwqubUu3qdnZjB8qhLw7+xKPVnNG4ZrwpNTI0RyRizIY7KfdW28jb18dTxgwUH6fUwZl5KRKMy4Rzm1as= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:40 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:40 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 6/7] serial: omap: do not override settings for RS485 support Date: Wed, 18 Oct 2023 19:48:39 +0200 Message-Id: <20231018174840.28977-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: b418d7cd-1bf0-4084-071a-08dbd0029a82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VHAsiq3XvAxdS3WWCIwFicMti2yPapSJO9fk5y/kCh2nB3Dwkp2jr+5XpBhMnSjD3MI6k3vOAYaZLmeJK0ywHtITk34ZQ0aqAI7bHUoVrHqqXDqowR7fleEMQ9Sw6H5Ks2DoZ1cj3gSQnDv/yNP7yTjD9VpVc1HTS0ppbTBujU1+iEpfwPvwIyFgwd8VUsmBjhNNFtJLQjNUv6XgtjMsHH0SP88trX7dSKUW8J27Uf66Y6Cmts340mAvMoYRufGAu/Geu+NhRjeWDMRrrrSYe8uLHjMsvcigB/rMM3Ci+of1y/8SJoQI6jzY7QfepFu14wdLg+X4Os2/WxqKedvfSowpqpJEMBh9Tl0VqpFG2RRbQGzovAh00AbwOMpRLjTnXv+UNh0GGfvHw12HLsJWLGpXJ4CJqYTUOCAyipJm+5pdErhv86+fRVQBDjJN963W1w064ulohxrRHROTsBkeHq2iaWTDHbTNf72BQ+iHyti4R1UP6Tk+bRDIXA0tNer87VrpTj0AJAM9ejLFh1QAQS5HYteWGwAjnYZEOaPWJhtZvYE7NeBzZ+Vq+YvixNnG X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SOdOzTbHzjsp/2/fgazchfTclQfhrp25bQ4MxcewI2BzGYsmJlRxMKAUzulQ3+rcBNioIcEdmgXXbRmCFSxI4FJt0KYADOGemdVirBMvN6npYsLT0wbH4dNb7TFi+payxIAqTnLKY6jgiFqLCQXCQWFaREHs5TXKAIsIhDlBrfaTfUDdm3cvvNIGyfgS+PNvLhP7PhmXeW/l5roZBWijWqAGV0tJGP6My+ae05RXehNBkPzXTX15RHN3wAseAcAv2chOsScze1VS7O1PKSWPfR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49FLlYAOfs/ZcHCeFCxMlpYJQgzgYfwGQbT8E+heIdGBqp6l2ZXY6Eq16FAUBiybJzeiO79GZpHoaXDVGv9/ODNOCo42iBH4G5fOkbigN62eoz6TsQ3NiOO6Jel0HvIAFEvS8E/pSmdiscd8MQVUZFrGoYAK27bz0vlu4Pfpg7vvT+nK1ZwRwRd/HzADrljZ7xUtQduMXAavl8+af5sy3dNPU/YMDL2+qFmUOmGpQdE7TQcTD6xA4lWGGFBJFPLw9ofpIwGD02va3l0d2uDrndEjEAcjPJBLa/QCP/HARf35aod1 X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: b418d7cd-1bf0-4084-071a-08dbd0029a82 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:40.5117 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HDxx/nWxUXTX6mEinBFWvpZd35WRx4a2pS2N1/jsgQBIJP11JRchSNQ2WqY0KE3jW9K+eJHzEM3+f4JEmsmb2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org In serial_omap_rs485() RS485 support may be deactivated due to a missing RTS GPIO. This is done by nullifying the ports rs485_supported struct. After that however the serial_omap_rs485_supported struct is assigned to the same structure unconditionally, which results in an unintended reactivation of RS485 support. Fix this by callling serial_omap_rs485() after the assignment of rs485_supported. Fixes: e2752ae3cfc9 ("serial: omap: Disallow RS-485 if rts-gpio is not specified") Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/omap-serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 0ead88c5a19a..4f7ee4392034 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1604,10 +1604,6 @@ static int serial_omap_probe(struct platform_device *pdev) dev_info(up->port.dev, "no wakeirq for uart%d\n", up->port.line); - ret = serial_omap_probe_rs485(up, &pdev->dev); - if (ret < 0) - goto err_rs485; - sprintf(up->name, "OMAP UART%d", up->port.line); up->port.mapbase = mem->start; up->port.membase = base; @@ -1622,6 +1618,10 @@ static int serial_omap_probe(struct platform_device *pdev) DEFAULT_CLK_SPEED); } + ret = serial_omap_probe_rs485(up, &pdev->dev); + if (ret < 0) + goto err_rs485; + up->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; up->calc_latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; cpu_latency_qos_add_request(&up->pm_qos_request, up->latency); From patchwork Wed Oct 18 17:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 736147 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 61237CDB488 for ; Wed, 18 Oct 2023 17:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbjJRRt7 (ORCPT ); Wed, 18 Oct 2023 13:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbjJRRtx (ORCPT ); Wed, 18 Oct 2023 13:49:53 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2057.outbound.protection.outlook.com [40.107.6.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD81116; Wed, 18 Oct 2023 10:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZI11Qp0ddyi3ArfPj6/gxZ0GYiY4qu8wh2njXgL3FnAb54hRe5JyS+Bvfgvq+RTvJ48Qn8YmYnQQa9EBTFq6Ftc0BokRhR5zVAzh1+/eR0F3xe+dlj9RMfje0SNGxWe/BOPUiJ56KDzvE2MC2Ux6FYFrcxC97CpLfsgwFCsmx3gVOyWUnarySyVyq7c+NO9ENCtdIVhF+M9ulXfogkATdWnOyPmmVSHpwc0QsLtKcV1rR6aBasdFX5S+K5FVCvDHubadJBwZfd7t/8FsKF5j1dYD/HMTzYpGANkWXUx6QDPMq/f6zHoXkMquvqzQp4iqpu7OYpv5jHo+J8SOz0vuMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KixZxt5y8At1EBQmQPkFhCe8T2ISnHTFVXiaP8tzWo0=; b=n/ybaCQ7K3jKLhxWsm+wVxTmnEf+53MJvI6nMtyUH6xIpvlw8KKdluv7+FS5Kn139bU4m556llJdYKaQQkUw07I6tEY3xCcvgi1g6M5un4bVKLIUCzyFsbHtomAu0Z9fYx4mXglIWpNtslrsu+lL9/6zEeK2pOsCJTgdKbHIMVwi4gBPKXzAlxqS9AT49o+Ce58loAJHgxRwZTAguy5bdBaEScSusSi26pwfHTI75Q0U8uqkSFX/OC6gJuiYsHsGIHxC82ku71kliUbNywj9TyQR2wGt7HgGX6y8FnqzupkpBtDGedbWDnlVSknSjV1uQCl0hSf6m4cQhue1synCgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KixZxt5y8At1EBQmQPkFhCe8T2ISnHTFVXiaP8tzWo0=; b=a+Q1ikQM8PAbOPC7VKtnALztbYQp1OaETVlctgOY5tVMV0N1CwwUMFgojGCdyoWO1f837C4eLX0izQHnwmgWJkw+QrAEqKJG9ofN7+b45eb5QkzAZx12tlmKXBXR5E9dlYN+r/2i/sWGqbtfWcEr+ofuAw6kfO6GTI3mmp7ck4o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:41 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:41 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Wed, 18 Oct 2023 19:48:40 +0200 Message-Id: <20231018174840.28977-8-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b44f502-6f15-4798-29cc-08dbd0029ae6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rZkcZ87g+MV0N8+Z6DVmA2u3soE55ZeWshYC58BRH/JYaeI63ilaIVPWaUOCc0A5oGRZjx+gA5Fnq6QiFd/iP4M3NvUS54sRcrIGMbdEsmLaa5PdZk0OcFz+8LIuqSfBnqHUS05PRYHd2aosHK9cXa218AT98aSsmeaaspdF03Qi9sMfl2yfD2cEhOBRre3NDDAZ6bMSsemaKY8pQKuf6ZNI3hFTd/iikHr/S/eu4a3+bx3+A6jpEVNCIPc0Ydm4FDO/OaliBBMjmRNj2WGIFC2NgqKwobDYglpJJuPa6mbfQ2RnAcYV3NdP4P5G8SsU1BkYdY0nMGZ/PYuh7989WxvY5bSKNWA4MoOShYCc5ZhjK+29edwtYxHsDQ1hmHvhTEdwd6COJX8MGG1hVh5EvTcWs9aC1NctBd5IOD/SfjJipv9n0jQPgqY5Em1KlMjhEuuyNUAR/hjLLwbHdLYq+z9xdqJVU7VjygAswBI9vI3oHrt9p10YjBfZ+GcR3d5nJ97EBAd3j6BQjRJqpjv0ryxlN+LgYMA2mjg7FmmQbqFdCH5N2HxY0VZ0BMsp4O/P X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +Vg6WFXscyqjfbqBBEjQg0Onb0PsOjkTqLQJ7dcX3x9QXM8aIxV2cy7zEhwy6lvc5CK/bhcr57HWyl3/oehwns+aQuyHiwFpSsS6kfekM93LgomeRCDq90aMpm5wSrxtLGwCniFP8dPG/lPkUk82fN01qyfd7HSEEQUw8gESlITnr98WGAu/S10o/+0Douqo8WEkYPohcv4pZ5h4Lp4wUwohotGvUeVtBdyDmXJVgMLomzIUwlbXsXyNpio8ip2m7IlN2RybGLBdmtGmidZWlyBICBnXql+8w1vOICcYU81DNV8kCOySIA/78wPMHox/bkQBjU7ipAH9O5gjl5FN9ZCVPEZc9fsDho0YI9KMQnn6HZNAjEVdYJkNthOJDFjl1e3FmGbgL6V8GrR0Eoaogiy+TbS/b46xSuDIb/t35EFfkFNmB7muId7IDyh6gf9kOSz+0ikmPaxT3uMOglKl6MkZ2B2CBLp/r1gxb38Nri2mI1Rb3R/4GqTRR1cZ6PDMJKD5t9Nci4iQfIJq/B+mE+fD4JKGz7Ci7NGok8eZ2ovCy8SHz7+n6n50h0MC96+9takI4A5vuEC4dblwMONaxtBVt6hvxw5oeGyPfQb/o4dU5BDLlMSi0VvaiOTqB4+DgxaplriLv3+zHdhfNayB2f0ZkPbpVKuqKg6hB5jyk9II4/sW0iSURpmsmVW/V/2upCo30CYNUhVCmFtHhQi36D2HKZ4EhA4Ag0HT0WZGXJvjyIh8hqOH2GGAiPuxhcUt8FanxWsVCVheLFqSY2wW85JFyktaDj8asH4R6X7oDfBwMnWdFcE8bX+/p7R3qMfhl0fSrZOZpF3jD3SK2r8n4uVDIgk0VunWzbbkhooQebrLX5BUCsSwAPXA3gDSy8bWThS7YtYttzNh5MLlPiqbLIaGMgwHK+xgpzTL6tHQ45Z6+BEJ3/JrDxQDZY8NEl15fCMKUcZVVK7on4MK5g51opDl1Xx/cEDK/tlcQ3rn3tUpXT2INkDLYzEXBYYV8dVrr/XacZzn2zWccIZ6V5OqOavGDcgdA7ysEpSq3CNULWi/avFYR78Zz2XWuQPvawm5WBphIoRc05bk8oQHEY8UvUKCd1JKA681XGT0+mWNrTmZAQDgfbJlo7NCORZirJeo3ThpgC1HTxpljtm3Y4I05RoXzmYaKbLotTO4Rebx4wIOTsD78sVWWEqTAryX+MX4K4Yhhk7bEVpPRGx1vdREX8wu2MEa5E+lDLaVzl5qSvra4A2Stk3NJSwFcyvI/VhdTiiTZi+WlfCnnvNdLiWe8dNOZKwegre8avSEGQ0QplTPHJW4xv4hnAfuJhHP8NYn1WUqCi4sfK/mMAX0ECuBYA87RRKT0WyyUKbSCBHB/1dRTWJVld5KtPYkMX7cEshDudz5ojz7P5WuDm13o9YFhz8jbBcx0eq7UkukGOl4d/LsJEz4PCJjFAer8EE4TBaaFHauClVBrNNfhVMrzvz37HCIoUguNuJB8hpIal/ZGlJo6bU4P4gFERj77pe9QtkWOuMiDFJ0gd3amqjAQFvuzzMWgb13O5MlUlK5O785fJDx/j9dGtdsHrym8kiCfMsx+w8CjhRY1egbS/VKpg/pQLAjL2VBt3I0dr/W7mE+ODlzjOtkfC6xYkKYz8ZGZXRh X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b44f502-6f15-4798-29cc-08dbd0029ae6 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:41.1409 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GZuGhQcJ/UAZhnIJhtsXmXjPPFLaAHyc+BG0wmsA7KS3mCRpFcLTiVfjVr9+trzU9GWHDgJfHCRXfMJfew+u/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The UART supports an auto-RTS mode in which the RTS pin is automatically activated during transmission. So mark this mode as being supported even if RTS is not controlled by the driver but the UART. Also the serial core expects now at least one of both modes rts-on-send or rts-after-send to be supported. This is since during sanitization unsupported flags are deleted from a RS485 configuration set by userspace. However if the configuration ends up with both flags unset, the core prints a warning since it considers such a configuration invalid (see uart_sanitize_serial_rs485()). Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/8250/8250_exar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) This patch is only required if "serial: core: fix sanitizing check for RTS settings" is applied, which is also part of this series. Therefore it lacks a "Fixes:" tag. diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 077c3ba3539e..8385be846840 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -446,7 +446,7 @@ static int generic_rs485_config(struct uart_port *port, struct ktermios *termios } static const struct serial_rs485 generic_rs485_supported = { - .flags = SER_RS485_ENABLED, + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND, }; static const struct exar8250_platform exar8250_default_platform = { @@ -490,7 +490,8 @@ static int iot2040_rs485_config(struct uart_port *port, struct ktermios *termios } static const struct serial_rs485 iot2040_rs485_supported = { - .flags = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | + SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, }; static const struct property_entry iot2040_gpio_properties[] = {