From patchwork Wed Jan 3 06:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 184633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856274dyb; Tue, 2 Jan 2024 22:20:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZ9bjzJv5oDdZchoDDt3ZQHZN3YmQCEyfxAxMU7wX4UBYhAv4ETXtFkunXXXfwklniZzLW X-Received: by 2002:a05:6808:13d3:b0:3b8:b063:5d69 with SMTP id d19-20020a05680813d300b003b8b0635d69mr21355589oiw.80.1704262850645; Tue, 02 Jan 2024 22:20:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262850; cv=pass; d=google.com; s=arc-20160816; b=K09cn9PXVa5DWrCkTi/mCAlYoioTFaWVZe63rjLtPCyIMqIK0uAOVHiZYGcuZoDf4G PpDPoBpe6uAHkaesml7fuI86IEhSyAVCEH+qvfQot4Rl3757qqAly0+lUVWrZb2vmoWW Z9bfKZU94/4dpGBQOnlgZYztsjx3xQj/1ePm7jknGjFpdXSSQSF52HCND3kes0lk6/h8 iTEmIf93ROFito8GwCarBWxockb2zEcQnNjwEnf5kHue1c41Ujqt0juVXSErMr+jJYPF 4XtGZsQ7gjR0zndAiTDjAJxsxNptHbgY5bjIYZDP6ObzyU/QSlDXbYHA7oAqTbppGpwu CCZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=A7XY6q1hHzURDCSJAsn272m2uNlivDy635/jnq949R4=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=ibU2B+zmGMYfpA3+UmfRdX1wWJNZDtQCe7wK0uvrDIPoNm8QIk9wi3zhE5cVNeiSF7 U8vWZsVZc4EmvhdLYypEvWDWE1jpP8iryvVcES82HLpZD3jw3RfsOAUz9njvkFiobsNp 8KgQ883bC6F9EZoQKW7Z6cmdGdXWzvN/aZizp9MndS/tsnNKRsIytd+nYr+gz36dHZpn 0nWoW++fh30ajuIOjBMaSmo/bK6uvOyHT3cZy9ssKo3J+0VCoInNaqZIviqSrZ7ykxej y2sdZl3Gv9wkqBt4AY3+jEZn4RkWxHFceDbdLgatIzzX2Q5WEAX5bwmE2StM6iwmNGO1 x/RQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b="y/yFatKQ"; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15207-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15207-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b28-20020a056a0002dc00b006d999f19b4asi17424618pft.357.2024.01.02.22.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:20:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15207-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b="y/yFatKQ"; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15207-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15207-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C2B43B22C35 for ; Wed, 3 Jan 2024 06:20:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0F1F18B08; Wed, 3 Jan 2024 06:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="y/yFatKQ" X-Original-To: linux-kernel@vger.kernel.org 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 9B0041804E; Wed, 3 Jan 2024 06:19:19 +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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AlDcfOGDMVo821yNuIXqhducL8kfwwAmpUoS4l9TdcRZvedWpZ9/KuroUQ6sASKspxEOMSgmPY+U6kxLMZB4iwJ5D5Pg6N8fZodM3Swm5Be7CJnVixSrboepHUmqcsJA4gBefKDHmH2+97Rw/tEoimpm0JNNTzYTkIkKSBxsTMLHtF2Fdrh2I1Fjlz7Uno/zz4Kp0xuDGh/4857pOqSEyxmLNZghg2VryNuTgj9r7cF9hsXyet0ak6kRuYeM2G0K9AX9TUUw6UsT8oX4kF1O1V6eKR5yjjyDcbVi842CR+mzqNeXlRZFVb6JQnXHUVBUzJeNehkujyCSnJVwBUQmkw== 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=A7XY6q1hHzURDCSJAsn272m2uNlivDy635/jnq949R4=; b=jjXsD5k4PVdJRbJTeyZ13Jtb/Tr1XMhbGz6C+F6JamOvKH6QHnWNpMmtiJVyR3i2rvC2/Uarop8SU6SteEqqc86Jcz3lIXC8J7xLhfDrOHB/LPhVlQvlPU6lL3tPLGHwnR2cpuDVULZHhi2+sk8A5Nlin239Lao5sh1xm1NTlNSWo8G1mjApe5eW+W/Fcr6fgR7L10EI8WMwHW3a6U7oM4aZuQqBcBEsZ+aKsewrg23R1xf4tYMjYGp/MU3qmIg5Mc8zFO0PhA63DpLUeeYK6Gb1YIGvZOvb4hyw0fk5O1U7JDK/0LmM6SsfaCOQ2tclXJKgbZNqW1RSi4oU8eEMuQ== 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=A7XY6q1hHzURDCSJAsn272m2uNlivDy635/jnq949R4=; b=y/yFatKQEjRUiKUCfMpJ32w6fKMxdCTivrLppKwZx7X2LJcKTWp+ZVYaJbCZcVTouVeaDC74rCKXDF/hKVcoHUwDSNCqZX0vsWqp18sbLRWYT8NVcW0W6QMOw7NSgMyD/417BVEpaY2O/aqSVx80ZjAz5ubQ/j2tobB+SB5ppcI= 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:10 +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:10 +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 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Wed, 3 Jan 2024 07:18:12 +0100 Message-ID: <20240103061818.564-2-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-kernel@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: 01f1d246-a59f-4310-bb13-08dc0c23e5c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xw+9grU9SzQgsPiQCZgwHiWqVAFooyPGuxUUUYRZ3tPBnr3O6kGiAJVl5hssSf+/CYB+yYg/02O0buQqYcHOSZNZJMEUP7LgHkh4FamFvKc34I16mS68RyxkF2j4dh6ORLrgR5tS4CaDJ2cK8lZ63/of1CN69zZi2tJ/0I1Y7bg1kWtNcegW+6OsQKjoDjcCblD6NZBZiMa2FDBszZzDiRMEx/9nqjX2ca2IwW2cKH7tVwfGhogID4favPnlkkUvKQudsUGz4c0m01P0+e+x0LF4p1SBYh+yZk6R/wj9SR7nlbXMforwgl2qIfr/t3oysxV3f22lVbCkK4bkVOhhKI4UlR0KFL/2e7Adw0juaH2p81NRjDdvtt110FaBH3cjc/2et9ULdjuATWKRFw55BTQ9D276SLm5lNbh+JpId2l9JKnH6Lc/Bg48qfHBI3Uy5TkfxB9edW886K2eBWjZM7GhYRl4ZqIYO9AbuU07MDe8lNPgnvMNsXtd7dusyAffI7ejSZp19sNSspS643zrquzt5JV4J6TGYfpBAkAqiX6okIEWpAXAdfx4rBIH/1uC 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: Z6rc2GsGjLTaB7jGhYfVQ6E0snFJMaQ826RF8RURvqyBqs5EYXtaYmBPYMzB7sn9veT6HgNhdoe7CuWl/nzFvKvzY3wWKqE6l14q//MaiDHHAY7cXrgiMJvNjoFuicbTSAljXLFGZzsrjhrEYMatmwgJ+qpLjas9IbcRWAISodn7jeJt6EFHdX4L4c9Bw66fkHM8gSiRDD8D96Hdsf2kqzGgv0crdKJonLpwlVrB3k7l4MMolHKxnXh7hzvfjtxXavW/4c9gQrNNN/bvZlM50N5gHSLlFbhFGnj/Kzjk/nBKFuyBnwbhVi978v8PTyQDH7MY0BlVFV7TKL8rINqC+LgoKJ2gawUm8XX/4HWx/MVO2qHayjPDg7yUUiDjRgfTVwLHod87iVL7GIASOFPGTyeiuMGnmLP3s4lv9tIZ4hiY+xY6+3nrLjWpbuHUKclMTO8jFECFSEYNwwRObolHXsrLmmV4i1OfEaY8JQIZnioYKs2iThXTAm4lqZwGhtLBceC+l0+o3y5KvP71rlxv6kCpaz5gKDBtywL0j58AJS0ipvb173ix09L9M+2tXtrmdUrND74L9HXlwU7yBYD+4JSPekuLEdkl62z3jD9HTj2oBbhZTSkW8+mk+YXUe8RvHxQ/M2trHhOMTsUdGbTIgQNceJFWo8DQs1M5s27CZYgbO9wFNL+7zmm9g0NIaA9v52N56EmKAVasEVY0Xe5ZbnaA/aOP8WjSsGl6Xc2Nyp4LKnzRorzybtVaCHrjow+ligQJBIO3rRjuB3A/9yO0yXfp6rtTzwzMaFlvxgH7WYMLw5IfdcXWm/G1BIaIr9YH+cNXvyy9CyHVJiLPSAVpr/Cdh7tcEwdsZCBYXqZsj8vvOYA5EW+WuLKn4V8uGKWQQedE4JK0VBQj9XDNdeQhtOifA1pDfOwstiNsrMs6qo3hzFyh5NxgN3v/N0AFGUUUsWvYe/aDBBdf+O8UCZaftwoWWyGcD7fGNZJQ9kyUuJ6wfYsXvq5XLFeovVR6/t1AsQSp/KyDVV0GV+W3NElGkChX8Xoc7l30AD8aQcMegaxHXSFm+mT9XzVuB5Qo+kLBjemcyVZI/kqZHvJ2U/AX7F+cpN2bU70GwlZLVSlEYcQHqugXX8DA4ueoCzO27KZCZZomGTBO035cxJNXd3LLe7ahMARIQpBunVIoeRl/z5PzrbxsYPmhqv1zdGUO15Q4Ua23pk85Swl4iFq+DL8RhWe6QLqyq26oX8mPcHkgnjpKu06YiTH2W21pnAC75nFmVJ4tsp6Yo8IV3tW8fL5o9fz/PnYfnL7yzIdfcKSsxZK1PvN+U70sNEbs63/vue9H/xkb80w4+psnISBFfL8J9D7nkSzZrBNm1UUhz3CVs/hYyXba7cqM7rIMsaJKnLj/xVvMgzRagvl2Q0nzDYHdgmoA320KeyDfb3lYbgMUemT+RdW3yCX7ax8EQaiE4IzMV9TBOthSofkHKeAszi4radlRVpfCiHsPVVl92o5Mm4b2TokRXXZ5h+WD9HwoppSXmD0+U0ihxkccBC99kcHaORJ1xLNMPaU5bHsJWR/7TCXDMmsuGngqDx6qmqpAJ99x0V44UJTucL5tXKD/bOH4TQBHbfsKqz/vzmhxgN7WyJYEVRRuVsNccp0kM4IHYRetrb7SXjJP6zyDAQmflgJUgw== X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01f1d246-a59f-4310-bb13-08dc0c23e5c1 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:09.9931 (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: IpaUicFCG89A6B5Lp6oNH/8QjyZPJ67MA1FIUihfr+VLDtshDyEKLjmbCARQUv5PrqQ0b9wbWtJbGuL5eUuwAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049123318947205 X-GMAIL-MSGID: 1787049123318947205 Both the imx and stm32 driver set the rx-during-tx GPIO in rs485_config(). Since this function is called with the port lock held, this can be a problem in case that setting the GPIO line can sleep (e.g. if a GPIO expander is used which is connected via SPI or I2C). Avoid this issue by moving the GPIO setting outside of the port lock into the serial core and thus making it a generic feature. Also with commit c54d48543689 ("serial: stm32: Add support for rs485 RX_DURING_TX output GPIO") the SER_RS485_RX_DURING_TX flag is only set if a rx-during-tx GPIO is _not_ available, which is wrong. Fix this, too. Furthermore reset old GPIO settings in case that changing the RS485 configuration failed. Fixes: c54d48543689 ("serial: stm32: Add support for rs485 RX_DURING_TX output GPIO") Fixes: ca530cfa968c ("serial: imx: Add support for RS485 RX_DURING_TX output GPIO") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 26 ++++++++++++++++++++++++-- drivers/tty/serial/stm32-usart.c | 8 ++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 708b9852a575..9cffeb23112b 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1943,10 +1943,6 @@ static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termio rs485conf->flags & SER_RS485_RX_DURING_TX) imx_uart_start_rx(port); - if (port->rs485_rx_during_tx_gpio) - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); - return 0; } diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1348a509552..d155131f221d 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1402,6 +1402,16 @@ static void uart_set_rs485_termination(struct uart_port *port, !!(rs485->flags & SER_RS485_TERMINATE_BUS)); } +static void uart_set_rs485_rx_during_tx(struct uart_port *port, + const struct serial_rs485 *rs485) +{ + if (!(rs485->flags & SER_RS485_ENABLED)) + return; + + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, + !!(rs485->flags & SER_RS485_RX_DURING_TX)); +} + static int uart_rs485_config(struct uart_port *port) { struct serial_rs485 *rs485 = &port->rs485; @@ -1413,12 +1423,17 @@ static int uart_rs485_config(struct uart_port *port) uart_sanitize_serial_rs485(port, rs485); uart_set_rs485_termination(port, rs485); + uart_set_rs485_rx_during_tx(port, rs485); uart_port_lock_irqsave(port, &flags); ret = port->rs485_config(port, NULL, rs485); uart_port_unlock_irqrestore(port, flags); - if (ret) + if (ret) { memset(rs485, 0, sizeof(*rs485)); + /* unset GPIOs */ + gpiod_set_value_cansleep(port->rs485_term_gpio, 0); + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); + } return ret; } @@ -1457,6 +1472,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, return ret; uart_sanitize_serial_rs485(port, &rs485); uart_set_rs485_termination(port, &rs485); + uart_set_rs485_rx_during_tx(port, &rs485); uart_port_lock_irqsave(port, &flags); ret = port->rs485_config(port, &tty->termios, &rs485); @@ -1468,8 +1484,14 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, port->ops->set_mctrl(port, port->mctrl); } uart_port_unlock_irqrestore(port, flags); - if (ret) + if (ret) { + /* restore old GPIO settings */ + gpiod_set_value_cansleep(port->rs485_term_gpio, + !!(port->rs485.flags & SER_RS485_TERMINATE_BUS)); + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, + !!(port->rs485.flags & SER_RS485_RX_DURING_TX)); return ret; + } if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485))) return -EFAULT; diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 3048620315d6..fc7fd40bca98 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,12 +226,6 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); - if (port->rs485_rx_during_tx_gpio) - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); - else - rs485conf->flags |= SER_RS485_RX_DURING_TX; - if (rs485conf->flags & SER_RS485_ENABLED) { cr1 = readl_relaxed(port->membase + ofs->cr1); cr3 = readl_relaxed(port->membase + ofs->cr3); @@ -256,6 +250,8 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter writel_relaxed(cr3, port->membase + ofs->cr3); writel_relaxed(cr1, port->membase + ofs->cr1); + + rs485conf->flags |= SER_RS485_RX_DURING_TX; } else { stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DEM | USART_CR3_DEP); From patchwork Wed Jan 3 06:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 184631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856051dyb; Tue, 2 Jan 2024 22:19:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSOejB//aoIylb4zp9+KlzTWfsXSS4RQSq8TSMhpZ+0gQ4YvIO7nBsmVcxerSVqscF/qBB X-Received: by 2002:a05:6a00:9390:b0:6d9:b296:8369 with SMTP id ka16-20020a056a00939000b006d9b2968369mr7784654pfb.1.1704262794484; Tue, 02 Jan 2024 22:19:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262794; cv=pass; d=google.com; s=arc-20160816; b=dUgARMGadoGOrOL5LunJtos1Z5ufRgM7t0n2GIi3A0lZqJSKUTYharrMuT+E2esf+C SnKKUmGq37CudcKcUJ2V+oj6Uq1H7hCZvf/mYsPDQb7RjVLccHEIFJevuXwGsfVDw5h/ F/uwUBXWyTP2HRuyquQyNMn65C4n4DRY/c4vkAjA+ByvXTomxwjXMe59FvhWxM9ZfPlm XbmtVw7Ub5BZGJ7GP8gt9nsuEd5OTbBrwI133pGadKk5lZu8oPUZKnKYVv2DLdQYRJna hg9Gv7n5JJ/wsb2D9wjPf93xzHlXy5ItaCOjiM6GjFS5B204qBz8xMW8fMbRmhH8ZFdM SCyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OncriHkcvWJWNFlfsrQo1DKSpaTIWLwBKZU4AvicFoI=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=ppporAfYGgdtqwyp1i+CnHgaISGYc90Vx3IfEzGHwVb4++iG9InaN/1VKyQsedOdCU rRR/ihH5/ZCkfC9f4hoJOBJkat2+/ZoptSmAZDW4rNqT2dAd4D+E8B2c8R3CVt2Uacdb z3K2QBCE8yev9+Q8KwZXeH9HLMi4YUasOAJ6Xo6Ar2oC+pt9/OKHoEQ4lDwnA2q6sewj 5dYosP08Ct7nJJFSVPcrikbztacFzEmPgFhSqBqQCZnxXQq7fo8E7k3g2GFWC7c0n0Hq 9wtVDekIIJhQQvMfjWo8xZbD9fW63/G5LEx65LhlLls0HyITSlY1tGs6Viw8zSgu2z6d bDZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=bb4RoBbm; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15204-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15204-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 8-20020aa79108000000b006d96d74f3a3si21373486pfh.101.2024.01.02.22.19.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:19:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15204-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=bb4RoBbm; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15204-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15204-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 62200B22CBC for ; Wed, 3 Jan 2024 06:19:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6602318041; Wed, 3 Jan 2024 06:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="bb4RoBbm" X-Original-To: linux-kernel@vger.kernel.org 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 BCB8C1803F; Wed, 3 Jan 2024 06:19:14 +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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=knrgDtx4aHgQffsK9xidO/yhcmTFYP+/x2jL2R1EV1xmh7Sdf+BXwLMdxi7krOJmIj80Q4w9Zy1OogMIW79GzG5K7OZGNSosE7CKdAlPiybBrHyFFVlmbKp7vHel6iYECb5NL80mOfvdjSAhxflp3S/x+ujbCKIkauY9vTpcXbT2qV7JXo0smwfTevCUCBLotBytnKRLa//zoxaYoO5rJbi3A2UY3g5wkxfBUoR2nP1C5aaVirLZDmsydYpLpXrjrOBHetybefdPwJ9oRpYghi4LG6gL2xZS/180KOEpE4bTIgaZkddo5X41O4+rPee/LctK4+PbQl1j+jHCwM9yUw== 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=OncriHkcvWJWNFlfsrQo1DKSpaTIWLwBKZU4AvicFoI=; b=ZAKEzm/v8FGn5bncOhpWfelx8Ag7bwLP2PktcSOKovoA+/2cPUmEbwzmE5fLaKWsN/SJA9VDwyDjngo4cTZTjdbttgh8EPAkKmhTQ2UEPwg3sIhb2IaAo47anu7Q/Okxf73xU6Wy12bUfoEhlA/KOn/VcchMAnDnuqnlxaMFr+uXY8sb8rcfbcPHOR/1rDtt/sG1p3ycWqNcCe1yTpIg38OTvf+Fi0woJbLgK+6Q3oP49qfFz4xEAIkjG0ECDz91O9/SJl9k1zBc6pjtKfuMF+ceK6+tMZIT4djn2Z7FwUJtqBmeZdRQVxib5ImAW05JSRfyUo6B+pnfaEgLhbbh4A== 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=OncriHkcvWJWNFlfsrQo1DKSpaTIWLwBKZU4AvicFoI=; b=bb4RoBbm4p4U2U0Mniu6VaEzRf9FQF1GxgWdFNRB+Ax1GCfFM8IOi1sa05v8dCIMMWRpRN0/DpzonYCYcRu1bMiV1KcVbPHsA4xl28eCdTHiX6eb+RbXGDU8+WuzVZ5lgnoJ9EEdKgliYZxFqCoGLPqzVjdF4CRVI/uTcqCNLpE= 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:10 +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:10 +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 2/7] serial: core: set missing supported flag for RX during TX GPIO Date: Wed, 3 Jan 2024 07:18:13 +0100 Message-ID: <20240103061818.564-3-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-kernel@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: 0ae9fc89-1f2f-47bd-68f8-08dc0c23e62f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pdR7HZ0dlxXUEVFFbT9JxESoSnXhvjLBu+JK3I78pq38fVFXD+vzUostfkByuI6357nEqXlH6g3/h6Thplvs+uyd9WINkj1gfMi/NfttvXAFWtPMft/sOPs/Kr8OENmi6anYHEKAAhsIC3FAmItoRAz5tH7DOIHRfiEy0BG+ej0BtAlLMnZq7qyPFivD6cODkDObRFMrb5lvCsC+DbE6k+MV45xqCzzP7G5/6NkWpfReHJk2YbUzlxri0GKZUpDxMxkLgdqwKCjaU+i2fVu76+8eciCd28A54upCKTuMM2UuZaxF/xX7+ymEGuTwIDpbpHL7KAoWelgua5NbIdJ/WtsLzl7Wtp4XcZToG6PYBEeDuqh9zsoNV/jKlq1PPR9BDN/6nj6Pd6n0mSNfhcdrcnKLqeGLiKN1TGHdl4ifemOUIxTg30tibL3DRvKOLXXX5Cw2GHdXpiBkbTG4DlbLMQ5ZV8afSY0fr7PUk7qIr4HH26rOeB9cTv9Pn6UhTFomyufhmuCOsF/PWp3CaMSnsh+/I11o8MH0NdHSVW5BSpezLnrxL0Q3QSdqRMQvXbTA 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)(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?SLEWfKb4R2a0j+N+6e6yK5TV4gbm?= =?utf-8?q?9GMrKYDCsIfKFOI+UgwTcFcUMqys+S/g5BiugnORDYOZaj0oqoQFTcviHSXMG3hI7?= =?utf-8?q?Zhs+QY1H0yBJ2ukm3R0jPtUVr1hPJihO9Jpqd+wqZdSCkLGPWBtDGBuosUdvvTV8D?= =?utf-8?q?d2M/1P8KVZ2sUQi6Zwwpfpxn7CCgTcL76q6g2NIy5YdRyiSysixQAacvdqfm1xX5G?= =?utf-8?q?C+b1OsCpiiwN0eVRi9RauoCvKgV6Gn4buggVYLof0c8R3tBP96eISZF/nqVSjuCkV?= =?utf-8?q?O+AKmgHFfaRhtjcuEfF4muTo7w+gCIqvc8uObpANjNWQ7s53CuYS6AI0EiRPfw79M?= =?utf-8?q?D2tmJf/pkj72fLBrJfGvviACt9XKgXjYvO+/NSO0lrmaI2F9U2KSrzPyrdrCUKEc2?= =?utf-8?q?ZdIZ8blgr/7kt6qZwqOcg7w+CzGudCtTXP5W6ZxjQw46ihOuC7y5Ir9HAIpOPbMT3?= =?utf-8?q?jRRllv8I7dkS60PuDL7UFv3Ra1t+YvBV3RY5xjXU/X6M3g14og3r6ocVWGqF20h63?= =?utf-8?q?ankEym4iIIesiW8cDd/b1vBh5sjis2Pl1vAMU3o21e4H+Zk5XFUPIXESHHyj4szCS?= =?utf-8?q?cFQFEGkMfl3+aNswelq6/VvRIHLdJ1Lo8Le6/vF8A+1aG5UjGXBKkyJMTaM4nyHYP?= =?utf-8?q?VxZqeyZNIH/dphs0zqfaCehPyHpHYuW+/r8WlkjRZZcVy850lkiaak2UD9bRkO9Hi?= =?utf-8?q?e8ZtsBWGmn86KcO1VLIut6PyJpe8gfULHOACoMN3UnqrSspb/x+oUukA8CZv8QgBT?= =?utf-8?q?Wohxd7BHMMqhY24eAWZ94zbx4eksfzYvdQv0Ad84tKcBl90b4r+k4UKXSDvlL9sEl?= =?utf-8?q?0emQteZSZP0jt8p+eOt5uU/pZYRHgTt29SkX6TYvbC8yx/NJKhtTA2qf1cnulZokg?= =?utf-8?q?e1RrYBF/J0lYlPUly1BzbjLrUVYdRC1maOm8wxnkf4hPfLcJfPAcSRHIbUXfAijYF?= =?utf-8?q?byn9H+Bx0SKthj0XPpbrSrrtozb9/aSQzWyTNeWbyfY6NYpv1tRPRtgFcWEAA+ZC8?= =?utf-8?q?J1OLJnMJIaZ6HhpIW0fAnhFPemVvmunF2vVvgLo3bgDfHo0ofwC+iZWFwjUMK4AT8?= =?utf-8?q?8+qGWvrn6n4oeD5B6RysCYREKCR++PoJtry4xCQzbH3AmpncLaI2n3OsHDeJ1xMbF?= =?utf-8?q?GmcWPXqu0lhwX12evH0N2w5Zjs25oWyOSerkY/5z/iqgs8Pi3JP5La8/3nBvg5WuZ?= =?utf-8?q?NqVNyjRLPaCePsmVGw6guzIGEvQHyNCTkglyN9aLTj/HIb/91bk09bRPYfOOeHLf5?= =?utf-8?q?UKjOvSbYVBUCtHik4BJFg/AlbtDHsEaXp5K8qVi9awI+dHVhWBTOFe8xVbZBgS4sX?= =?utf-8?q?nAqGnAnTKC/JH3h5J6n78KoaGx/bEDPeRKCVuYCifj6r5m8/9pFCwfKAY2HmD+hh5?= =?utf-8?q?4rgiQtCKzmD/uDDcV4oMp9V/M2FmF/TEDC+BlxBjzutKJKdwIeBcj7aHP+1TbbXqn?= =?utf-8?q?ZUaDbEzozmwsGRTjWzvr4rXgtQgA6YGR1BcNOlc+bgKLmsvXQ4auT/1em5526c5Be?= =?utf-8?q?hoWRDM+HkRJWpbQgdDKFum2GTYI/QIdfexg2iAvbU9AB9NSqtGyIErS7Fr8RG71JB?= =?utf-8?q?EqYQGB5+sWOGXkw3hpA9UYicDKBRkrVkw=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ae9fc89-1f2f-47bd-68f8-08dc0c23e62f 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:10.6329 (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: /VDTsV0tbeHMk+3yml99Jgx02/RSDXVbZlUPgA8cCcIuFbsgt1mbBrmeVtyC1TT52xugtBCRoA4+ra5MMEja/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049063822568858 X-GMAIL-MSGID: 1787049063822568858 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") Reviewed-by: Ilpo Järvinen 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 d155131f221d..1204102d7162 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3642,6 +3642,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 Wed Jan 3 06:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 184632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856149dyb; Tue, 2 Jan 2024 22:20:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH9qPAveTPRYUpd9RYel9wLEWQlQucd2vwNB0VX9gtNvTC3Md8ifg1YepYKQgEHh1npaCH X-Received: by 2002:a05:6808:1388:b0:3bc:229a:e8c6 with SMTP id c8-20020a056808138800b003bc229ae8c6mr970657oiw.116.1704262818298; Tue, 02 Jan 2024 22:20:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262818; cv=pass; d=google.com; s=arc-20160816; b=GSd9wljnYXrkdwkLJJIefBpytT5AFpuR+AsQfGSX8Dd2ZR/Pj/pqouDmVIGm2RGTHQ 9ij/yqYWkRqt9NJp7TR9tirmgzlZyATtUdhPg6ve/T/QWYBH+sHzHfiLjgZ7bVmU1yy8 s0/JW7moj1o7VfSc3i2KT2VYEpwMyLgnaQ1IIBYCmwcs/pKEjG4HBal/3L/29+iRGS10 6fs7JOveTc+eHfWSaJD8JuwkIos1LC/2XCM1350l0U62ZfHdkahHt39cL8jx98P6EP4C 2cuEsShScFtNHI0WyDNHNc4gdDLn6GU+ZLC1eYpTWi8uOdG0/hatkLw7cLDaL/dx8z9a 3qAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=zrTCdaXp4RpigukbEw/E4R9h20jHnCpK5qa1aIze2JA=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=Qt+W24RFsChHGfniGCDzHYl1YU+EsikqdSL0jg/YEKYjn3VMt7AH9yBBtjrTwMmZKE FT4dsol7H6jiblowuyYDmfu8yUSe4iYd4fABGrYkL14KSPVbpbWLaxQqObyldQLAtYBx lUGfI+GGfmW654BVsxfdMKqmCPLAb5nOkHkUpqf6WynvdXN9kTJfAHPzL383VnUH8GXK oBXfCslhcZPXWZ4x3Lcm2fQRY5DP9FetbcQTCaCAQT3iyY1H4jj4A7Ho9SkSDZm7ggf2 QgExfiJ7vmwA498xSREHFij41qTRRT1DarqOLUdoVZfu90t8bYhktu9OexEI9ghs2UBX kcEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=L8zvlucy; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15206-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15206-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c24-20020a0ca9d8000000b0067efd85e8ecsi28911721qvb.382.2024.01.02.22.20.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:20:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15206-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=L8zvlucy; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15206-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15206-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0BCED1C22F0B for ; Wed, 3 Jan 2024 06:20:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 444D118644; Wed, 3 Jan 2024 06:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="L8zvlucy" X-Original-To: linux-kernel@vger.kernel.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2045.outbound.protection.outlook.com [40.107.13.45]) (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 0A7F1179B8; Wed, 3 Jan 2024 06:19:17 +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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M6RJPARFzI/7wHNpOsGcAMzNtpZendogO3Qc8C1h5F2Z6kicfPmrLnmTl/d3xuwpF4b7V1/4rPX63HYyOXffhcO4OMKXZn3x5VVYTXagOTEgS3PqAhelhWP2lUmoTN3Pvr9ioawDSJZ5DS19yo+qTtSYLlY6/SLY9pgCwS5q9iiydo5DHrrAvI1n9Di7ZGwW6Mfrl4aWLEyvPA7aMbpDWBFZnFy0Cu/Mtr08GChVgDuvAINPkWsbYzdJogcnsTL2B9cFr0hAX/7AmvrgznugZnxtP+R/yiS6OYSkVV4jmKrWlnSf+3hA28qfTqCoGgng1/Zjga30FSULKlhwU4zCiw== 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=zrTCdaXp4RpigukbEw/E4R9h20jHnCpK5qa1aIze2JA=; b=gp4Kt72cvdZbU5o6dciSGsAwQAH+PEoQAQMD4ZuCyG54p3Pm0yP4BH/yYdNjAK2GaTx4qH+6fsK3r49w7IvID4HlTPgR0QL4rgmXuD4iVb/0bgsZxO2iGq53qYMSZUquz9l5hu7D4/KyNfhUyLbueMFgzm2dLn+pEdLKOvi6/tAeYi86SOO9XgBqhqDFlCZ0JRgl8s9mPhZXeTaL5yBsK4hBfv33uUiAQSEXA/YiDkcVmt3oDkTbaUUqgQy6e+DkR6NQZOgCgLUpaw8gwWXbm7Ph2GudXlu4IG1jWy9olS1IfCPwNNwgYX9exfDjyGI8RS2o7yKfzHJvnJ5VgdROuA== 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=zrTCdaXp4RpigukbEw/E4R9h20jHnCpK5qa1aIze2JA=; b=L8zvlucyZ66BpXgAfYsx35nRkZt19wMp826M51pUnsOtOcsuYmci2E/FpUvsJrOFEZd7yUgyMDXmqC6zMykDI9s2+9Um83b6DaRDpyqdWcSLdZAmN928+I477kR0ZBnqCc+sruNwLnaiyPPZabZszYf+0MCglgvXqJcY+5h5e8c= 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:11 +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:11 +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 3/7] serial: core: fix sanitizing check for RTS settings Date: Wed, 3 Jan 2024 07:18:14 +0100 Message-ID: <20240103061818.564-4-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-kernel@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: de4ec4de-fb17-4a40-efa4-08dc0c23e695 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GRQNwK2l+hoH/xiv122yDy31H4LSMjhdq3n7O73w8Ilvr6duClDRZNTxzpVv/CRMs84dli8hVMS+DnQ1kmA4Sg+pd+5rUUSwc1BPNMglqnn2P6iS3l1V261RRi7us//B0KW/e6ohStvpsMTV4wBgUh1B+k5p0jfye2v8setIwaSQNpvNWil+B5hURYcq7LTe2zRMiwNdCjA0fy6ShPDRnvYthk+HLe1B/sDso87KJnV5GD4eO7CdeD7AJARIRSuhlq7j6LcmST/fFRAKlfD/LEHc8yS6nrlrq6xaA6bMjVuZJ8903MuhOm6NuXCOrV69GNSKMNDEFVfjGzjhHcOwwxsec7QOXuKX8zq0r3n9yzQDdZ16u8H+qBw04FQWpxmL5/otBVX8W5BY5VfB0kb4RPjqGyIeSiMWDBAzqsO64MBQkg0P+Efg78tbCpnV4Wn+/QXXF8EczARsMJDd0MozrukEIuNvPb8P9MZMeNzmBPFUJItLq/IQXB7Kz0/iGr3ycjyCeQ8/KVWfyfN3kCTqDRQlsS7360Hu5auAdgbkXdinvanIHg+svUMMG5ihh21N 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)(66574015)(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?c1E0xvjC4DcORSFbNLo1tPi/1o57?= =?utf-8?q?RiJT8TStJ1Ef1eZ8R7t1nw6wTHRNO/qvz4gm2RPedwcWrXq80HExPZ/vZEMQKjQMF?= =?utf-8?q?KpDCOR07dK2axpfYRLrbdME6iPM0Awi0hMhG6M2+sYg7X5lkDTKy4mLNbkQzYhP8Z?= =?utf-8?q?ud40QkJXcBTZ0KFRUDIY9sfHEqibb2HPAE4FofIM0FZ3asl9z2BTMAf3A/5qhpD9H?= =?utf-8?q?mu+RQvkuGZRpjruHwXIzgV/pr0bCCCdUYEmAYAR0aV4cEWByMS35cn78/odi24job?= =?utf-8?q?1xX4gURHIGgA304qPrkjTInzEu6dbSH4vCYTFjdbeuAW8DgvC0S/S+E7eE4/7Zn27?= =?utf-8?q?cfv0VUTbj5WmTyBUHzXyHsK/oePaPeLEXrpDy9MdqDrAPeRUdtfiKQBeir4NeNqbH?= =?utf-8?q?vJV+/oEIVWUsaQnFglyLCQ+/wAKPjwDFxmZsngDsNYkwjXquqsWafjIWXy3iyhUgn?= =?utf-8?q?89S4Q84Ii3WyGqiATObnIzuIJIoeNqKQ+BAN/ogIYuWFUNxdxSt0jGwvzs2T3gLBh?= =?utf-8?q?aa0ST3U+6r3YAOYuQxvaC6zADUc67oTqCFTT2bMjOUTJ68aGFGAPNdmpiO1uMXCFp?= =?utf-8?q?w8lu/R6Te7jns142+V1AQg1cYhVItIlaydxfHWb3TjtjbaHG7bZQTo5ChQf7MSUp+?= =?utf-8?q?R782jCBzlzZzCZ60YOu8y94uX9erIpVv+l7v7hLDJDPTRsoOYkEtb8qYNeIgixJws?= =?utf-8?q?KHBX2zRwfxLqulNbVQVXb0yc1MLqNPcXgKIDxQJUAf7WTRyVZIG0CmpLZTseDNGlG?= =?utf-8?q?3miT2xRwhngTUlBGM8wS3CRObCsU74ZG23gHXmotErRs/0r5wJNUucByF8ZHMQbji?= =?utf-8?q?+P8HyiBsGpDKibzA2hwJ+GokR0wjNBGwBkSjf9ckgcoF5e0KcDcpQVyzWoHkn7KC3?= =?utf-8?q?pPDOK1bAGuoXu4/I1qsjXDHjcRsF/kFpMGNyyYpqQp1rOEd3e3/xsunBvHWaFSAih?= =?utf-8?q?yf1Va6KsP3HAm0HhQ1djw0NOJp/KhpBuC+KTboLfliGd/filAkjsxXuIX92MwuGw9?= =?utf-8?q?p392GttIKL1ZjVgDg0kga9+u+1MRDnt1ycQcQ0hic0IBwBujPAOmXP+MIDCzisyOV?= =?utf-8?q?WdG0jsvV2kJreMxGkHEmVETKI+0EltQfg6yPKFOohw+JSBBBqpMRsHz2SLuJpG5Ng?= =?utf-8?q?bQ2N6nne8pmOzWvojhWJEWpujXwefkOmEGg66AThNRXQgJbKJKIK57OXM/+wQZ+Cq?= =?utf-8?q?EA9f1Hhmogh1cQxA2bKc54KwHNUdbblcRlevOD85Wl9O5XeH8xfQ3VIrhUYrTxovf?= =?utf-8?q?at0GJyqB3aElhuUwnUeJb4oWg2mgMyKeTvKdA4WVQM1MucvJR7q3KZKEzTHUkiPV2?= =?utf-8?q?XGk6S0n6PP9Mx6i8D5M7mcqmAxp2B4AlNPGrXdnzrjmr7DzCZ7Asy7bwI9teQApj/?= =?utf-8?q?qBJygIIqHrc7LXpyrRNj1DP7zcA1peAr/Q9LpOCwmw0byE4vrNgUCl9fGhXbTe0Nm?= =?utf-8?q?+a5uRpP8FhEK+ods4QPrdcvZogSXE4yE9S1KdO7rFtyP9+g63VV09ODGXVMmzzHwO?= =?utf-8?q?fR7oy6kLZY/KrO+ryF344rCzy9XrSAZ7cVwW+J5v2y3KMeynCB3XWQsGPhXXf6HP/?= =?utf-8?q?lrAxDpnxtDimb4vBkafs1GyWDHkvv5o9Q=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: de4ec4de-fb17-4a40-efa4-08dc0c23e695 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:11.3419 (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: AFCljxlJHEUCbJAY90YvxGRsYjpe4+x9sw80Xf70nX5Bi1Gc0/18nalKYrsdK12V/EXeNnlAcSWn12Z6Eq7Hjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049088898991275 X-GMAIL-MSGID: 1787049088898991275 Among other things uart_sanitize_serial_rs485() tests the sanity of the RTS settings in a RS485 configuration that has been passed by userspace. If RTS-on-send and RTS-after-send are both set or unset the configuration is adjusted and RTS-after-send is disabled and RTS-on-send enabled. This however makes only sense if both RTS modes are actually supported by the driver. With commit be2e2cb1d281 ("serial: Sanitize rs485_struct") the code does take the driver support into account but only checks if one of both RTS modes are supported. This may lead to the errorneous result of RTS-on-send being set even if only RTS-after-send is supported. Fix this by changing the implemented logic: First clear all unsupported flags in the RS485 configuration, then adjust an invalid RTS setting by taking into account which RTS mode is supported. Cc: stable@vger.kernel.org Fixes: be2e2cb1d281 ("serial: Sanitize rs485_struct") Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 1204102d7162..f67fb6a04983 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1371,19 +1371,27 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 return; } + rs485->flags &= supported_flags; + /* 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) == + if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { - dev_warn_ratelimited(port->dev, - "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", - port->name, port->line); - rs485->flags |= SER_RS485_RTS_ON_SEND; - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - supported_flags |= SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND; - } + if (supported_flags & SER_RS485_RTS_ON_SEND) { + rs485->flags |= SER_RS485_RTS_ON_SEND; + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - rs485->flags &= supported_flags; + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", + port->name, port->line); + } else { + rs485->flags |= SER_RS485_RTS_AFTER_SEND; + rs485->flags &= ~SER_RS485_RTS_ON_SEND; + + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_AFTER_SEND instead\n", + port->name, port->line); + } + } uart_sanitize_serial_rs485_delays(port, rs485); From patchwork Wed Jan 3 06:18:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 184634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856295dyb; Tue, 2 Jan 2024 22:20:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKPji3iYPMfR3dmGcCZ/T+fJYs7WUyWSulAGjp2hcq5rSjN2MQdOJnXCxSoUt6awcVKCGq X-Received: by 2002:a17:906:2e81:b0:a28:4a2e:50cb with SMTP id o1-20020a1709062e8100b00a284a2e50cbmr999414eji.64.1704262852971; Tue, 02 Jan 2024 22:20:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262852; cv=pass; d=google.com; s=arc-20160816; b=oKCaYdZUHzHBAt/nmHxI6HUo0+TXS8RJoV65oo2LsGjt8+GJ35dNrUtrqkpMegps7X FdNsVJysCUf7UDKncFGLnwZhZr/xo946VdPboYi+e9v+VFScCZzVQOhlwq1atZF1/JoA azXug+w7bYgsrXEqqXyMnQ+OTg7woQzb7ETbW7xYxHLngUSO/seqZOE8G8448Amwtmqx 1fUxvLlFdyTzFkO5iKjihOu8unNaqir8YjjJZfa92FyTNIBlgiNV0C1VIlHjBvvx7n6a 2AZL2IoNebQXZO4SfaTfXNw2H1RXRFarLFXFuBkNThkyLJx3Aab2mgcWtWU6LPua+3bs Ualw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=cTLoxQU1AyB6doWPWoB/79IwiIX6Y/zhIfsMchbKxJfm4aXHDMAblmGb1YFNlMkHQZ ivm8RbxKU8j7aY5Os2e/LCSI71kM/TwHpE/XVpT+PLk3a2O+RRr7u38Dx7NQl1ZBwxj8 3jSKxgxYXUOUIpf1EjalbjpypGMc1aD9gHxsWN1e9kxpZXwJOHXT2SEONSNkazlHzPcM 17Xg+lCq92mgItH6q0jga+oehv1dQyDF131RZgzQAPk1BqyCINhUUdEgRrB34etrnDQZ P3bn5fknSWqfT7v5556hq6kViO/InacuNmMPbVM2+EEO9ZnwYSTJCAT2A/KVko/9xaZg Kzfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=Ca8VPXCR; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15208-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15208-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m26-20020a1709062ada00b00a26e2746bffsi8675869eje.450.2024.01.02.22.20.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:20:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15208-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=Ca8VPXCR; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15208-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15208-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 554C51F23BB3 for ; Wed, 3 Jan 2024 06:20:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2445C18B16; Wed, 3 Jan 2024 06:19:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="Ca8VPXCR" X-Original-To: linux-kernel@vger.kernel.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2045.outbound.protection.outlook.com [40.107.13.45]) (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 E1E621805F; Wed, 3 Jan 2024 06:19:19 +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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReUKFJOc8pdC2BrwrsbPflFcKyFRh+Wpq9fX+/ax8XoQp4M19foKlMaLvVj3n5RK0hhHwqcTf8HaOZOU3JXn8u6evNZ3iLptd5a+Kx/uO8PX8mYtexTImJvp45hMUEatioCSRutSoLQFPoxV0m3XO+pwVkhVksTms63p+GNWsSSNX29RvB9s3Mljbe6b9v2Pi1IBP4wUIUfORCFB7xF82oKRCGXzreg/pLyI0/EriEnE2Jad9D/S0RWJVh+I+GSrZcHxG027vqJ7H4IKGjS9TGx3U7q1lupYOZgD53FjNYjsweofX0Qui4lzMSYVF0ckM3gKxkPsp0+vbC+jBCrj9Q== 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=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; b=ZEP9dpNrckSUD6EFp3FDT/kpbI3oNke4Z3RkGGGuX/yMWxE2PU60CXw4EXTiHl0q/ATuGmubK8mRmw0qK8726kzzvfhrDTuYwWeeyqVNzSMFBFQzTXP9N2O9iPN3+oaRD1aZmwSRQAetZUnERAmP3seccfKam04zHrtG28yEbEvPAbqLKPzhajBgBMY7pcDNyi8E40PWt7UwGj+F1TSwPPh7JRhQU2eS9Pz9jrthGloiRNSGXQhHbl3AQ5ir9LfJQHGfqPRvluJEIkgeQlLSFMvEbrffN9x5u2d3F9MfzbB7j6l4FPLAwa0BYswpetNgZvdNqWiefxT2wyKpM2XgEA== 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=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; b=Ca8VPXCRa7PQmXsd2VayhtfZGWVYNjyQY1gklE8qQcjjiCKPXlYxs4uRgX5b/u5aOgKgTmE6upoHtrX+EKNCLTMvX86kptqTex9CdT0en7G4MZhEnQPvsYongas6nPXYq8/pdc2veqILdjh5fr47u+wOmoGWXw4sftkKGSnfbPg= 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 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Wed, 3 Jan 2024 07:18:15 +0100 Message-ID: <20240103061818.564-5-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-kernel@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: cf558815-7adb-4749-d8e8-08dc0c23e6fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GRht9JduYW7VypezqdPVybv0kO+0Mh2jH+U7904wTxlNudmDOeZJeyjTIpyDXGYUnfH76zPm/63sm6yET6phHquD9u6XGu8oHal6A9ELQuDtpRm3Fzvxaayg5YHL+NuJM9BnS271Ram+ly5LbKZtk6GNAS/NaQBwIeeSQuX8FvBFiD5+m1oE/NxQvl8BlI/lbH9Obhf66jUu3Rq1lDo8FxvQBEVNVs2ALRWR37IJZ+2yNH7TJ5+PNoYmtA6IDGsjKAE8t2Qh51RdkiomrFowUYPNKZlugSxJHlrdfzNle0ALdmJrBLG7ef4pFpNe2z0GjJZLGEAsl1vnYj/SstHr90wJ7zgOhLXC+QkQEje4Ur0v4ctvxcyyJ3jGDAwxttW0yqBJtCRV+ANyAE6og3zxmjyt4hcZNTHTOtcI90vAjXM81wk5pkYYJdb1Fbf/iVK1N1GkaSJasBoLNLu1UwZNJwfFbkkY13mxLPlQOSTnwxbZyerFTR9V8QX/Tsoxz0PLgDqH1CiN91JqxwpEwjC7LUxy0FVXHBNRlG+9n8BWcZJXcj2EtkFTGYqIjAhNJ7s0 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)(66574015)(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?ysTk6BMr15EzD/uwVWMd99HeUWV5?= =?utf-8?q?aiIs6Mt2YcJfm3U6gFFBQ0lwEPiTzzVyqeJHrHcUwrNxfSL1sHzjg+RlERqpUx/bq?= =?utf-8?q?UWoGNnveOCUj6K/y/xSePvnHf4VL+P2Fi8eOqbN0u3a+A3ay17tsMV5G4hzvjJXVi?= =?utf-8?q?K0jUnzDay+A7V1tW5ncg3779uC01lMzv0aBvM7K4BxkbziE6CUIhd/FSTGsA7iwcT?= =?utf-8?q?vAier8ppkRaFtmpkIfXqxipYAg7jsRN9SkRNHkNWJhIG8Po5jyiHIrY4lK0OBkaX4?= =?utf-8?q?tAyr8jBOuCyLg/nUahY2351xAgyduxdtxasFije8/RF0cXfu9EcM6vn78ki9GqWPF?= =?utf-8?q?0g5vPDqNJM0aE6Xc6wwftLW6cL0e8/Ipw1COQyhjG0OVeujzZ5P8Xni6DfYtPmy64?= =?utf-8?q?jMXvUgKxUdQuJEiV2AHGF/JfChzmmtFGHWzS3+wNDWX/YTYG0AINNZmqpFQYpj0tf?= =?utf-8?q?DDGPzqGZ/iqAMK70t+yK4kHhMumKLQxGE74/JSORrqQyCIi4d5AbUHpmzlnDacRnt?= =?utf-8?q?UqGxFJgYTiS61HOCuqHpRprlUOz9AvRcdNkKIDrrkIAziBoLf0vvIhtDyIRYJJ6ee?= =?utf-8?q?s/dO1D4qWqFU4URMQVnU1N4EjdFuM0GZjwJ+ykmxMdN07Es+NxBhFscGsKSPEfKeG?= =?utf-8?q?mvgcQUNEf3/o0icTuKMNbYNeQrrQrD0ua9SRoP1g6uUxKbnPNellJ49fBopxUI4z1?= =?utf-8?q?tG3Rn3XDnAaOmw4xEgDcBwzjaL7FOkZ4uSeGVda5GQV2MOA9iJ+03eLMduVdwGrtZ?= =?utf-8?q?DDCIE1M4W3EvLe3ofql20a26QG115IUcg23yb7Q66PCAkIkjX1o/q6Fc5opgn8hQd?= =?utf-8?q?zss+im1WbvJJHauG0TvbG5JxfB4eRY9PSslDRf9cZ47BcYRuE8Da5CemDthNrktIH?= =?utf-8?q?UlWrAjj6XTHrqfTvHOCax+X29zvfJW7oYZf7+tO2tVouz1zJjCOMqS1O9A7KkVY34?= =?utf-8?q?VJhpm//lhGMzOFd0uGqjBHaE4a4Ux62FIB32bk/eno2vVFJfoS888mQWiQRhQ09/J?= =?utf-8?q?GzwdnJJPqITEdNPqk4b8qI+aXfnK6bOY/P/95g630dlTLsxpVyCSDttwTaF5epIwj?= =?utf-8?q?e3A2agj3Xy9UtteZqzSG2C+sAeRNRPIlop9EEWaASujBYrDLey+VQoXskoOmZ7eo5?= =?utf-8?q?Gc5D2w+5jzBwe+XY+Nng0S+JzTCvzUq5BX7SZFb/svUeYtQJJRGQZZv2TTb3pl+yq?= =?utf-8?q?4Ig/FOhFDR6+xX5QQyVXhYpM0YWFWbOe4f9foucP09OdzLizB9ZCm7Cvxt+49gb+/?= =?utf-8?q?swmeiDHlOU+DRf+tRaXOZGFDZt6a6ngq1ilS+w3Ygmp255eH0yRUDG186Og42Z3oJ?= =?utf-8?q?MkESwjcQheD0i488YHAFJ7ccwwdZGP7LdDBiGmB0ajiY83xpFX4sPMGdWe2O+li3v?= =?utf-8?q?qsU9IinUeSpOEr/s0lIEG4nu0tsr7Je8T7SNDoLmri8oBTLGwlsTgWV9O83J0o7K+?= =?utf-8?q?At/9z7oVuPfAC4YUB3pfapLOWXQfZvz8LQplc5UIxbohNEb3LGzKhCx2+wcvFFxMH?= =?utf-8?q?mHkwfC9MI1zx/xPEUtsXbUE59WtAgxtElHZiLQfPd99+VqExwNZiaUU7MshOR/n2D?= =?utf-8?q?8q9TlWeVh86eAu19J6k/mTf5A0SnSKMDA=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf558815-7adb-4749-d8e8-08dc0c23e6fe 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.0145 (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: Y6lpGXtb5wpnRlmfl65T9cl789+8p2JTTJbTkkK1LvitBt5vkjurjW4pkOxa5rC4XDZ2Rvi+izbsMmFZTJsGUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049125318556731 X-GMAIL-MSGID: 1787049125318556731 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 Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f67fb6a04983..28bcbc686c67 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1469,7 +1469,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 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: 184635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856386dyb; Tue, 2 Jan 2024 22:21:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFiBEG1VlFXbSkwBsMi6ukJowIfK807/nUilqE4qHuRjkg/2sLF4gcBrCepxK4NdlxoFpe X-Received: by 2002:a17:90a:b005:b0:28b:de88:d870 with SMTP id x5-20020a17090ab00500b0028bde88d870mr9543937pjq.51.1704262877321; Tue, 02 Jan 2024 22:21:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262877; cv=pass; d=google.com; s=arc-20160816; b=DlNo5tIDRhXOO888/5lCXd7ziEHpu6Uym0FZYug6VZM5RRWiFW5YfXvuJzN4D3Bcwg Gx9N/x30WsVBdolc3uad/uUrmYOmDsC/RXod8GzSBpNnutY/Ia8i94cIql2RQhKKPjEB K5+3GddlpELsAJ9jcgCAinx5szvIwDiCspLTAiLD9+2M/utp6zdt5YSgb1rg6RA6yUq6 E9RDibl7OT12XOTxJpUbZaTDAyl1hVDNLlyIYixi8eBUY+X/HdCgn5yD8+AaDhDwJy+L 5ms3bJWAOHmzXK6zV3GrjLH5XVB68VJ4AmCwEdkRW7SvnL19YyHu+YQdNZl+i1Wg1bnC 0Ehw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=yPnBAB65jmBQDLunpS8k5O/cIgfIkQi5kIiRI2Szkg4=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=ThC3kg4TsT9OEQPsq4IkloG3FNJid04hXeVBP59ewiaBNDGH7QWygaQhNzgQae7TYL ZQDLK5kH+aG7k7aBSzuk+Hu/ywIILTyKgZmWzxqq5kiM4jq+7x2/3ZMfZsN62Hm5IkMn r9tbLgaIvFeGFLcRq8cFdnHVkDKfEvLiH6q475kUGkLMT0JV6r5AJuIa5SkRE1XFDkfp a1jF3XY3WiP27X12oQNCjqbQ+ZMYRVImUYi7Znz/WOVJMx3oksb3hNYFSq1PXukOTML3 pch3ZoapA/n0M4qNL1lLMruVMdhZYJPcR7W4qHxz2R13uI/4hsEXnGSZHBcwp0nC6nj3 C0sg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=DdkWwkVO; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15209-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15209-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mg22-20020a17090b371600b0028bec866b0bsi686218pjb.11.2024.01.02.22.21.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:21:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15209-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=DdkWwkVO; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15209-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15209-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 17EE5284D6F for ; Wed, 3 Jan 2024 06:21:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D972E18E07; Wed, 3 Jan 2024 06:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="DdkWwkVO" X-Original-To: linux-kernel@vger.kernel.org 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 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-kernel@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/ZQbAh9c3+TtNxu0LI2UqVBl22EH62Jk9zEqVuQ?= =?utf-8?q?JeHz7Br4c3SXH7SDOB1aQBqJ8TVqmw1rirnBzhPKLikuErpMKZSMmqjMkLTBAxjXD?= =?utf-8?q?RYTorK330OXmSw5iSBmZ9MHSnr1QCfuMrJiE2ypdSEIMBueLOtgqVRTmMl/8bMuJi?= =?utf-8?q?GpX7++zBvdy8+ne4CxCLMTXa9wAOHtvFxuSfbpUR0FlgQTQWJgWNLkso1ezicp3C6?= =?utf-8?q?C5sMa4Y2AyPEgHyunXfL9ivuu6uGZsV1K2jC/tMz51d/gZnQSUhBr01nhrHUJYVmu?= =?utf-8?q?p/Pi+nMqPsC0RcWkpQqqLKEKL3sOYhJjSru7gs5eRFGMUx6L7bDur7jS9gIw2US+e?= =?utf-8?q?BBUv04U11P/pHu/O+KAx77mKz3WS9tG5eu6nONK+bECUTXP1nZB0aVSHiYBtAhcRM?= =?utf-8?q?Xjx3Oa6mk++u5xkbj8Z7LWFJynNcR9NTBYWZU2hbuFAhQUxFhBixi4hfAhKq44cyt?= =?utf-8?q?dVJaC2J0Ev6qyYPWD4rUlIO4/T0BJpR1cPR9/wSYDkjDIJDh7bgFqfg8OnHGVkgEY?= =?utf-8?q?hPQklwhRV6W98r/g+XA1ASFagy0Zq9Pve/k4IUmhKaBh6Itph7M7+Eqper7oL7xMn?= =?utf-8?q?A6cMrtLpNhRkjiPXJXnIufKPXu8+0+OVlET6eu6P14I3OY5KfVSqzDWPwEjUw9Erx?= =?utf-8?q?wqToY8Gr1EgJFFIa6OrbOsoX6SIUKYupvcC1DpOs5/Qrro1bgAEhVygPuB4hgxzSC?= =?utf-8?q?3LQxKWBfuwKz8kBZ3gKnFfoKpgyN5jyv7X9V1oS55SP0lq8yOc5kW335Lnm9gvUGm?= =?utf-8?q?xrXlj4M/1rJAz3ROgbXXC0ATVepfpb8DJxlijaX+f0MmBShZz0O0lRaOpRCGSnqD9?= =?utf-8?q?gVeeHKvoZVWgop66Jb8H3+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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049150771498261 X-GMAIL-MSGID: 1787049150771498261 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 Reviewed-by: Ilpo Järvinen --- 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) { From patchwork Wed Jan 3 06:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 184636 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856408dyb; Tue, 2 Jan 2024 22:21:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSey9JwQwTmtKK3cvnLwPwpjEKBQO/1Pn4Vv9ZWzQZboPkHUQpf2AnOxj6RK6JNohVd9Qb X-Received: by 2002:a05:6871:2b02:b0:203:9e34:b3f0 with SMTP id dr2-20020a0568712b0200b002039e34b3f0mr22085157oac.0.1704262881112; Tue, 02 Jan 2024 22:21:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262881; cv=pass; d=google.com; s=arc-20160816; b=CX/fyQA8rJQoFpSYEptmmJTgDo/bSA0iEG+aEk+JCIVc88sGGuQMVjdVp/NJ3/fVVw ri/q4o9V4EoeyLuWY9s2Lo1GwRFt7Fhw5ih3ptF0y1i+6IspzY9OoeqHeb8lG3U6sB5H /qxjX14pz7Pb1OBAEQJyF6i6HoQOZQrMryn3X2SFClMqt0OWzkdfAy/Uyzfd2dEZdvob fHZFDaqPx8i060LBQh/KiBfpTh3/fO0xmk3WxdBbcGu/kGqXlVUa63gxbCJnzMEdMfhk fUllwQ4xeaS2Fx6alA3rYozk1I7PXEXyZr117zFJYzvfSbcmrc2QXN+HH2HiX1XyLw32 p9EA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ZVOZN69khZ6LoPJoQx+tVmoQmuWZgx7tuQy8+yaM6uM=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=aP2UIqlwNd4JuF5KmclL5kmhItIvrtI53TWpmpMWAFzJo5odHFBBZl+FuRXCCPrDK5 PKVfnrZamD1ABAH3iPKLP1qmHXAK2D8BtWWp3f4H/V16T25gClMaUPPpnHojSseqSttL 79G6MeKw3ugpL+cTOCmavvNlAwuPjR5UZllM1ObbU2wZ8RuYyPYwU6LRv4jITTLKdT/E bfGZ9wy8QcQSlXxbAHgohA7DmogVoGPb4955EX+KW3QyIqm4tAx5I8BHNqFJkv38oUfr gBfU11l6CI/1Tt4UD07PHDp0epJMyOb8/SO3FwZQCaXa76N0g72mvcY7m0RLix6YwEf6 zNOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=bdUyPiDT; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15210-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15210-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id cb8-20020a056a02070800b005cd9835b1ccsi17074905pgb.820.2024.01.02.22.21.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:21:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15210-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=bdUyPiDT; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15210-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15210-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D3179284D70 for ; Wed, 3 Jan 2024 06:21:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 238DE18E12; Wed, 3 Jan 2024 06:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="bdUyPiDT" X-Original-To: linux-kernel@vger.kernel.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2045.outbound.protection.outlook.com [40.107.13.45]) (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 C565118629; 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iz9vcKkxykTiUgdsbDA0ZmjUNKdxVALyNByDwGCUo3SPnjV9USRIYRw538+xrO1RNQ4PJQfgt+IzJVvV6Z6IczuJscrKmm2cMC6V+R3SXiY9rMJYrVOQsRbC2lZ/PKgEzluCzqDRgzjb8UApu2PdmQCWqkQI6VyGYor8sQQvrFi6pxCFSyFZZONQB2X7pkITWqzvomwGmMSRi/mc6/GTkUL5I2LtpYTSg3tWHPkrNK0QQ2lufZJ0kljj2iNWxaGdM+yv+kwlfv2WtPkdSoV4KMmeVcrQb34MxrBLch7KrYo5XLM2xh1WFqUH4GuP/GM+QTH5q0+jPvHUnnO+ISnRDA== 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=ZVOZN69khZ6LoPJoQx+tVmoQmuWZgx7tuQy8+yaM6uM=; b=eJ279wtP4t8h119hS3ymUnVlq/CQmnS/pxw4+TCtne0iwPiDoS2pLCBzNxs3uWJUoia+AeTdT+WdKcjSztuejSLpZev9S9k//n6ixMLx9DruHp0WQiQXui9DP/HR+vjkIi4h/1zoMMcFk84PGVpVSih/Jz7/wl3At6KR3N6NKgXnVKYAdFvpuAre7YW7lbCmLj9e4sK0E8fgumMad5YaUAx76idDCGxAWHdaU/uc4fT5EvfOY5adq6wmzA/9iXz9vC7uetbsjHdWThuXgmS2jB3wwxh8nwXq9Skh1RavZwsCAyGbdV1jLO8DtIE5mKgMY5+j5nFCCpXtV+R+OWZ7xQ== 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=ZVOZN69khZ6LoPJoQx+tVmoQmuWZgx7tuQy8+yaM6uM=; b=bdUyPiDTZkdvpipiGBmP9bTa8zFt6f5AfTHXY+Y425RswxHT8KoI1LDh8n3iPOIVsVE6TcrUB5KQPxcnjdAGPWgqHU5BhFkyNJgyBh1PPyRZJYWRVShJa3uDomg3bKJe2bm1I9Gk8xLoKuFvgDz/kSA7BQVfDSFiwNt7/q7y/6c= 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:13 +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:13 +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 6/7] serial: omap: do not override settings for RS485 support Date: Wed, 3 Jan 2024 07:18:17 +0100 Message-ID: <20240103061818.564-7-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-kernel@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: fd13a624-49f3-4740-5a9a-08dc0c23e800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HnQusRXrUpgMw5oKPnZ/1oprMx2kv2LhOU2IWqfvtwvBQaraOXKcbHaFeTSBHA/EI//uzut+IK446QKxjn9/bBfr/+KfA63o71R/xq3DfRy7Q4HTzV6OCua9P7P/VW6Nk2XMNHVqnWKLMDJOMB5i579c06dzWKWF+M7Wic7JRWViAS6MSiKP6ovYCAulv50LkQgGC+InVyxI0c5ibKTCM3BoqoibX/qVNdgLcGLuJDWbgAKpeSBAouZgbyHym1VVFr5F4wiYbVgfx401DusiHnYUqJDTdKPKgg0Tu7VgPXW/wwQ/fECJK/3lsinecDUc597pU4hvmAYJg1D0DYP7NGGONfM0LfcnbZaA7UtpMiuoUwfluopP+pDZ1aj6lNv1OBU9bwNjztxmZRGiOSVhuAgKo1JoRRmXbPJsKPs32TRMG8Wik6zV+3/wTgH/ZyBowvp5QrP4oYHcsioqhBJm6MpW05FPlH4IWRnNkTeMHSIsr3cx+k1XIxn3Tc5pIlEl2eOx67NtEvlosisiloLVf/SZkJN6JnEvMtY25dP0K3hj4iFtRUluSnj5BEPxi/fb 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: hwE/F+ApB8FgPkbN73DhiuQxQ1HTSyN4nDoLoLfUWIukNFkr+WqEJi+ZHgTvPG8KemceT3jRE7dg8Nf+x1Hy5iLO663rAEYxK8bplM/RQCd4ORk2vqMqa8Z2Avs1rwFGhhXWb0gBevn7YwccxPWu5Aap1EgEUZzDdN8icX/KweiNKnw7RzdRREfaXc7wMWWZBDiLz67LBg8IsM+9d8N7uUUO6Ode8tCTrreZVvbE2spdQ6l2YWDC/haAKsNG0tZx3gl0u14emyPB7o+JDsvXWBprUSqsEeo9+6UapDYU6ptk7gdQw1ZLlFU7+6bJPwqE1tXj1H89XvJV3PmMnZ1yRsa/VhSycY2/37DQwWjCqkjo67qPNhB6AfHj9L4/cHvM3Hf8wKk2sDFj3ZWyPKJ0biAMuh+fT1RMSRdmC85k6Bp6UDUOqBcsfan6ct7u3Cbmq8hUTvebLyFS0PyRyI06pA9/Q/0K5rqUgKy0MiHRboE6OCbV1Zp0c3arvZPaeTkAwhrX0bJgkpPyQH+R/saz2xfQvoSIVWzCoy5as+VCaBD+MqctmeX4AXHd28mHsjmweqAIXy7FNU4yBS/zYVfcUFnTaImdfZRD/wc+yLJ5bNLncrNsPZQkfbTFlj6RG0NRvzwhXmV1bvAgVeW1IlAMyBGN9FHUD1+6AVDfNrkKYmNhAfYYqm1DhusPvbPldFAvZMOpIcbYJi2PEFKyVgQWWiSqcAg0LKsDNajx3/6YzDAnxHdjnGpS5DEtXCb2cAVKQL5yJTIWpqU50g5/B7LuSciexKZXg7OoAENrckAgPuvSV1Zw/VDXid1iKZKshe5fc/EIJNl9QDCDRtrqPNnkiXIekpE1tE3s8OF/K6Wl/lepeC0DcqmKSKNGnN7wEbg0R6XtKov0osYl+cuvLGXgt6pOwtiqFjPPGabeGb+jl0g3UouIN0Ei1I03OeZQenqV3RH12H+n9UQ9wgxXqj8Q0cblg3W5qp23rt6xR/ZFlydY5Q4zvORznnyD4XvBaOKIxG7LZTtKnomh96M/u+VAnKCALSeJALxbBvL17kjiqDAPJ9XIWtv4dcfWZGSzVH177gVYGpdYPm2KWzePTO1k5ovuEHdWkiRfEpRBBCrHxCjQMIeKvHiuXHH2t2fht79xHiZW7A7FZ9XairaH7Z7RL2zq9OPKpI9D9BDcVtBnFA0reOAdyoZc6PDTujKuUFfNRypEffW0BtViNGCuwbCc+H2EGaGXZLZAOHv8lxIRUhxL6A6VfmuUJfs/xyD7PDNCG1pVZZTJNX7WbOSq755/7skYw1ZqYrj5+RdvGxvNg/NkXQJ1Uwv9mWI4OCdRV4nqGVbGf9vSWDwO4Bf0bRQ8Wof0xRu1dWv01sX4wg2CUW2qAss7ZZGbGjbcFbUm329kedbZo/KFpyhDtwNU63ga6wBEvQuyqGsbx/0cZ6MHN6dppq8/5jwWMKkR7J1o2l5HdPW15rVwdNKvY3sX4krvq2FjTtt5QppnlKSxVjHqB5NYlhc66goYqf6Ii1O/r1Mev9NepH03HmX+TW/NKTrcBi5N4GPbsA8VI6ExGW3LO5uqj3tpEhlBStqGv0GQ7D7etf4W1RWebh7m3mTjYhKOVfxLqfiWuNQY66tTXqS82/FTsrQ7feKBo4lxuQPFR7yC5/qgMX9PaEfGeIv4ja0a+A== X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd13a624-49f3-4740-5a9a-08dc0c23e800 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:13.7566 (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: zkSHq0AOPn1xEZ5t56r3aQSFzqc5CFup1SoHC3z0ihiwNQbLuAsyfqO25HDOK6tYs2kkI1d59kdA4HOcvZdAGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049154723354875 X-GMAIL-MSGID: 1787049154723354875 The drivers RS485 support is deactivated if there is no RTS GPIO available. This is done by nullifying the ports rs485_supported struct. After that however the settings in serial_omap_rs485_supported are assigned to the same structure unconditionally, which results in an unintended reactivation of RS485 support. Fix this by moving the assignment to the beginning of serial_omap_probe_rs485() and thus before uart_get_rs485_mode() gets called. Also replace the assignment of rs485_config() to have the complete RS485 setup in one function. Fixes: e2752ae3cfc9 ("serial: omap: Disallow RS-485 if rts-gpio is not specified") Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/omap-serial.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ad4c1c5d0a7f..f4c6ff806465 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1483,6 +1483,13 @@ static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) return omap_up_info; } +static const struct serial_rs485 serial_omap_rs485_supported = { + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | + SER_RS485_RX_DURING_TX, + .delay_rts_before_send = 1, + .delay_rts_after_send = 1, +}; + static int serial_omap_probe_rs485(struct uart_omap_port *up, struct device *dev) { @@ -1497,6 +1504,9 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, if (!np) return 0; + up->port.rs485_config = serial_omap_config_rs485; + up->port.rs485_supported = serial_omap_rs485_supported; + ret = uart_get_rs485_mode(&up->port); if (ret) return ret; @@ -1531,13 +1541,6 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, return 0; } -static const struct serial_rs485 serial_omap_rs485_supported = { - .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | - SER_RS485_RX_DURING_TX, - .delay_rts_before_send = 1, - .delay_rts_after_send = 1, -}; - static int serial_omap_probe(struct platform_device *pdev) { struct omap_uart_port_info *omap_up_info = dev_get_platdata(&pdev->dev); @@ -1604,17 +1607,11 @@ 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; up->port.flags = omap_up_info->flags; up->port.uartclk = omap_up_info->uartclk; - up->port.rs485_config = serial_omap_config_rs485; - up->port.rs485_supported = serial_omap_rs485_supported; if (!up->port.uartclk) { up->port.uartclk = DEFAULT_CLK_SPEED; dev_warn(&pdev->dev, @@ -1622,6 +1619,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); From patchwork Wed Jan 3 06:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 184637 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4856470dyb; Tue, 2 Jan 2024 22:21:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFh/jmpxMFA2FkJ+GcfNcrIv79vU/aCN7DTFUKks0NhusHjPaC9DUNhKo7Ka7DityGNQshD X-Received: by 2002:a05:6830:1a:b0:6dc:685:5093 with SMTP id c26-20020a056830001a00b006dc06855093mr7109135otp.1.1704262892914; Tue, 02 Jan 2024 22:21:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704262892; cv=pass; d=google.com; s=arc-20160816; b=R+KpHhkgFssbTZKA2kEoKjMntQqeq1i/0MfhiVP1glX2LjduqKWebv4ak4VgVa+jkY e/3KiZJISLeEXWqHZUqTcSIVLRXsK2Kq0kOgyBMbUqMm3leFqyg07rUNb+7nx7fDRUeZ PWPEHJcEonZm3HBgDhPr4945xkkytlXKzOXimzxDv6mf3pIg3nLV8m3XPN4exVTNVzEb RuU+5uxWmrxWaFdrlSAVtSd7leBU73GnPlhyUTBqp9xTQN9HzlxY26v/f0kVopr6j2Ti 29+TigW6yjrngEFRmXxHkHVrak92Qj7LSgv7+wlOp/gLcGokQ2NeuDV/8xua88b7RbEQ l1PQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6BcGoe+ESDzoCivkDyl+SvQ6vxiyAUtVpHN4Fyf7TKI=; fh=MN/bkHGu84ooMMTgCiXP1oFxiryoF+JDoK0S8hA26Mo=; b=EfOVMjJUUjYxA3il5L0y9FRQ8mf/E5QTCMWD+OjGpFmgKzquUTGWuy8Ai3T+yn75C1 DDRF73P/S2Ya1TCrxfoZ2YoriH5Wa33NTlABX9cHUHdV1RsaR3RBTisOyCvqmp1c1wk8 imxL6LEDAonsgoGwhmFXKWHX6ULndIuI7oZ+KepdS63KIh8pbgICp5sRQ/fEcf9SJ9U8 Avznolzw38Z4LCfund33yWJ2XkT5nY360zdRwDkL0//QIAI6WGXJBY0AkT4sK1zX4iUp u8hG80WQMX2e9YzaaTywHuwmOe/LDEXq1LpvEfYIWFLzOUMi4BRA9uOO46NUAIrCuQyy EJOA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=hlRPHxUT; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15211-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15211-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bs123-20020a632881000000b005c682e0ced3si21489778pgb.97.2024.01.02.22.21.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 22:21:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15211-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=hlRPHxUT; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-15211-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15211-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 98F9D284F26 for ; Wed, 3 Jan 2024 06:21:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B219218E2E; Wed, 3 Jan 2024 06:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="hlRPHxUT" X-Original-To: linux-kernel@vger.kernel.org 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 9433F18AEF; Wed, 3 Jan 2024 06:19:23 +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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/BoAtEo4+jettHSX3QXWeO2bVAO1urqJw+CpulYdsDwZedK5ybV+SM0QvqeHYSsosyo8rgkxMP4kgOYYfBiUkJ4b/abILDGPeZjDL9rOFZdSa1g4H9OHtBne0UrQ+QNVeMQ9eKguJRz9pvYZqeWfpMck5bKcwIyNGKESYBTnSFtrpVa5Ka7c0/svjrbjdbNGW7Flna7tFyIEdphREmJ+5Gkmzrep/5uMXn48xoGNXuLJrDm0iW2vWEsT1vYRpaga0S6ak8Bptw1s9tCLk6CzuVbaXne07nlNMC+7f9rsyDbtvyS8n5kt3L6Ikxb68YH2MYN6MZ/reHTuvqnEs8vEg== 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=6BcGoe+ESDzoCivkDyl+SvQ6vxiyAUtVpHN4Fyf7TKI=; b=Q11JJE0u/SbCoilMzsMC279WfaNtlEqNoVFNNpeyLJ/8ldhz0Sfq2PEdt1l42cdCCEHIIlKFtt6fTaK29ocIn6yi+5WBNiswZQqH0EAQE6vLh7f2wez/mf4JFtxt8Oblf2JZ3ph/UvC6SJfQBQZlGpGhwDeLkCzXnUkQ3gFhbLEjtnrfQmNMwIEH0sO4i9v3K1Bx4erAzi4oZabjkvNQAjYgzy2q896lmP/85QUhGv05pr2NxYlyhwNtIhJZVqaYt4VDpm8WYwieErT9c0U2T57BgYm5EAxZRslQAl4Ny/2Nj6/ZR+/ZjxnDlutXIlJLS6OTezRsos8cmpHMz7D5/g== 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=6BcGoe+ESDzoCivkDyl+SvQ6vxiyAUtVpHN4Fyf7TKI=; b=hlRPHxUTZXM1jLsUtxbGH6StlAXqbRYeDqgOmCTCGw6Kvy3BSB/KAuOiGyFvNjSA1tFRAoJzJu43Z/OozJ/5VCqF/8qCe87kJVAYcXwpK6fflQsw1dPPHHFI+WREp02C1XKxnF87Mv81F9C4VPa8u9vCdxGAPvZQWMzyR2KnuUA= 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:14 +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:14 +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 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Wed, 3 Jan 2024 07:18:18 +0100 Message-ID: <20240103061818.564-8-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-kernel@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: 5442ca88-43cd-41ab-1b81-08dc0c23e881 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i0i10wbcsseClDcPxXTkxp/eOzY6dlwiOAs0k+BQIj8AUmIg2obd0kyrGUMwwjsG31dn5ymS7u68aaoRjGIVb0+MRI9Nk7cbdyLf3wDbxVCxj90w9tmj4GPGToPeYvLFqsYtU6XRw31oC2ShLehceFSe0f3XZiN7t4ywP2qJYVx7u7ubvmVWpDsHpQ90t3AjNPrUDelzColVcHhB6LPKmEdviHa05n+UdKKybHOHW8gZ4JEXoq+JyQXa8Ucba1tTRaxLUKp+0sZfIIhelh2B2790beSH7x5r7Xud7LuaqQefcG+JJp+7UmQ5z5naFBrMQ1VHtNjZFSB2SD3MZU9p9Z+EwVUTMUqlbxiLb2I6Nzx9dG5Y3FALs1tq7hrc04h73uRjQ5ymzg81oLogmX9sJmmTmHjahIzhhygC2QTDOQIZoawdsFi+YPSzHuLNZwY+cxKKXqCTS0jj+eEldBYQNE2tm8IFp77EkfKz3ZKAehUM/ePoUduO2GjAcAaK7kvFfzV2GU78Boy8j1zJL2vieDnaEdLylpY9VXYV3zHh7UzRVo8VAFGmwxZi0ZDWLFd9H6efcW7ZLQOsExQd9hhvB0x4i0eiIg8n6LFw94BHlBC+d8zQveLHctLgqEScwtnx 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)(230173577357003)(230273577357003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(66556008)(66946007)(66476007)(4326008)(478600001)(316002)(8936002)(8676002)(6486002)(83380400001)(6512007)(6506007)(52116002)(1076003)(2616005)(66574015)(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?qEBvHWspHtLO2/+rbBN2hO3z+N16?= =?utf-8?q?/vWZJsBwhN1fP1kt5NGschUYMTRslnlXZWypgHkVtAMoW3tklXltMSYOexSBV+HNR?= =?utf-8?q?vDQ4TAiRNGn5xCUL3hhd1kZX85uLuRC9O9JM2c2nj/oWgKcenJ3BD54vUQEh9HDLt?= =?utf-8?q?/MOqbE1WAaNg/36tvk2OesfZ4meOnHYo1Ur3V+FF5aRU1rRfrdnhonzbUealioP+y?= =?utf-8?q?vGE53jIzNXUYTSGqeEGYQ0sHmgoW3ZNV/Ck5UIydYlCcviIsglycfWWfcJ+sJQUXz?= =?utf-8?q?xHkis+jXMvjKmcBXfRhiDGXAtACNRPdymgfs8zS8OK+Ex/1vPScXcbuUARG2rXlsd?= =?utf-8?q?I/9pzNvcNudhpW699zSB6JsdaPRytBl5X2aRuPyDPWoaqJC+J3D3idf6o0mN5SYvE?= =?utf-8?q?Uihp94OizMNjxN/z1eWy5q0QMc2zVjTahcSGaJJqKXXbJSV8ce+aQQbe3/Ru1Xnif?= =?utf-8?q?48r1JHDdwtiuUk4oxpg2AWMYiJJUU4yeFGqU6ykOQpyR564OxNvc/gAnNpeGnGJJA?= =?utf-8?q?VrWZrSoSX7nzO60ewJ9uTIu65bT02gHFSx+jFaf/dSNqCvRnkrh19LlTxpyh9ZktO?= =?utf-8?q?QEeJ6ZVzVQSH9K5Pfy074jDwBfwYTN5X81Jo6SJBbeZbxgwXiEWp2Q3ZPMn58Jx2E?= =?utf-8?q?unWBrxekMlHw7HNyHksTcJV5OT8BFg5tem1IH8NTlLC1EW+qAv+FByvdYPj9dUzuc?= =?utf-8?q?9Uzh3W6VjO8/t3ltTMZcb4Se0Z2+/aD2yqG0vvnLXXkUIvkPFR9Pz4/AGxhgcepYk?= =?utf-8?q?2eCvBNwOKI50OwhLu7d3UkYs7y/TdhfApt41p7ZSUzgTtocxs0Z9eZBGYNHQiauNA?= =?utf-8?q?7lcgiMOk0kIm/muo2t7bwBX8iLUxs7l46D1dw5cpzbvLymLuCUfFVzQh6lwfiJssq?= =?utf-8?q?LPSYC33in4UKUC4rCubBwQvaz5YSGcmGpl6HzB9YQkQ3u9eN/8A5jAgLX+syxLLHm?= =?utf-8?q?6lLg2Q9ZDXOCbYCJDKCO1KUopI3ZTujXdnbEbpDuyhMpMiP3cg8xmYauKvqleidj8?= =?utf-8?q?fQ4DAfYbCjIM2h39ozL8As3bvdiHb4/TKgDNeIYFgsix87X9imbXTOZizmq//TSZe?= =?utf-8?q?aQQ2LCl/xM1dYxhKT4OVsrfi2rMBCZYsXA6uTBBTXDtFrY5HKVoC/HlGscs3F8Ecu?= =?utf-8?q?tRVpRjDtIbet/tVb4bR58LhZK/QGL6gkKZEvuf0SF0034xPLrnisGYoVV28FSKOpL?= =?utf-8?q?WfOcEyGZMhWp9VWxV6/PnCxEXafY8VMYqtV87ntGVe8Mi2E7EgSEnU+9C0Ref9RJE?= =?utf-8?q?jo/BlJDK2N9CUJ4UzOPjkSNUFt9n7zish45l2RR+Sd6WQRRbeNJptvrLOquyMdFRC?= =?utf-8?q?1elsoGDpMUKS8fHS+Ic8s9v+Q/omkKqp1WE3pCR5aqxWPYqGWoNnnFIqmJ+m7vIbW?= =?utf-8?q?Qi2XeUrMxjahiMPfw/Gr/75ZL3wlO5Nio1SR2N1XGknd8CzA09/qPddebYh46HWlQ?= =?utf-8?q?sHZRoB0lqY7F2fzR27hkASn15r+Fzr7dD3NX4c+2hKSGxa5hYltKMjleyzk1DUoTt?= =?utf-8?q?5AFE/29NM+VfxFJMgwKBSHeh4ixuP+sVFw+WjjWx9MlFdmWUKPTW3paE7P5krmqkL?= =?utf-8?q?Ly7jR8C8mxuxBkiQ3Bp6jdcrTqGFxHICw=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5442ca88-43cd-41ab-1b81-08dc0c23e881 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:14.5241 (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: ThHwi2955tpYL1VnFuPrqJoY5gVfMa7LI713tMIqHSqQjRm0h1Up4J6qzYhdDE5guumhg+khpNMKXf4g48I5Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787049167094131472 X-GMAIL-MSGID: 1787049167094131472 The UART supports an auto-RTS mode in which the RTS pin is automatically activated during transmission. So mark this mode as being supported even if RTS is not controlled by the driver but the UART. Also the serial core expects now at least one of both modes rts-on-send or rts-after-send to be supported. This is since during sanitization unsupported flags are deleted from a RS485 configuration set by userspace. However if the configuration ends up with both flags unset, the core prints a warning since it considers such a configuration invalid (see uart_sanitize_serial_rs485()). Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/8250/8250_exar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 6085d356ad86..23366f868ae3 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -480,7 +480,7 @@ static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termio } static const struct serial_rs485 generic_rs485_supported = { - .flags = SER_RS485_ENABLED, + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND, }; static const struct exar8250_platform exar8250_default_platform = { @@ -524,7 +524,8 @@ static int iot2040_rs485_config(struct uart_port *port, struct ktermios *termios } static const struct serial_rs485 iot2040_rs485_supported = { - .flags = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | + SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, }; static const struct property_entry iot2040_gpio_properties[] = {