From patchwork Fri Jan 5 14:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760402 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F29942D7B0; Fri, 5 Jan 2024 14:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kunbus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kunbus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="S/8SUKsg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F/QPTRoJPsHYzI7Y/eZi8f48OO6K+1YbYVmB6BkSqAIjT7SGQugK54lk/WgNWUJuxPpWi/TqqD7AAJmlJF0ZyR7Dy/Jv4DwJCF1Mm2YgqgI6Vqilld5EIPRUvREtID14QfAHiWTtl6duNX88w5sW7QEp7v8TjUm7P2DndS0dUsp34y2k6QGlXjoH21l3gSOuan0OgOeZ72DIx6647TzhEQxSfwUeGSyyyivU3V2YO7DqxUm6c+H7hHITIMK1QUVIPVRoeINRLzwitwV9EacepO9sP02c2IeAOCZV0mxKsLnAAWF5dS1EJw9+zfT182R8MrgQJYc0tOuxrSi3GYmrJg== 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=MO90q+6gxUPedgZTk9T0oK698FDczikJmPxC4jA222g=; b=R4Zqkxe5ntveX9ULH7nAeWgXtGDbpXaIu3I4KwCo+0Opn/WyVFXdXzUKteDog5sNyjqWVXpKQQdUyHd5YDbQcCwPIBDUPL5puZGM3hvpgwX340hHWZzxXm/6RFY+z6fllmsTjSvKJSKc1G2v2VFrIc4q98nOMnLWb+nXiRuskdjoMsMGzgBuMVbGV3YsjM396HMciOW/mf7z4X4/6UUOAKDkKYvxBfbhtdWx4BdjgPWMtTVLacHOJWQrGE4V3bNhn8zJaoVhkpyiPvWKJvTYKul+N+9d96rZzMPkl31ceAzWpC6pKyeDe/9ca/QpSAeIwiHt2E3TILl5sw7J0+E7Og== 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=MO90q+6gxUPedgZTk9T0oK698FDczikJmPxC4jA222g=; b=S/8SUKsgb6ZvPyKEW3G7bHLLjcnakHCwQk6KbH1eGc8ubt6BTWToeGZZxaGSwSH4/9/4wGWaqiJMm7yCW+R8BhhcCamWFJeBgAeXl6XEyW5rDbfXMM5CTjNLLjgO1jK//pkMARRaXjnnbQgif4q/yTS5l1rN6MEf814owlHzLKI= 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 AM9P193MB1538.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:30a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:18 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb%6]) with mapi id 15.20.7159.015; Fri, 5 Jan 2024 14:12:16 +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, m.brock@vanmierlo.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 v8 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Fri, 5 Jan 2024 15:11:51 +0100 Message-ID: <20240105141153.19249-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AM9P193MB1538:EE_ X-MS-Office365-Filtering-Correlation-Id: b1625078-dbf0-4cdc-83ec-08dc0df851d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zkrSp1WpqhNISZxhdP2n9577Lf+dwFRdRHq5Q8OERXCKHkBRZdFQkNewckBDRs6vFXPGa1wQtxjI+bCdocAkcqyxDELvaoKmqe8WbJcZk6KYenm/MxH9n9kyEFyDdU+mG58NvELBav99A45UrPBIZx/lkAkkbRVnM+0jR7XmQ7wqprGaCTia9n6yZaLnpDhvByu24I78ItL8QDWSLT4MkodysWY2ZOXMfEgFrH4inFEaNl3lY/xLWKnloUdNK4V+GbMncI0PaHktfwQzj+HjX2M0TBvvBnDOiyazJPpS6P8fKmsgXoHyNvxGSFRDDgyOL76m8MY+Jepe3hnN2pWNEh43dRpahgjOF3cQNVfAjGx2l2Ud01kXhktHhJa75rv9bkGb3lL6M10uqK1Yr4P2gsQtEwvaGrgSRBCnanTiT+edAybTpi2EswRkskx1nGxotI4G5qPNH2ms6HJmFEjvD378t3Blhs+f/4ie6FZ9M6AbfSreCC4Gh6P3E2LlVLbNEp43HB/E0r2TIHvvHiQT1qjx1IpRf4yz28DKSoKAd3OTS1Kt22TRv4IiQdX5mbjw 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)(376002)(136003)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(36756003)(52116002)(6512007)(478600001)(6506007)(66946007)(66556008)(86362001)(66476007)(6486002)(83380400001)(38100700002)(2906002)(6666004)(2616005)(1076003)(7416002)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WCqu8lTli3YFfiLEYUKIUTHidJWE?= =?utf-8?q?0vW5E+zTSCeZpaIqRRDkF4a+S4F3xUSU/MUEVBRAb9LUNkKuncLgFKVVmvSwQ4hz2?= =?utf-8?q?ktnuPHipXC/WV1d/0YKhY1LyNQPhokAzG2CUX3yVppI7jiYkkr/moirzLFIiHoj7F?= =?utf-8?q?nnXKkIXV7gfoE31Wbyy74/3hOWQ7GCKIQOm3ILu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GOTBcfOo0201+OgP0Uo7qwzB3UFpa7?= =?utf-8?q?s5WobFCt7GK/fU3WNw7uB7Bi8Jf7usIlDOBFr/N8hiIub767nEUVO++v1c7YHYLRo?= =?utf-8?q?qOvrG2qjaKeVE2QTbTBC1ys8HRe50okzink/9XXJB8fdayE0ox9TqnB/5TTvqEdjd?= =?utf-8?q?4ebbhwuw+Zecz7ibWbTOM+HgGoMHcbGP8ZJ1OC5hkcz5dtNJ0CYCtNk8T/7HNWpD/?= =?utf-8?q?hqMeyU6PiWD91GjRQWCRLyVYoXCx9roihMFx7y95tT5dNaZW6QudE753+u+CEeMTQ?= =?utf-8?q?wCbkdi4Q9WQg0L/pb3MW0uss02PqYTAsZqSK1tRFOAajQ0QoOaQ9oAv1azSrJ83bg?= =?utf-8?q?rqBltMqCBSSWXQsV5fFinJMRV6LjF3WvRlhVho2jBewhHVnwopT9LgfghSqWBn/sH?= =?utf-8?q?r5cK8EWLQky2X6TB0SBHVlCX24KRYE4x/lFEMJxlnNeCAIHeBUGYlbyepl9dPL9Zb?= =?utf-8?q?0avZdkzB3SqwETcXx6oBbSs/2F14I41NCg+AltlLawhYB/Bnc4/aDFkzXH19B6sXV?= =?utf-8?q?fv1Q7pPFsUuJQbFNdX6pUiqwcXoiYURWQ=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1625078-dbf0-4cdc-83ec-08dc0df851d7 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:16.7359 (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: Ga+VbiUBD5SXtC4BDn1IouYSM/sF6+VEI8cboMWmc//Qqj5m37LAi7aUZa2nzlaGr8fuBKhHBPc7MXEGlUTxVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P193MB1538 If the imx driver cannot support RS485 it nullifies the ports rs485_supported structure. 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. So remove this check. Furthermore the explicit nullifcation of rs485_supported is not needed, since the memory has already been set to zeros at allocation. So remove this, too. Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen Suggested-by: Uwe Kleine-König Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 7 ------- drivers/tty/serial/serial_core.c | 3 +++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 9cffeb23112b..198ce7e7bc8b 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2206,7 +2206,6 @@ static enum hrtimer_restart imx_trigger_stop_tx(struct hrtimer *t) return HRTIMER_NORESTART; } -static const struct serial_rs485 imx_no_rs485 = {}; /* No RS485 if no RTS */ static const struct serial_rs485 imx_rs485_supported = { .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | SER_RS485_RX_DURING_TX, @@ -2290,8 +2289,6 @@ static int imx_uart_probe(struct platform_device *pdev) /* RTS is required to control the RS485 transmitter */ if (sport->have_rtscts || sport->have_rtsgpio) sport->port.rs485_supported = imx_rs485_supported; - else - sport->port.rs485_supported = imx_no_rs485; sport->port.flags = UPF_BOOT_AUTOCONF; timer_setup(&sport->timer, imx_uart_timeout, 0); @@ -2328,10 +2325,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 28bcbc686c67..93e4e1693601 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3600,6 +3600,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) {