From patchwork Mon Dec 25 11:35:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758364 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (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 0740E524BD; Mon, 25 Dec 2023 11:36:04 +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="k4bJpEMs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYx4NuAc7XhQ97gBxeJHkX471JybGGJfV9KCCux9Psqql6FXxXdnTQmP61v0MhsVLoFx2QjqUDOijHrTQeF621s1uXGFfczCwNlrU5JRKChOK7TWxoY/o0KrEEqNmn1oAGTTeiyRVj5JrawryUviUPl2ugpRd5jrBVhmIxTjy8gOFdL5OkmLzlILpnW3be18Ji/DIP1VNE/6Y9deHNxfHnPX21fBFeWeWpXwzheuWJwz0bkiFr5rWViRKWGo/wDaV84FZ74iBgLssgKj9DLK4WvISrUk3UHdYcQimVxrnnj8N6BDJvCd0keu13qijj0biP+j/mTd3RyUvQcBwnpTCQ== 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=yPnBAB65jmBQDLunpS8k5O/cIgfIkQi5kIiRI2Szkg4=; b=C38aQgxrguska+PIS31RCMq8xo/e6B4gcD7K2L61VXDreLMpI7oq7t/woB9m0Y6PKY0zhL7c1Y8W8GQwdA/YhU4AeBFNIBGh/gt2fvLX8RKNsRvQ1voh/XT13qzfQFe8+27aIQn82rU7tONfy9WCP3HLTJn6SWxzu2lZDMyD+XACvAoDyJS6gaCu2hl4vRBj7HZzjVS3gWeIUwq+MVlpKqA0uEfCsMqw122Z0moUvx6Kr+FDMPKogHvKEPaB46kufcWxHHNnDrnilfWBuFcjdPsz5xumPRxt8Bcdui7Mi46Jz8P6XNqMAyQSEuf5xKm3AtmkFunwRC9XHiwxmHWXkQ== 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=yPnBAB65jmBQDLunpS8k5O/cIgfIkQi5kIiRI2Szkg4=; b=k4bJpEMsad4dfxfCn2W6zYW1XUkw39AWvj2SzUvgJe4U5cyRbXaC6er9EuMsg2FmuJ072bqF1/1SAE6KM3ljI5ZAtffuESWe6Ibh4F9Xzl1+4vktxkTgbzg9/mVlEk5+KNSUZ521bQmg4AmUvCL4tEBFnItdy00h2mAyxtpqMKk= 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 AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:55 +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.7113.026; Mon, 25 Dec 2023 11:35:55 +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 v6 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Mon, 25 Dec 2023 12:35:21 +0100 Message-ID: <20231225113524.8800-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 365e86ba-c222-4353-5610-08dc053da7b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PlB/dzJlVsp6kOYONNs5G8rQy3E0bfSyqbZZ/KLqsUHyxFFufMIf2ge/bOVIp6BjLChBPnWI6E/0ipd9eGbvimehEi8a25QbhV75UcA9URQL0JjS+MplZcNkaAVlFiStyArm8n0ZulPL4z/dBvl4VWikTAVKFoIVMbp4libo/c3QOhqZAM8RqO+cnyBjeqZUdAM0jcpSR+UrB8C3TjH/tvvzyfvgONTekMitEx+iOIW/UuHfE1NGIu5kGrFkfvudeNtfU09Reii5G0sXfW70FkXqpLrja9XIOI0qVSevT+FZjJndw1u8UMph7TLweysN0cAm/CKZwom3246U4TQp2NEkNA+p/hZNu9kqzJIT0gaOE8ulzK8nZCxdizE1hy0cjLMf3dEKtsIlbUO2RVXLSlvLHPDBRCOxU2ZxXcmYm7XusOlAZBVS+fYDHYY7XPupadB2DA6HWx2plTjnBcbsofRGBGduIsbedJgY/O632lGHAXHl7o+ERCGw6HYwdok/ZqwR7zBlB/LBydj5BTpF7ANj0IIQ+unxi/UBaTdDA1VFpoNP+n0oaEkCqOi6k5fz X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(83380400001)(86362001)(1076003)(41300700001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yy7Q/fVAPliT8+RcWQ9fsnClNKAf?= =?utf-8?q?+F6oP9DO1j3wgotJUpEJ60elIBrXj+n0SfDfNDlMS78ej8iSJ4mGC3HSzDwlIRUrb?= =?utf-8?q?vUGB4/kX0thGfCZ5EuTuGPks7GVnBpMOBJ9cAHrvy9199ZYCShHxP2nuQMyGadfBY?= =?utf-8?q?kK7ojy9CzadS/3V4wbkL8SYwHq09+g2cArPySGmOPbkKH9h2y2R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r1z9?= =?utf-8?q?Jfc+CNpxxOUXCrLrN0h84iQU7ZcfvO3WDWV2RODYbYblsw7eecXmik6VwX9D5qmpX?= =?utf-8?q?f3W9oAbMIVYP0OpQ67n/QrbDhumh2w3rIm08Tr6Aj5DuxtJ8P0E8oHODuaxNYVVYO?= =?utf-8?q?XaOSBhmqkglDH1dfoj/j6Jgglo6pTBBqoWYMpJfo2qZh8e3Vy8oPbMyTG6zFaW7LC?= =?utf-8?q?lZDNOu9EzOIE5bwlZQ71tvYdPDyGksM6DVJ7K2ZD7yY7bHpr8cEbl25l1VotmNxxY?= =?utf-8?q?6mtTqRB6tk4T6uVvFRI4mvbgbXrBZEXN+e1m611sp6/MrCPMdcR/xgkKqWFixI9kd?= =?utf-8?q?JTbUdUhqfgA7MBrOUnCSF+E91BQ9elHny/lAv22rs1VohpLZVvRY87e4M2/obThwb?= =?utf-8?q?WDdflU4PoKfDsA3x/K1pQ7mC1vHL+EEsO+rkVwzJbHtS4JtUmDvjKtF3yZwc7ncf0?= =?utf-8?q?VeBx0ZeA8F+yOHirhl82a2GBHt9tiojK/96GvFTppJQ0qABUwN8AC75RZfNaaOfej?= =?utf-8?q?gOh28yRZcvZ?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 365e86ba-c222-4353-5610-08dc053da7b2 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:54.5452 (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: MhmUu6DHwmQHVNngcV4n3xhznAqp1Q5Bk9kRjuwGv5btj9ceEsJJW/mOvbKp1PFuFDHAMEXzcWum694+s627Eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 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 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) {