From patchwork Sat Dec 9 12:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 752454 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="iN/T9odS" 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) 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_|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/OI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K1A31YeIb6T90BkFzgFJjycB10OftLCLmRFntsmBu2ObeThAOsseEaDldGkWlIhqWyTz+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 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 --- 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:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 752453 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="IEZv6+qq" 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) 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_|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/owkP25oaIuYJ0J0U6YzLqoA8bJg91JOr6g2mEquE88EQ4KhldfqXwj0HHjj4Xp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V5jff1lCmMMGP7a5mZnqi2G8EAjQm6eEv1yLMvyzKVfF9xta3VFR0p8D6kPt2o8BYVrpHFuFA6WzILCGO1EPvujn8Nrnk63CGdPP8lW5YbUMegb+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 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 --- 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: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: 752452 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="qksT3Z4z" 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) 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_|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 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);