From patchwork Wed Oct 18 17:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 736148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10E5ECDB482 for ; Wed, 18 Oct 2023 17:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbjJRRt4 (ORCPT ); Wed, 18 Oct 2023 13:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjJRRtq (ORCPT ); Wed, 18 Oct 2023 13:49:46 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44AC5112; Wed, 18 Oct 2023 10:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Om64yqT6QtA9XIsqZl0GfdomHbPCvLmoyO5UJksiXefv+C7xZnz56ivs7UcSrPxufXZZfXYb9wYyUjO+ozf1qb7aeiA/4r0CDBmjkJ3pEMvBvPGQ2JUV6Mc1n3l8klSo6dzpBGE6oTk07tPLiynW15OjpdC7Hx/Is+phGPiXj9cRGayY8vrnh7cSLRgvBmF2/iTYbAtwyMOE35olNZIreaPr1CLSFrl6PgFPU/Hobhc2UH0LLj6ilLURX2BaV9ZjMUVfGcHMDDU9HpmgjqyualrwtjLtf4Tgv6alNaqF7dXzfQ0pyuUmKHafS5OVjJK8++1UH5CQ4dxpcqaTYJ5Etg== 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=Jty28h9E0xtb68sEWjbyY0P2pj9xkcJFJp53NmKQG+U=; b=ge58wig/MMVgy57YNCIPSYsFAllTU4SLFRV+d5CFrCMWvYzG0N/evARgUB5jZyR3IRKPbZV3EATXXYBkAHivr0mI99W7nmBhZ4y1xFwGHaJaR4KogI6MC+wESk9GjTGsfkM/NeGAlY9oM8wvbZeDQS0sTKZdBtL3n/UuNjVqJ7H24VjAYUONBQnmhkoPwJsCrtWZiBP5Lu7NrhFXGwV4sBHsHSIjYjxzpNqvAf8Z5fBi44swP7ceD0AJzYtRHmkEc0emccsc4dvGkvXmjKt8kejtHua6AY98IQ9zeznTClZYEyCTMlHJot+YjSPL/2hS+ccu8CUyCZeCEgVFnOs4jw== 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=Jty28h9E0xtb68sEWjbyY0P2pj9xkcJFJp53NmKQG+U=; b=l+eAnmduG0YpjI7aCljrJG9ORqd+EBhRFaBNSFHsgMY/W3ifBygnYLNOyANpNWs2mIKB9stP2MMIr0ESYxoeyZcnB8RjkAmOvQkNcW6dGh9Pyb+PkM1aBWKC8dnyAtDXamoF8EiBXE9HDKqqggNKOf26pGtkMd7zdYEg32j1EzU= 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 AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:40 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:40 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v4 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Wed, 18 Oct 2023 19:48:38 +0200 Message-Id: <20231018174840.28977-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 72b92e88-ba23-4c86-a918-08dbd0029a22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KDOMFT4bE62M04KLes3Y92TMGUbPgcsnfvRWdFlzkZIKiGR/fVnfZ+0HitHq3GBO2HL3/piUfbry6ujuwqEkTxtsKk76vNT2nVMF7ZUMi8rmjYciqRVr5VIlVAVoIDSOKX9KaSXo+XgWEyf5LOsyHf8/hGfmCSDqj93vfbk8amt1o3qcNSQgcEyKrkWsJnsTSqHwAlQMX610Dfw37vKTlnu3QN1v7qI1browjrcV0XNXTGTHOcmMgU3ipoBYI9uXqq8bx4YA0Z3jthW16zbCRvrXlvbqofeG/ad+5kdf0z473fRF6h/Bkj6RR0RDFZLbIJIKpvrdn9TJ3/yzW4grkK2KvjAB4SqFWFpQwv48K5s3mt2o9XkQQXAufLVpqFbJk4Z2eTrhrETJ8a1VKFg1E9jv2ToE4yDX9QCWROIXXGHj7HrRZ5maPPnq6t268dCS+Z+iKu9pd5uzuQxKcOlFdlWNFBT+2Bz5uiLVtPx5v/nLnEI6nm444GHJBdX6/0tHmxQdXLDr9PbV8tdxAPjVHzwknSZwuo/U1iaGIK9oAs0QvYV/HdEiZF+r/nuSzgdk 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)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?U+0r05znMH5+SvnOv9rbFGY+CteN?= =?utf-8?q?WN8afrDfeu4ZtU3mKZKT5Fn8qWVjlLchBYcLPfJQto7GPgR6wWKDuX9McgtHDHugo?= =?utf-8?q?IMNXju1Q6SHsNAT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?q?GpD97Pm9WazCGndVCxpdxGqGXkvVzJCg2pRS3wMeBqvWNLBSaZxJq8WIeuiseaOjQ?= =?utf-8?q?LNKk74Fm0Adr7cj+iyYPcgnoZuswjzf2XArJgSpyynEaGBr2JKDRyr+7yru/aSXxn?= =?utf-8?q?OX0OnHgSX/IiWeZQyQU5BMzEjtW3WgoucfzhdeDgCYagONsYBAWbCWKHKr4mGaWZL?= =?utf-8?q?kw3Oruwzgge0tySWDvVC4ZswN40urISCqw9P4+yYiqizZ12njRySMUNmrPLWWyhF2?= =?utf-8?q?YvJq4bCgmRx6uJ0p7FxmtVZSQlWjYYMdQqDCmLHP46EMtpycB2Uk/Se6QmHDLace8?= =?utf-8?q?B3Z6lhtMjcYtQ5TdXpfoOVvAMPmeR1fO5OS/ICZ4/V2vW9COu05Pnjliv2aaAqGtK?= =?utf-8?q?DqXwOQw1t7cR/RTCY84co7RBBHhIGPEXL4JcGepxNYmTmIg1sJACxlTQX9TBaN4oQ?= =?utf-8?q?q1i05vsqfnstpBM3vwzOLDo6sh2lj/BZTO5HU47T0Ia6L6x8G3BK63//bhXd8SxN5?= =?utf-8?q?4Z8x9VIZl/TRNRoMW11xN2up9bSdd6mMNir3Vfyo+FCOJcfrXDmucZqIJfdxz/td8?= =?utf-8?q?jUtcDRI5nFiFlFfUJNfnyzvJnnuBS0c0Ss2fZ1mAOp2osNHkhJsg6uMH7eOBqvZfj?= =?utf-8?q?MLOSxp62qo+?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b92e88-ba23-4c86-a918-08dbd0029a22 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:39.9162 (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: 0aP0OJ5xQjQtUKhP3as4G8AuHwhn8gk4iza0d9j7nnK2WyXfZ84qJSd01bT29XU1hDGVTaluT/FLHhM7pVfl+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org If the imx driver cannot support RS485 it sets the ports rs485_supported structure to NULL. But it still calls uart_get_rs485_mode() which may set the RS485_ENABLED flag nevertheless. This may lead to an attempt to configure RS485 even if it is not supported when the flag is evaluated in uart_configure_port() at port startup. Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED flag is not supported by the caller. With this fix a check for RTS availability is now obsolete in the imx driver, since it can not evaluate to true any more. Remove this check, too. Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Suggested-by: Uwe Kleine-König Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index edb2ec6a5567..c8c19bf8585d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2332,10 +2332,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 49dd5e864719..c85275a573e3 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3586,6 +3586,9 @@ int uart_get_rs485_mode(struct uart_port *port) int ret; int rx_during_tx_gpio_flag; + 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) {