From patchwork Sat Dec 9 12:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 176170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6032869vqy; Sat, 9 Dec 2023 04:59:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJ2h7EpIki9QTA8TIIXTAW2S4NlaZqMC79Ab+1Lh5UO64cMl4dUTYKb4rX8UNEH0qzHRT/ X-Received: by 2002:a17:903:2305:b0:1cf:cf43:303a with SMTP id d5-20020a170903230500b001cfcf43303amr2025802plh.64.1702126770818; Sat, 09 Dec 2023 04:59:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126770; cv=pass; d=google.com; s=arc-20160816; b=GCgT5i9s5NAdj8I2IOqoJkEu6eQ+nqbz8P0MZphjduZxiaO3S10n4QK/eRgrToG0vQ 8BuqgUA3yYB6VcoEl3Y+rTMtOTWXAKjnAotvhbgCgVRf8O8CT6L2jEEq1f/+3No2BzKh 9RjngTs7qVAjk3Uk2WxuKQ29UKxsRqrvcN8YqBRYx1e2hz2Guz/rbKcPkFH3LJq4b3J2 S0op5nG6lcFJSKl5bjisSWM1C/veVHaUlZFwLitlaP8QhjWjEP7t+n1Yv6wdCMY/lQCW DcHstASyARXH4wzRTfaHeeDdvyV1C/GybMmDWqM6fMxaBPLbunLK1Pza0EOC9vFMbfF5 VfuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ui9KCTXid1xQ6I8QFDMz29kSlbNm7B3mfuhdJjPmypQ=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=OM36ZlNkRBLeB3mgz8SjyUmTEsIyzgKkAp0kaIpDCXddB2gXMIGtZjXSpIRFo77caG je2ThDCsSMnaeGvFVmgbcQDrRR2w5kxgIbkrVf6JxDlgrwNhs/a8IQ1Pe+f1eWS2ifH5 cBkuiGvlhIE+AHsrA/hVhPShM3HILEkKQO62O7QZ+/yDUIodhZv3hYRCRW8wxC9lNJd/ l6kVd7H5ACAcHgWIGYvHLqkBI+gGCLN9nrlSVTy3RJy9lj3qt3fMEYP5Id38FT6fOCFq RNJ3FHA5C7AEZvToWk7k9hPT9Q3v4csJ5Q5QTdjlcsPTZi0Cvs8nsSIOJevNF7AJqXGM QCeQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=MfhZWO3F; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r24-20020a170902be1800b001cf5c99a61csi3040465pls.180.2023.12.09.04.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 04:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=MfhZWO3F; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B79768060C8C; Sat, 9 Dec 2023 04:59:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbjLIM7R (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjLIM7P (ORCPT ); Sat, 9 Dec 2023 07:59:15 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E87F010D8; Sat, 9 Dec 2023 04:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3nuZnDB1sbK/8slOWy24jbK1DynajwdiRaYGh1gzS/DRBJn1xTJs5yteHRfhMnN0O4qVBcJ+9Do9g6dcOMWnO5MXZTEJSn1xOZMRHtaPi3hxEZ7GfMb2dNFg8KAFk6OV0REAJI0bRM+Zlkz+0W02Pb3i8qAGDAq97a0dXU/ZZKi5IVpxBkdJcXIQWf8DDDJEYGpGe6xGxq5C8wI4DqQfwI1L/PDbA1gZsN4kLJ+o/k5WOZkqNwmJBF9vT3lvuhdFetJ3BXfoq8LbQOVJv53Vx6asdbWdYOZF7ZbltSPrpCzwugd2ZJIM8Bd+6IqZqaBE7eb2zssEoTMzDqlJZS4Kw== 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=ui9KCTXid1xQ6I8QFDMz29kSlbNm7B3mfuhdJjPmypQ=; b=a1KpvBvo7wiqdirTWw3HoSCuFvEz+WFIQjDj3adVjGHFA5xXb3hrxZ8o6KQdweABRGTGL7u50GahQtBEz9RIuGeZsfmgiCN115I8iGbqitcnfI0qq6rJY8Yk2qOYSs1xdwAi9Rb2POTEQ6B8us1UQcBKxOPoWF3UEa6g1E0Un2Vwnch+y1Lt/wV76B/iwhjdArlRb6WNnXEU+jRkFdHQweK/3Ngi9yrymWk1tux6BJzmFoQ6iRVrkGN2hGjsQmPav0xBFMMcuc1saxET71fVW1yaim43zCipyW4rGotoal2xHwjEf+K32WqXQz1wtpaghXRHf9wOOXZzxcr1zBqsMQ== 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=ui9KCTXid1xQ6I8QFDMz29kSlbNm7B3mfuhdJjPmypQ=; b=MfhZWO3FWbkxNtBrKbntGgThLZLgvtlBdJ3LsmIZgksnj0r3GG/s76PlMLB5eukAkAn2dyQ62qKGBWR+RvScdI3DQbqgOztYTAyOj6I1QRcoBEXhkDc43LfY159pUlSfxuVGR1ZXo7th/xM72DZBDB0CVNjQ/q4pKBFHIlyRmU4= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:17 +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.7068.029; Sat, 9 Dec 2023 12:59:17 +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, hugo@hugovil.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 v5 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Sat, 9 Dec 2023 13:58:30 +0100 Message-ID: <20231209125836.16294-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: f07165ad-c521-41c0-72c8-08dbf8b6a69e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fy7yyyM2iBJ81/YY1YEVoIB6yAqEAXTHB9SqJiN+zWrOmlRYTjsKGCDIMnTO7qlwNbngoeHUggAI7WrdFM9sJsyrw+EzZkDdcHsyuLZjniR5aekdCdVw+/osoCALTRBq+7I4sF7MKYE48hEIQL80BUFiNqNtyomAmqwUKq6m3LfUay8Dwe6GkP823kJuFNK67MpVrrwjQfmhzzhS6mbNpThvDvFFE9aVm2CKqiuY6UhWlEM05iUSbcg84GCn7XcG72awYZpwu7rfZLvqUXj9N+4Z7T9zt1PrIzZfA7KDPywUjY3p3QcsiXu2nlFxvgGGA0KdWKffGf084qpwRiGvUoDJxBMJw2NmOrr8celxwJvcmIB5CpgdplCJRP9IavcElkb2CtVcukQvhv9K2w6i4IPpzu4kBEnGtIO7EnDcYkc4aemJkuvX2VXelw6cM0fFjmD49KaOqYERtU/NCWphvvQIVPRcXrj1hyYWmahdb3Ay79KrV/fZ4WtzrxJdQOf1voEakuVZVcSI+kt9dInHesS8esTtf8tdqV/7cG+tqidAY764K35iGmiDcN4aLd0A 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(83380400001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QC3nGixn46mXECUwVXiCF0FJUfsIYc7NyQL4CvxsYwaa44V+ptxqWe4zTyTOIa86Tq0svO9IEelF2GHMjagNHafr+Hav9hC5b9YPcx9W2KVgyJ6BjDitna1+zaN3WG3RtkerA3IG5fVxHl42V/By7C7bUDFNfWTRapmxxeweDai0nzu0/hMqK6O8SPQDZMZVrWWPkjLx+jgpBAwaomDM4Cca62j872xt8B9tPfLB/GRmgHVNI1z9KtJLccDQYvG7gWlTVNAZ9WKRQ7OoTWJ/TGFooM5GmurbFmYBiARE6OJIjr0Dq00IaFr4ELy51oaL9b1Fm83NekBwn3hgNGRxVk5xy8zKT3cErAyjOyFUK91JOiUFalFJ7gu0Pi7hvV8jZTeADtuNGvL8vMBPVPeyJHKCKocZBJRVxLyli8d5fee+1aXGwSlY4IiEB/JfkPD9/ghKybSWTmKubOM5cjk2qQAYMSZddVUxCaqFwy2p5mcI6oOVnd+N7akAYub8XUTadsx/+mPxlaV1S3Li7HuHtxChR4OZbDIEBICWQav+1eWO90QLPMMoh+XTHupCvsBZYRM6VLffI73A5/PdtLtvnCqAUh6S3Wd/8XXunA8si2/LPEE1kiKLtL20rhwU2mK7TvQUrwXPoqC5dkHLeTtIq9IQTOITZsdbqxz4E6CYbSkaXMrOguMiXCtF/MtWlQ1Gb2cdH2YI2Zo3zO+4voYgGjMv+To7daQgRhtlrSGfDSAqd3OTgLnsvW0eTO7yuYtEIGJFsbLd3LhFWtANL2ymdIF1jwCulcovEM2pT0eD498Z4lIFFzVtyM9rzP6Wjnc7N58q52fbCL7ydFz6c2tpcdeLZcWzRurpxOnfKNXg0nJ7+0z7RuoyHXG3XzfWIwdL5Stz86VxoRiF/hZ9tKD6i2dBXxmgdK5h1aS7G+dAYcx6CA7jQs7IuGjab5s1CzT3hsw/Be8A937lkOAxkjzF4iGfWA83K0aWaVbueYEdq08a7v++o5AJV0HP4xowFgPJVJE4IP1r6itLlXnZOb279KApv2rw+LXkOOADbg6zFMp3iX5H0WHhd+0Voo9aa6TBtI2vtSduvR/xiqnxjV/sdMS515RQtPgxWSoY+5miZ7NLGrAagELl2qo56rEB7zcCoDGtgXA7dHLgtDZrjWOS1HGzy5i4HCMxMeiQHrqzf6yIe9p4vyDVrFCo1G2xzNKxvnqvB//yyque2kfCSjRhOiBN2SEN1uTKjyV1n+oXS1/kUEEbr5NbdTNdJNRj4slR1IQuFFHS9O44+LZ+7tpvjWkYYzm+KYlMM+cMmhOGwgtAR1Wx50vZEBAuFRUkF98df7zMHPmyp7eR++e2fHPRIOK92+RRz4JKF0q9UICm3Vv91P+AoC5NZYQc2ZuOAu9ctaQwaFKNqA3a9GlrOD7tmqw5yRWtIclKUQxGtD+TjCAayfs62RFNrh2g8TVquX+LloMYmUDUzJTF74tVDucnAPHOFuGY03s0jnH32mIT9BIww1RXEUD+pC2/oKhwZA6p9Jt4jCjjv/tDN6zfX5pHOLKpyRkXAWpT8uBLhwNRnOI/0BgElmuTv18lNwYOWoXSOUPTtw8AiK22hV6kR5xf7WsNRQFw7R92Kb9Zie7Vzyl2VCNVdiaE6fEPpv34n84n X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: f07165ad-c521-41c0-72c8-08dbf8b6a69e X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:16.7942 (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: /J16/FjfSkP2LSYuYnSYrW1IIbPsaqP9Qp1Bvv6OOpx2m9OTxJKUB+Gf5t2L/K/qMdyZo7SREo09Lw2wbU0K4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 09 Dec 2023 04:59:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809280769261290 X-GMAIL-MSGID: 1784809280769261290 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. 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 Reviewed-by: Ilpo Järvinen Reviewed-by: Hugo Villeneuve --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 12 ++++++++++++ drivers/tty/serial/stm32-usart.c | 5 +---- 3 files changed, 13 insertions(+), 8 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..a0290a5fe8b3 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1402,6 +1402,16 @@ static void uart_set_rs485_termination(struct uart_port *port, !!(rs485->flags & SER_RS485_TERMINATE_BUS)); } +static void uart_set_rs485_rx_during_tx(struct uart_port *port, + const struct serial_rs485 *rs485) +{ + if (!(rs485->flags & SER_RS485_ENABLED)) + return; + + 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) { struct serial_rs485 *rs485 = &port->rs485; @@ -1413,6 +1423,7 @@ static int uart_rs485_config(struct uart_port *port) uart_sanitize_serial_rs485(port, rs485); uart_set_rs485_termination(port, rs485); + uart_set_rs485_rx_during_tx(port, rs485); uart_port_lock_irqsave(port, &flags); ret = port->rs485_config(port, NULL, rs485); @@ -1457,6 +1468,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, return ret; uart_sanitize_serial_rs485(port, &rs485); uart_set_rs485_termination(port, &rs485); + uart_set_rs485_rx_during_tx(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 Sat Dec 9 12:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 176171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6032939vqy; Sat, 9 Dec 2023 04:59:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6tKczLD7LviD+U+sN0GHQJCxNOapj3C35rZO3lO9f4Tf5xVTUHfRniMMK3bzdV59EX4Y4 X-Received: by 2002:a17:90a:6b83:b0:286:6cc1:3f0d with SMTP id w3-20020a17090a6b8300b002866cc13f0dmr1210402pjj.68.1702126780199; Sat, 09 Dec 2023 04:59:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126780; cv=pass; d=google.com; s=arc-20160816; b=eFPBDY2OjRZCfs5o3+DRh/stEmGjz3hzd5Ipzpl+6gCxLqeRXfTKVUGhVA0Zuh89pL i/nSbzfG4NkUunT3BI7XWZkxZsv+OixyfPREs65nANUZpAEIitQWCEhmsDxGQWUPfxWo utRmJB7/nBFSLdTJVF4PUTJYXtMtzn0UD2O03kWBm5u+UtIB917WcOnTWIuK3UIXu6/5 IT9wCEul2o+oBfgzTurTfqmByh3cJ3X6/8/g8PAjh/3XfRmEfmwYyT+3Fip6QMMcwE4d aYpLS1I9jDPP4IH8cO/s9cuV8UZz46CkN0KmoSu8BSMug3uJkAKpKB4KF4djwIVSYKnk bzkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z37oomI38hjFz0c5Y/ltYnUcrUN1/Aa6wnLuGYM+HyM=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=fVzz03yzejxYTv2fnKp1R3MUBCbwqy2CeyKhxSgupuNkwbnKiG1E7P5qXyjFsyciTD tXieIXmR4u+N0OmbwiP0b3MrgDa/uzCG5kS267Sn6ZkMY2ZHkuWIenpUpxXVMD5cYs5/ EQI943e9C4bh0ZNQKQHGlehSrUaarY9W9fqhjswoVKEqBditnZ1lPgjzmscDFFCj0xHS ACLSn8llhCo3jcpRFEv+ZPr8gUzlN2CkhoXOVr0X3pPLq6NanVR4OaCyY4bdElVDjfnx DbQiaYljzqZUAeaEVNLRTOoNoMbV+6XWZy0nqZM7zOxKgT2GmHRh+7uH+nde7EeMHaZ6 lOQQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b="iN/T9odS"; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id mq15-20020a17090b380f00b00286e6c8b27csi4618128pjb.9.2023.12.09.04.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 04:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b="iN/T9odS"; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D8CC1804AD9B; Sat, 9 Dec 2023 04:59:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbjLIM7T (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjLIM7R (ORCPT ); Sat, 9 Dec 2023 07:59:17 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 601F610EF; Sat, 9 Dec 2023 04:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=km01yQ9yVNEYXOgIxCwmP1pzGCvvIGZUbzcX1hghw9EKddmQbhwA6OAfMXhmrsyo0fLjdTXgjgK26hdH+YBlJmtYdxk+CWm6M3T54kO/DtPeXMBRXYguo1oUsag89J5nf+TI/PzpxhbstA7QZ2GgnoF/7F72jwtFnK8slHS86OSItFrEd48VBTBeW2M916DeD3KJjQRw2r/GZ979sciXDAiCgrgKUylP76iVdabIF8SRVs0ezyp+l+zFC3qpICy+ycWQN/aL/11w4rMruofYLC2nSGqKRCIAFLDhFRNEth2cW/R6FLkKOTG4bulQMM48iquElULl6DjDmfZoNiNTBQ== 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=Z37oomI38hjFz0c5Y/ltYnUcrUN1/Aa6wnLuGYM+HyM=; b=S/Gx8k0hUVgVTUy8L1XMF33yckusKax+81Npge1f1C5SSQROHYMiYP8vCty80m3Wk4R27O89VSUeLwLKtaXsdxMC5APr/2ti35yvWNs0vDSSG7ouWdhnPiWxsbcUoO2dfNB/xLJsJKQxtDGT9mf/DJWP7GZ1kknMPG0qtkOktWtiE755/1SPxGQdD0DgYdg//etlLvubez7OJUCo75tqTb0JmigCZQbVGIASVrExssrGE+icgWsCbriZGA9lYgWoZ0zD0A/lBBm+03l0BpkD2kXbE/EJuKDjbE/KYWBf0DWZGvKbsgYK6/nkouFox57vzSdya0x4xPXG3vIGluzJ7w== 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=Z37oomI38hjFz0c5Y/ltYnUcrUN1/Aa6wnLuGYM+HyM=; b=iN/T9odSKbrEfaKHeSPoC7/9HENUKVQvDN3haM4euPFn/STMmcNr9XD+WfnPfyWuEkK1/qXjwvJ3E0xN+PsJQ7XLGLqbK9FD8ZUvK7IfbwzU1ZZYmvphN+vRB5ezrVYQ/hjaruydWZi+asRWEYYrl6oIFYCkEWWUVAOPkD+AZsU= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:17 +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.7068.029; Sat, 9 Dec 2023 12:59:17 +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, hugo@hugovil.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 v5 2/7] serial: core: set missing supported flag for RX during TX GPIO Date: Sat, 9 Dec 2023 13:58:31 +0100 Message-ID: <20231209125836.16294-3-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ce4499c-d4c4-4557-f7f8-08dbf8b6a704 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C0XgYvWmPwYllDeKHmlBnCjqM5UJMnRmL00aS56ohJnCqDiVvMTW6EuLzvhkjwLwcO66rZJwfh+xypL9bWWQO9JrCavfIoMl5Qwks36STgjWCrOSn0CfJOcCD+W8bp3U6iF52WOXpTPc2ypyft15wYkqkl4isnixqMjq+ybE4VWB+5xZUVuTOKGHv9SE0l3wBXK7lDPZWgT+yJ+Oft7C2tXftRDCJv4Zuy3dwXldFTYPFvi1JS/pTTwxVuij3Qhh/LCdpDl9wbcInLLe1rB9A/nZOjT1P4V1X5z+3Kl1qkms2fcz4BEuwBt97obvGhHzpGYjKuzDekxgyJ5tryqKlj3yjvr6qH2+YoiPq7a7ulMj1o3fpp1ortGxYD4w44RVewy9DsQxbyJ35M4WABWP50abeR59QxzgG9UvB2iLg6COMyt6hQwRXpIS5XyTudGSn5SLSLllRtnrGi9KS/sO+CVWDphHb58YqSVp6WwnP5hm6UUQNsIQA2sO2Kd5r/oQ5OWRF0dka4nRXKRLNX5c368lkbr9nJi07dQ6omUo1OGh7fWeIyaWaIyW/u3L8Klh 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TRLhD6O3YSlL0LsJvVk8dvlaZgDaHZIwG/+Uv7aNRkgEa3SDyjfoIs/btba63Kauf+e1629sKe8IeiFebrsNTZRmuZfKLWytBOiO9nxBlqCJjpYz86WhvDMcBfEan7LzRGsFJjj8Avk2cTtUw3wZ1oq57AMDGxg834FCs5hnW3klQnnw56FBnZxKVbTwMFkPkC/D07M52VQ/kMEGPpzYJDhLHQVgd+yIrbhoX+Wg6dJrlvA4chhNE6Ght/sp2LUf/YhJfFr8YwgtQ94+vnX4Fe34Mjsmh681xcnIdJ6QKGnWt6lV0LQWtKgZgk6Cdai0EmjmdZu04YeajbvybtB++A6oZBx/6rrbg0l1EuFyzndtWeNh3TEIxp5QV/geLLvtt5Eyvb7EFqAb0j1zSJjKejxLi0Ikye/OIxsj5mXXTc388hKVjwi1afYGjhiJJDPyjjprWPlUZjJgWy1QPS77lP7B71CmHlPlTcWSeiOEE3whhRmh2a9PvUFwLXDnqWBPM6lChzhgShhcw9W68YHG6FkYMMAykt9r5QvSQIOzoGrc0KDGDKDteVGFV1oOdhZu2SSF/hlNBAicnlArdoKd6y0P+7Sj4zsowAl9ZGGXGH1CLxyZiT9Eu7Sxsk6e6HcsLKZjtycKvY0kU1BnqiQaT3cDIZd5DBIRmEbtsMgoOQnlLbZvyDg5Pd1c5Yh8cqL1Jk03dN72AxBMTXIOqODSmyLZo8F2tLgG9NlhjecdvDEDg4v9C2heZfYi9wn1F8n14op1ZMTL9iFhKvnql0+dyHhlS8fHA8p4CSvPiaPtaS8TnO0EKNwgXGWDlI92A9yJSFLUPpSndcom7vnwmY6ooaETwW7kqY//8ece7WjFix6NEJVNvrgMS3Ne4ueyHlD4FyuNk7SWdtbHXHTTv4zm1f3eKWmgLEwy7k3kRiGEtLDrH0SCWXnpNFfGQBvbo50YOcuhAt1Vl74tmFJtW2G+J7yUMs0vEqbxDrs2xPfo7NPF67a8F2xWJMAPSXNQKXYLGFe6Gvj8ijf6pqfw0hvP7ApWoIP/srNmoVQb54zPoI95yp+wN7I5kg2qLd8sISqiAcsvbfMvbkbMD//F3uTSQ+8Lbtg/KlvSQW26DKvfRTgqUU+vZT2l6oGbp0HU/JwWK/0wufjuJeWrlNZgt5KXY/A852s7dV4rtMFP6M+WNudcE9lWL3VmkjVS/kUaTDRxXEuX0f8+amEV2WLSTH0ULXLQkrNGwjHDlDnrT84eRUZuXOC2IOK7szL6LYo61QUE7xJPpY4eVPWWyX6GbQaTGnOlnMXeju1+8NiMbDBlyq2wpQVOXZxFiC2485+oZtSuAoRATTreOgkAvaTcaT3LQOTrrk6T2SlC/A2rvhFrqzKMh2bfH1VpSTvojXzWU96xV8rMvrtJnO9F6pI/ibCpHQeSWzxeXGK31D0+JKXELhQBTihzmisjiJ4Li/KzlsYxQUEJyi+9JR6FyWK1A31YeIb6T90BkFzgFJjycB10OftLCLmRFntsmBu2ObeThAOsseEaDldGkWlIhqWyTz+PyIHFUgRklHrVA04EBrxY32Qwn5au8BLMrFIZp7Musv1z80EnnuwWZEFKMHcsb8iGgppmn0aTCwoPQTiVNW3yOD+cNUDec1LL0T7ejLZ0bBnl X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ce4499c-d4c4-4557-f7f8-08dbf8b6a704 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:17.4954 (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: 6B7S8zfwk5RpG0mBIUuXnzWplIdW+QqoMgCI5sSAWQ3K7dusfTU80PsMI5s7MfLrhs6O4FoBH2ZjIuZf50ueHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sat, 09 Dec 2023 04:59:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809290854091451 X-GMAIL-MSGID: 1784809290854091451 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 Reviewed-by: Ilpo Järvinen --- 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 a0290a5fe8b3..c254e88c8452 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) 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 Sat Dec 9 12:58:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 176173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6032947vqy; Sat, 9 Dec 2023 04:59:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs26vmh2ovZ0M9LDbhMmljvgTq3Db/0OZtwk5gL9BvMqr4+iSBc0FhP8y5e4eXkq4kXoTY X-Received: by 2002:a05:6808:320c:b0:3b8:b063:9b77 with SMTP id cb12-20020a056808320c00b003b8b0639b77mr2313323oib.105.1702126781836; Sat, 09 Dec 2023 04:59:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126781; cv=pass; d=google.com; s=arc-20160816; b=lHRY8Vg7HXiNWxtyQO4lRynsqGW39oGoOP5fJOgfIDDcJakK/rwAGByCBNbXbpLxlA SmYPkN5uASBWYQJvbXM1UEQ1aqYo6oJofBaI3ldzTI6fBYlT4b+b4nYFbSrssoTWMoHE PWrLK5FSEoXDvlVkRiaOXvP3qWV5aoaQifhPuVSHfUTxVYVWslrG2SdMT0DfIgHTD1J2 IRNPZWwHyIrG6W5bI+FitXl2eQsEnuuAutMsw7rbukfE3Rrw31UOfckJNr7GF6A7IBn2 40LWwFlzznaghFPiwo4xVpay/+AVP8yeGcfYgLxOdkazBgZKQbhXNE1ShknLzhODD0B+ dWDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rszBlcOxsSoMrEwBQMjDWsnQP5LdeKunsCjYCVGKsZI=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=AUPTSoptFJPvQg1OmHSGmvbclLHUTK+/BY9ukdsQKBa65W06KFc0o2ppijlvT5B7d/ yjCjC/I+L1w3zVskAgBnzP+JXbTZdpzdH5aMrlWBURuDMqiS6JcA4By0M7TWUvOpEzzO Zi1JdN+CVKuiVSvtf+E2lqKITaquJs/5Z5NcQwzHQIms6uRedNfuiJipXWfEi3OG1cN+ 0FZGjJB3KZbfZZgwA6WwWMO8yVaDkzy09m5qNVF1MOtwSkpJ3NxC/ODQLi9Oy5b5EWTd bQHC+M9ENYpP+o1Ftrw2XqzD7emof848uiN5Mn8itCEuNex5bFZhLjveBbsgWjXUVH4/ w57Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=olbQ3ZIb; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id ko19-20020a056a00461300b006ce83264887si3159318pfb.57.2023.12.09.04.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 04:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=olbQ3ZIb; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3B75C8057E7F; Sat, 9 Dec 2023 04:59:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbjLIM7Z (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjLIM7S (ORCPT ); Sat, 9 Dec 2023 07:59:18 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BE7510D0; Sat, 9 Dec 2023 04:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mnh5tw+jySzm6oFT4sY6kCzsSwiYJaEWmeOrFwWjUBzYVNm4mCD61wL0jJOlSz7TrqMPtHd+oIgq5CdJUEEEtcgREQNzzpjCpLMM3MNJJZlK1C0TiaxR6R9i6u1u4eN6P5JaVI5Eu//lYSlFyuuJWNLvVhcu4QzCkjdoHKXYtAPxiGXiD0rJgsucyT3RvZ9zGIOvR8Pjpm/V9rNQIeOKT9CXaZeJHkjT2bZvVrpeupYHbK+DVmCGgsVrWCyzdxFkWt4r7XtBvOvMx8O17TnDnp1QHC58jNniz0mqUeITr21Py6JKZyo6kZvG9N1e5r6UL1BwBwO2cXXKpgKUdYDxJw== 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=rszBlcOxsSoMrEwBQMjDWsnQP5LdeKunsCjYCVGKsZI=; b=SDviClzrvRMdpO26oUJc3bmup/5DGryqBtuAm6lpYzXpukr0no+bMhFMprT+FXmdTcG4ZcXORAMCZNCBe2zuCHu8IZ2zRKzYxdhAMZT3A6gNIdEA858BIwXk556pd4ZASyqwUiou6Z8zN0wfRitnzFNrqHzlBFyYgRBw4bz2TbZSx7dzZ9o0lC09bMAc9CD3X+//upmqJE3bSrn0fNB72Fgaf8zcpLJ+Qa63WMYNuq7hEBYxpcHnSwtZkvc+U0rAZS5Qk4DRBHS+sObEkW4CPkmbUaofz/umjyMiZardxzVyBXtOneUqiRDHkQx5D5MMduSc0OGILwpaGxVa4MMj4w== 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=rszBlcOxsSoMrEwBQMjDWsnQP5LdeKunsCjYCVGKsZI=; b=olbQ3ZIbNIjuMx5WQpe5/PDYoVSYDgZRoX4LDaDQEl+m5WL+sGpG8Y1xpLmEB3eIlNhBf5znH7hajF5y3WR01kndXgMxXBpEhfrpI5T7O7NoMBLkeCBQKRKb66EpZ9WzYvr3fuWGT2A7qwe/7C8K0oDjm/2hJdX0UQlBzCOrv7Y= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:18 +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.7068.029; Sat, 9 Dec 2023 12:59:18 +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, hugo@hugovil.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 v5 3/7] serial: core: fix sanitizing check for RTS settings Date: Sat, 9 Dec 2023 13:58:32 +0100 Message-ID: <20231209125836.16294-4-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d57188b-ef44-495d-a3e8-08dbf8b6a772 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /0okGIZNCuW+G79mn4HXAjBdqq2xw1qZ8WiGyoRN3Mt/0BxSVrxCbOaqd7bwNRNnK12AmEmQNOsljQTqnasGKsf/z+HcIuNRThaCAwYN536MNBYoyp+ZpCE7SWJ+tlvBjv5m1hZYx/2u0ngZdUs+mun8jjfhuo4NuwX9r1Cn8OW5P6VSfJeRexvB6iZ5plhUfTUeEf9hogu/2Dp6RfNPYMyuVTGgDIjamTnmh2toNIOCGQY489dATAweKyerXT/3ZchfV7avHcKisFZUyfoRnqxefpWxXQmoif4TC1JQFKlNvuuT83R21bwL+2QggsWr9QTl3jZQFwkL4AwxtiWqcWj2M9BfvxNJi8GBPahYLdcWv+xzhktUZujmBYng1PiPhxeuApDhbifSgAPzDK85xmJDjTUCKZeh1vpLEo/6bsAKgnGuz+Pkpgo02MqN1eULQduapicXHHFTyc3yAmhaKT8/3JZ3O3HjE+uwiWr0AGq9MSWVBpXg2eyk9gyVRmLqsF/NeuvasjRz0Vwi8ZTkN2ndg61IyuCtctRfu99oaYl380dErnA8wQjsu8KrH1Lc 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(83380400001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MeJmEEn0eCJa0xvD9sIEdlNiNuUEZAznyl5t80GW/AdKkE2LGeMe5oDJhQyp87jozw4uLR1hV4EMImPPa+aDM41SbJqsPSq2yubtjk16kYIaPlHnu4AJ8TJOOa+9JsWuODshFXdbKtDzDAFYjc0wHRm5/BR5TTeSJ19s9tUm9B9zYRJ4mQ0gZ00P7VYJ64D6FxX6eDJn9REtRZEAJPF9kb+vkqYp0fKwNq09vw8qirfzzq2RDiDMdlUPXwg6AEUqKWtzLeFpoduDXblKJ2wYnfVL2t89wNteCAQdUHVgu7K99GwkBdPAWpDB2mR0o+DKeA2+/e1ct2a+FikKBoaSewkmvTr3GEwWD9zrJjx/NRq8lHaXiYMeBfsOp4ZSS+SZl/EkcYGSiNxOEZM6sWM0sENY3GxjE0K3l4rVanoUK9T4P8MYzr6FdkgWKd+RDNV+4y5NxDdxTRdRIIWJERTQ+h2HoYvJoK1BMntvuX70xbf7Ta+Yy0BEylvXF/W+tMXS0n3SPUbUjT0vkB5OE4nRD8Ms2K/0s9UAjG8qozSX+6JK+mNT4WVchc+gDPz/cPvAX3ZqThyCCEd/xB7oU/VHdK2mjrpvWnMPsCezooNpHC0KY2EnQjO/cX3kWj5gN86Vt8RPL/JebZS/Mc40g2QqQ6fOdytwtektkNfjZJXGB6/z8CC4unYwq1pLZUMQYBdcbxGLCXlV/BdymgdkiGJl+k+Hcuch5/4Xfr+cKRLKEkSJaHvbSU1Z7rvCKYi15hyHVJqS5kwHUP42eOaZEtO0lxNsV4LI5Za5kMDftYHLOtecdYa+nwBGFHL3vE6cTtgPqlbwYlUuVYXZ5kDObAYw7j8o+bJiWgb3fHmJnWMq+KvfDFBfGsrkDB8D66T1efDTzbaoEVPle8wKBLtqFlOKZmwFqXCJwnhUhVN3ncYrga2d5mZKCFNugiqaPCEtv9m4NYp+7EkdngUBA9KEF8zvk7hfWAzPElEVGedKDKGJSPJG7uae0lLm1ZA220+dkA9pzCLPUoPpWQGB9zIDcqVwi7zmDzW53O5JE227TIwDcQ92gd2OilZlr2IaktK5B5DTWNHesDBRKPidKN+d8Qu/TYnXpmSgDO/zAzf4ynUO+JUG9JnF+J387jSQAWKG5IeV651+ojjCfqYRMPazXgkxnDkue4k2hqBoIgeTqqnq+7K4vulr/ayjjyfzwxSuYkXISZ9tXr0lzcA0xrW9IiOe3rCFDgCHD6Ei79hWtkcedyfWq83N76MwI/e4HSc0Md+NpAtEJLHs+blsE96R5vLWscHy9QvcGci4qRedTcmJ3CFyiaJYgeaS4A+H+vFq9hOVYwrElO9rBm9jU4Fe4HXFaDuAiyir+sTTfHo79R06wbA2o8uwElqdB6eqK477ah2/vS2xRav8h5oOeQFCRVZu/U/qIHmvNV24tjc/hOA7uVCWw3P/Ni8UHuK1d6UA+zR4Vv90SLCKabX5qYcmltl2rwmfJQMHw/brm3KAHBLm0bhEqiD153Xkrd+wDlOmAc3GXMiEFhJ8CJiRhZ5806VIHVfqZvS0T/Ilmv7YgY8Wmajx9I7NbjC8hEgowIfjw8Fwooni5ps6Wqrixn5Ejr/tjFSjsGeJtvc11FFjX3n4bJPTMsJuBFSyX72Awyxq8+ip X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d57188b-ef44-495d-a3e8-08dbf8b6a772 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:18.1827 (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: b7KnC4AAlMfVdYOXFMkvkC0b6q/1xncjkXubvUbluJ8UlfB5UjNLAu6z+WsZdOw6bLmMh3X9EipzSH5x8updEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 09 Dec 2023 04:59:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809292481769904 X-GMAIL-MSGID: 1784809292481769904 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 Reviewed-by: Ilpo Järvinen --- 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 c254e88c8452..4eae1406cb6c 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 Sat Dec 9 12:58:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 176172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6032946vqy; Sat, 9 Dec 2023 04:59:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGw7hq+4TsZMuAQljGekiRPQo1ywxF/q/th1cRdCglrm241cQrxSNaLXHKKLWM19Uf5P+2 X-Received: by 2002:a05:6808:d52:b0:3b8:5ea4:5bc7 with SMTP id w18-20020a0568080d5200b003b85ea45bc7mr2071143oik.39.1702126781786; Sat, 09 Dec 2023 04:59:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126781; cv=pass; d=google.com; s=arc-20160816; b=zxRf3UTItkd7TY/B/ClKxvQJHsUlUKW3a3ej/AwHO9fC7efhxhAtuIXZbThleVXdUm Ma3amjUGCyClsRskCHIjSc/LLMFOr9I2XIhZYzPRJ7Tfw9vqiWPZKp346soXeQP2MsTA mi0tX0vByr/Gtt6NwGIFJoezk/0XB8wcszsVQXpU6J7+CvIpre+jYf0o2VDzwVpVHZFs hw18+6dKhURm61C2nPJC6dtOXYJgsyTfQ8NXUN+RCAUc0C68v/SEaAxdE4bhtI1ajVBp XPU9t6s7UFx2n7+8cyaNFSXExNSJrWUqpcCa0xXUXdtaTpA+WmJhZv9dIbIqgL3dg3K5 6Tyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=giTj5RrPHXa3a+Lx1xc7jw4vgGwf3+BKO1xkJ+5ZPDo=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=GL4exJI0U7mfSJvmS8YHFOE0yAHn1xx7VXtU1/YzVZUjc/uml54Idra4I2Xp9uNk/2 XPRoPvI4K9SzsHhcFpKU5GQ8/1atTqorcaenceNFvUXDbO8HBeZC7R3sh+INXerVqKFR z3Er2dPi4oro6dAA+Oj2EoSsYs4d1mYUsgGWRPjU6P3k7c9fhXC+O8qDq9dpI2LhlAOt OtctHZSd2l4mkSPV6RbLONcYQETDwu56QIgSgMD61LLO2twEndv7XoH4qEepVY0tYt6J wVOc8NjQlr+eky18dyudsvwNjAscCD9D+6FS3Wtq7TdGQZym89MrIrU1xBbEdH3LZ74/ l5Zw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=IEZv6+qq; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w9-20020a17090aad4900b00285f918f395si3099541pjv.190.2023.12.09.04.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 04:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=IEZv6+qq; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C1A6A8061CE7; Sat, 9 Dec 2023 04:59:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbjLIM73 (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbjLIM7U (ORCPT ); Sat, 9 Dec 2023 07:59:20 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B90F710D8; Sat, 9 Dec 2023 04:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DwGjeDt+HZ4pv0n0fE2VlrLzZcuz/qoqZrXMaTF9iZHStnKNSdLPxH6ARySb5Jw1jXkSvKNqtqVL3og30UtLQiMpyTQ5S2lTnj9NNN1PCNYP0Q2gvFufxcN7AsozpBE0kWr1+vNkBdhIpfRSV4s2lu/skq7xjBMqZvmrRiXnOAa3EkmarvtM/QuUSoWS6BSVFYtDlPZVx44n9ixPALjVhut12fKl2AhbwP6tdzEPiUNY+oTDrjiQxsHien23fC95KHM0cgR4SQyZpv0yRBYYIj58nKSfbj+CStqhNk4/xYqbgjQ7VmqsoBGXDLTsjTIME/bOlNb0VdoxQY9n/6II7w== 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=giTj5RrPHXa3a+Lx1xc7jw4vgGwf3+BKO1xkJ+5ZPDo=; b=JtaQAz+xe4nUuz2IFVNs/NueDn5wpxO0+pcEGL72H42K7nyAiOAWeMgDFlOlR5EjkOiXrvjYiX8f/OixVuQ7JBrj79ug+9f7A7znzZwP/n7l+J4e0ev59vRxuSloeyrl42e7mrrF7+ucG9Rf07jrvi5+HE9LkazlFX07o9+8nyupc70yb5Q+kLSGZMKxDvE7pQ6hFjhyYtjgAzfRYjRteYHMVZQPsyLUkn1DiCdROFItmJ4qN+Wfw5kyhsb2TLHv1dpdOzN2U8xR+GEodFZnE0zYo21BRhg0Wy524C7H04cxLPYbZJLMwfayVDdjRmy59/pm+jOfmrH7FSKftNfXgQ== 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=giTj5RrPHXa3a+Lx1xc7jw4vgGwf3+BKO1xkJ+5ZPDo=; b=IEZv6+qqSpeGVls0ymRynD9cbAk+3O6ET6NS9ugFaSnJiXkvzr3W7mkAwHr+fTIby2Qvp4bub0pj6OcqA67GHY+bpblQIX3eW3Ki6CJW7TgyVAMhCtIP7DLuti5Y5iuPdmc2knr/O1bhggwNR7Jc1aZ7SmmK9X9xk8wXMoAr6GU= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:19 +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.7068.029; Sat, 9 Dec 2023 12:59:18 +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, hugo@hugovil.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 v5 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Sat, 9 Dec 2023 13:58:33 +0100 Message-ID: <20231209125836.16294-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f929983-ff7a-4f98-d96f-08dbf8b6a7e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TMnn2UGZpEGMBSgFA+R7ZeE0qTIQJ9xMCvKxabWdl3GX60XEi8JslXdmWppGwzWy0YKL6bVNCCKiwjIlh/bKaMeavLj9vzgYnj+hO0jlIDTr2tyrul+g3H0+0bt5MOToxNTgLGpckrBHeXkbcshITa+wO2gzkvZ2/W/T977427HUP8O8wTtYW+oD4GtX03MUOV3ngl8LaZsaI9vZz1EE0uetJkM/0mow146VJLI6WeOCqMu+5m7I4UBhYjAb0wQQ3/iSKcZG4Tn/pzUazsafv4jscoWeiOVz5EaeNbrcTQwQb/cynlxXUB2nYhGcgjHNYafMrn82hA3PuynJ56Kt/thUBuuVnDZlMck6DRtLEHuGhG57tGBtUKD7P72zgcWtK3DqEnEqIk7NPokJzGVpEeh/KfCO8HShrR4r52wBNU9+XaE/cXf/suC36mpicbLBE50n1rnEzfz6pMRZsK21WQTLFPazkgT5n/gjibwkkxYRdaZDexwwbIAIi8eVnP6+tG6FCxJYE+Hp8KfS3ICp6xxW5bsGu7Qc/AJArD0qRyrHhtqcij9hzqyWyNqAgnwI 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(83380400001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /kb+AFq7Shdeot/IU9p+Hch3qin+YP1i3I8EbG+HDPp2fEC4HBqvwSqpPPQCulFsQcLY38c1eDzqD2z7XWR6hzkcITt+CmvshCoP7PkgHacBl4YNm2KoG4BlPQKBPVn3IARf7hC31bBOglc/DswB/4SY07i3Yjsa/sCm9BEvxEYcPT5HFzUN6/mYCGyP48LoHi+3DOgYKEyI+1J/owkP25oaIuYJ0J0U6YzLqoA8bJg91JOr6g2mEquE88EQ4KhldfqXwj0HHjj4XpJUQeUGopeyen52lk0WmE5t11Oyin9c2wAW2kxVuMhb0ZFLTbXMxe1ttnuDevdFORuHPrz742t5BH8HRR7hGY3CpGEqjtfiRum4eqcVzCFb6aShgiJhndwqHr0Z1k+i9D1zzkZyq5PAD5eg3pPYmtnTn3+MsS3FzTFbN2shVuSva0XQc6j4Ds6Ojlk2frr8PsWuAd0sJMaCHn9DrmDK5nmZWMJz+iOtgFj7iMNEGBAbnU609Y3rmX/sgfpWK7HgLaj1g3PPKmZNt3xUaH2KWDodNzVtwhsG1yu26J9CszBM4CoYTGVlyQzGxN5ysjSZdl+t8z52gUjfN39TDfYrw6kRsbTHHFqZDW7OdqVGEiY1XFfgmUWMeixhFxSvDqdBm73k9fTVpLi+QNtIX3oPIybx3RNRRhWUuMnPz5GKNbtY+05mM32LEIlivdJxxCf9b8Mro7kATm/7jIaV+4U+I+0P9ekfx6cKOa3ob5OGZ9LPshY/pAbXzndWsICS1kQh/w2qkuaFQwfkNo9xJORHTRwtJffXNzPBj+k6oLizx26VFKKpM+JaJvxhN2wj83i9qHMwCqZy5mGrYeVsfHRF00X+bajhqJIL3fFTDSdN+CINeSV2DlvubAcHTvo0nJCt2Pi8u5Ku6/eqTZebwFZbEI5IuJsXxCwsy6QrdIUU/CaV4hY2MRC7OeM0zsignp9NMOFJXPMkeIXd1GGfsBy8gDs13xbuJdGxIXFhpIOpuBOj0qj7w9fA40TUW2RiHettgLI3Cy/6fVj7jIw2zC6xAi0kdP9iMgX4JReE2bttA1huxbn8Q/BmIBz8U2h2fsFgERLd6JO69W4N+per+y8MfeZI8rbUd9/zZN5+HiMuFU9DP0FkO4Eh+ZaoyZ9AkovCka70CbVkyA+Vhxpy885HOgNRgrFa6hKUsoMOBmtr751qHWE6PnPfw6MQL2ft2cX80YqjeW0H+wMqy0dHm9twtzwxw8mZPb6VXq0O2WKB+mT/NuUPiqN1G5GWiiKUKL5p/m2vjGD5uSdKx2GT/LlERzELgrZbi5Jm5GPMgUfQhsUTwdngQBfsUV5jff1lCmMMGP7a5mZnqi2G8EAjQm6eEv1yLMvyzKVfF9xta3VFR0p8D6kPt2o8BYVrpHFuFA6WzILCGO1EPvujn8Nrnk63CGdPP8lW5YbUMegb+kqxb1Y6osaAZu6xIDL7alCZu3tYiI8iTB3JOiy5cSYAVcWP/o59BoqOBmUZzCqVqhG+1Z+cpxMVwpIeAB72AG0GFElWWtfUpLKoIFlcQ22+g+huiHt7mUKdbbEf7QOl0C1sgirp3xs4cBGOqH8jGrFpCJDQTnQRov6I9tztQzTDv3yqtuJRZROip7TDP/BcRGc6rrcgvBdTIREp X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f929983-ff7a-4f98-d96f-08dbf8b6a7e9 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:18.9258 (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: PZbWvp9aAfEst6+gLAp4bp7CQo0Iu/fWI+YPr/GECft0qxGPO+kyMdzvb4Jpo3ht9oA3swxB/F6ea3elCG+fqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 09 Dec 2023 04:59:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809292097060191 X-GMAIL-MSGID: 1784809292097060191 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 Reviewed-by: Ilpo Järvinen --- 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 4eae1406cb6c..661074ab8edb 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1448,6 +1448,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); @@ -1465,7 +1468,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 Sat Dec 9 12:58:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 176176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6033555vqy; Sat, 9 Dec 2023 05:00:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjhteCEYDvC5ujaZZTltqJPhT3QuLDMomr3TI20paRbGuoxPJeyYDaq1g+LNxIFXuuao6f X-Received: by 2002:a17:90b:3612:b0:286:bda8:9633 with SMTP id ml18-20020a17090b361200b00286bda89633mr1910462pjb.25.1702126836148; Sat, 09 Dec 2023 05:00:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126836; cv=pass; d=google.com; s=arc-20160816; b=prMhUSMmzKY/lWTbqe3K/Aat8Ho/foJ1aeioXYuWQhOENPjd6kz8ztREom2ftQCDNQ vFq/4ZtZBU6iE7VBs0bAUBYzBKEl6fv5qdpGJ3JFLa/dO7PvPq9zP4gTik6jXH0eJUwI T3sguts4qcKVSz7xcbyF2w0K7NM3BkJUvkfHpGi69LmeSylKdS3HkmSWKJwff1roF1Sf xvKJJRl4znSJOFYVo28cUjC97sQRRUtNQ4C6J4s4A9CqfUqnpxRMJDNLoGQQu2aSMWbt NSRmpt3pvEc2GNPlacBHUgg9l8wgqjatjdaF19TqPi9ragmJpj13OVUdjUMNuNsy69B1 wZqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qHmqorGPiqKU1kxDm9dkMnJf57dw2Nb8XZdG0MJ9jEw=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=GUg/2bKC9+gFmXGYqKoG+w2QDj7H2KT3fRUoEoulHk0NltPgzxV9FXM1/GFqTPSyiH i9cHdFtzxmPX3B+uYev5mVOfsZ+gie7uZ6/4NeHla+ksSiI7duKhob9oW6eoJ0J3i/UA suPBv3IMliT+PO1ss2cOZ8KDLCIhL6x/yXyjiDcEz5vJemYKLlc4yIFoPnpaMG7V5F+x LixcxMz+uYOEeUWt9jBNvb967iXmIawiTjxdRnS2dTnTbkqAFLlrLg7kl7zLa/599SGF R1PIOfn0NDTrA6/0JuiJNA6fB709awnOxUnDExh2dCvxrLFs+nIWo/NeJ5vSK+4uOkYU X56A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=QWQ8DxD9; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lj6-20020a17090b344600b00286dd5ae1cbsi3204001pjb.125.2023.12.09.05.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 05:00:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=QWQ8DxD9; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4B56880898E6; Sat, 9 Dec 2023 05:00:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbjLIM7f (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbjLIM7V (ORCPT ); Sat, 9 Dec 2023 07:59:21 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FC401700; Sat, 9 Dec 2023 04:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYKjBCdu/eGPMNX+fe+3/V5zgyrTSTpHBOQ1awwSPZ3tO9rXImITj6kBWkNaPiD0+eDpZjVFNHS09sn1tkjN+Bcc+WKgXAwOJ2j3ATOV8H8IBcOI4Zc/UOu6Pt1ywTjgiYO8JMjuPmrDHhP9hEqE1y46bnyjme9QPUe/yL2CAj1Us7haDFCF43oqNXSi7dex1pJkYPgnB7aPY2UF2EoEkPvBUbWWxL7Ruuzsizoaq7NC/WOoDd0gIf/esu6CMqDe82Xhkc5WvJNwUFFJvytLavypObC+fI+WV7Hby5/u0ExuPdZceZ4O9bBx7J6o/JNCr1KUO3BIrhIF3BWVlfd6oQ== 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=qHmqorGPiqKU1kxDm9dkMnJf57dw2Nb8XZdG0MJ9jEw=; b=BpsXINK+GkGPWFRkBEJ1d1P6liWojs4EgrfcSQDtY3nsNJ5caDd3i6JbRwneCBbQWDF3+L7R3CixMGsoaqCZKcB8vkwm/3Oj1qfGLhaS/rxm1AioNVH3LCdeQjWpPOsH1c6+UmZjZSCu86i5uSRwc/hjrj94FDZAqJMYYFC0KUiNSTdb4RTSUk6qrk3Tf2qg+Gs+kdqdXp5aiePxzsV2dEr4bdGE2hRTss2KZUZWbRr8gRoAT7DDfHz80YouHt/67xaM3WlRUGmqVkG51GetylT4kEURHAcYJSrnqHIzW+f4DhFckXBS59p+ugkIZpaE9VS9Dqr+8ryVRwh7bkw4Zg== 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=qHmqorGPiqKU1kxDm9dkMnJf57dw2Nb8XZdG0MJ9jEw=; b=QWQ8DxD9jvfp64kfnKa+DZdR0Fo8tOqDQjxFzMifPYs+9chnXBKuO2n7NAakWE3Vnk+WmwqXed8oYvVrlvxkdsvoSIJry6YM/5IR+CLKQiQo+xjFHq4pyLCCrHUGc9HNgjzvVSCV6AL9zGr/fs+1ulZvXxRlWGJ+d5WXvC+67XI= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:19 +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.7068.029; Sat, 9 Dec 2023 12:59:19 +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, hugo@hugovil.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 v5 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Sat, 9 Dec 2023 13:58:34 +0100 Message-ID: <20231209125836.16294-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: fd583afb-b76f-49bd-9a10-08dbf8b6a84b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LuWzlqxT404t32a5H3O7UTs/oIv7w3VLSgR+vV4JuYI4sbcX48eYcXlSk4iVdfqad25mW36LCl+0x8Z4lSenuEJEPvo0Wts3oXo7SiO4310M3egN8SJZzVwRHbwK0ugqwwt0QcU6ECS1OxMYz7ef2ONdlHgI79QtBjdzMSRY5+Pzv5xr/i39ipxFcYiEQMq9Vr0fHCP9d+oajmycb+RjTMhz/KNHXo7BRU2fRkWv4+nPy/+JGLvqLqfPJw74CepFljpxvqzOSElMK85PTavxjMbp3g4HvG0CPGzNoP+xvd6QpJRlDnN7ivmYXFfRQk8eSlrZ4pacsEKUTo7GTAMZxwh+pp+sCHqced8e2fsUYXcOsxkSlNaJ58hZj+UCyvbEO42AaJssYUNXhoWqxpcjVCnm3imT1EiAQJp3cH1HPmJ4rgPyxU5J8RwLOUhCHc8b5uL0XfiXCEd+8LOwK+p2Qr5P6sck43lcREoTQ6ORl+XcZuEvAOKhkUzrA9yprvv8F6x1XirZG0be7JNzW72SVNhpIcjG9rPtijgqs+MZDEkOQ5AgpotEJep3vinwWu2L 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(83380400001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?x/wVrlekpU7phDO4HKfuU7eHOpaL?= =?utf-8?q?eavCjxa37Fl8b1CuBR553BrF0EFinoYXEk9UQ6GLU0xi6S03rCy8QTthjch5CekAF?= =?utf-8?q?M2Fdxgq9BBXwcQBFNetZ3ysrCfymxBqWJww+b+8KqS7AisEm+1FchDJyfymk9GyVP?= =?utf-8?q?yQDphdmA+GWUqObqwyPd1j7QrW8LbKJzigvXNLhqpO0H5NVS5xsMcQtQYr63z8VOM?= =?utf-8?q?2qhYvIjDl/UBQX5YpYYQeveI/hPRGEQQhYAF5eiy1CY6ae1OJzFRg8Zts68Z1zriD?= =?utf-8?q?FpCdlat7HJrKadQELslwa7oeQkKJO7jYOdApcttRnxC13JPuLYZZG/XvMFpfra4wr?= =?utf-8?q?ZHmmpR+m8OO7ubgd3mq3S8s74TAlWsR/SW2VY2h0TiGX7Rz8p0g8ApTdNvOaYM7r7?= =?utf-8?q?5esafmksOH5MYBPO0J+Jueq7CfjwCX0YFj20Gcy2h+LP+KrreVLEuY9PrjFrt81EN?= =?utf-8?q?H+ZGY9Un41/n8K0w3XUl9dh1pHwdLpG9N+bSeoGl+Gp5omELnNyqZmX3Y+RbL+og+?= =?utf-8?q?h0xNFe4V5ALfJnvjQ2pbl32mnM9yK1FpT9/5wgXTVxyw9scTfZeYglwcsHtR02sOz?= =?utf-8?q?4bjk/TDNLAU9fPjIZ8dT5t9YY7JBLJ1hk3adxVzZuX5NIDQvywYTsEKJUYmzmazoL?= =?utf-8?q?CZ9L4e3vYgOEAK5HiYVOQ3AgiCji1iKXw/KWtvVwzTJQ6rH9IAKOPSUWHNB5CTQTq?= =?utf-8?q?PW/0XRAr3wyec42QWd6aOE6QNx62pWDIz2h4xWoexugQwRPi8m2PTREDWGL1Z3csO?= =?utf-8?q?Bl/tYNG2cAOgfmK+I0FBQASiAVZTnRvJSMtRmuoxb6p4Ik4tnbR0Pah6z4nnb2UFp?= =?utf-8?q?g6ssA2LdFdepoJcm7yfvvHhdb8/Cc2LEosRCbzlzCWfcllHa1Bkp30WDiL7XgfYl5?= =?utf-8?q?LYR0DQYOH7ebXHSZX8cnPXomKLIlVmzA2UOuuXh3cq5jqSwToJxHAkcAS1FL8EZ5Y?= =?utf-8?q?L+IRMLdnXJaj9A2xkEbAvKYzsDcx00mSKCqiNDfIZDez+Dx01Xc4oGHYxRbMT40dJ?= =?utf-8?q?TeYNXPT6v5SrZwgrXzLpPTOkAUxOfH40Mb2VaptruF0rScMJ7i9ZnxGvdNwyQz4gE?= =?utf-8?q?nKe4NchKH2bWx4LgDMvj0lPSeNLVy37k8IXjVSvt/RCsTiVhbJdhnf6wgXTNFdkHV?= =?utf-8?q?u7XRGLBEiqooVf5mgnUOFqghCFBXtAdPFBK9q1Lz0JOXOBeyXwAVDqq+qq8+Uv9Hj?= =?utf-8?q?SNnY7LvdyrdjkcnJ54o8Id45pI3/U5pm/4TSSj1jQ58EXl1lgLcHresVq0aOAKR36?= =?utf-8?q?KE+OT5xCdlvvL9TekJPlAJcrcZiFY3zgbmUAAW4dXALTssWb9lgG5P63UH70mYkUz?= =?utf-8?q?/RT6IZDsyMXiHGGgGC97XAqYNa0N9TJpIen5ZOPShO3oee7fvDIVShTaIEHOm4B2x?= =?utf-8?q?3XYM1VhSwega4GkNh5qwRnBBCF8LPyrVOt0nxA9iOdf6qV5Zcf/fDxqHZ5UvhsKKG?= =?utf-8?q?dpSdvEykR5T6IEQKo+nifEmqkMMWFdlNtjVH1mptmX1rW7obcBQNgzesASLQCDFbF?= =?utf-8?q?aIwNpef4GTotVcVsf2z1TPC7huyS/1r83h6CrGm3CXM6B/MStZJYzZCCXa3j4zemL?= =?utf-8?q?VnGjnOZiB4d?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd583afb-b76f-49bd-9a10-08dbf8b6a84b X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:19.5497 (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: rMQLiMbnIIPC2Sll4u+t26Qb1EKC2d0xMOQtvD4hEonnn6q3SRuW7y7s5zoAHVrmu1dOrpxMGChWr685cgFnpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 09 Dec 2023 05:00:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809348956221890 X-GMAIL-MSGID: 1784809348956221890 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 661074ab8edb..b418952c03df 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3593,6 +3593,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 Sat Dec 9 12:58: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: 176174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6032987vqy; Sat, 9 Dec 2023 04:59:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxLkoAeqHxb/62M4f9PheWL8tZnLW6JTLufd28wqr9yB4PVbb8yp6aw4ziJNEPq3IlfQ8u X-Received: by 2002:a17:90a:9c0a:b0:286:6cd8:ef0e with SMTP id h10-20020a17090a9c0a00b002866cd8ef0emr3004577pjp.38.1702126788338; Sat, 09 Dec 2023 04:59:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126788; cv=pass; d=google.com; s=arc-20160816; b=uAUO6ftwXEzZFQuhAWLJNKxmxIQcN5Ysh071hNwdIg4G0xrewedGt05TEbhM11gy83 Ll6SX92Gaz0OYf+RyOCmLAQ8YrAuHs+SjtiKCWaqGn19EXA9DSHCkUHON1Msf74UQPX2 SWCIOl5N+TftDqBrl5hUyYCJr/RYJgd4Rb58PqodOJTTP2ndNtSwckSGiO8a+NO2zyP3 EMjxR2UbLctIoFWSxOY4pxCTiqMpNrofdGdLyK5aXzpmGA1AdmfbuKDj2Ud3SFO8XSJM mRmUcApq7n3PdzNBDvM/wETewnbAy/m9EkHHOpz5djc26CPoF5cn5BoZqo+LHzBqTdwv cY/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9sRBm8gY2tDiUYzcClFGE54s4heCXu5xxHjSH1pF67Q=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=tnbOLqgbj0BBwEiNEZAFTCvXjYrVNuBDd8o08J01+s65yjOu1LmyXIhdtulbkP5BFG zHoDwSXT5BDe9aSOCl8+R9TM3zPOWd+WNkIp2qUTmwHYgLrDu9xucp5MYMu7NWELyXU9 5RAHnEHaUYbsX99H145ciU9n1sW0NzHxTNLZaMMOxjnZ7dc2RoUIqnKvIu+udzMPfBQU 7e5xrwCxk9NZ0ZNgWG7zUnEpf1TgGRryQ2rf5Uxcw4rGfvurmouipxywB5ERiUg6tTeA BW3TpD2Mf+v7scp6TS+rC+HSSUj7k8nXNDMtxkoVdHTc/BD3eIxZIzWoFg2hOXCZm7dI ROdw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=qksT3Z4z; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f9-20020a17090a120900b00286b27124c3si974041pja.1.2023.12.09.04.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 04:59:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=qksT3Z4z; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4CD128061CE7; Sat, 9 Dec 2023 04:59:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230206AbjLIM7c (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjLIM7Y (ORCPT ); Sat, 9 Dec 2023 07:59:24 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3BD41710; Sat, 9 Dec 2023 04:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijlLalFUnd58B664TWlflMLEeLslyOH3d3otA/GuOO1LADVYwdJzpK/ThsU+KLCkh3bja++zbnbJOpqej2Bxf2AzJ/8LVBoZGm4RbGHgPl/C7TzUYWGIHH61LkImFxxeaUE+UDEU7cZBL/DqBHV45ASPo0IA6nb+BdHK6KvgdwwWPo/2m6BrTqJBfzRG+GrzvwqGRLllej+1SoC/mIUCg7WjPigjWmTFx7mP/9NbPuzqSX8J6n7dyiugDlB5ozAR+k1f2+voF2prT5Sv384h0+OlIz9mL+YEEU3qgj2zeRXOw2pEa4cYhhXx7ggmodC6VhAlVpJb0HL+4+NuSpOOuQ== 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=TugaFAE9ED7qPyWXPcQlfTlWcweypeRjV3wLXu4rj4LImE5CCYxWrRPpFnsbUglVolx1zxQt3C6WtTWA1I4dW6OssYXW0m9kHGTFr3Qs1CZ0k1EfjtHXmcZrwhdN5Hg6A8qSloWufIotdJBKaNDeYE+Hw7/wOaKOdKXt8e4UWW9RBoUh9YNIyzRhLfVFsQIfHSGzhhhUFEELmWunBXzNqlGPt5Em8XgzeHzUHJcqIre9sY9c3QX0fKKOYVVEZinaqxjBv32/uppGOM+EF1cwkep4OoJomBDYZVWnqEIttwEOjqYvyLI7FZURhCKVdo79EiLSSbOuYNAsLy6zd0+XGw== 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=qksT3Z4zN12YlmRmem2YRYEX1joJ5sDCl3xYn5KebEQdLop1ztYk7fCfWeOwFiKuyzBydh8fgkCfOM3bK9Jbq1AX67OyvXwY2Yckp5HAha2y66MsslKj5Q5fIqPtMDAEw4y3WtTuoi0SCeHTwMwd4PQdTqtuEiAWahjhhEoNu1M= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:20 +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.7068.029; Sat, 9 Dec 2023 12:59:20 +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, hugo@hugovil.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 v5 6/7] serial: omap: do not override settings for RS485 support Date: Sat, 9 Dec 2023 13:58:35 +0100 Message-ID: <20231209125836.16294-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b92f7cf-e711-4323-3316-08dbf8b6a8a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uocdsEkqgHqFuSPW9Db0ig8290u2cJsSeIQ8+MdrJlNedicYd4ofc+vS+sHO9w5hlubaXkLiBEIM99yOCkKQbsYBGdesGqoWfZW2J2PCU1GLtpyQAmDeiGKpNV6XyXF1PKsmHqav3+pu3n/wBBhL199VtacrAZ6ofdLPBy7JarejIr55TatDv+Ai29dT311fwGn6XVvyadXwB4+f3mRS7IOml04l+bukE/QaJ9NoiRAJqkor0ofyncXHiC71UvLfGQCpNFsY9MXhyEJk/gCbCk7SbO0iJ/pTqon86oL+L5DRV8C2PZSKjXuyW9Wr1SUnMA2F+jKs4s+pa5CALCrix1YANjm2hwZKasb1vLMl2yL/AYidlKhEQwCE6s4ii3BqsWBBIIFM20Q7n8fPgHjKA50xjEqmzaSLbRGdwUalaAphcCRgnSX0/4+XvBWkshcqIEsvZ3kmoLl+K0WkNOlx6RD23rWMlbnBI0bITK7yBVlljvEL4yNrZBre+v0aW5dCef/TYhdY6usjmn8aK4w+NmpxE17T5ybG37wc8E1JWG1Acv+V7qwWEZyFKMi8Xd/+ 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(83380400001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jBF3AoWOhWizXLv9eydv7WNO1zPuQVG12NhpoN3RyxWyKCH3WraxafTSnOw7D5wz+tKhwCHbDWALIaqCripH0IirovHsRrgW8ZJ+CLElo7u9d7vVvad7qfTnIzmL3+bUtwt/Bg4nAKZRBYcbq/yWzm2Fq6qkTNjmG7j/E5JLfmujdAjBSSPy9yVnYYDMK8qpuApr8HqLA1o77AtzToyZPtoYfeGYBjj7Ox3sTrs8zHzupJYE/BfesAITyc7y0tGsB6zflNyQT8UAdeWAnTZUQyk9il9CKl6kKz4TkwhPlmzZ7OsrTwcO2Enkx9mmCWeMBm3hYRQpGM5QaTDjYt4tyUZTD2oRhu6h6NZi5xF3LULFf1X8GcvLF+RZaWCc18RM7ARLpUVy4RtfEN9Pj4vagXLIkOkUe0T57cAae7T+/4SzAy602IxhCXG5pPAbh6CQXXZW4J8YHCLHDAmcMXLl+v2uzSpSlIOYC3ZpZ3DweSqfEAnBcEMjbXXAk8zs8pmAtpOdLByYz0ydQX1AoPqHDtfj3sRuCNxoWegPZQCf0mYacLzK6Qsclcv76KX3AW2ihyeK/1S6x1hPEmNwl7AXWGpMJ2RZgydempLTSKCdE+e1Klu38DbtvqGBSk4j1yKY6wNMTXJNZFwEjgXabbjkh+dxQ+MSuLp6vR/j4iYebm31rqTtSc/F4apmYLo7gdMz1FxxyP5PWgUJnTlFAh2aK6J36cBnpnRVEhr5BOxgRL62jLJaFNXjDYNHxL1IbN4gIp3q87zolNVlgMtZmH+mZzHLVIFHDMO0rSjWL5WkP28C1r5W1t34QHBglITTYeW9dzGQ/MGkS4SfsvL3GUpGxISQb6VTuGEst8OPbyKftcCYZSDtpDBp6n1X/Bssmbr+Q9LcMdOfN08NcmLLz+Xt19dNXgJTw8sFbmbcPCDKyQh72avuWUYYlqfrBg5y202S8Ec5mDEbmdk5hej0C67QuAPRbvm0SQrxG7MK5ENhpx8XLNOMs7TGXmuS+60pi6lk5hpozwpKFHbFF4mI7DM85t/CmxdOyO5DuzuXpeQsNQhxeF5StxxSYSUczGHTArhCHGHTwYBsMz6y8xM4BJSEB55ktMXKsBFTW6SmQyXbmFY38kYcKEVb2Na/K6YAcHkmLtXpWdrDRnprgDAlGATMtTAoWcr97KTZif+InBNtTITp2z3mptgdhXKehD6iAFae9KDTuSGDnCjbIEKRzccfebs9JDpDxE4mC4+lBOxb0hoTfdspydvq7kWl/8UJpu98KfE4ShuNbKTG3yEl67U9paah3NmCv/cUZ2zpEv7Nomw6LL/IzcOqHA5TRpwat9Sar3nu6FhMhDVKtG5SW1j//LxpSLnwKs/8AldN1uvK9uyPfXAS8PAuV6pDcTS3QxtusaRpQkSZbScguIEWW5G4tWyEO9p0fYgXtv/osyeJzO3QM76T2FdN8eH3ecRLWi2KVz/lipEGlSay2LV9/3CmCgCCbN0g/1nfqJuyDWwJCG/zSA7YyJwoTJKlCvmwbljW9WglvrD3/IuTNEA6W96RF/m9MKBOE5RFiusRPisXMlJCMzIEQDYih+RYpV/8UfOkzQsCDdULCQLc0LudCZ8ctIN/YBySkSo2B9tBBKJtbLCNOvQV/qaT5d8DaiedLzjB X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b92f7cf-e711-4323-3316-08dbf8b6a8a6 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:20.1656 (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: p0C5MMCwIzJn5shFRgodHEu4/CkWsEMAgQyEPFNOdeHMsaKrSzYmgNQwozv/tZsd5d4fmpV7RKHEPUgB2wLvzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 09 Dec 2023 04:59:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809299250035050 X-GMAIL-MSGID: 1784809299250035050 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 Sat Dec 9 12:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 176175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6033076vqy; Sat, 9 Dec 2023 05:00:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFF6VNVnSnskZ7BEYdUzKY0h97+uKrCN6ODmWLRUKOBox1Zxh7VY2E3/QHhgfrta8zckYy5 X-Received: by 2002:a17:90b:5108:b0:286:7c14:6d0a with SMTP id sc8-20020a17090b510800b002867c146d0amr2772820pjb.10.1702126799821; Sat, 09 Dec 2023 04:59:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702126799; cv=pass; d=google.com; s=arc-20160816; b=fZ7KKCgKQg1vPCVKUiuolqvdUxYmgIVZi9C2FD/i4UUpV7ojtQIvwaGJ/6TEth/bBT jPU/+jBtFGTayuN5EcZaFIdmQGGVNVqogumeGkNUc4/+RDzAm1NavLVLlXv+JDPc3Zv6 hnpHjbGI9lB7hNDktEe+qmrB/r/9tnLd6TXxRb2M1nbKrqkTMgI4Ibdf2c/QpBbfizsq hFAvnwScHd6ilQxJe7p7Db2UDhK3fMhKgKjbyejFCOYv65NTNlyM1MLELvHni2vzMB4m 3VciXy58n0rTZwao34mvlBVvPlUCnxEIwld/YYUlzw4LnoRymHlhPxe7rn8MyaqVQ66d 8yoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CCBLbQLe3EP2f7hu3Tl5EQiwyecLdsnuvnoNW4MOtrQ=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=QbKSYYfvRYqKj5xAfFuP5G71AoHxoJxSg6X/5zCmJ/OVsSifFCZGh/ZU24+G/A2XK5 rDbPruIAbIfMyxWEztFy8mw1A3sBhyY1VRyj0x14S7jgNFU8oTOt/CEVQV5KjRO1yORy MEwOwTovbgWCbawP7PXG3TqYepGg2q63Rds8lqCX6DdZFJ0jnDV4L2L1FLegV0OcJz2h DlzryxLr58ts9wtcMFfGjTHEs1yaw6AHfbHNG59TaJ5Z4mbC5Drj+kt1n18WZ4Sm1dcm 0n1LNi9DSbJq7O76bdT+7LwOTPlfzI5+Cmpc3K2k5a8ePT8UnCEUBNvm878/nhqyyOI3 Ozrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=kimpEe5Z; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y2-20020a17090a86c200b0028675cb4aeasi4354292pjv.47.2023.12.09.04.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 04:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=kimpEe5Z; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5172F803EBBB; Sat, 9 Dec 2023 04:59:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjLIM7k (ORCPT + 99 others); Sat, 9 Dec 2023 07:59:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjLIM7Z (ORCPT ); Sat, 9 Dec 2023 07:59:25 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2043.outbound.protection.outlook.com [40.107.7.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DCB71724; Sat, 9 Dec 2023 04:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PGVldkkRPUKN9fDU3woKlupuoUDpVmI60cp6menB2RCXvO2hDF+NhgdGLfY/p2R13OqHjQGygQm+xQiRG2REbYWnVq/aaUYY+iQMq6Gji+cWJZ7Qvw3Cn9s1gYmjhA/BFi9y40ZfneXO5jqy3A8qpPCUnUTBX4xLbVlOPpzvVLj8rKrhkmVARHl5VMk3X8TJVA/m7EeU2F04PDV48tCDd0D72y/naEJZSRwzJznm3C8kHsbmAqiWKxqrhM3FcalGfckcvqJQa+1wWMAgxFLeDtaOAncG6jIANFSr13TzBX7DT+3Dpr7he7CROxQ26QyREAaonr0e9Kd96E9OIfGlBA== 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=Fwi/S4hdEVpgiDtN806+kDfa6X+4p6EBkB9WXKXueyHTh5ud70iRhp+xou6FNVCTQ+fjJrkg+NvPPzhUDD4vjY1oWVQ6072gSmpd6qSgv+e37z7s1n7J7+lDnsrlMcZIhq8k9isNDZqCgUCSu0HA9eJhRIFmfdZ2II1tjOTq8jKravLHZiqcB8UbjoHUXjzYdnst0bsMnFYC5CBmTdTEopSpxFiSqaBvmo0A68RuPk95zh2OcRNHwdN0oKLBIyYKHZbJpi8NKuyOr4iPDoTvJ4quombglmKjTr/LFrE3WgWHqCTW4s6CFg0ej+HkeDJ5jL64Ahg/HPoDCeab7S63IA== 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=kimpEe5ZaxqTZLyzmHr8rBvqCP+1KPZWLa9ycVO0djZOW42oDoVha/oUxD3mODCeQKJdYa3QuYQBdN41kZj7jp/isMYL014imhFTXF3M3BqMk3qk5IifVDkWy11QncQNY+9TdQhepXMRbIec/lcwMxA6CsDuDt7CBWpyEzMpe5I= 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 PR3P193MB0555.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:31::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.29; Sat, 9 Dec 2023 12:59:20 +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.7068.029; Sat, 9 Dec 2023 12:59:20 +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, hugo@hugovil.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 v5 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Sat, 9 Dec 2023 13:58:36 +0100 Message-ID: <20231209125836.16294-8-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231209125836.16294-1-l.sanfilippo@kunbus.com> References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::22) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|PR3P193MB0555:EE_ X-MS-Office365-Filtering-Correlation-Id: d1e739ce-24e5-4821-f388-08dbf8b6a907 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AOdQDXFfhLn82yElBF2NN57d/Ps8IlmMgi90v/OgrHeBwyXPgg4Wsae5jzyvwzgJvpJlKXVh5DsR9XGMOEm5Y4UW1m4doefPTZ9JssvkEDbAXzjYsmA7p2KKLmtvclxLOTI58QUKnk9UqIbqpvHmA0d36BCCBCVAud57RHnFXo8qK++9eU2wMqNe0LQdS9HD4breF53VDW3z78fN3NQZUIRBdA6s+7aHqQQ8J5wIYZDAT8cG4aFPCwDJ2W7bAZlfM7Wh//3sCSWBw0IWjduv48CyVpCM+HMKpOy6lNhhq3mWruIPNmG5HUpRxmHqwzSYNvWDAvjDcUkvaVDVGXaAeuHuPdJX6BblvDlmINNYCApW38mK5BMKmHP6cnkN6tbedl1S6VNznOLsekWX6UYfWOggU9QxvMy9rpYgIX0a+JcWU+UjXwrX8MgYz/GngovHhNZlhi7nzUc5k6Zr58K2zXPv9J5IltLGfQsG95O2hD+LozT1mtVFaok/xmplLywzrHEXY01SjeJxwYCa+K2cOGGhOZJjOm2WLVQDn//EoiRuNiJ2g4i38RPKNxiXVd9oRiPVkm/PIi1kgNQw+i1fVzDRjGl3JH95k/xEni/A9tRvGVkSksclKLHPTgj/YQ7a 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)(39830400003)(366004)(376002)(396003)(346002)(136003)(230922051799003)(230273577357003)(230173577357003)(186009)(1800799012)(64100799003)(451199024)(2616005)(1076003)(478600001)(6506007)(6666004)(52116002)(6512007)(41300700001)(83380400001)(5660300002)(2906002)(4326008)(8676002)(8936002)(7416002)(6486002)(66946007)(316002)(66476007)(66556008)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pdah+BdrJS/RxmI5EAukwsyKzXR/d122mSictOTuJ2IE0uMzKcGgYA2U86HvBQ7K+NXwX9EYpa+vuGtK1qEudr5QGGF1BxWUnGLlITsXC+AT+yW76tPpjEFptg+/Vbo7Dxqg2i43hzSCF4zpKr8FIJANkTDO6dYoJKoZHc1VFflBAH5cBYLNpvrGJ2+9tPIl/AooaEXNJIKcPxrrPjZVrve3ATPdzK1A+pP/TnMLpNWWVFfYIhT5nYXcMzi1S9vN1+s8Hz7teh/Fy4rJK++6zs2fS+7nNhn5aGRZat0Tpg3+HDLZ3qkSI/zPCLEPIhMsAbDqpAjTeJQuUF+TnArVJ3IqeXyF3fDKZGLV1CWiEpGlEFO9q1KDlNA1qAaHwaudZyxUrGuTyCHRknTVvWnuFquPRlKBtMSZACR06QZ9ZnWWoQmwgY1h2TEeTtKj6CsIuZeCb+CrIJ/xc1ORu++K3QKcJLvkbd270uCaYgRNjsOE0E0iWNsLzUCW+MhJLJk1aNPTNB0tEatmVhUD1uphARwQdwdYKdAKVb/jskUCUo+zA1j+GZZMvlBpDjkSZpIuNMLxNb8cGFeOxqKEdrc0sq+fbURz4T2HLF/u2BKGuDQPhf2XpEs1PeZWQaRL5aYQiK8uCPEg3yUIfQB+qO79oL1yrz6xdWD9Bd6K3mGiupUkFuabHqAzmDWboxYkCVeUX2Ms6a3UKTfN8LNSrcYYiOciYVcaaXvd8JDcT6pmwYf4gBdOSbMhogZDZ6eYMuObjj8nwmtmlfcSS0I4W0Yf5daONlspPgZapdpzB5qABL5SuBR39flDwe0MAeQCJi8RbHQODPtXY4Mo4n5dI1MiMFfoq2I9ie78lfz/I2oMSJYhLKn81BHr51G4COkbtYAF0KrhTuFzZCsv+GYjXfwdckbpY5GEc/6v186JSjdbyMQuNm+y/LRYeeAJXmDW+SPOQJyiUpJ9gOZ1pKswa5JSmfYG3NtbHEvDYc2d8jNVxBGqSrUAw7rBrPK4Nrinvh4ktvGFbVPKrgl0W4VI4AgehChP9wzyv9O1PWZyoNyyzjpgIOnjojhi7xc8kjVnDuRar19aCeTakmxD+oDNdjIkaBWiIF+VsfVYnnvbHv4JBsHnFHupRcIm2cziBg5A6hLcpB2PvoDRBQUQVe6OuWOzP9YORAmUxZ3ohWLzArhcMmwX9nh8V0h936QdpIpHjBb3DyKzczciZJeg9KEFZALzsroU1FZI+xCCumRtYWmzGSv1E+Foxn5yjGIEZq18+0OYLKFFxgI8cQ/dIWlOry5dzBoKElNAbEbPBFrAiQNsREjNk1K9sd5CovgWEvYIupsna5vCEbx5Nhm48btCGBWdnlVYnq7SB/NRh3mNx5BpwyO3Uwe1XVqnpz+wMFgrBhWuAPxkbqIAyaYeAcLG0YFbe4Kn+mZzhzKzAtPGKhiu9CQvfg1dy/hfeteu1+oCENsZkkXPs8waOCcqi8y7hg26+OURwRslkjtX/s2oOi5CZYCzry/CyGBmF4uOEg7vp5RyQri4YZsRWDYNyQTGEY5zgEEtzR7uy8ym8tWkMN6r/VMQqbfeTw5Jpynz3NphEy88+kPQ+e6JSPZfMdghklX9NoZk11Hm6tAYR5vLawqPX4/+4KlnCqcxcYyqkMjm87Vq X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1e739ce-24e5-4821-f388-08dbf8b6a907 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2023 12:59:20.8152 (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: +AQG1+7gcjayBSpolyk4t+yUcyYNDMEHxnW/LEaU6W2hCxBx8E/2dJGtP0MHUhF4bkewy3Xvb65XAZa19nu/5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P193MB0555 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 09 Dec 2023 04:59:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784809310961072932 X-GMAIL-MSGID: 1784809310961072932 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 Reviewed-by: Ilpo Järvinen --- 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[] = {