From patchwork Sun Nov 19 11:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745601 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 4B3A6C5AD4C for ; Sun, 19 Nov 2023 11:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232005AbjKSLcX (ORCPT ); Sun, 19 Nov 2023 06:32:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbjKSLcG (ORCPT ); Sun, 19 Nov 2023 06:32:06 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4784A3AA2; Sun, 19 Nov 2023 03:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gqMnpe1A7TTuPXB8XlXjjpGFNvwYV2UDVDr54x5Nau8izBIuXhzwelALKBkyJVnx8teBM+OEIU5OIMrcVNml8jweKTmaPN6egSFHSBe6eksIQ/RFkiUd3FskI0JVzqcBWEdk+yIjl7b3AgXnSH2Dts+8w6V/vvbt8yup0fKeucr5SkKVWqEHE2WCy3eVc+2zyxXxxIqOg4Wl+eBxoS6X7uyhz4AeTzZ/KWmK8V1YqIQGKe6UlacjrzLOQ3nWwK8B5vhFUPu3CcRBjA6xYuoFCUWhnxbgvxZsiH0d0e08/tdsmovKKwgbYcBLBMuqEqcDqJVMNem09ES8VtBD5PXASw== 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=Y2pTezH0DgO8+z7w1y5ywOUCZlRR/vO2d+VhJfncoRA=; b=Qb0QQbA2gQU9MoUOZxSeqFTsWKJXbVP/AxPACyDocAiYIye8QktYLOL8XJ6Q/oh2HhACq2Xrlv9u6y/h1VBjSA1icN7FGvRseDVz+lQuEhKaEBEeNbZ3YGFncUzBOnSF0stjlHhwKnA9UYuhiWwU2eVF5W0N3P7dKCt3cYvggMapQD22sMAP2MjelSYB5WgS3BwsDdTxzphr+El3MMZnAGV2Yu4t//d3/+KekEb1oaK7OWI7W/WUrnv8LXci7f5XqO8Q3N468AAILAwVLWw5k9abbYu+JLuAnTMd82PC5smaHgLENqCMa7lTJxsvuZUAtt3qtdMocUBwHTgaSQxM+A== 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=Y2pTezH0DgO8+z7w1y5ywOUCZlRR/vO2d+VhJfncoRA=; b=kVyC4JL3qta0Rq0u5WhXjLzyr3rywyZY73jY73LdvUJcXE8ivyDERZ0+OFAlTrQ4bpsPdCeODtcnLSbQOAiyi32kQWio3i7U0ege/iVDKvERXutNc57ppVRilbmufmDJz/u0APaK/+PjG52AWdmx9FWyYOtpJfTounVEx6Woelo= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:29:59 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:29:59 +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: [RESEND PATCH v4 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Sun, 19 Nov 2023 12:28:49 +0100 Message-ID: <20231119112856.11587-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: ef6725b6-4b36-4df9-26f8-08dbe8f2dd1b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GUTUgW8ALe0G2xq5rLSflLGhGbHz3foUod+q/Bp98SkOWkZwLAbsskDqkpHr9rDpdSFv4LJaPkAmb5cRFluE5IL1YdFZf3HqZtXHNb3PjxmV1imKZY69wCrnncJBFNlhqSMGlwDut2EAscpTzlUV5xjH6yhixcMMP3sKv6/+T413/BM3PuPohcifnEdd8zCimLDr072z31F2/3fZ2ao5a8ovIi4pCyof3SkPjcxuOj0r7wc/vMvuj88MvaPXk9H6aqMDPmYdauclQ9/DRjrrNJs67FabQyJTP0/YduobSwEUAg+shzoJU27Txxq6I7Gog4KRrZTPNCsuKVJHhUWp+cU6kT1KRlzT7cluw9bVmakw9TtRpXLgIO6OCIMCFPidoVRUotFJCM2coNB2/ErELsbk7zXr5dHE/8YT/033tvL9KduE/1fLtneMHcIRHFMIjI4CBxCPGvW8ULVCIkht7mLI2yLCnuB/L2G0sYNdBaWAt4P3w4N0dk+tw2bem37L6jf8p0D8hoKOVZ1W/Fcn1ipxvgo1EWj/6K7sokpc5nQ= 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(83380400001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ycBRkyfAQ76L/h7O0AVb8etclca5oTgbxv1WjzBeBCu3iMySu9gu93whUXT/DdV1OzEC2aF7fACCAsXhILk5v6qPb+NgtAh2mykA1P3arnV3wZGSTw1at0TWd30b0vmtsTiuYB95FKk7yEE6CGG87lKs+OTCds2LPBPj/77Yw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vysZhiQ9ZOk5bCEj3lpBmDqeuqHdiFK0vziBMzN5MuUNLYgkRkehiGHHoZzUQe2ZgInXCfyiB5XyDaEE1iYgFZpNJhRsBewCYIwX6baqTJykK93BiBxszgdMSc8SDfr3EsqI/Wgaw1L6h3oHmwgWFNep9PwXlM4tJsfua5KUPaBqOdtjILZOutQM7l2hJWjLQH0UOplzfkk9wHUjGZLaQpo4lNY4FsfsBdz8DWOsgadgDN17LxoWO6EnO4qDhvIj5tmkoNcKcWuShfHpPnaEeJkk0HkdjYzeHakS3JzoyT/SBzikxnN38y7xEqZjmRuJbdZPmESxViImKrJYcLwwONcoh8v7EWr+gZemf0Ut5jdLlH+fOZwag5aL6aTPiBO6GOWkR+Gy4StS0/t9y6IuO8IMgmVBe80EGeRb/ X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef6725b6-4b36-4df9-26f8-08dbe8f2dd1b X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:29:59.4907 (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: IM981oZrSd5OGu9aotJLllfE8gp1pXovJCBdVLsFPmQfz/yw71jDsJtx6/lujfBQ4im35LMfVGIN2F4W1CTtpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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 708b9852a575..9cffeb23112b 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1943,10 +1943,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 f1348a509552..ab766f48c172 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1392,14 +1392,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) @@ -1412,7 +1419,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); uart_port_lock_irqsave(port, &flags); ret = port->rs485_config(port, NULL, rs485); @@ -1456,7 +1463,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); uart_port_lock_irqsave(port, &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 3048620315d6..ec9a72a5bea9 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 Sun Nov 19 11:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745600 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 10692C072A2 for ; Sun, 19 Nov 2023 11:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232070AbjKSLdC (ORCPT ); Sun, 19 Nov 2023 06:33:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232047AbjKSLcn (ORCPT ); Sun, 19 Nov 2023 06:32:43 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2065.outbound.protection.outlook.com [40.107.104.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9C71719; Sun, 19 Nov 2023 03:30:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kyVTx+9nf+1YNu4UDyoB3DuwM4uZYmtdbvV2F3+w+v7+JP9S302a9Jf5K3oTCAQkSLrCjbc9SmPRY8MfIr9Zm3lw/SEoy5kV+rgq17QnvviTUGqMRl8hRfE8z3JXoET96Pb0ZEKE2hWrVTTuAOBI8htD+F8OLws/jzhmZJQjuxScNi6HLun3pDBQF8sKyoTjpm91Mcl0ZqEdwMmYhG2ax51LiQOPmLLqm8oAf2IN2SLTmML97nGTtbFY8wYQn88gWOX8gTRdE7jWc1btu7geYSjX7UA8bFdymhiarTWQx2Bdm31tHtiCz/DldwcoMrsCs/fyDS8f0bZTguQU9WLUOg== 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=Q4z698JLUkkru96cdedTpremk0cvUbZVueJtn/hJiUU=; b=YhyjFFbqyLxAIVodcTCTBxs20OtFqsmBQXcBXpObk6jGg6ZvqWbOK+mJRiXD2icdq98ae/I3iSWYMUFvA0XeihwUTKRH8mllEApUB8WGoJ5uS78JpR7DH4IK7u6yCHe5Kg5IHCh1Lpx9Y0oLY+0AVnrNZR0vyO3GDe3YkjdQlvp1x+i22bzarcJE0PpLA07SGhe5CAvwPz0c6P6R9l7/0QsuG7Zsk4Ddw0fNMwx3f+jGQBHZo2dvSVZ4vNY/rpQbfdCHlgy0PKuk6IbPTFOkTPIwa7LvQX+Np+w2F5Q8E4DTe2vW+5gQipmfWn8aZ4MFCYLQmOTZES8gJQemoJEOaQ== 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=Q4z698JLUkkru96cdedTpremk0cvUbZVueJtn/hJiUU=; b=TrEINb/E6SkAAVfvMuGjiUF0lHEtv0uUHJskmVk0haC+N0Q+bhr1CRA3UHj1nVdp4wbV78n/jSLp0/hjfl/r8RR14S61/lwkRnQ+buDL/RxVCozejmvy5AYBz8rh3WiPVPVn5HMnVO041CoES4MqXQzXuj1jyQSpqCl3Yv5KOrc= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:30:00 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:30:00 +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: [RESEND PATCH v4 2/7] serial: core: set missing supported flag for RX during TX GPIO Date: Sun, 19 Nov 2023 12:28:50 +0100 Message-ID: <20231119112856.11587-3-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: 50846c25-e5c3-4f5f-0e96-08dbe8f2dd84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1wU9hM38ah+qre32fsIhck9T+JgRUsfDwGKBAGGTvxJkiBdu4ziKcq/9DkObNfUyHyWbtznSjaDPTgnI5Ug9K/GN2DOx5vWyCVquXFVJkOPO1WMojYMMtbL7ntgpL4PDUqySMfd8jAZc1jVvNyBLqZ3JRRD+M/qTB4npJpXmMpP4tcJhvCqJ8/z6/kon4950XAuAZ/DDtEfARfEmeOkkzaEOeG3X2ZWZRqZ5VzZ9GnpTSgrLUJoGMp9TF5dO2nmOh98N9S+P1sm9qiNQo3wLPHWGKCLMhebwJRvBTzPXB17FoAVoGGx+f7IP5jiJ6PzqHoaL9/X74iRoS26ilNzrE7UJIWeHdpTNqB3z5TY9dWEWrERtyyMyrziU4x5VRQMXZFonrFRpgOU/pg7TtJQsODxD7r3vycLfFjoflzPBU5NlgzvmovtEm1niPhzDmu23mHjIg+8nRS+EEeVN0T2wxcdZdpe3EEMY+1FhqEhkYcC5rWwpePqyyIwRTu/PaMavKqaLr1pFanHpbxaJxKrH4k5VH3Xp8HK0GPoYbrDCAn82tcL/IL5NhrVNi3E/Br6v 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vFkRnIgn+NoC3iA19inS+7TqhV8FQnsMhv6+HkegsjnqLBCefLVF+z/uLy8dG5My6xN7qDkuRDZuGbZ26Ffw9BECWd+ys7+Kn24GzmbOBg8fTlx263WK0/cIrBYqacqBCQMIi0V3MTZywrVl+qpV6Zgu8zN0GkzAk68x3K0/CUjw+joGtgkgjSwPiI4U68vXNMew7ib8/yMJq9+bit91KkNtPs5uhKxpVqTIFXd1SAbaLytK6Y5zgnQeMauiAAIHswQzn/Hl0QCK1sIaaMsINzrSZzyJsgZDrLgixq8YUw5BgQfxNSBmsi4o5/iA6Vrh6Bg+ZENMdkbwm6MUFp0EOn2Urt1iDcQW+7Obk+nY6d3lxuN13+8y/DxpJKH5l2zwdCWgLoaeCOGiMBg2DAjfQTEG8Oj+JapGpyKkU90amiVR6QrnfHbFf7pOzh5EW0WTXJzwU4t2JxIAGG1ds8CkZjoTzd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21RbuW7Mn5utA+hMFAeuK73Uk8Y7aHEIVgteN/egLox1qXk7sNmwfqAkwDVXpoTGEB3ZqiweaWqK8fU2toW3FL+/rDkpvBxHC3gU2uYYAqWdw9Tr4vj9pD X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50846c25-e5c3-4f5f-0e96-08dbe8f2dd84 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:30:00.0566 (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: s2SJzB5xe3T+JWxFOwCI8xuJTUKWzCTA3KSFbN7RYB6noY3/5Nh924EPgc2H+ZWk/R49uetOrpWTlIJuVbNAew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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 ab766f48c172..af175c803c22 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3627,6 +3627,8 @@ int uart_get_rs485_mode(struct uart_port *port) if (IS_ERR(desc)) return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-rx-during-tx-gpios\n"); port->rs485_rx_during_tx_gpio = desc; + if (port->rs485_rx_during_tx_gpio) + port->rs485_supported.flags |= SER_RS485_RX_DURING_TX; return 0; } From patchwork Sun Nov 19 11:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745338 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 07E69C5ACB3 for ; Sun, 19 Nov 2023 11:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232059AbjKSLcw (ORCPT ); Sun, 19 Nov 2023 06:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231898AbjKSLcj (ORCPT ); Sun, 19 Nov 2023 06:32:39 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17DD044A7; Sun, 19 Nov 2023 03:30:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dU4UICB6flJUXF6E2PVbUV4OXfSjXfyKlGcnfFh9VagLv0tzHWiiqPOByzMM+YpAVdD8M0BJGhX39rcg3Lj3FR+pu0OxMl6w4cvh85b0/UlIOprR6yLpq8HNcpmUONRky8BAapkeCQfuoVzzkfld03JqFgSR5c/1vQXh60ZeLJUsj5nUQlLTOCQYaWR8aDieAMRe4BKjaAaQU9jlNc+EHGG9pNwQhCrBMq1u3MPLfauWZBQGK7qTN8nWZNKfWkPkcktg2YXvWpooXXYchpPWkv5rqAiC87xu6xiCE6GVUnwdENPPoE2w5eWEQmU55zRyaFcN4EL2KeHJrj8Aj10DIg== 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=6ZxcY2V8pvHHlMHg+raIYpD3DErsKilkTaqXyHGRn8k=; b=npHDLUtAh3Wvs0Ulwg/x4IBRfguzkwg6VB03CSh9jrsEHn9XU3fYXanzXX+JW2sWo2AMM55kZgFvnbxmthQ36my12MbbELM1G388SlncbF6aer6w+2goT9VN1jqAj+3iC89YQws/viLjELFehAXLy8YoSdK5uBzdqhQwuRX3ljCfYujIcG78MRipMNOasIUOnl4VFj31pS4VQJGa0wcI34eRayA8My/GLQL/5Mqk/ZA7PluyTTuCNBepZX/ofOowciIRxwq9AC9+KvvN8fatuzWe+WB9GDtIxZAC/XAhCyljH8sVDCc6F+LMDI+ZteDSUJHm83afmy6FQlQmR9Cxjw== 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=6ZxcY2V8pvHHlMHg+raIYpD3DErsKilkTaqXyHGRn8k=; b=WEpZYnYcNGG3RWiZrki9Fo42W8XXlb9JstMHyX70ACLczzVibvzquhnk+h7JGbU9hzEJaYpdjRTEzQj2TYrjNReNEksGC26bHJKiR5wIgeTo1HgyChwg9PPO0vl8hynTYXCafriukiDAFkKRgpxCuJtZPBRv6VL101ODiES9+vM= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:30:00 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:30:00 +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: [RESEND PATCH v4 3/7] serial: core: fix sanitizing check for RTS settings Date: Sun, 19 Nov 2023 12:28:51 +0100 Message-ID: <20231119112856.11587-4-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d05352f-e67c-461b-edc4-08dbe8f2ddd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +q8ospweDuzsc684eHqP29cq3Ilf6Oy4tYHZfv0HRnNu79l7raCC9iXZz9d08LbVB2B95NNBWZeDK0drnG/yX5yDgXO6jNE93SYY3MN/yFavoNo5eBjpkUu0f2R/D3ZzCsdMbVt9hb8/16EuKV2Kneu1qQyUC+PGZ12zv6w5chIHwVS4b/ywrEqG67Z331DeATLvQ5Z9pwNLmUOPwqsiBDuvHBP9JLfuHZ2wYhSmZVuDElVRRB2l2W3lZ+pjrmw1LfbZREKlx9yEj+gdpeOItJ6Rb64OfTC2LcPAOUQXnsUAMhcKcmAMMk5U4ZsqsR4lBtVm1gNAVkjS7Ky7LVe4hD44N7VGNKCy+1DP9Rqmm/quiwYrh+WzcjbqwdYs+WsiA0UPvnJGw97otRl7DqjGDeFd+SkpFtr5brE15rko4G2rSGiOOLaeY+asi79EXCHfRTiI2jNG3Ju8oZsK2/PRQvpHKdj/vhfYNb0m+qPJ1mkKE23lPZ6zXbXAH9g1okX5mGyAtHph0m1LomFNYVeBpwfg5HzDOeuWqLgx0PrbyPXb8UQYv2hXdbzV4mmLrSEL 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(83380400001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6u4g1OP5QkpLJE95y/hVsrKoKhkysPtKhvwNVuEpRrdqRNUNQlRcuq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IwAnlg2s/I9BTS5tBYmpXzxpvxF8g2n6BjjB0sew9/rP9APE5YcimDFC6nwb8BUoroqPnHsYkKE10gJ+Sy1uCKi3C8E9z4ZVWdKT6cn4Y6zlgibvp65OQKMIoiYCblofozNUxwAAOpbpoEsG+VhqvPGsyR39iB2klZCaqLaqqxdpCESp+nYckj9J9H+5juFU5KkHuRVWx4b1MCIunHeA29e0EJ7RkXbGK5gsTunqprtKypxqgs1SDMocDgYUZuSASlpaSjIGXqfNNNgXBIaOO5vV+bgog7Abno5BtsUzrCfXIFAhwG6JT0yJZrh9OWIT8ggeDXHH6Boulag/GbCWmsQzbaCDksioPEPC+JzJU1PtfWKARC3i12PfWGEdqjVaSU8JO2FsBwnqTzLhTF7Y9RgqqSM6MOTDunsN9r+qZkPT1VRujyj/7UqrSrUVNzDBpcSsaDfdZjeJh1Gug/XK4LGGLVKK6qkjh8oZ3CRQvNw5YVL04QSWCR7uV5esrS8NzAVq8idVNlPZoN2igjLycTO X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d05352f-e67c-461b-edc4-08dbe8f2ddd9 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:30:00.5987 (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: 2W4ArfopuC7TAJg8TDADqmZQijow9Vk2TtAs+V+2Sa/raR0MfRltEa70yjmlsmuGyyWVtZ008/Nupwz4tz9A3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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 af175c803c22..b96fc2ba8596 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1371,19 +1371,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 Sun Nov 19 11:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745337 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 CE210C5ACB3 for ; Sun, 19 Nov 2023 11:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbjKSLd0 (ORCPT ); Sun, 19 Nov 2023 06:33:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232100AbjKSLdM (ORCPT ); Sun, 19 Nov 2023 06:33:12 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91C619AA; Sun, 19 Nov 2023 03:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UNMcTDzvC3EETKyZMKdcgGIZRj+ruNlMyjouDE7yQcoLtfGa7SyvVLKmJBJGk9CEyVQiIlNALsGGBp4hL2dzrKFWAmkXRQ+0FnHImr+S5zUKEegRCSPpLzzXtVCetxULZuzyBYgrHpNl2m8nMGDZCaRjIfHkw7WqSxMwxr/VsePDRRnZGimnpUP22SubtohyS1zyl2c2iOhbJgoyNoNkRR09oND695nC5ehWkFCxH9CNuyN+b8TqAP/bz6bL7bTkJ5iAip2FfiBk5iZDZBIkUDzcKtsd9po2ibaUKqGUJhyN6dklisJVAxGcPL4bZKRjvJZ8iEqD0dJ9opU+nVeb0Q== 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=ebPnrpWvtNskQGU9VdxDDVTFT0EpFdJL+SfMBJwjsmI=; b=mlUgOkPlx9k06qQDPmwjgFhyAZN5mebBrFeoHOquEvl2IhS/jfuXX2Fat1wySwJrtfr7oW5m7zZikCTYjAV7SS7vZ47umfF8aqoVSaG0myUteAHTr9DHRzvY7TWS+gZBgU+GkJ+oeAvtJV8Sbu7RdKpuh0TR4fmVj1ZDZzUowSjA9JPAP+11MjKhru7O8fJ1YJv2wbxY4TLlizDmy2rRAS/EmMM0fTN4NPR3o3s16BSfcyAzxdvZtRq4ew8VtGDWYFzBK/Sz2zkzIo1PUBhILc+P4Ou2bpApU7tP+khBwocMHRoF8IqkKUjc9Ge19bnYF5GK+2Ih2/vuIlPTXj2n5A== 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=ebPnrpWvtNskQGU9VdxDDVTFT0EpFdJL+SfMBJwjsmI=; b=Z16GkgyaNMbGMuK/n02nZUR5hq1G67JIydjsTmfCIDsIu2rbCXrDdaqUDe8zLYzhcLMcj/9HfQblSvyA1u2/B8Iwt0K7Brg00KyWBYO4zs9ZfSQzP2CiDy0sAgqZJaplVxgYZ5D0Y6HBoxtL3ILiPzRpBMw6jtWlsDo059MBtV0= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:30:01 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:30:01 +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: [RESEND PATCH v4 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Sun, 19 Nov 2023 12:28:52 +0100 Message-ID: <20231119112856.11587-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: e20746de-aae3-4516-5588-08dbe8f2de2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jk/opv8mj/wscxDT/+tbinvNKNDSd7wnsNI+s8owrocjfKDfkWwpPihK3FJftWlY3fGUBTfa5spXA0yGm8lne4vDjnC53Lg3CVNSCL9YrId9gcM6Cwqc62A1LhEY98pzF8jbYTl62lgbUjE+ySmjTtnR9QSlVtVff2Rhqw7Z5CspNEfnwHhudAmS0ksN3rRyBk9WhPKJcloAsbSl4ofj5K3TpBR35Q7IwDGr2UrBXWPdZOqja7vgSvl78Gg7mJzThIgbEAmk40MFMxWooZBxnYAu61flz24AKqNCIwzdbCcq9EfvWpUyeUYIgQCZmxKZu7LC8G69DcEmpdcykQzfpOdnK6tVaaLR4Scc9ArstnjBOGbKpLBFt6kbrFfJUdzzRpGcDWEqPdDTrdkDkPfZaNGM7VUYd1gXPG1eDIUapH1hPzHpT/FDVDP5DSTe9pDzeYZOWouwlfErvc6MQYMsKYjf01ttmy1b+KUyFLLq7DfccGaG6eeOunqFTTnEGsi3Zpo1AmvtFrL0VK10LeVEUA4oERhW3l9e93HP9lqZYqdaQn8/XFfzC2HklKbotKba 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(83380400001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Ex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jZUTtt/M4RttU2knah7NNdT3a/4jM2oQeGAK2aGVHgfjJMAxK9ceuJ/Gq6rr4gpN4xldEbE45LQDDGvdgU3hnNmgzeEFRbFD7f1/k6plxBx5LNnUGRnh9/SnsOvvqKraTIGLcK9YJsWuRQ3KpQWZEBm950eylUloJXw1Eli0mst7jlKgRZpE04eXmwteX43kYCSPHdJ9R+q09AhF2I3cc6O27Vm+YOzw/SA9V2Oj7XrvR8H8M1PJb5B++iAJ9XpL6/fIdrGElxX0yXhr21EcOZcvaqFXIKZC2eSJWmunkd5TuEKqPoJ0jNwHkT6VJSvVp4H//obn7EC23NruIx0JOXwdafVoMP3yZjyYaFdvwH7obgZdf2dOwgcqyBKleoMMezLykDzs/6Qa+1ctSl8G+CcuERiweySk4B2X4U2A/koLR2ezzcJhdWNoz5LccH1rxal6+0aBc5KvwyRcwyE83s5u73Ds/nJROJHk969/Azuczuuid3E98Pc6BEbDCOne9Ymtco8iCyn6L9sotCNFH90yabw1DD1YZHo1tmgM3hJCjYwls9lNigruHet39kZ6RfUafKk+vOK9FE2tjm49poNvgh2DTWikICloWRgLrwtpx+qS1G/VQDSzQg+sCszw X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: e20746de-aae3-4516-5588-08dbe8f2de2d X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:30:01.1375 (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: ia8XkdAfzXIMiWZSRr1ER5Fvfnvcf4jGuJleTvzYVN0/BEUDe7KtWZtikC/fsiYGeEHPgA8HP9ZgvuxD6lVL6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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 b96fc2ba8596..b636e2ce6e8b 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1444,6 +1444,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; + uart_port_lock_irqsave(port, &flags); aux = port->rs485; uart_port_unlock_irqrestore(port, flags); @@ -1461,7 +1464,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 Sun Nov 19 11:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745599 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 5A533C5AD4C for ; Sun, 19 Nov 2023 11:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbjKSLdh (ORCPT ); Sun, 19 Nov 2023 06:33:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbjKSLdT (ORCPT ); Sun, 19 Nov 2023 06:33:19 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2065.outbound.protection.outlook.com [40.107.104.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6304E19B7; Sun, 19 Nov 2023 03:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EZZO99TYhUAuwAU/VRsfU4Y7Mvt+DWVKX5PpufP9z9sFE+tZQ0Y4xRwAKeYlI1gEMc6vCz17EGw5alIxdhMdQBTThErUvqLVBCKlA9xNXhODq/0y5n6uIciZQvSvcH3GG6xelhSnRUfIdHjCh9mvxK2k6YA4qok86r0X1Yg4WB1ZzMqaWBT79YjLvRX6cKs73zmiLky3M0LmVFCSyojhXpRStJBKrejuJhFJJTDZu5AA9KmXOUYHFPI/Sjl9y6dqF/xeW8WyhmCuwXv0PBVToBLPlru1tOHwFwmCtIFaeKgmHj0ksx/nwveF6RotZofZPDrTicTa5JH3mdZAT17ZVw== 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=K+1MxCDAL+VXAwZ1w1tZbusxF2hjn3qObDdr33XIjkI=; b=moTK5RxQmomR3mOjqSF3yMEcFjtptadirU20qzvYVqi74AKfIhKU2nnAbm4WkzjDnceSojs51QGC8hFSZo4M5dKegHePPrfvzctfAxJNf1KdkpPzJ5/1iamSK0WR8RAOFaP37etfRrvZcrK2mCZSS9izok9WerH+QHG/Mew3Oi0BjqQxe4HzvMy3vQ8ra4g1hONXLR2EAOWpx7ZL7comV3mis/Wmq4AFzHb8R4L2fOIo1stz/jj8HwQ+OjKZydeKEGNF4P8/bP5613LIT/cZm4Amq9XNjjCYb2kxQ769TBNe/UmUmcfqRqJFEb2nDiKNrm7M8zDeSSY1nSN53OKJhA== 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=K+1MxCDAL+VXAwZ1w1tZbusxF2hjn3qObDdr33XIjkI=; b=D34l9eQNS9HV75e/oog0ZDLfiw90Q+PNZN2RTojKky7+EwvjLR0v7k2U6wuIa7+OsRffbMZrGCjcdYdvCJYT5yO8GWTJKjU5F9frqjo0iLHXqwPZ4C1jPPNEaf3Sg2MAPFzgSgG2tKXtLIs7C5+HzDB2QSLc4tQP6ifA/lDxBTE= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:30:01 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:30:01 +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: [RESEND PATCH v4 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Sun, 19 Nov 2023 12:28:53 +0100 Message-ID: <20231119112856.11587-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: 64c9931d-4f02-4340-29b7-08dbe8f2de83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q0LGHB0c7TTeM05ow5gD+ElnnQL/FhDSeVFQhodrWPZS0SwP7AzQNQP5bYlw+4HKxeGCN6FXOl7gKrShGUbOXRdt1EZy/q/Sx2BVnpUfMBQEZklWLZvWX1OGnb+gVwjc0fNzdR3+NSOfCycUrq33XJe7NIiY1wUYXwI+Ivi/Bq+3sU7hk3VX6x9jkCmOHqGs82qJN1fVG8yeaQfE8b9Ji1wiUtgPyOCUndDHQNTtCuv1F1bnkVM+Jtks81qGg12LAKY2avguv2ve9G50tW/vFy5JEgmylJxKO7DVJdNUKq0GlUZ7hBf/mzZsMY46u/3YekOlQwlKcSYnGzVZwdFCcXbuEDpWEZSf1tdAn+YTNnMiM5jqGC+h8Jnkk6ldlH9Q5+thPTDsz/ifi+D+b/iMGbrpXAYcoFCSI7vuaSmqkK+F9ZmNLPgkFi6wVotrKp4JBRtNsIUHZejQY87Ru6PJEZApAEfljwIYA7xGDrOyATDLV+36PGp0Kn81Rmy1DolcPSeGNjCGwlaAhXfBcJ2S/B1QIhF7rl5ic0BHKx0zJ2E9ToWbeSS1xHONi9XnNBNp 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(83380400001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?u08pylkliJKBLhRlkJ+qvR95ajqN?= =?utf-8?q?wJnnDKH3CGxGVAUPzRX/Q0FjxzzRNcU55Akfeqyh4ilFl9TdJLSg80tmYosPc+nMj?= =?utf-8?q?7+kTq2ecxFc3kYyIgvFQGi1+JqAicIxozRGSEX8Bf5wolfG2EjoG8ndlP/uTZYWX7?= =?utf-8?q?sfDp+oki0fPO5djpq+L+3Cp6qhbC+nFRL9gVQbscrctVjY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+F8p4+rdmk3MJZ7g?= =?utf-8?q?nHeBoCjWPPs8RCoGrjvqdopHIIoTIJugO7Re565CStt5SoCPe7XYtyi5z7LfxP9dP?= =?utf-8?q?4kNxss6fAYlIbNfpZ5pWVDmNkQZvYiGVnQhpiZCsk6pYl6N0uTVsQjEE9irtGwGmW?= =?utf-8?q?iUXs09P+SdjVMiPwrF2rJxjww3gynzh+WsOpzC6JY9JSNDxTgZNeWP6LQavWLrXwV?= =?utf-8?q?gLXFqB5ogVaHisvkzrzf3U01X7pNPGQghgJrvTgYKFoWU3ieg3ziebp+DZ3w1t/pu?= =?utf-8?q?FyQ7N9NpY8Lus7Cs/Lf6nsnst7+vEf4xCYAeErj34xWdoHqNbqSi/ikoSILt9XiHK?= =?utf-8?q?JTSljUcY7wfSU3lxOvAtYKHyROBbFa0L4svUo5r5lRFVqLv9xvyjyopwv7Q+5qPY/?= =?utf-8?q?9w1o80pJSqGjbcfuB08mh4pWyVuAs1qARM+JUEhConhUXeZtlsPBsVKTxjVD/jP4e?= =?utf-8?q?ubhjkXAUoQYa4EkSf0I1T0bjT5vdXLI5sfw4mHCx/TdkeXmMGmIOVWH/l7hr5LUjG?= =?utf-8?q?46BEvMsNSw1?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64c9931d-4f02-4340-29b7-08dbe8f2de83 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:30:01.7062 (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: pPdr3yjCygk46Gx015I+queD7HnsBbnEMDZHMDEjI5HrMAfVD+qJWxtZ1wSA24RKSqFKTaJMUPthXVNzXrjkpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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 9cffeb23112b..98b78d360a74 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2328,10 +2328,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 b636e2ce6e8b..518e19036983 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3588,6 +3588,9 @@ int uart_get_rs485_mode(struct uart_port *port) u32 rs485_delay[2]; int ret; + 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 Sun Nov 19 11:28:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745336 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 BCCFFC5ACB3 for ; Sun, 19 Nov 2023 11:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232035AbjKSLdw (ORCPT ); Sun, 19 Nov 2023 06:33:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjKSLdf (ORCPT ); Sun, 19 Nov 2023 06:33:35 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67B4A171C; Sun, 19 Nov 2023 03:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rp2xRMGjs/OAEPIR4iZshHe4TRW1v14fvnVa9Rsaftbh7ft4DlNWpT8YZsdGAFZD2uYNc0YYiY2E7TVpT1bnfEMclvteirYUivhWBGaGOHBVvZeVH2X6o3ZmsGJw3iOOAWM3+RsMAjwrQsFw0LpmFcEOgVU56ytTrJtS5KE+Tu0WE1R4xQ5WvjZkGpesU931H2D1PW0Lq/ohsrSyK5uUqjiUz+iR0BZJnT7SETMF4IXNWFgtFwGiyS9cOV5vQvTFH6S2YGb8STbrcGhPDlWBGG9p35gs/x68/xNKSqy1pa8zUJlwxaCEqc6KCFzdvMj/PoZabOM3srKHCbe+YOsH2g== 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=9sRBm8gY2tDiUYzcClFGE54s4heCXu5xxHjSH1pF67Q=; b=AZ7Ag5nRr0tyLckH38dbkBC1J+I61gvA34zjA0LoeTXeTw0k98d6cb5tLFpov+RWhsGvxLDUc0TU4ArQJd1u7WcCwbylvr8yDeqt3+iztiJfTf4tsGVq4BvsL/eI4WKKmx1y/FXdmtg2z8CW3u1S1FsgSQo3hmqDKNPBmQHIMmx4mTP4I5sd0jYkb1H5CyOyMu2V4dE4u2pLagtFioVw/ElOdZ/V+rVwAzbslhgswqp0sbvZae97Bve5fZf00S/K8sc74UR7anwMshYZOq2+WmOplCTJbARExHLLB30k52pRXBGPxXgcMgqtIxws9e/B3UzNmTAGyiHZANr2MKgfLA== 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=9sRBm8gY2tDiUYzcClFGE54s4heCXu5xxHjSH1pF67Q=; b=XofNqO6PcCF4MmU/CFqn9rx8fA2Z9aHxirsgAb/NJqOt/9Zy1L9S5uTO78yibqKE8Bp0K+mePZoolzFeky2DjI+U+1tis791TT6UaoFQr8wY4Nd3Cc/kujLlVNJuCSBi+S7m7EyENmjzUqiL6t7wy6FS85s/dO/cH8Z6yviCaJk= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:30:02 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:30:02 +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: [RESEND PATCH v4 6/7] serial: omap: do not override settings for RS485 support Date: Sun, 19 Nov 2023 12:28:54 +0100 Message-ID: <20231119112856.11587-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: ad1d9d0e-d8b0-438a-fea6-08dbe8f2ded8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sx2pcj8IhFGyLLrJ93U04KCqNpFpRn6F9CjOfv60TqM00A5aLN0cDERetSZrdsPcreArJX3XPOZVx5TC3V2otFjhGZ5eaHNQMpNjWsZXW8SiaaIxsmsJxcd6gTGTqE+DTCvCRn0C57TVRRa2/z+Cie5bko5QpdqPzcPMLBZYMYsoUO62OMxG3KdilArTWrH+Fj6Nl7xNE1hGX8ZoPN9pm1rPgQxU7sUdhF4/5K7g+w265iSQvGbj0EgjJoyNRWEhOtkwtlX4BDB6Dff69vRZuoi7YUvSAp443bzOyh5xDhHTXKOArO3ZC0y/moJ8fCfDmki+L5SL5tAcXImbk1bPDA/3C9I+Tij1nerjeCocYokdGksrYqJuJCLftjsi7GWphzl8ZMEmjsb4W2Sfw8wb7b4wJIYj/WcVxKd81TxMM+v6oKDgret/DZXbBTivxFNHEFDEHtxeqDZvgzP5kNuDz246P/LtHirH4L8CgyC3Cv6264ghiZZ9rksryXftLohY+dmcZM//8teGmKWvGx4j9wHyIIK3N1oarZ4VbRNhZ4OYhy8GBeZPVHAEWxYCh02n 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(83380400001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tJfAXPFQ9frJgoDsfZKkDxUsfRSudgM6Vyl9ML77X0M1Sm/+8x8G2sEwzdpBF5t3NmfDe3GRvjYnwK3KqxFyOii57nI8HT5EDn7q4QMv0NCMOfmtmYhujwx9J1sBxeuABLp1wef78K41Nw+YqEFfJf+Ej2lzxidaX7hY3HSzywgo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R322BlgN8bIONiml6wEq+HGnwmNR8pLJ49Ho7rOWXbhOPSwqSsoFZfKXOfZv/lapryNlKBUmHjHES+p+D1QePiXQC4KS3xkcbcWK9JfagkgiBthIA6icRU+s5Loeamhr83G5LZ+XucJGA8KRfaQGcA614G5y9N8mrhTKAoDimgBfIqbedFzXfYd48luN0gFBx1hN4cSwnuopX/R7aVKCz/cHD8530Doxk8/NKICfYcFVql7Ibkud3AJYoqIefciYmpgh4vNKq+9NOD1VEWV/jcbSpuW10mgz04OqMYc3jgyZM7y8fWqEPTzt0OxfHyGHjWLgzQtdEEt3qS+IyYQCIwXAH7vNVmUE1gPVykmiA5xDG7SpfDm9vCMx6bW6JjAptFKgNA8O1s2VXy7YOMgMOJmvTW7 X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad1d9d0e-d8b0-438a-fea6-08dbe8f2ded8 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:30:02.3019 (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: /Wshz98cV/eg2kskAUluFsjLgwjQEN6fLYnzTLdTFXIVdHr407mDbSZEhGSY/8rLo6Mzdk93h9e3WBES0k7Bhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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 ad4c1c5d0a7f..d9b2936308c4 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 Sun Nov 19 11:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 745598 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 3F7AEC072A2 for ; Sun, 19 Nov 2023 11:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231972AbjKSLeB (ORCPT ); Sun, 19 Nov 2023 06:34:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbjKSLdi (ORCPT ); Sun, 19 Nov 2023 06:33:38 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2065.outbound.protection.outlook.com [40.107.104.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93ACA1BDF; Sun, 19 Nov 2023 03:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XuyzIgxhSE9dxlsROJxWrIvo7la+evCTSzzXOCygkmwr+lgycWuoY6cwilWZETGLUSgH2qvKJp0bdIGdWFeweGlYRoIXs18EIwwEL3V5PrLYO3xilxltc4zmNERYS35ub/HJiIGs+B6rLmT7Ck9U2hxke4IXaRn/dKNU4drqtA4KbFF6LrcZvwZ3A3nSbBQt3Srzh/JePGkmZbqywHvfmBNqEAM02iQbpqT/v57ROYHZiLB0qizo14v3L6vfOxHanhc9HziMk7g+aONXGGP8aXj64lzMGc77jqinXdxnH/0PCCvat9XYtF4CCxvilDhb7uba/bnRA+Jrbs9O7EXERw== 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=CCBLbQLe3EP2f7hu3Tl5EQiwyecLdsnuvnoNW4MOtrQ=; b=fepJF2Wn/8eIdW3ceXD7VNYyv7X/lAeo2fe2iozGy4EXOgQD4ZuCDTZJlTIf0p3F0TpbjZ4hRLNRhB+iGPVLOzGo4UJ4JUoMr04UVd2M+OirMcjkkwbmhl2LZ0L64Hk+jqU2bIoMv7+YXXQyA7UIqPou8E1+9N7tmgAlLWN6hwBeI+rxOgrWsTlGAl7wlwIuTAiXMuSr+tIwuXnSdnIta2ld8weksE8sKfVN8NfnxjV5eysqQlEejxvsY9ElQcAM+qAdVojAqbqC6o0BCwgIXhj4m9GxSaaRij5V75OtspWHwOdUZBJNZIDe0xraQv973IY0k9D8gfvyxuyrMzvBCw== 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=CCBLbQLe3EP2f7hu3Tl5EQiwyecLdsnuvnoNW4MOtrQ=; b=PtERTnGtHgR0xI3i5j6IrH2PybvrEbCVTQz6A7GGgWcZmSzog74pEa53ndbvDZevdpjKWksS4jmvlsaBw7yAE2JeXCRIT/JXpyibLt8X1ZQMEyvGotdjCw2BUX0s8L3vccGg8uJlJnZo3FwLY4S29SmVRrF6J5U9Ah/POJYQ+cE= 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 AM8P193MB1060.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:1e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 11:30:02 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7002.025; Sun, 19 Nov 2023 11:30:02 +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: [RESEND PATCH v4 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Sun, 19 Nov 2023 12:28:55 +0100 Message-ID: <20231119112856.11587-8-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119112856.11587-1-l.sanfilippo@kunbus.com> References: <20231119112856.11587-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f2::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_|AM8P193MB1060:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f578803-9a79-4f9d-fa19-08dbe8f2df35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OSq0oRbRfkcJICtkyU/cBDmNyCzhEl3ssvSm/BUzyC/cCI+RdJ1DE5Vwvp5GnR+UD56UQRDgny3MLOCg+68NAtD2OElIGVkiuJpp0UYMrQ6Ke1gP55RgPg1YFIaGciFwX8oEXcX3mYPTIOow13FmgKVvzVsxRKoguTSMyKmRhwDsGqekc+m9WLTMN4rtKDP5H6K3K6iINBCZ6mUWhlpRYHiox4ckhkgVVlB1KRPSjkjcUmIkZP3iWvLjPlqh9XcmMXG/BdWqLuaEWXZgTGmsGN/7mQ/7+bn4qeZihLkkcpkz77FTEhHFn8X8Ofz4UF+poVqvLVn+RnJ77k6Vrm2/tPfJrsgwoZLhYuwf0wsiri6aBhdIBODusSX9aejxSmsgfOuxOazdgsF+ptHTnnzw8qIFZM6SAvWCEioXJ7yCvOkeiSKVjwiPKqxTUz9tDdtjDzAG7M9gSUs5EdenYKOk79TIQGbElsvTl0FB+qs/TEMWB2JlZB6JwgJqtesOE6lWg6p69ldfrHfA/jptmIupzNc9dmURWt8oKz5IDHgAbqUcuE2jsVf6M1fWHV9hoRsFp1jLBiwJ2Wm6d7SE003Et6lDCNPRoEUhYwe7HEY7gGk/QOZAuRYQgD3lt3LUtQux 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)(346002)(136003)(396003)(366004)(39830400003)(376002)(230173577357003)(230273577357003)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(6506007)(6512007)(52116002)(66946007)(66556008)(316002)(4326008)(8676002)(8936002)(66476007)(6486002)(478600001)(83380400001)(1076003)(2616005)(38100700002)(6666004)(5660300002)(7416002)(2906002)(86362001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vh5jelDQHAy7TiIUuM68eBUvVDrpigeeqH/81av+zLrCCu807fxNkT/HLNkFGKHLk8ty4nz7UrFF64KvFnGw3nbGHFEJ/qsmDQT1H49dYFMG9ZgKst9PRlfUmexnsr7NhAI2Dfdtrnx3t4ixmwDJfmIvmaVWlVMyswnfd4OPrICsmTCDLaF0GHtXh00ymkCsBNDc9V67S1aZEDcZFXToVhiQF4zgWgMEUiDIjSFGqOJEsgf/YuNMIARWk+BGVt7gpXwDsLt9obucmbbCFYGFnGZMoRQTOzkhopVxtodq65yd1t4oMTfQc8zapmG/nPIMpe7F9QfFSF8y+j/AqlxkDWcDCSTAMaf3f65OmHmSX9UzX6ZW/HqxBTy+CvbD+xFFjUKBHpi9gN50AN38u1G4T06Co4xaJ+ON2I0XIJoL13oUkzGYEUQ8Cc9D28dUh1C2f5m5LfXP4rexQ54c0zK3akRn/8VBDJJB8kLo9MmGyE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7I0gPy7yWhi2icqTl4iJsu7S0nGw68JE4Ll7Sp0uyV9K5Ky58SDeARFfaSen9s+WKGNIXulmmhrfbHL61UJSr X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f578803-9a79-4f9d-fa19-08dbe8f2df35 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 11:30:02.8804 (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: 6bw151wiF43gNnoIrhPWPTpYV0V15zdXLLvWliVLJPKgk4bNMbJucQpto+Cp3t49twg/1EqsTYrU28cVw0hAQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P193MB1060 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(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 6085d356ad86..23366f868ae3 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -480,7 +480,7 @@ static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termio } 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 = { @@ -524,7 +524,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[] = {