From patchwork Fri Dec 1 07:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crescent CY Hsieh X-Patchwork-Id: 749769 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=moxa.com header.i=@moxa.com header.b="IPLJJ5eN" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2047.outbound.protection.outlook.com [40.107.117.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C71D171B; Thu, 30 Nov 2023 23:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HWDqxYTGwRELfFowCK9f5YFiRd3j/KBCeiPMVQkhW/bcUdSTu8+9YshfyRX7ycT01GFU0KpCXWfbSO+cK/sEpf3ny19DIvyUopirnDkr5cmIK7eBIUJJVMLyqMDELgDmYkral1ZLefeVw2L8kgmlaGAzTB0ItT904vIgKJcXY+Nu4ZllwOkxWYEOxm69ZG0wtkBGTDCZmAyMf8qcQM8A7N7v0dRssdOuxKkyD/Bq0gEFNXKJ1jdd0XBB7xE6gVruugB9qK0aTXHKBU5aM1yuQdTXmTvxntp9lM0HCS+hSJPsoHJca7HPc73hqD/DJ/8tYyY0ES8AKNEtgvWAYUXmRw== 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=Dtg3Sb7WUeORxnfTa6IxBZVTwoHGiLFCIT9cX3ofiak=; b=UXMuWmaCw1SJy3LrB5nhOoJ0XFGQFD/L26qDO0xnm6ORiRfn+QVkwwhq32+Gi3iAr0cIOHyZKq5QDNxcc9SjtWA13hT+dM2YdnU2ev1mf7DGTpRQxxnxRl3ICk736TVIPi8EJFtV6RNbveeMjjcoRiRKUOXhDlfcJUvaDrLVIOiWaOxwNWChTN+k8+3ctvcBny7JUDaYK8hMSxy6jVO2jRk2F856O0p3IQqpyBO9I/bS2OmFaub6tWbODlGc3awduiDuQcWR8yDpON7NbYZa1ckOSRfu9npEBE9v5NmBKmuWUt0M2g2T6f2jTjQEHd52eh0EzL06igfG5E9O1pAb6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=moxa.com; dmarc=pass action=none header.from=moxa.com; dkim=pass header.d=moxa.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxa.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dtg3Sb7WUeORxnfTa6IxBZVTwoHGiLFCIT9cX3ofiak=; b=IPLJJ5eNjlNINzkvFrjOG/d2Htm43WZVYG0HuWcyecVof8g9wdVXqVMxwCBpl4cC3s0nAeWlUu8NFT56ihnOodHTdU6wvfGOiQjKLG8lx1T331bxDq4psNBsbLNOcbtt8OGXA4IPMEhNnMUshL9lPUOiiKXSibeSQVH1/6HIKrg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=moxa.com; Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) by KL1PR01MB6537.apcprd01.prod.exchangelabs.com (2603:1096:820:13d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.26; Fri, 1 Dec 2023 07:16:30 +0000 Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::1023:2132:c05e:ea6b]) by PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::1023:2132:c05e:ea6b%2]) with mapi id 15.20.7046.015; Fri, 1 Dec 2023 07:16:30 +0000 From: Crescent CY Hsieh To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Crescent CY Hsieh Subject: [PATCH v6 1/2] tty: serial: Cleanup the bit shift with macro Date: Fri, 1 Dec 2023 15:15:53 +0800 Message-Id: <20231201071554.258607-2-crescentcy.hsieh@moxa.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201071554.258607-1-crescentcy.hsieh@moxa.com> References: <20231201071554.258607-1-crescentcy.hsieh@moxa.com> X-ClientProxiedBy: TYCP286CA0255.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:456::15) To PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::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: PUZPR01MB5405:EE_|KL1PR01MB6537:EE_ X-MS-Office365-Filtering-Correlation-Id: 28be55b2-ec7e-4a02-db91-08dbf23d709b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k9u3/JEsslOfY6neJ++ljyx4XHddiZZdxnvyIwXLrva6wHQE20PVkHQ4GN/VHpFAi2n6G7qo6n0qbGWMO6qey5lBo7jSpA3/j9GKEpOchOcDweE+dJo6szieyJgsYFiPMpqrKpmpdQFvVEKKOLh9twU3qglSTL/9q4rvLLi633LxezSlnQ0+bnmzLIaRFE1610XCkBwqAzmJ3BEcEb4QRIdyO5s2K8moHxT0Ec3sxbHs9oJSDIu/ZjjyDL0ljOKhlAHeeNrtrpbBE2aoT0X6C2bV3njKAPSGuNHPd/DB7BcfF0mMbKwNb3xzf9CEXimXJJIlDgIrKRrLSI1UeTViuq3GvFAoJJ4cl2yACemFZlrlB3Op+POn3/g/6CBt+UPjzf3zTB2SUhgruW3R4vv/IJ17Ux/ZwCkVfQnggOJOcP25KTZpJYcQ7cRas9GybBhLwHKViTY3XgnsWKUuiYB+fXPhaZoZuEaFjdiHah6TKVLfREzl0e1lP5iX7s18FJmdBrXsZ3D06Jq0lTjkFBEMvn2tqU3WccUYiJjZSEtKDJY4yNfhUkpe3LHVC2t6khwjIaqxjhzN+7wXXufyzHdOzKzLlXzI2jF5jz/oGj2JCp9vKKPWEhWNrm66mcvY8vRK X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PUZPR01MB5405.apcprd01.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(376002)(346002)(136003)(396003)(39850400004)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(5660300002)(2906002)(8936002)(8676002)(316002)(66476007)(66556008)(66946007)(4326008)(110136005)(41300700001)(6666004)(107886003)(6506007)(478600001)(6486002)(52116002)(2616005)(26005)(1076003)(6512007)(36756003)(83380400001)(86362001)(38350700005)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: An7yLVzfDfjeomynMI0yFiDItkK0qyGSPS7JOhIVX5YlyiYv7GwapQclolvqUiACCiucMgezIA0daqhflVz1WnAionbJP8iYzAhj3aoOwhN83ZMyG6HRvM7mG6ubzyz6g7yT6QjPTPV8brSDJMzwpgE0LrLL03wHiQScva8WZs9BIfREWyVlPF3fIp5/poLIUbZWufaWcS2V9Nb6ACVD4xwM4tuiglfWxMDWth3EobD4nWwHwVb4rC5kNQi2WgIXL6PPW/k6UNIsqgDnnxo3Azt9FXEB9xp1x4QsxkN9WGuqV4LgF/FG25TEUW2surNdmyS/MRnii+p5VaEXkXxBgv0kLY4diW6LY1dxdILhc5c2oVOsT24LYait9EPJfUqw/s3Xl8oGNLrWOZqlCXDYeYz9RicO7je2AKbfsm2nn5qzTkpnlUCy4455uq3AzllphcCJgyhc/eU/d8iX+6Ef85aR/DadyubroZskjGiKrj5IAqajOoDTnF30X88/60V5uP0QbShjWVvIyPZYvDYzO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w== X-OriginatorOrg: moxa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28be55b2-ec7e-4a02-db91-08dbf23d709b X-MS-Exchange-CrossTenant-AuthSource: PUZPR01MB5405.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 07:16:30.0887 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5571c7d4-286b-47f6-9dd5-0aa688773c8e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JuxZIjYiAuztGSeWWFhp3fwwaV+1A7gJqjCaldYKDBKVpHUWEfuUFz1eWl7A376XZVMzc+/yP5kzLCdL73+kyp4I5aEzAY5oFtS9wMlbxY8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR01MB6537 This patch replaces the bit shift code with "_BITUL()" macro inside "serial_rs485" struct. Signed-off-by: Crescent CY Hsieh --- include/uapi/linux/serial.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h index 53bc1af67..6c75ebdd7 100644 --- a/include/uapi/linux/serial.h +++ b/include/uapi/linux/serial.h @@ -11,6 +11,7 @@ #ifndef _UAPI_LINUX_SERIAL_H #define _UAPI_LINUX_SERIAL_H +#include #include #include @@ -140,14 +141,14 @@ struct serial_icounter_struct { */ struct serial_rs485 { __u32 flags; -#define SER_RS485_ENABLED (1 << 0) -#define SER_RS485_RTS_ON_SEND (1 << 1) -#define SER_RS485_RTS_AFTER_SEND (1 << 2) -#define SER_RS485_RX_DURING_TX (1 << 4) -#define SER_RS485_TERMINATE_BUS (1 << 5) -#define SER_RS485_ADDRB (1 << 6) -#define SER_RS485_ADDR_RECV (1 << 7) -#define SER_RS485_ADDR_DEST (1 << 8) +#define SER_RS485_ENABLED _BITUL(0) +#define SER_RS485_RTS_ON_SEND _BITUL(1) +#define SER_RS485_RTS_AFTER_SEND _BITUL(2) +#define SER_RS485_RX_DURING_TX _BITUL(3) +#define SER_RS485_TERMINATE_BUS _BITUL(4) +#define SER_RS485_ADDRB _BITUL(5) +#define SER_RS485_ADDR_RECV _BITUL(6) +#define SER_RS485_ADDR_DEST _BITUL(7) __u32 delay_rts_before_send; __u32 delay_rts_after_send; From patchwork Fri Dec 1 07:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crescent CY Hsieh X-Patchwork-Id: 749419 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=moxa.com header.i=@moxa.com header.b="DNRwgU1a" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2062.outbound.protection.outlook.com [40.107.117.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B9571726; Thu, 30 Nov 2023 23:16:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h4kVCPfHC/qV2EIzwSh2iR2CFhHVuxdkX3+QhhB8LaXcctUNdgDt4IFGD+79oAf54+V9byuHD8GvocRHkiP/1GnI/urorFwf3qTL9TfuhbjP2axsKrz8kT1C/3yeBNpIEYnIMeCsjLfw5mHMeYmp37nZVv9tiA/FO2c22qSzEGWUEZXfsp1A02FAsawzUTOBB7JoaRj3eyVhYtVXzl2lBUjlerD3+k75i+AvI6NuEozJjgdj7vXivJc7gjPyYJ1aKfo/16YueHPFqyz2ITr2va9w/6ZpO/dDgcggd4B3NLz1oVIImneIrMvvQrwKrHfWNE+RN5WwkU2X8XsAxZiyMw== 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=ArAh908wYFJWhXcoO5REz/BBDJ1hRKCWJknYZ87vrC0=; b=D9g0yKbQsPl+EUzzaKnqBtjFKuc7cB0vqs884VQiqDl+Etq4i8kJ+gPKQJx163MNBtKsk0XzKkGzulwJK/cRd3xEY4ArnGEE6Kv8eJfr701BM72ItgAURGvu9KloBZ6bIsKioyoeUAWuroGJjHPufWYeoqcTTaYbed2GUcYESqIqLbrlK1I0niWtekT+UTFw9KTERvDr9oEuRxFIHnVm1Aezq7VR9oAxq5ucvORyUlEiZFf80tjZh9aS+dIMA6MkwHHsUDqdO4l4m71OrNaI0mWg9nzdqOY29dkp6+TldGZ3vyzSFbJzlv/wv0ulzwIhmA3IT0ArGA0KaXtclZ2m7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=moxa.com; dmarc=pass action=none header.from=moxa.com; dkim=pass header.d=moxa.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxa.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ArAh908wYFJWhXcoO5REz/BBDJ1hRKCWJknYZ87vrC0=; b=DNRwgU1atp+6yLdAwYUEDrePfAUVksaFBUPngPTQ3znjP4EP7AkD2luCOZMKOFLYuNgdAI2egTP2df2vGzr447XAzT8IsSh7prAXa900t93BHWqEr6zu4MvwLMONsrE9y4bQVnZX4DFcN1VxhR2TDDd7vvpVvEcAS7JRh/q2b5M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=moxa.com; Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::14) by KL1PR01MB6537.apcprd01.prod.exchangelabs.com (2603:1096:820:13d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.26; Fri, 1 Dec 2023 07:16:40 +0000 Received: from PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::1023:2132:c05e:ea6b]) by PUZPR01MB5405.apcprd01.prod.exchangelabs.com ([fe80::1023:2132:c05e:ea6b%2]) with mapi id 15.20.7046.015; Fri, 1 Dec 2023 07:16:40 +0000 From: Crescent CY Hsieh To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Crescent CY Hsieh Subject: [PATCH v6 2/2] tty: serial: Add RS422 flag to struct serial_rs485 Date: Fri, 1 Dec 2023 15:15:54 +0800 Message-Id: <20231201071554.258607-3-crescentcy.hsieh@moxa.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201071554.258607-1-crescentcy.hsieh@moxa.com> References: <20231201071554.258607-1-crescentcy.hsieh@moxa.com> X-ClientProxiedBy: TYCP286CA0255.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:456::15) To PUZPR01MB5405.apcprd01.prod.exchangelabs.com (2603:1096:301:115::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: PUZPR01MB5405:EE_|KL1PR01MB6537:EE_ X-MS-Office365-Filtering-Correlation-Id: 133a18a7-5ead-43fa-106b-08dbf23d76b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gIBrpIMCwHacGBpXz1gT7o2W8O8fo0uAZFrZSDOh8IF+xJ4II5Dz9oeSWBJ0FWDTE/cucTEG9ctRRFlSSJ531pvdfgxf69fgi1wDb1aVehUiPTwptipDcWOefmkOJ9wFMPXpSEV8kZc9nyCPe3zA76ND5G876Bq0kAEehK9oVigqkKufQdr+iyeGBHsGXcoau/+LYna1CIXe00ddLzaUmbH8OuxbPnvPGTjVlEm46f+IJD73OFsH7KBpYNMh9EHSYhA62A32KwsvkN2oRDIgAFziAn0nkXFGyY1ZDhPbwffRjsda+oVVc0BSDNUjDfUB1b61VeGSD+BlzfOgmH5S0KGzzq+YbbYTgVh1ngNkWousZW0B+1wHkgZkL2q15Aq1inu6gykn2s/DwjOnyfSKyaVMRAcSSgKvTVO/plCbjuRwHh7yEyiR6QQVYbRowzZQoVAKcyQH6YUCd6KDbc7AnHejPP0FtyrudwHQeLpzS1C18Mtvq0R5o5/G37ECDbibvisDEGNuWwgdAU2eEzGC95TdZBym+zpWccNQQ3USIfermPfkJl3Gegz0xyW5JapBuDsaBnSLRjN7pXGlh6aDt7e7+xP80M9oC4N76vdk351yrw6EkCiFkqvqGgGXTdYi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PUZPR01MB5405.apcprd01.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(376002)(346002)(136003)(396003)(39850400004)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(5660300002)(2906002)(8936002)(8676002)(316002)(66476007)(66556008)(66946007)(4326008)(110136005)(41300700001)(6666004)(107886003)(6506007)(478600001)(6486002)(52116002)(2616005)(26005)(1076003)(6512007)(36756003)(86362001)(38350700005)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P/OgwyaJph+28JUhXgNS5wDKLDHDb0j79ZxsZu24XAvZvyiK0HtvVJ3QP7KeHK7ej8VqwAf6Ot+cBhf/dKDjYkpoXQIK+uG6l+sxNMYJ3qrxSJhibN/aW5WxOlwAIqsktFV14kJe06F6nndjOC2K/rqKEK6nzIsBT8V3obptiKriejtgUvfAJmU0/ykhYvhnGGcSb3DnNITATbMrS7BtS+OvO7kOxw+4kuWLx7ilUxJGBNPjAod5mLPqJx8HHE4/aNYMjP11ZuNXDtj/WbOJ/db95JwsJ7qa7S0Tsh5J+in0NwcD2VOC4utcvG6nJd5PBMsdvV3vVuChbG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h+GWpV9MJ5jvjfRjrUQ6p+hTBb3Vd49grFn9gkUKHxgtT16IEa07o+t2LnXTHe7VD7IpTUXnC2xhwblwMgci3I8LP7FWPwPn7CsrnVYq8ZB+J3L0Oi0KYNAWrpb4TlAvKjgISn2e80iOrc16nHlCA/uHbW4g2Wcz29PgZelStQce4FDaKUDCdnQk4g/hMOnM6N3Ua2ksJhCj1RnSfOyYRAJfi3RItlqIERA== X-OriginatorOrg: moxa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 133a18a7-5ead-43fa-106b-08dbf23d76b8 X-MS-Exchange-CrossTenant-AuthSource: PUZPR01MB5405.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 07:16:40.3086 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5571c7d4-286b-47f6-9dd5-0aa688773c8e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aHnZF/j0fysNg+rlZtoa5Dysb8O2Mo9ehPA3JKxT1FJ8bXclQB1fA+GDC8QFveG8LB6i8qzXIJVlJA7GjMBKclLeLBXHIZOSEib4hkmsObQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR01MB6537 Add "SER_RS485_MODE_RS422" flag to struct serial_rs485, so that serial port can switch interface into RS422 if supported by using ioctl command "TIOCSRS485". By treating RS422 as a mode of RS485, which means while enabling RS422 there are two flags need to be set (SER_RS485_ENABLED and SER_RS485_MODE_RS422), it would make things much easier. For example some places that checks for "SER_RS485_ENABLED" won't need to be rewritten. Signed-off-by: Crescent CY Hsieh --- drivers/tty/serial/serial_core.c | 6 ++++++ include/uapi/linux/serial.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 831d03361..a195ec1ab 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1376,6 +1376,12 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 return; } + /* Clear other RS485 flags but SER_RS485_TERMINATE_BUS and return if enabling RS422 */ + if (rs485->flags & SER_RS485_MODE_RS422) { + rs485->flags &= (SER_RS485_ENABLED | SER_RS485_MODE_RS422 | SER_RS485_TERMINATE_BUS); + return; + } + /* Pick sane settings if the user hasn't */ if ((supported_flags & (SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND)) && !(rs485->flags & SER_RS485_RTS_ON_SEND) == diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h index 6c75ebdd7..9086367db 100644 --- a/include/uapi/linux/serial.h +++ b/include/uapi/linux/serial.h @@ -138,6 +138,7 @@ struct serial_icounter_struct { * * %SER_RS485_ADDRB - Enable RS485 addressing mode. * * %SER_RS485_ADDR_RECV - Receive address filter (enables @addr_recv). Requires %SER_RS485_ADDRB. * * %SER_RS485_ADDR_DEST - Destination address (enables @addr_dest). Requires %SER_RS485_ADDRB. + * * %SER_RS485_MODE_RS422 - Enable RS422. Requires %SER_RS485_ENABLED. */ struct serial_rs485 { __u32 flags; @@ -149,6 +150,7 @@ struct serial_rs485 { #define SER_RS485_ADDRB _BITUL(5) #define SER_RS485_ADDR_RECV _BITUL(6) #define SER_RS485_ADDR_DEST _BITUL(7) +#define SER_RS485_MODE_RS422 _BITUL(8) __u32 delay_rts_before_send; __u32 delay_rts_after_send;