From patchwork Wed Jan 3 06:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760416 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2081.outbound.protection.outlook.com [40.107.13.81]) (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 9656D182CA; Wed, 3 Jan 2024 06:19:21 +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="DdkWwkVO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZujBbf01IcdCM1f3Jwg5ek1O0b3+3vg2wSG1XCxC23RBNl9lVMp2xWC8zSEe2xnHQqf7CQHu8eGN3Kc3Qo66LZv8TDQhaTzb4KaARchySEPOphTroDS2cra5IN55TDXFgFc7cg09CCgsLUgrwFvmJm75LrHy33YIrZabLZbi2hA7xCeUzIePCX69quOmjLJPWL6nFeChZ9/xdyha1WgxbQdmfU9lDVGjX9khmDmez/7DQaDDyjhT2J0XtNMdFy2qpCnOyALxewRTLXZUZzfaeea02v1ym3iAhNxTDFFfS2CGgA3bBAptx1Xe87Qil1uOn8E9kEBVaZaLyCQnn3PbLA== 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=VLpap3fysCN1L0A+G61Ig5vjNHDwq5LMYvqjA8EDBHAOdm/cyAqBhjTudQG73p1lJU/EItYdn/DAedi4JKEJlN17r8GLmat8GudK3o+0rvQB6wBGgQXcTvs8gvw9CJg14XhnvvcMmqJAEQKiHAATWEgau0fTnk1zxpMmizNeK6cQ5wnxatuEayTn2D5MrA5t7+pOa4TaN4pl34pQ4bQsEfZ7lEAA/2EdxoiIscMsILQjoIzqDciChFyGSt3QlXAlI+nGCsvdzyj+wJB8kQ9PMq4th2vR29ceDdeDOa4wnWbUVFUV9zePrzUAraTZfJM7a0K0k6D4XDBVFnbxhI2RkQ== 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=DdkWwkVO1EUqR1dPhDi2gD3XFmzCHU9GJW3Z2m4ZHY7y2nLbZvfivXT60ONHOVfqkSCyXLytdOREhF2mpLFu5wBuOSFSOVqEKBQLNcv0QpnhgUbNb8p5/ocn5TBDHeGFCk5DrMEk2XNzUaJWrF4mKDuBJi99kO6RUk6laQsk5GU= 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 GV1P193MB2245.EURP193.PROD.OUTLOOK.COM (2603:10a6:150:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Wed, 3 Jan 2024 06:19:12 +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.013; Wed, 3 Jan 2024 06:19:12 +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 v7 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Wed, 3 Jan 2024 07:18:16 +0100 Message-ID: <20240103061818.564-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103061818.564-1-l.sanfilippo@kunbus.com> References: <20240103061818.564-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0267.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b5::13) 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_|GV1P193MB2245:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f77156c-8206-4263-c196-08dc0c23e767 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGEyZu1xfvJUAaMFj3Wd25DC2K3Rxxu9UMussr0XYAx36glD5pvZclkOxHQNvIETGcl0nBFj8rCsTD4rp75VS4dlFeZct+afsWTEjSkuxRvtzEitS9ZOpaiXvBPPkqrhE8wqaDHlKwr+UhHtM8BKIcSaXMuGsggVzFl2mQF1VqMt60mBBe8XcjEhheTZ7BZrL1kvUTvmnd7def+d2HIvrxJzJBJ2rCl5B6T/rz6u2Y/Z02shkhKLjQPRIPFDENASnkfvwfJbH0u4CHDWDIQ9bB6QvjySclI7RSfKfDtGhfOV0WmuzlaiVOB21e5+YdzMdFpp1lTdIn3VJlSCp20ZFnUnIK3rVa/dKQw/IVUQWQmxhzYOHeCLy9/Ll6AO5mXLPKXqw2vl9WB/GvtxWRszuo0EQcnklo5g9q4gGqS+RtwNkIscK5l5LBsblbhlwryBssZZZ13CZuwj+p1txfmCrTpm7G4KPrgJwePIxtRLNH9zx9iziVWdk0Y2Dfqj+4aOxi0zSqgirQfyXiISXOw2LBtq85UzgIr3KDwXAjivQhuwYFmFGYrn+QagHd3SLX0C X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(376002)(136003)(39830400003)(366004)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(66556008)(66946007)(66476007)(4326008)(478600001)(316002)(8936002)(8676002)(6486002)(83380400001)(6512007)(6506007)(52116002)(1076003)(2616005)(7416002)(5660300002)(41300700001)(2906002)(36756003)(38100700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5rSgsxANlDeer1lwBlQLWlriOjOC?= =?utf-8?q?aP/rDx1M6eMjF/q6vEIr/PHME1MWz/UL8yo5Rs4niFmeBN6DmPBPk0tyo8UGYQFfN?= =?utf-8?q?EeR/NSkMiebP8/vIr+iwmzez3oYg0OEH4LupMNKfB7SdhJLRna0ygVEf04K6MinKG?= =?utf-8?q?XN3Tf37oB1LHJOm0/2djWKi4Hj/ZQbAh9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ph2HMTV04N/r70DXb1qjxal066Dz4NR7bYup1pcyCaL?= =?utf-8?q?snqOnAiRsx1kGmGP4Mp+eXbMeJ5DGI+4/fwhLydQYKPmfHmNPzfoWuVpdpDztyup9?= =?utf-8?q?3B0BLpp3AUf1CsqdGdli9GD32rH29TZKOPGiUMjyRw9/F+BnJKBjbh7EPfJ50qNpT?= =?utf-8?q?SS0dl/pV+YemEvvxt+N7mNKsI2pw36ZyvbO68huef3g7XxwKCEKDa4USD4m9jimEw?= =?utf-8?q?GiHe/3RplswZIEfR8CKdAF6smlNOw1QpJHcO3txSPZpzjxzzCGzBjkdf8dXCKlz5W?= =?utf-8?q?+oLVu+owiXZftJd70WVdGWXSuZeR9ZE/muGnqdqP3JVlaZLv62Kqd9vMrp8eH6pgk?= =?utf-8?q?/lPpWRq18VANxXcTa/JQB97TJ2sP6ss3h3a7QTvv768s8gSpWMDLVzKMyAYTkKvOc?= =?utf-8?q?y5EKN6WOiDhVykLJIKYl4JZwxjAveoYptaZCE9LIkOQhf6eqfoh+0uJczqZpZDdFX?= =?utf-8?q?fmtokgs8oUsipYZb+WOrrUeyp9mvWKL7DuJg/KLtF5fF3g8kcEUbU/9EyE1iTeAcb?= =?utf-8?q?5+qexItzKaXEpIY0q9i+7cHD2V26YgfrQ=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f77156c-8206-4263-c196-08dc0c23e767 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 06:19:12.7168 (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: HZhpjmiY5i1KRCeGKK2uOixqTpu5Pw1Xub0Dd+vXMU8gSay4CMDqgQoQDB56Zq4y5TjlEYkFxrWe2STNIxU+gQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 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) {