From patchwork Wed Oct 11 18:15:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 151520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp729012vqb; Wed, 11 Oct 2023 11:17:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx+ld3YM/kCwUbimnVfYh7NZZkmfAxIH3NVMfy4wCahe2dMX/s8lzUICYgJN1sEOgIiIdC X-Received: by 2002:a17:902:f24b:b0:1c9:af6a:6d12 with SMTP id j11-20020a170902f24b00b001c9af6a6d12mr6381307plc.5.1697048247490; Wed, 11 Oct 2023 11:17:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697048247; cv=pass; d=google.com; s=arc-20160816; b=HxZuURJguK42B9ecXYPA+woagTjjCwYjqwYrr/8xOIzXmdKD1GhbkNMFWbsUuJG1xt FOM/bSllr+9qxhhzFTRBRhaR4X9kLtlEQzC+7g66WMb3xdy+GFVVHmq4JxeAPC8AijwS VMLvb5yd2GwyJ8/Fla1+NIXMimPL2ZgdFpsDNEgwhqSFt0etddapODDPGrkIh7AK0sWc 5Vpt8gC6nJMpQk6H3Uy0FdqSDiCsmACSNt9gsCkh56iagAJ8V10VQxGu5xwigvOxPMfE RH0jgqoSVI5OTMjxybXCz929blZV4kntGnPN7z5TqcXu6Ah4eYJth/cJHHpyr+lZBiJg i4CQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6KQh/iKhf9LXRW6pVMZ1tYdiYaWX6FeHAsXrrGRngEU=; fh=USa8qwlB/WGEeDqy6MOlMhU1i9vBvqThUFWUX/qv1Ho=; b=Epx9QIbiSK/XUO8o1sjpczZsgilSKi8XUSpegNcsHXR3XKpJvZ0htmFNxaAO47XyNB 87cQ4YscL78zMBy1OpXGULIk4d+as4Mo8/EZJEbDxDNWpi+VswYbwRJuw+dfhCBp1Ofx +Jo7KYYMRmSNoPwWH7S9gV7NNmGQ5VyAQ7oq3gTcaPNVs+Jtee9ZlWFe5WI9raaIgNRK uwgkwo4dlhNQvIaTpaSTXFYstRe4aUCO+Ydp8UqaI+9eMnenzbv87DG3rFOPgfj+TQeW F3LqhWbV+2rbOaNEwtJWdMKFDmSGKY2XYEay7kABkTm5tueAgECLBFiyhpZWxTSM8peg 3YFA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b="m/jUMRZ3"; 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-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u8-20020a170903124800b001c20db2510asi295144plh.53.2023.10.11.11.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b="m/jUMRZ3"; 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-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A8BC481904F4; Wed, 11 Oct 2023 11:17:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbjJKSQg (ORCPT + 18 others); Wed, 11 Oct 2023 14:16:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235145AbjJKSQS (ORCPT ); Wed, 11 Oct 2023 14:16:18 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2041.outbound.protection.outlook.com [40.107.6.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15607E5; Wed, 11 Oct 2023 11:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TJMh+HfJAapuUDXSiFnJcZ5wZkw/cun9KKwYmltx4LEz1tt368wyq/9Dr8mNL/2iefS2E4/3xsL3CKOhLiAlD+CSa4Cb6MTnrp8zK0gDCR9TisS3RPeRKxKSzh2TdrMOj6xavFkPwSHCu3IvMCG7SD60iQrZa3aXuQGm2EpOUfFqdb9v9cuT9Q5PXVghQ+0RG/Bt5TCn2KgqhzSaQVBNgoQWc6SunvzKnU802eI3nJthL8DImEf5lk/IIDV9CV+fUaanfJesXXdUm130A4FF+dceLWTFINvNRNMemixzmv/5I5MABiaQD9wTUDj7iAomndt+MJIvJx68ca3G0m4hUA== 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=6KQh/iKhf9LXRW6pVMZ1tYdiYaWX6FeHAsXrrGRngEU=; b=m/6m+9dZBljNANWRsZP/JaSMsMGLfFo6cH1xB62lo3+GxoIj+mhnlqG8Z/8R3hcR0/z6hxjGInpY8oa+iFJ5Q0sK36qI0vBerzEkUwWFUKklEdPy0YQg7StbQ7wrY9ZsYk5zWq40/LvVSFO/2skaq2NxRoffDi3BGmVpneTcxk7HtTmRqCFch+GoyTncBnZ0vwA48q4PqGKhTqI+RVMsXp4bH3fzunboeKpZNidURw4IpHg9Y0qLQD480Doosx1g9fmJosZ+27iFqkQ0J2zBHSxsDMBg6JDJLiAgk07n5Sv2oJEZQffIJiT812cvf8GE1O5V35nO27nGY23YJQXJFA== 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=6KQh/iKhf9LXRW6pVMZ1tYdiYaWX6FeHAsXrrGRngEU=; b=m/jUMRZ34/i6WEEHihlwTI/6UyJqy0VzBJcYOaATzUgGmHz8T5Tclm/k81DB2R69EXp41EouNr12/CvdzhQIU1AMAGmGeUpj/OhdhSAj70+74jj50Bqe5o9KXBgnabdvyLRWA8ugo7C6qIMv8hNuYJDzyP3Zg0wlpVhABsPm0I0= 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 DB9P193MB1497.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:26f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.41; Wed, 11 Oct 2023 18:16:10 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 18:16:10 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v3 1/6] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Wed, 11 Oct 2023 20:15:39 +0200 Message-Id: <20231011181544.7893-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231011181544.7893-1-l.sanfilippo@kunbus.com> References: <20231011181544.7893-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::9) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|DB9P193MB1497:EE_ X-MS-Office365-Filtering-Correlation-Id: c516f870-7ac6-4a98-ed74-08dbca86256e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z1yNtvjSSbYkbCFaHtHQpVy2frvfV17lirdrLjUVA60sjDg/3MPz/4R7jp0sLpXweCv90b5rR8Is/e/Pesgo0eHcWJFcfK83x74L0E2nIBNJCcoVO7NnWiugxdleHHN2mQkZCXLKPHBE2LKyTeFfAAr0uxLpdZwy6c6uEXHvv6yQxmsu8Qfl+DXnVipUPOlZlFB0GYYJv6fNUQ/IKJ7nw4OtxU3A4Cwg5kJPqtBSmgTHvFYHLcuKfQCBk/HVqYp/YcHG7bqwCdqVhol5jSSMXACKNxHV0xIryPfF28fnNxU/nZlj0//bkVLUa1Ok5PViCyCrhIIX5lOnIpTM6IUuIQ480deZV023Z9LuZHqDZRzi/T58tH8A2MbpfgqlDGeLvTMWY/IuVvm+R1UP4gaVzPNG2dJ0tsgheZqOl5TfNnUrCvMQv+n6672cnrwauww4SIvZSBT+lazsturB69Siips3rNswAvB6v4Yi7j4eG15zYYUTB7smIOchOnDVhHfVd7bE67kervLJMnBGva/TSsfs+WSNkUW03UPPDBE5ptLxh/kt5iiN5o4iqhK1pNYt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(396003)(39840400004)(376002)(346002)(136003)(366004)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(52116002)(6666004)(6506007)(478600001)(6486002)(6512007)(38100700002)(86362001)(36756003)(2906002)(5660300002)(7416002)(83380400001)(1076003)(2616005)(316002)(66946007)(8936002)(4326008)(8676002)(41300700001)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NMgxcCyxUTPkjNSD5JJ6kDg1D+pLMjTr8NAgT8XKZINBANxj9/pwBQtIlxdwcflVPBIEDmdHpBK6sgi5vw/biimnJL1/AyxdF5wBc5XPPpsKTpSl3QCkhxnZ3K9bXteX2cOMTLFh/8RZPhhmBC0FZYmtnXcAsW3Fjgm/tN6WCwDdrUQjcM/xejTeVVwyDjVauX8AX3LK7qv+JR9IDjnUTIsB9iZXMtT+TOlN/o+SIRuNgyF8ZkEgCSs/3HLOkUtDCqS9qAPq9ragAEt8Mp4LSr/eOcHUpJDbfKOPLYWN9q5zTSUuRjIf7VNcqIxbd6mj4vh8QwCsGYki2vF6vNdkZzHaG3gLfBlbiWgxK2s+9GiXVOxVNu9c4NkiSk6aWADzqyu2d5tsHlx5LuxXfdxOp9WgfBV5tU++4TCbrEjj3+3S+6mfXA3X8M0JPpDTDoI1g9IAUYRu9aZmmY7kfFcfweZfgqJpwo3lq5vQAWjHV3fqyFc7ZjZbycx8/fL2dVUPDXQLhaF65+NCjPD3r+7KUDT7Hy67MFfJ9yg9M+TXemK1AJRPRDIU/rYB7f+Yxj6+qM7kQ3RsTAtbIRK3n//NMdvYpZmduqO5vCGHRbEExFv5H9DF7qeO2V7NV0a1LGOKMagt19zMqci1OI/4EVYcvHrkX/614EB0WRIrwh9NfOPkXsvU/Ajri8wY/PF5eYbS4PbTcrQZ3Pe4FrUCicQ1VK9HCQXe79bnABXQ3OLKzsDOZJbNUGv3rvZND7yDTAUk1bV00Uhmuu4UjPtCVJbBwqQOFvE/LNdLJulsjtg4g9G0GBmObP5JCagiu0s9tljUXZkjw9Kmj1Jr7T0vrBz/XqwDxUoB/o8VGCeWFTvcRk3nlKP727RDWIjZy87+LGHHnoR0NXtwKgKRmoh3dDBLN+nm5emL+EqCs5fPHIFM706Fk2aAP6jjVyhJbWuRIXOE5p8VhaDLaYMP1KxcWYQCVl8og8QHug+EkCXV0n/ZIqEQ63kRCKV1RCw2p/nbROCRHf3lisg25kMBYDl1jLvqABfr/AQ/Iwjj4pVynSF7jEhTPpZ3sOtJPYv71a0XaJneHGRHPVDvBaKrrK8MmLhusKKjKivyvorxmxos4rR3DZum7bROgp0LlsYqeq2Hh3DtcSVevFo41d0rbvtgmuQ1orf2Za6OSRXsGKfBlj3XZoDXWzuh5N4evqaHGzTooTkSvoktDSILiaZbmUDx2v5yDTktw29uSuV08CRyxPqLUQ7+mBZFbvqFSi8c8nbl6x9qkkQMpY0vr6OFCEdmhrswplSq5ONGoM5C3Qkqr7GybRcH8D6wC1OpvYaZO4fADAXd9lSkqQHLaRKVWu5xpR3J49/IfNQvejkMLWewoVUHcBKDvy3xkPoFD0zigQB3zAWbROw69e8g/SsBNF3VG0i5RK+o0QuL2KOK9rxmf92l/oL5WkgJ0uJa0ayxK9lfepe3ylWpLmCsk50ASu+0uxCVcCbuyMFWk68zVEpcwAGZnkjTlB2Fkh9jyrejYNAbppXvthrisLuKBVfiHteccXof7hBA505YH0FPj2dTOiPd6XfSZLsDiS6AAWYvmkPy4faj6IdhM7w57mPue1B1u+aRvgt8X/Tp1O7rD7gbmLD3oN0wWSNiv/tDoA0dwgak/Hnn X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: c516f870-7ac6-4a98-ed74-08dbca86256e X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 18:16:10.7169 (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: /PVWPRpN2NsAEQX68DA3vZdpmN7bEKdye0FutcYi9Lz6LxVa2ExQm5cbNYIqYxPyUcEOTC1G0NDkD4to2ZBiLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1497 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:17:24 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484063034490190 X-GMAIL-MSGID: 1779484063034490190 Both the imx and stm32 driver set the rx-during-tx GPIO in the rs485_config() function by means of gpiod_set_value(). Since rs485_config() is called with the port lock held, this can be an 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 setting the GPIO outside of the port lock in the serial core and by using gpiod_set_value_cansleep() instead of gpiod_set_value(). Since now both the term and the rx-during-tx GPIO are set within the serial core use a common function uart_set_rs485_gpios() to set both. With moving it into the serial core setting the rx-during-tx GPIO is now automatically done for all drivers that support such a GPIO. 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: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 10 ++++++---- drivers/tty/serial/stm32-usart.c | 5 +---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 13cb78340709..edb2ec6a5567 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1947,10 +1947,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 7bdc21d5e13b..ef0500be3553 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1391,14 +1391,16 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 memset(rs485->padding1, 0, sizeof(rs485->padding1)); } -static void uart_set_rs485_termination(struct uart_port *port, - const struct serial_rs485 *rs485) +static void uart_set_rs485_gpios(struct uart_port *port, + const struct serial_rs485 *rs485) { if (!(rs485->flags & SER_RS485_ENABLED)) return; gpiod_set_value_cansleep(port->rs485_term_gpio, !!(rs485->flags & SER_RS485_TERMINATE_BUS)); + 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) @@ -1407,7 +1409,7 @@ static int uart_rs485_config(struct uart_port *port) int ret; uart_sanitize_serial_rs485(port, rs485); - uart_set_rs485_termination(port, rs485); + uart_set_rs485_gpios(port, rs485); ret = port->rs485_config(port, NULL, rs485); if (ret) @@ -1449,7 +1451,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, if (ret) return ret; uart_sanitize_serial_rs485(port, &rs485); - uart_set_rs485_termination(port, &rs485); + uart_set_rs485_gpios(port, &rs485); spin_lock_irqsave(&port->lock, flags); ret = port->rs485_config(port, &tty->termios, &rs485); diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 5e9cf0c48813..8eb13bf055f2 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,10 +226,7 @@ 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 + if (!port->rs485_rx_during_tx_gpio) rs485conf->flags |= SER_RS485_RX_DURING_TX; if (rs485conf->flags & SER_RS485_ENABLED) { From patchwork Wed Oct 11 18:15:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 151514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp728778vqb; Wed, 11 Oct 2023 11:17:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGap0OHKRNekIDi08qFAopetypaFebKpZiayO8CR1m6pML9aV/sHxSTQA/KrtuS0nJxfUK X-Received: by 2002:a05:6359:b9a:b0:147:eb87:3665 with SMTP id gf26-20020a0563590b9a00b00147eb873665mr17628430rwb.3.1697048221183; Wed, 11 Oct 2023 11:17:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697048221; cv=pass; d=google.com; s=arc-20160816; b=kir2Cnt/9uoLtfzk53hrlhmW1dJwn2wt6dj2EPhPtL27WrITJe1ZCljEUiFowEexdU fOO7eZZTTcrNk/XVC0d4pv4PFb2scWr1G0F2sCIWd0TeT08uvjcKRKAehMUx9lfRL9tG i0ezTejp5ZiNlXPvWI8Otrg6Q7EhxB+l37dtYUuCfzG20B3Jiv+VI4U4slECy5ssSimy fQlIADig9dTKLt8EyOZ6J7kx1Jpun2/9VCpgkflN4XELsf4ud75L1bC4b3g391hv6yJs e3HLu2lMo6LXbnL6DgwdXQCenDqvw5bEGyzt+HwRuBlUzAth/ByZhsJ6w4sHxq6DuXbX 636w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qfr9CVtu2RhfuGF5Ku22UhpbfvaQTz9uuOjeoqXvcnk=; fh=USa8qwlB/WGEeDqy6MOlMhU1i9vBvqThUFWUX/qv1Ho=; b=Wc5likYmQI70xE0wA1KPKKTCkViSXUNpbAuLtQN4U1YwTIpNILAOV6V9ifa7z89FlK DTq/qbMwhUnNyrB17G0+mkVXAc9j92tn78QH0bnkg4PGXgiFyl1IrOHyak7JkBlW+SVq qZxv6H8hAF5XHgCHhXVghNOZqUwGwbs1DQrBaZCycTvegFIJfhYhtdFTpGJy7B+F+7Gb 9PrSeV3FYg4SnFfXFg210bsQl8G/TKJUVauKiLEn3wOtIiA0v6gkCvIIVg7eai76dbs/ lok27TF5BmtKCH5OO3HbAR0fyCLMXHYwi6ytKun7DYBSyj2wMtpLEVk3RSjAhrD4z7RQ gjIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=BKOd4aCP; 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-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ei22-20020a056a0080d600b00690258a9777si11861936pfb.20.2023.10.11.11.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:17:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=BKOd4aCP; 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-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4050080B2887; Wed, 11 Oct 2023 11:16:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbjJKSQ1 (ORCPT + 18 others); Wed, 11 Oct 2023 14:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235125AbjJKSQQ (ORCPT ); Wed, 11 Oct 2023 14:16:16 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2041.outbound.protection.outlook.com [40.107.6.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328E0D3; Wed, 11 Oct 2023 11:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZpHCnwsjKlRWK254mIMVeJVliv7z+M06W5SWheBaBFBivtdXNS2/Nmgg9a7CZBZlBjAcO2EgqKKM/Gf4jtSgxuPUEgemG2XZ3neLmg23KEZo1eAjr56ndE2GQygwPA0abBBJkfKjeuVttKULVaRFDt2yzpOAjHFN2+IgYz3c1bDQGMzaWh2VxUI0tZTOw8o148PlRP4BNuGgzMdNMNoRLVrn7B+hhXf6/lgWQ45U7N7DYE0yt+ujLuhrhnXlKFqKYr83YtyR6hujqbSdA4H/wC4ZuWc+iWamREDddCOaloL/HgGJJUzmUytYl/BNzo67tH+up8S8cIX8RWFJcEkIxw== 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=qfr9CVtu2RhfuGF5Ku22UhpbfvaQTz9uuOjeoqXvcnk=; b=g9rvEPVF/+ojPwOlnOE8yxM9OdBgpbzSPxqUYzar34oUI+R83Ho+/WwTZcdI5YBb7tQQ0PrzUMzdOxL+2c/ZPTXClE4dNW9PfQBkdtZac2aS2BRLryxdb1YZO9qEKmI1oYKBbxkS51h92suMKMg5j7KRN3c/61wnA1orakb+MTEtUDmHhzykTZ82umeQ11bDYrsx4w0oumOsldPPlmpLVumuszXYSUZUdXAjCqDad4plfRx1Alf5sHu9nfFRTFlHoes7YsBzvLZfsxWgsjLwdr9D1MhLF3uFlylc7y56XM7OyKChLTRnhGhnQVQBgj4zxD8gyz1EvSLOwoPbboq6Dg== 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=qfr9CVtu2RhfuGF5Ku22UhpbfvaQTz9uuOjeoqXvcnk=; b=BKOd4aCP8zDfInALoAoQIwW8zEHpcc+gFIF9ulIMhvBKhWHCKel66v8oq8lsqzjRfteI9VTQqqKCXlDw1wFI4YCCLmoOU1o6l7g8LLOy9Jl7i9PQwFvC5u5ldDsHrwu/Vjw1CbZj6+mcgpWp+4AgUlkCQVSMjbNL1ECds8pqRxA= 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 DB9P193MB1497.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:26f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.41; Wed, 11 Oct 2023 18:16:11 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 18:16:11 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v3 2/6] serial: core: set missing supported flag for RX during TX GPIO Date: Wed, 11 Oct 2023 20:15:40 +0200 Message-Id: <20231011181544.7893-3-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231011181544.7893-1-l.sanfilippo@kunbus.com> References: <20231011181544.7893-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::9) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|DB9P193MB1497:EE_ X-MS-Office365-Filtering-Correlation-Id: 89d5d62e-89e5-42f4-e789-08dbca8625cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s2OU3bmYejiuvsHxVCOjuc+42S4mVK3eg/fg1JnWJewZTJ8eqSlGDfDk3ilrKntjZUG1ICoFluCrFq74InMjd8l76KjBILRQdI3GHeLzjgzJSJVF46LKFEwne+qO/KaSjhgxNon6h/TQCvmGNHQab7JLmrWpCc3tMa8b6+OLPYu7WcNNIUpmM7v1OaMYW+abpcTSt+4Ly8swZEcXkuCTy31KLGSaV0Q8qADESD5mxoMLz0CZIj7efGQfHs/nwXGESeBspv6oTkH4SvOOdZaNPycU0ifTfmWEB74Ye3PV8OXFZHE4I7XqcCt4lpDG3YMFnr62X80uoSQ2PCf89hh6+uWVmQNN9tbvCckA/VG/oUEVMvEjJ0Ge1jkblsPRAGLb4qccc+vc5cIr6TQaK9AEGMNwZax61ij2euNQdHPn2q3iOMfC3X6/IxFtDPNT3R42vq4rDrWEUQpYmniVKgl1AU2QkKsFYVUCPY6bOoGh2MZIs/Gb4rdf1vWhwWbSa/KZIH+G9oNwGwUvUWUeftxfixz5edPlHzwoDRAhjBFi5mhGun8v9GS5m3dm6KK5+ZbF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(396003)(39840400004)(376002)(346002)(136003)(366004)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(52116002)(6666004)(6506007)(478600001)(6486002)(6512007)(38100700002)(86362001)(36756003)(2906002)(5660300002)(7416002)(1076003)(2616005)(316002)(66946007)(8936002)(4326008)(8676002)(41300700001)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XYgGaiObTtL4UPAdeN1i0aXzv3tVIafzXi2rCXwkVutlA6zFHx9/rIND+U3wHoxcxt0/f9glDWYgbSJX/GcMe9Hf2ex2JTpwwTx41vxhNyF9yXHh1oEG1mhdK9PPxtDS9uaMptZvlGSFz/bkp1kpW21edj9VpfLhBh8W+mqB6pbjK3pLYQc2REKrlR8qTA5Yop2CiEmicdzQEd3Q8nzaYRfLeEE74jYitKmoQcWwprwyc7A9DBH8eRDJkiV29W3oSpEWt2H0J7xV6o05MgoNvTpf1xthDIuXMzZbDif5CUHx7/n3ykLzeEdbs8sR3I6TgIK0qQWlfphPz3yaXxXbAtc34JBKZePnYZV0Xg+r4coRpt9mOGkZJEN5FmwAycb/FY7JV7ZxyghVyjf+HRkCQhstboaBzFLky0Za7nnnuiT/ldQYQvn1iUvqGwdAWmS6BF2aeA/rfvJonzWC43K+KkGmEI/Cd/rSlxvzlFIFjykBIfSHHd0l7dedhGU48Bsb0Hd/l8QSSmrcIKHRgZ34JuZ+trq7bYvLC8I9nk3U8gILtVkRME1Gnssb2y3E01IJDmqIdUDKOV9hXElEF1a06U+rclV5Zb/k3H9DtJmbLZ/gY1KN7qasE2ShnnEO5fHi+MdlYNsShqfB7ul4Vs5GEBNfAzmw48v/kcnBEgh6lZgOoyBFCXlk6mQ6zw+xwAgoTA9Y/z+MyEzR546KZzaGaHgU+tqrCZsD8nj0pzAWP6Y+fJpa5A96G9MSRpmX/Jsfjpjlv6LwqY3hJWm63iFIp1aIin5sHoE8f+uDkL7ZbR+o1Krn1iE/cqqVnQLN7bdfVTj5BdPyacKQJeBsyj4RsZV+IZ5bk1dnyFzrefbHa2OC8STXxM0VIdrVtpOi+Pyw4utcPxHHULTqB8Gz2tCAvip3ABZvovsY1/dz8FH6QAtuBph9tY2AFZkWZYwmFmWACKoVBC4+0dealkOYjO6rh0Cv4a9cKm5PA2sZ8pcVmoc9aq0MmcFEwmSOnPvNL2h3hB1rgzuHXadNhzfKcjHjM+rBY6O9l+MlMjC1i0eUAMXY/1ZEJ6fy0U/PuLesRak8tN2JAq0AHm1HGxuxJFovNnBvaReGAAADcf9xOmk4f3MMIkE8jPEGqBtR6Mu+E678HJ3AdPT8GZGp9ayrCTK7IpgCjW1S7SaM9dsC2cd8MzWoOyjKF4+Vj2kk85wXB2iSdtNL+zv43l0RzTUWHXk83SlnGu9wNc/HkhVOu+tBWSlzNHqhTqSBDl1+a577Se1Tj225z4QuMHiGHv8/9bgp0uG6TK+lMZm9Hc5NYQcH9tnzsxHtPOQRjeHR+1DmhweF/3bXFJqPVh8CZZDCQBhjGBPoJ/VzD2EsT42zVlhPx8Dzi4FbLhnkc5hIrQhmRFMIEyPzLWS+RZLBOqbhpzDomdkLRetCGOTJwrnM/rclgNjX0b/on39A/PnKMRllMTcFKpETR7vl0CnKXnBxlMz4UdLAxUzYM/3Rn0jptkodWxbzlM8k7ITZobbTxjz0mPmNtlmNWaLzsRUB2N+Qtz/AnhaQnruYjkLRHziWnExa/C2qWkjSHSD7Yn5JH5A7++0ArGbWZKLaSK0KNw62sSIvx62UnVgdfUNurhI+ixNz1KnxnjtomfFMPuzBhQIlBVyv X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89d5d62e-89e5-42f4-e789-08dbca8625cb X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 18:16:11.2648 (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: 6QHQnZ3xkQGqJ9KY2i66AydTU7IFvEqyVOFTM0L0EQ/cdE1taOy9IMx77tuEtG1o+LQ3XdOHPKFpPVisPMPSjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1497 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:16:53 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484035546313432 X-GMAIL-MSGID: 1779484035546313432 If the RS485 feature RX-during-TX is supported by means of a GPIO set the according supported flag. Otherwise setting this feature from userspace may not be possible, since in uart_sanitize_serial_rs485() the passed RS485 configuration is matched against the supported features and unsupported settings are thereby removed and thus take no effect. Cc: stable@vger.kernel.org Fixes: 163f080eb717 ("serial: core: Add option to output RS485 RX_DURING_TX state via GPIO") Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index ef0500be3553..697c36dc7ec8 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3622,6 +3622,8 @@ int uart_get_rs485_mode(struct uart_port *port) port->rs485_rx_during_tx_gpio = NULL; return dev_err_probe(dev, ret, "Cannot get rs485-rx-during-tx-gpios\n"); } + if (port->rs485_rx_during_tx_gpio) + port->rs485_supported.flags |= SER_RS485_RX_DURING_TX; return 0; } From patchwork Wed Oct 11 18:15:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 151518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp728997vqb; Wed, 11 Oct 2023 11:17:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvnOo1sbCMyz0CZEsegRvpj/jh8jGANeXsJeuvvB5FB+XQfoyVbPxL1BynBKWIXp/5p8Ro X-Received: by 2002:a17:902:e885:b0:1c0:bf60:ba82 with SMTP id w5-20020a170902e88500b001c0bf60ba82mr24946411plg.5.1697048245813; Wed, 11 Oct 2023 11:17:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697048245; cv=pass; d=google.com; s=arc-20160816; b=yOyB3AMgzdpQiujFlfwzhI4CE7bnzhQb+lD+DU2hk7vf0XXQJ9obJjSrgltet0UKRK 7121ZtxmTD+5uI+D+ws4GfEd7qPNUNWnyLuHku7bxEicO+FvJZKbkE8pIj1qkTb2G5Yc phB0Ndf7eVU6ohiD+/RrChmoqP0TMuWM648bxTy9gaWHezUeO5NQQ1Da47Pq5H+Q3TRG cl1Mk8G/7tfjnmqDq/Tel3U2x8ed0LUOsl3+dZcD83LDMoepcn0/tiwEEw46YTDvVv1V EP/ZLSyalvZkDNxC5UY5gccwywhXkeL2XNgBu4PdEaOJTw6W3zSjTP6iYprp4+23Bkmk Px7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oK48PGvsIKhBF+d21ldU+Id6JckShcS/hsDClCbGVHo=; fh=USa8qwlB/WGEeDqy6MOlMhU1i9vBvqThUFWUX/qv1Ho=; b=bu70TljaXG6OK1c2MAf+iKmlx7/ebSO01PsezjCtXvCPgXP7SFFL4/r9ygaKdaY4c7 9wiVjmpIXg7I5j1v2vZ7SvGClGbe2IPORLCMAk26/0hadRg1XEYbUyzSmBl5AdP/OWgC Asor81Of7H6W4QOAH52bkQzK/58dLuh9lHxzAgmuBIxNWP4OCtr2LvrUhjOMe7opQvP9 DWAR7PiYgIlMPcuunDBvysaKnFGfZITtGTxzr2iQ+fxTBk59hGIqK9t3ijTfWHtUrFV5 jxfx6FHbSA4Sz7E/si77QYdHMsxNymgDqHFII2UIJUNc0WQnAQ/OIk2GjuxGwBIofO7J btOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=X799JHKF; 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-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h4-20020a170902680400b001c35864fdbbsi219498plk.406.2023.10.11.11.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=X799JHKF; 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-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 02FC1811245D; Wed, 11 Oct 2023 11:17:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346995AbjJKSQk (ORCPT + 18 others); Wed, 11 Oct 2023 14:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbjJKSQU (ORCPT ); Wed, 11 Oct 2023 14:16:20 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2041.outbound.protection.outlook.com [40.107.6.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85893B6; Wed, 11 Oct 2023 11:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R+hdFfT+R15uih21pofpL3/QwClNrlJeAskkXX0B1hgKPuAZ2Zpp/V8JbZqcx9SKHYUDfAF36dn7d/4A0Ch84YOk59NmfZIVGtRzbMYS1BcAFEHfTEfCziqO9Wir3BlBkKhR6gCjFUV+LnF/hVhFUUZKg7x8t1IvvIVCYu1tSx+BUv8Kd6ymYXYaRuJAggrNi2h8V/8gCPqTxK9cVED07J/l2LxNlFMqcgSDHq9nENaIQE3vqkblPZaeG68m4XkHpwp8thMo2VgrI22XrdSxoYLSoibyCtsj7+yPvmZ+P7XocGVSoNDHrtZbKfgzJ3sPeUs7TOyqFVipQVlw3JOhnQ== 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=oK48PGvsIKhBF+d21ldU+Id6JckShcS/hsDClCbGVHo=; b=iRGED2Fi0ar57sU88uftMc5JL3RqAmFd1gT53JxXLCuIHKzqLi/2oQdV5eDNbBiUzmO9GKESqMHdiCs4gXWpEciFwaG6FVinc71nZt18HP0BYCatAn2HVuWstQdl7aR2i7i/S9639jumM7kGAufCkdDEwPNDboJsvH6x0ohFas+LMLx7uB1OHbQwP5XBA5q0Cc8lFaQCMKsoyucL5h3q473oGPoT0GowQ/iajEnPeqbFQXRGOvKFOK9zwwlI3qEbCZTdyhNgeHs0jfXlX9NpF6GF4w0m9IZ3JQ5Ouo9kEHT/8pl8QVgkraVIxH9wiu5SpaJ4GNZkwFMZAjKvDEfXZQ== 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=oK48PGvsIKhBF+d21ldU+Id6JckShcS/hsDClCbGVHo=; b=X799JHKFKYF/N1d/OuJ86tBRjc88huH/RLbaPRPCAVfCFSA6UyroiWbStH3YqmmSSUuzXqer9vgi0Mnk0D5yAUKqduD2Y4eks8FK9q5IHCWznPDeltQSp5rA3o6UK6hJuawK5BCzjkcFVso95isDP7XGqtVWNWYWWEfJcViV+Bw= 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 DB9P193MB1497.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:26f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.41; Wed, 11 Oct 2023 18:16:11 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 18:16:11 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v3 3/6] serial: core: fix sanitizing check for RTS settings Date: Wed, 11 Oct 2023 20:15:41 +0200 Message-Id: <20231011181544.7893-4-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231011181544.7893-1-l.sanfilippo@kunbus.com> References: <20231011181544.7893-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::9) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|DB9P193MB1497:EE_ X-MS-Office365-Filtering-Correlation-Id: 43847260-053f-4bba-f5ff-08dbca86261c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pRYtO92ghuCmwL9JHuhswjOw1hrqbhDAy48W75Flad92NBkqdibTG8lkWApZgrBsqeiDJJuULCR60Vk1U7blWLiqqOuGkwD49KP1xL6ULFDfC2sFVlLtCi6C9JSaWgPxl2TF1fIwULj9ePnM53fVp2KyTJ5SkodaxoT1TbpuXpZ4VaFUPtCLouXHXq9oXpXmyokZ18VYD+alaIfDjdd8guf5wu7B3ImNuj3cTJuldOzvnQzjVOYpkG9JghnIkNuUSgW+9rq4Sqpqt9KfaqpmKVOnKHOpxTebaECRl7I2oHXtlJKlg3gFOXooFvHcnm7g6CZquKDn1tKAzCgghDhZAUfz6N9uyn20IBNfLkFwzE9CV2Je07pXHd4OqY0bheB1oHN2HPNG95kft+gHyMN5aaVGdvVY48YLp4G9Hzw/00WYlwPH/mSWoMyzfMb+kZRewpOxaibvYWo220/P6qeujxbV7imoMr7/U6wLTMRlhgHkDGLFdRlBSxg6zabOlPRJOqBrpavKj57hGJ+dYGM5t9AdNBfDDq2X8krv3FBfkEppdBNnsnJ4Kkiumdme2Cyl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(396003)(39840400004)(376002)(346002)(136003)(366004)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(52116002)(6666004)(6506007)(478600001)(6486002)(6512007)(38100700002)(86362001)(36756003)(2906002)(5660300002)(7416002)(83380400001)(1076003)(2616005)(316002)(66946007)(8936002)(4326008)(8676002)(41300700001)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DDKOJfUVJFY4/tBWkIyHhiiTogb17dvXGA4IgdBoNtnD8Ygh/9S9KpJaIOQBE/6dZxnYGfgTXHqXQU69c5cV6Q2X+IVrje/meaCqUJtPF6fPHIFVT2fNgEFvMdJfzldlna5irOqovOKeHSFWVDnMH/+SAhDgZLDE8a2q6QXoHnvD5Q0zC/11t1bLQfhxWw94LDT0zRkxDfTsUP/n4u5P1TvmiCThQp5Rj3bZ/fYgJgWnbM0Nt7+anbtTTo2Lpj2lvJPgPP8JzLmYHczDvi/1+mUY3YJKG4SuKTbdWjUprEkU+hr0a5olkSza2KLByv5bU3Rx5Lm39dBI3Z7uVIdHDsV10P2MR2evaRBGwZwiZPpPJfmlx9BuqJsDzeK+ZlWt5y9tVn0PKWY6fILoaUkNd9V9Bq7Oa2gpIcmtXxH9kVmdqOld9nxWOGBZjK8F6cEnwAYVYgYFil6vGUJMG8NsvyfJffi7Xm5vWHW4/KJXMoA+Xd02L5su68oeT+dVOHxVf/PXjbKYkRUe7p/GHr4KwNZPscg0Vt8LQm1qRqahwPzOXd8/mUZEKWMFt7sWc3REwqsjD5LZIFDXzHL9rBDe+n2sZMmhHyyH7Dye/yREetOp16PdGB4chHmlgscEpdW0nrE2qGb0OCSzprwQ69IBKREyjFFnz2oNZ6wnLfF3RRQVFfQF+ty0vBp8xaAgHCS/Di8ikWyQKALHTkJPWi35h+ehbCAj8hconEcwB8rj9G4r88UpICakVE/O0zpopxXxJEILCki9UuPUk+Wf3HdbnvS7eANNKnWLidEih8OHE+l/vbS9z/NucN0Y8mGVC0aB/tpV07hxfQxD6w3K499amy/rBuA1mIF19jfIzX2D8gK00eI0DPPoJ1D7alZLypgQwacZNA3EGd+Z7hjvvZP0KK7pH1zbGnjSbgJ3HDcw/EOD8kBpp8+eieIx1/nYCCsYyBb7161YJsS67jinffODesC9pcZbiSZIuq5yRKUzkalYKtdym0BrxSnnTu9N4iMVHfr05x0pEdgMVx9ys8Wq+D/jfF/ly1HnGoSoRod5EhAFQsfpW/64Ee8EONQQx7N5TI/07M5pnYqZC5m3mQslhJeYuMT2baF1PU+zjO+Z9jEqiiJmp/1/Gbh11wJhMWZR/1S/2G3bKFxBrkTTzg2ghz6wENJDEPpc/vBRsLYwvZLtLiGEFWgMiggJZQbFEAalIDSZdwQWZZ0kKvIMOOTYzCsCYjckjsdjb4WBUzvu3jEthCxeUQbr8d80Tl2OnAwF4F8YZGh09lSKgZTDk6dCuTlS8E7mz5PfwbftHVLGC3un1sxWZB/9zDWl7uubaHEbJhY4DytOU5RJoPLsBeosynYR0Tf9t0xoovSbI/0gONkxfTNMqcKd3Y3IqfknH8mAgTKeytjNXINRrm1RuE8HCxju8FMyD9FkQ/U8FKK+uad2TtCPear9Vf4urod6fsseUvt/OKd8Bx/8fBZvKyqhCzCRvblJZGabLCtq67LAJDrijbuw0mg0Gqtb3jOgyc3Sy+K6MI734CcGD0GuadO0UBtO1R38rh4UZ53ZEE/DMXr56+LG2eRKGo3zRb0FXeFGmkNRU6hwVJJV6cWsK+1+ong63dKpULywE5glYfTqxs8yu/8qbCLGykdeBi0y2/Tg X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43847260-053f-4bba-f5ff-08dbca86261c X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 18:16:11.8130 (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: ovbd2qOxB/1Wb+x1VCnRcBiDuQMSeRVZWs/EwQCfLO8SSeQKuIkCWT8NYt98SaKfmVNz88mpgdFRVS2YTKKUFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1497 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:17:23 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484061844741935 X-GMAIL-MSGID: 1779484061844741935 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") 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 697c36dc7ec8..f4feebf8200f 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1370,19 +1370,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 Oct 11 18:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 151517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp728853vqb; Wed, 11 Oct 2023 11:17:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1cLyZ6WQ0z1i0NxzS2+BzDXUdwPEHd2p0GNYfR3H46qp6SN/XZg525wBWDo/ejYPE9N/D X-Received: by 2002:a05:6e02:2185:b0:357:5188:1f83 with SMTP id j5-20020a056e02218500b0035751881f83mr1775690ila.1.1697048229052; Wed, 11 Oct 2023 11:17:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697048229; cv=pass; d=google.com; s=arc-20160816; b=ThQmuyzpmEnvGO0+RoyfR7T2HP2dcOyMycy9oDndgyajpCPkCvBJV9xsTmD70/xtnj BntMcUsSpTRsgvYlkZFCy123tVTOhp6ZIeRtP5w2KooMHL18IbtBANp9qRBz22PiU1a5 YxKruMMvoe9zRYLhSefIX1lt+QzwaN8mUlM78QmiH/zibbgIBqNnaZiFE948W9yYo2id DAau/EQq9OzlGu3ll4b7Q0QZfsMGxhSdhPUeNYfoCgKN5Mnhbx9HUbcL6G44FIjBjBru 3LX0/epWk1j/M1SgIRNnhmQ/4w3doTsPyfuyqNPikzFbd6o75CC50DUerUhK6Og8CYxf 4bvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TJ5/eJP8FSTSE85vf+YgYI2YYEXaQjMZKL7yA99JX58=; fh=USa8qwlB/WGEeDqy6MOlMhU1i9vBvqThUFWUX/qv1Ho=; b=kaBLhBaltxsDtFL+STxrsMlgZuUvZKTp9Xpwuo1AvBFJzVHaz4gOi2O8fh0551okBD 1pYm+VBdEggiOq3PTEU0iAZeVnJl7L1P59EElmtFSi7f0+sPjuOkNR0E2NgBzpHBDM1u Wr/s4e9PHRQZ9FNwBuD2r5lWWrLkvEUxTc6C6tyWg/Xedn7K4gExS679WWYhigj1FVvb plp//r/h2DGobelgEUgBbatNGrTE5kzSu9X+eKIapEvcLx4ZZtqRpvNXQ5nrU2DDU4fQ duj+bLCgjBp2lkegh6mKkhqlTNaPq5r2qa7D8XvU/77R7ru4h2b/0C/MlH/RnWJbXBGd KudQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=fll4aLeT; 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-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id v2-20020a056a00148200b0068fb5ca50cdsi13206431pfu.126.2023.10.11.11.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:17:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=fll4aLeT; 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-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3423881140E8; Wed, 11 Oct 2023 11:16:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235146AbjJKSQb (ORCPT + 18 others); Wed, 11 Oct 2023 14:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbjJKSQS (ORCPT ); Wed, 11 Oct 2023 14:16:18 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2048.outbound.protection.outlook.com [40.107.22.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DCDCCC; Wed, 11 Oct 2023 11:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SlTzpTC8AATVaJOegdOeFwuXchrUbHiyLGrrrwd/l/bqrccBIckkXFfg1Oz3CuoGz7UOBc32dfnkEKhSikMsF3UtwRmySfrsfxAJo25FcwXvc8lFM26LmAr5r7Xa1T6zEkQf86kw64ChWnAEazMulgUWprUKzl0F1wQwwEtcOm9m9mFVF0E2IZmMPsRqOvXq3nzHgxZnvZPDvoDo64RBfyKHV9st5ZObMIhZh3dv+YHY1mLd61wmRpq66yPeeUsZ+KnGFt3GlmRdh3wf5Q/xSLBta3KBKLRyw4/iw9ePJ5J4c10G6Up+snRDelHoFxFCQN+EprrW7vbSr8aqg+9spQ== 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=TJ5/eJP8FSTSE85vf+YgYI2YYEXaQjMZKL7yA99JX58=; b=NBLgAoDMSmCfBpfit9+AEkAJ/JXtK0R5RUhjM+dpUk1x3dcH5xZKkUiYRC7XzuIuVuF596d3E79yhWaJeUPGRTKdqudlZnkDZvULWxvHYVaOzNiW6hBp3mWj8qPmpy6OuFKPXYp4TmdCfn1yeclOsoGMPS7meZHsbEng4URRo5fKFZIw1RvjrJCx7Nscd/AR1EUO9sSSnm8fJVOfayPBYS43stVtKEcT3iJLBgWXe3J3EZG4JyH0L14CMo1bMuPi/YIXPLliIw7xVmeWBBTQyz097wSD3qqr7eHeQ9z0iTwzJJIy8QG2e+SSVgEQrYJ80Iuc5+8YkP3LCFjUbYa/Fg== 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=TJ5/eJP8FSTSE85vf+YgYI2YYEXaQjMZKL7yA99JX58=; b=fll4aLeTaiE1OqtZpWYA3II6GUfQ/V1RKc+rTzBXsSPcY45IlJ9vVK5pkygAzp7EZj5ODn6ClYTHi52sTO8gAOC5CvVB5EFB9HfpvlrJ4EChDUyGijBHzVIwPHwG3SYGhntwRedmr7lUxTRPiKD/l2orRl5PKrSoEIaIhIR37vs= 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 AS8P193MB1925.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:3fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Wed, 11 Oct 2023 18:16:12 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 18:16:12 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v3 4/6] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Wed, 11 Oct 2023 20:15:42 +0200 Message-Id: <20231011181544.7893-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231011181544.7893-1-l.sanfilippo@kunbus.com> References: <20231011181544.7893-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::9) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1925:EE_ X-MS-Office365-Filtering-Correlation-Id: f4a7bee1-354d-414b-8db6-08dbca862677 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1JXLIC83BsW85iEufFa2RRHTVcjnmYU8mMIQn6OAa94EOBOeK9vXa++pjVA11e6zrIGD7lvSGD4rBtmXDDE0aO8PyuAI5XoOs1eNlbI1WSnt2VwSNukQLnaQyi9KFRkp7qncwIQO1tnz84naTj04CSgrQ08MG8eJSokOHCCMhIzVBEoGrGImylrlMaiq/ZEraNJRxXlYRM6zaxZVwuxjaegpphURRy1b76htfv/i1N+45fqs9iHkkZik49mUfVwHh5+RFlS8B7T9vYOknjV2tx7VPQQE19qW5Kil/NrpzFeZBeJIXPP9g8DoM9QnkO/yykSCLmF44JIaYOD3RGlBQYmfCcZTxery/Upjq8fy5GUCArlRkBO7TvT1/QDnWSW98eeEt2VXr6jz/I71zAd6Ua1NVlBfsl/TtncOnyfrk8mo0z+IlZxfa/AOq1028NPYFxrLrJpM2Iqb9n9T6w51Zj7YhiXPVmCjhMWguOYo1h5vFmm8Qi6WeYB0wCTjcJPqJtNFPNRWteWd6wd5/qHQbeAkB0UaBlJY/vV9upgGifGXbXhuSWsA5ZIZrerep7Q+ 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)(366004)(39840400004)(396003)(346002)(376002)(136003)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(36756003)(6666004)(52116002)(83380400001)(6506007)(6486002)(6512007)(1076003)(2616005)(4326008)(41300700001)(2906002)(478600001)(8676002)(8936002)(5660300002)(7416002)(66556008)(316002)(66946007)(66476007)(86362001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7BRi2tYxfBa5bDJU+ZHMrI/poYhAUMY5Q/Da3aeM45p+hFBUgL9opQiqFZwV/NGlaus7B2MggFO4VTvVWa7Pzf0Zqk85IsUs5/vOZ9f2dwjYrNq3q1fn+GsSCfrns/51YUrv/fACjCFKo+9VgS2iXTrSOw3kJvjtbkCh0pKfdzesUt95CbvspAtcUVVkwQqsA/uXvowqJo0ewEMqnXeX1U1IDgqKC1X2Vod6u/GKbWVjIrbcPvP8H0+CzjkjQArF4o2SLLLCrfyoGUd6WI5jzusUsAmKXC4UeFXpjTPxkRP8UV+VXeUt2NwG6m/0UNeLwzoYjLnFblVPJ1MPgykSRW4jK5VzJE6Skiu9KaGDOpk0v6jBFLoJ/Yif5XLU1Jjop3LAr2BbtkQRKal6jKACPW+XyJrUpp+fRsNH1/gtGoMRSp4mTd9roEpaboDOU+CjPjoF6VSWZGx8rwhxqwZwJcU5MJP1nLEGLGONfCTb2nTbR6KrwaC7RKLJ4oHmMcrnmYsI76OotBVqklpPL3gTp+yd2jCQmyL2prndyKoAdsc/Hm7Hdfq7SdHvScYXNs7c5xXh77jTwAM0UhxHHJd7+fUoJehQCOnHdyn4z59tHQG/M33cbMckS/f6zjRrVBchE7gkoR/AcNSUnbGTfwr3MojyIbuvD+Q76lTAYXxGZiWP7IGP76G7PTngoNJ7xyGev1IvQ/FDyvLg9/HjQgUI0Zgxspt+pnrmomaMc0jg37PDwkFajCTry0gAq3hPDdEnP7S39LZhCs8qP2NAIGHhwyoEhmBbfBw4RBlrTAkvk8Blt+VtIT7SfN+9vcNfy6lTeI0HIOA00ekUaS7QbGEYO9XH648+VhOOWD2Rt5ltmKU/uMyI1lv3mYPaW7UyFt47gKDgC0X5vn8Dho7itlJtZIt7cfhkDJ4defVibLARzi7HcnJrffZciRxvTMHbDIgAvO4S0OVudQv2E2A/S04+7yz5FZsTTSPk72jGkvKDxuvtKHRaCiCzVJa2EBmVKd5+lHJMsT8HdpmZ9lxKCS2zPBZoQscVUm0v1q/Q/Ux6V4OFH7wvQSL/lnLIbH49BWxCFtEK/SrlvtqDDAE9HLOm9Uik8GzxpYysEJrpyMAvkiq7YfimtnraoGeHyj8XJWuebDeSEEO6i48fmeM3KhN77VmDmqeE2j7UfQWPXULg0GqnJNkTiVm1GhAGu5+QDuZj47+faILZ3kf6Ao0wab1FVg/WfcNoFSb3ynz1bf7PbFHiLPKxAnGA/gHmFN0NvDYlrPFGm7kyJFIlqLCn7y3uyoUpBIRUlCOr/PZNznKcUPFIOJ1nBR137gtX5Ve64+4oh98udYUcxzxpo292+zt2obY5ttpy8BTCdewp1KaJaedL82kJgs6s9LZaUH3T7IcTgXjwyKhKclYCwGxSwM2/aD8LRRH0eaDffAQDkWBFn/uc2tBuFPysWwaUlohbkidsZYCjCCqBL67yR7wE+Rkrydb2nBxVwQtCBjEHXJHfjZoVn6+dOHeXTXkJNJ6fXi0Fcmguc9oCv5w/k0dFQNPFj+gwzCqgV4dqXjYOAGN1D5dZ2S6dQx78V5TJxWI4L6RMMfixd7n5JZ/Tf5IWq5BBTe2JL2i+VJmvLp3ZETp6HmpBOoQEG1L8vqjWiEIY9jEI X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4a7bee1-354d-414b-8db6-08dbca862677 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 18:16:12.3864 (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: WE7OCKWKnzBs4RaaoKuG7ICatYY7wgRS7+ZweWkilPi32dvZOLaePMycwh3ECbz5oyg/wtfGTSmjeGHL0YJX6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1925 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:16:59 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484043912200762 X-GMAIL-MSGID: 1779484043912200762 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: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f4feebf8200f..dca09877fabc 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1432,6 +1432,9 @@ static int uart_get_rs485_config(struct uart_port *port, unsigned long flags; struct serial_rs485 aux; + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) + return -ENOTTY; + spin_lock_irqsave(&port->lock, flags); aux = port->rs485; spin_unlock_irqrestore(&port->lock, flags); @@ -1449,7 +1452,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 Oct 11 18:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 151519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp729009vqb; Wed, 11 Oct 2023 11:17:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHab3YYKijJJKMALMFlkcmTRmbdPGjUVKA12pGPZrgqnQHGDSB43tcsExZu/z8bkRZiyY/k X-Received: by 2002:a05:6e02:1203:b0:357:4253:c822 with SMTP id a3-20020a056e02120300b003574253c822mr4758664ilq.3.1697048247076; Wed, 11 Oct 2023 11:17:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697048247; cv=pass; d=google.com; s=arc-20160816; b=BZNLkmcvTXlNnRdg19HZ+2gv93dh0lCQsmb/ZTjgS9lS+wMPczHFXZsJ0UrN+yclo4 gGbASW1+/xeS6syFBkm8Fqv/KxqOIMoE816DBcw5G8lRcZyoyJMVVR68tG9FDFllv/2v qsN0sdLz1lyV9Z9TSEvitJwZC20lc4a4lIMLnRar5aTUPI/9W53d16X34UBCrVAnuot3 Sj2AMR96IK67fChE+gg/R66XN7UPN3/3Qg/IwbnkO7LF6tefwqxXL3esRNdJDSwsWPlp vIwS1BMbibiwtSuJWnm9gtieRJy29LdgjY5Dp+XaQkUku8LKfiiA14kM6BVYIF4nJ0Qd sk8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g9VNnrRh+93b9tiZ7+fqQ29BWG2jfMJ+okhxSduWaaw=; fh=Ocz+Y2u7bhoP659IxE7LNF1gvwEDr2znXfLmnknrN6Q=; b=L4VYamLip5Lt6Jv7GGBrV6SyN7E9bL6bk2GvwR0BmHQwfvFTigtJ0tO6s3l9HuUSU1 7F5gMfn5IYV8n/ykyOBS7bUIdbRwEYga/FjNxDyRyuTOpxQQb+lhqv/UJ0AEHrqUD1un Ya4v0PzmK++7CIsehatsw7xxA+dmJxUytuFH6F36bq/txlFlSJ13BFTU4gW+9kRUFZyy clGIqtscbAouoDkbquhYkwza4YL9TRz3mkGFkFMvoqcas5jogxcKDTNGtAQnc3l6V/tK 3sw/HhoMiXTA+oNNDhdv+uxVhtb6TKKQvNuyGrdb+JosDeZsoNaeSq6o+qVsOcpNuohL OEqw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=rB+J3iFT; 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-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x8-20020a63db48000000b005898e10f9cbsi298272pgi.572.2023.10.11.11.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=rB+J3iFT; 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-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3529A8068FE8; Wed, 11 Oct 2023 11:17:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235156AbjJKSQw (ORCPT + 18 others); Wed, 11 Oct 2023 14:16:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235150AbjJKSQR (ORCPT ); Wed, 11 Oct 2023 14:16:17 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2048.outbound.protection.outlook.com [40.107.22.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54038D9; Wed, 11 Oct 2023 11:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXdHBdnC6WhmN9PlfkTirPaEkYkML65kRjl2re4nlkNJ09jx80JT2vVIDD/0Mr8xybvrNUazc9hrsS+YF8Ur4HNNq0sOq5xE4Swlvh7HpkMPZR2fdGxrIMaWHSxHqSJdVC2sFxyhwUEJxBJu1Bp2bWcoV6AiV10+G/lUOwOTULe2JH/Gumy5IZQz19RmT6nNWWO7GE5b+Lqe4pu6F+ZgWOXpow5gkmbYnqKvSSmPSZOtyOncxxXXd5yX15gf9OgbywGHH2xKTNZr+9HD2cZp2QMrqQBOQhyPY3TLLbhQFIA0+0bJen+/3QtGXSpGWYHc8MU6+nFLKgtLn2JVfIeHOg== 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=g9VNnrRh+93b9tiZ7+fqQ29BWG2jfMJ+okhxSduWaaw=; b=KdKdLg1RH1oN4WpVsw111jvDuzHpMVxO30wO8tcQBrUH+DPm2kGksKw7Qz8puEsoo7C0fUfPMnCD2nB/Uex9tzs9kmx+f2t3D/TxmJ9hrWsA10wHLiiN/xX2Gv4G8cUN//CmW15pciNEswH+WwKZYzegS7iYUioj9KL8kjD8n0WBZkQ+Fcti7IhSgMuKm+eWcaZxMS39cmEsz0/JsRHKZKNbe+64MJolkxfu19IZbY+vjjiXmS8hiKU8PYEJNgJ7O39ZF4tY6q8oTDSu5eOnCPI56LkDBXv3fho6GNd5hrirKOm/g+yy8GaF3/OV2CJDUanGdWAlqR29rIozfFe2Sw== 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=g9VNnrRh+93b9tiZ7+fqQ29BWG2jfMJ+okhxSduWaaw=; b=rB+J3iFT50VeuhTkAs28X/9WcLga4mwUGKh6aQ4/J8vaw12cNBJjUdliK6j3iKJ8+MSZXVFz0sl+jzsJODsdNxyvbOGrj4T6ZL8FwAJw4WsNtZ3lipM2XSuTZS6JArLKo6LI/ufMedS72LEGAcN3D0M9NLdEu0+bJGxa1egVXwk= 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 AS8P193MB1925.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:3fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Wed, 11 Oct 2023 18:16:13 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 18:16:13 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v3 5/6] serial: core, imx: do not set RS485 enabled if it is not supported Date: Wed, 11 Oct 2023 20:15:43 +0200 Message-Id: <20231011181544.7893-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231011181544.7893-1-l.sanfilippo@kunbus.com> References: <20231011181544.7893-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::9) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1925:EE_ X-MS-Office365-Filtering-Correlation-Id: 431bd925-95d4-4136-c32b-08dbca8626cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xxAimYXLwWIUiYQznvLn5SMTRgidD2blBXwI6wau5ivXhaMed3u79M3uB2dcLynqk7ET9SECfQGGOKwQoupurBgYM5ylILXyoTxeyWwn+gLGE7NiK1G0x9dzyOdtSXGL0JsMn5iqoVTFHXoM3gq7BJlV7dfJmJn8pdKw/uhQaEqaE5XnbdClAh7stEN6AREMZu9j2MozqIjqof01n8/oc/oLAkd6zISZz5XMSrqeG2xucFsjjVKdzKT/t96GgqnT2/dF5rky0IOQ3og/NKIklE4nz19JPMeeZFMHqwmrhAHd3nUzk4r9mbVgJRdS5MJh01lEN+yTcln6JXwOVr+yDiIcuYFOR8/q8QKYwythPx7rJWQTpnhlo6+lVp6rutIaxPiEc6dY6yPEOhtAykGaUGkDGoMaF0SfsP7L4r+imiYxzQEj87FKR6QYskgvDHQkg77HH04CDfKagLtvsXbbySZqUZkjeLxfEVD1nLrM1OpG5vbM2UAqDymHDxN+lHyk1QLpVzylT8YhcLQTZTt8kniN2M3xCMkXrntroYjlMhOO0Mku7ILdGusBeKZAAxBQ 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)(366004)(39840400004)(396003)(346002)(376002)(136003)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(36756003)(6666004)(52116002)(83380400001)(6506007)(6486002)(6512007)(1076003)(2616005)(4326008)(41300700001)(2906002)(478600001)(8676002)(8936002)(5660300002)(7416002)(66556008)(54906003)(316002)(66946007)(66476007)(86362001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ELpE2e8SCDpft+UfH1/lYYXq4ETr?= =?utf-8?q?5QR3DIIf4wDf3iF7BwikxAWPwRITTEbfzuYJb5bODjde6dQNwn6iXy77pwrqeJJbP?= =?utf-8?q?Goj5JqcONAd3GWNp8BUx/Cmau1S6qm4wW474ppnURancqm2XGfNwTRE2REvdmsoZh?= =?utf-8?q?51TPt+H3TbmKoAlU6fu+TgtCNgKCOYDJsZhdh71XTI4tH5G4B0k4Q/xeo7qFYzq5j?= =?utf-8?q?eGA6YNknHXUZoUgMbVCSaGSPOIkWX8/ATguvjc7oi3nSwhjcAY3RTdy3/jiXwcPjw?= =?utf-8?q?OYmG3dpVBdF8lpwYSHbYy7u2bQoJhvSkf8yf6KV3FXpnrEk4t3yJ7qM1DARUE8tDG?= =?utf-8?q?Tj3fkU+C/Qs+a0xRTnNQM8W/betF4arkjeDnVQkq8Z1ReQYhZq3oOcBcarPq9Gm9b?= =?utf-8?q?poSMEmtIMpPzWC1f2/Jh/XUb7cnNAxpRLQdz2eYJX2+EHSvqptLgaWdxWddFX3lJH?= =?utf-8?q?cfG7NIfy4ucHXggcZWyX01Ajncrqv05VSUv2X9X5bVp7qTrrg+nU2orFntVie+5j4?= =?utf-8?q?jK6dpwVEeYA0qwbKVSx5s56rFZI7rNDWbUejT8hkrqWuW9pm4pvzJrWQxsxjn/66T?= =?utf-8?q?76jOn3RLhojYAwDWuIBtGwvaw+UFjikiMLI74TAAUImQMtac0IPzIi/LelcXmsC38?= =?utf-8?q?lr2TT5wNeQ668up6/IhXmMsXOVr71A3ITHPGEYN6ha83G06EJPlu4hjaEslCDNFBZ?= =?utf-8?q?a/Vv6OcLptcIG5G9H4l3fmYIMeY3+7fodWykk0hT8B3GOeGxRXbpjalhXitiSHXNr?= =?utf-8?q?hPfYEtlnuwnTA2QfcyVvchXRzoGrnWwY+5MMj1/wAU9e1tejO6xOa1PllPTajN+SX?= =?utf-8?q?erw0yJIcGuzJR/66PPGWKAYPPmEu435cmnxGYhm8veqbJuAOH0bwYWcXB2f6M6oN+?= =?utf-8?q?cn5ZrWrNfdL9CJx5QwEoIXJwTCkBImMvokjVVq19NCjiOcRSgl0BU5ypWtT1aEBa7?= =?utf-8?q?mfMV2H1rN/QxEkU/eb4++IgRrE+HvL2SUvnlcil5mjRqSXP1b0JJfoYEkrX/X2BHW?= =?utf-8?q?fHKvmNSkPs3XCReAruROId9ZHPr2vWjSWv6iiFw5q1Na+IJ2DkT74g2FtQOQ5ESQ1?= =?utf-8?q?xWqvFrufxUC66QetVWeMipse9QbwlciNnFRAbeNxaqa4t7rZzbDDEMFbaGu7sOYii?= =?utf-8?q?crP2k6CPXQpm931wCpwiezs1ZjVG36lkwNzt2GBX1F+RSV73H4dODT6js4upVmga2?= =?utf-8?q?jqhIu/n9YFY/3z6BasZ4Ywf4w3ZISYDjkuxBT0FC6WYvajhoCx5DHkQUxKgPXjQlG?= =?utf-8?q?1ou4Ygbzj/gOCDNq4FiaXihI5a4zv/txrYqbpaAddVzHPA2RUR/bkgXO8Bx35bVJz?= =?utf-8?q?KxIRhyjvsA1W9YzieiF7UitiROAe/fXByEVDm4a2F9RO2dAVPypIDo1IHrbq4wQ4o?= =?utf-8?q?aqeMKB2SwysonSFPaf24aVz/H0Cj0jXVeEe80nKt+zUVnxNs40QbY2ophNDoX5hAx?= =?utf-8?q?3jTzZyHl8qn9ZcsiVS5dWa3uv8gAlB9O5Sa/11HMRliCecqkyChNYQgIf4KvKVXQZ?= =?utf-8?q?+4IFH3L8vU5OEdrer42mwjBtyQ3x2el0qHjIk8Sx5gqsmPF3HKP5MBzmocJCmYQ1E?= =?utf-8?q?np6B/yRqez1?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 431bd925-95d4-4136-c32b-08dbca8626cf X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 18:16:12.9772 (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: q/tuzAMqmoaEiBKp4xbuH72d8BrsCnKnZiQgtEvcb20ar4O8W+J7Cwp3Cwh5MAOKghaTe5URiTw9Zj99P5Q/nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1925 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:17:24 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484062622974677 X-GMAIL-MSGID: 1779484062622974677 If the imx driver cannot support RS485 it sets the ports rs485_supported structure to NULL. But it still calls uart_get_rs485_mode() which may set the RS485_ENABLED flag nevertheless. This may lead to an attempt to configure RS485 even if it is not supported when the flag is evaluated in uart_configure_port() at port startup. Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED flag is not supported by the caller. With this fix a check for RTS availability is now obsolete in the imx driver, since it can not evaluate to true any more. Remove this check, too. Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported") Cc: stable@vger.kernel.org Suggested-by: Uwe Kleine-König Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index edb2ec6a5567..c8c19bf8585d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2332,10 +2332,6 @@ static int imx_uart_probe(struct platform_device *pdev) return ret; } - if (sport->port.rs485.flags & SER_RS485_ENABLED && - (!sport->have_rtscts && !sport->have_rtsgpio)) - dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); - /* * If using the i.MX UART RTS/CTS control then the RTS (CTS_B) * signal cannot be set low during transmission in case the diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index dca09877fabc..95cec2343b35 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3576,6 +3576,9 @@ int uart_get_rs485_mode(struct uart_port *port) int ret; int rx_during_tx_gpio_flag; + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) + return 0; + ret = device_property_read_u32_array(dev, "rs485-rts-delay", rs485_delay, 2); if (!ret) { From patchwork Wed Oct 11 18:15:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 151516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp728835vqb; Wed, 11 Oct 2023 11:17:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQuns50a7c/y1yk/YaHTLIJW+dyqGf3qvcwjDfYyPQ/IfQusF8vyMls75YJMlcVHJjXS7y X-Received: by 2002:a05:6870:b4a5:b0:1a7:f79c:2fbc with SMTP id y37-20020a056870b4a500b001a7f79c2fbcmr25848366oap.0.1697048227213; Wed, 11 Oct 2023 11:17:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697048227; cv=pass; d=google.com; s=arc-20160816; b=fTKfZ/5gFD273W6EF7ouGepl9YlkPtrYTgnWVPX/5W4Ty6UhKaI8G4BCWqlz1YhqCY rcsWCqh+TuZypXM0MvGIQbpDPTW9aQbRmwZtcSnrsz1i6HAX0IM6xs1nvlAueyeVju7C ZF3wGLPRHi6i8r9bW0+Iej8NSeaUBRLJ+ZgfHMrDiudHvDA1CFh9xR+wHUQqb5KDiYWC s8/UkpSQOL1IZNIrDKwI7h/483NfshKqrQOhuErVRTf81zSXGI2MiZDpHmhJfibcW4po pKyOSfWfAdiHVzDfadviQcffkCWewxqt2vUJY8UJaqTjDEbm4OSGv2lIsQwa6yorNZ4e nehQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7/vH9Q9jKs2GzlPx8DEoi1T0SBAlJ5DZXJzhZrsbsp4=; fh=USa8qwlB/WGEeDqy6MOlMhU1i9vBvqThUFWUX/qv1Ho=; b=Di9XiZy5kV8d3R0LDFu+wQ/wulaC1y9HXuqJz5HLc3v06SHb/h2cx04Bmgg35FIcir nI8av7j9bJQf3FpizPg+LfDcTBbAKKVFyNswygcCe7Z73N9sDbXaVDv4rnfVpwOEpseU ikN02qVXUWMyxMCxOY5t14UrFDQ/pCOBcWg6qHeToN7ajfl4mFATb7ZLEWERYREwLJUJ 2zK6HvZTOL9Zp5jG+5RomtcaOSYrjh41/suWWp48rcnfmAGrqUqQtndEct2cdvHcGkBo qMp7e6Ue+etz+n6PHKjXcjbOzEmAKpERRxT0vGRgtlEMMMbkppwZ6avnJINYUCanTZ4D Ws0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=U3Vl78QQ; 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-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j71-20020a63804a000000b00578b63123desi326468pgd.789.2023.10.11.11.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=U3Vl78QQ; 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-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id CD74C808A350; Wed, 11 Oct 2023 11:17:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347006AbjJKSQp (ORCPT + 18 others); Wed, 11 Oct 2023 14:16:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235148AbjJKSQT (ORCPT ); Wed, 11 Oct 2023 14:16:19 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2048.outbound.protection.outlook.com [40.107.22.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42413E0; Wed, 11 Oct 2023 11:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DHLxwzJaMi7/ikHZ90F4TWvBBJgT5J2SlDkkAVtSo+uby1PqLgq2oN8R2KbqbCi3JQokkz25OlRw54mPgFXAvUxidl1ttKd4UITgonO9wKit/Q2AbJr98YXeg6ElQEmHncEgWa/eER6jqVEWZ9TVnPnd4DT6GNz8/rprIAJwsXj55jzpqlOxAlo2ZMslzRFcYURLpt6ax3jv0LtzzNXMKoSHwirgLHWFRj7vAxAxcqaUrJocD44jWlUzO2g2Dt/gpekRKZvw+CH3kUuZeHfMIE1pRQ9fTknZ8kgji/pmJFeBtMMbklAqzLWEEWVyQVDDNVu3ww81BRuAgL/fQaMFQQ== 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=7/vH9Q9jKs2GzlPx8DEoi1T0SBAlJ5DZXJzhZrsbsp4=; b=GevGLuqtgfS/OdwaU7N817b/o12cz4KFlsOkXpramlpZNVP1VLVIg9ov/9IoUiDQd7VDiRg/HlXO1erHChayv31FVvbyF7sqVhM4I1PrBsb1Z+a8EgCIi6lQdue0LXlseP4P/JkuXo+lSISxL8lSX30mJM60r+ykS4X51ar7F/RdDEGJEyghMgAhet7NWesiCZ9iVBhK9drE7Z/OcFkeFq/AjfNglI1YPvgkh+qPMqLUXZQDTn87a5yyqftUVlILu/HC2iWvsyqZkDYxDSWEmLVXR+cso0F6SGy7XqgfDkCI1nW5nL2bg8vZN5E9RjBaxB6j8UcJe2MvTPI2iClxug== 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=7/vH9Q9jKs2GzlPx8DEoi1T0SBAlJ5DZXJzhZrsbsp4=; b=U3Vl78QQwjdHhVCmURIJv9HM5N5OdhaidFv8UBto3TBpWYcg7N72K34jy/K4UyYEP7askgQCvOx/yTQLWEC5kTwsPavJ+klkjSO3rXwmtHOIZtfSnXXaDKhZ36D3ofw5PCoKkzWsaREMbFM13SeuCEe+AT8gGLk00LdFA/LS3XM= 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 AS8P193MB1925.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:3fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Wed, 11 Oct 2023 18:16:13 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6863.032; Wed, 11 Oct 2023 18:16:13 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v3 6/6] serial: omap: do not override settings for RS485 support Date: Wed, 11 Oct 2023 20:15:44 +0200 Message-Id: <20231011181544.7893-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231011181544.7893-1-l.sanfilippo@kunbus.com> References: <20231011181544.7893-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR3P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::9) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1925:EE_ X-MS-Office365-Filtering-Correlation-Id: a446f01d-0f94-44fe-f897-08dbca862727 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7w5gboKttdz/qV5Am5syTj7/z6gQ29fipRuq46KvlKxKuFZkVFT//Eht2JFIvO5u0yM65ikKeIU1j0LcAwWwqypmc9obGZUWlQOOrpbo7J25hTadwmW4pTGUP+plkg0S05sxNsO8j+I8s7Cce9AqT/IcZn2mLbt9HvqCdbqFzzuM8VMEz9TUW1Qlo21yKg5Ba/sAelwgu+nB9QlIL9uCMduVrKn1E11bq2RJfxiBWSClsIAtWfWDgpU7BcNYXtTe653MjfC6kUUTyl2SQFB0PK0kh3ImttRKh+rIOK/jqKW90HQPI3kL4+8PbYweEDKu+rcOYgVT7dAt5Py8w7A968nrGQol0cnBHPA3lkLeDhby3QnOEBMuPB33cPirg1IkcvTcZ9fDe554GxBvBC8vy8h/ea/mdr4qkPpR/kzZl7dqzg6Tw1rJoi94phzDASLwcw5/x/p3WUJ040Cu1/uTCw2/PwhZIKf/uR0KOUheUeEst8XcBQd83k0m/xPl606mLriH5NPLkl9/6ivJ9WsjjLbqaezSX11G1EuyEr5uezODTX0rlnDNSmo7sYDOY2Dt 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)(366004)(39840400004)(396003)(346002)(376002)(136003)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(36756003)(6666004)(52116002)(83380400001)(6506007)(6486002)(6512007)(1076003)(2616005)(4326008)(41300700001)(2906002)(478600001)(8676002)(8936002)(5660300002)(7416002)(66556008)(316002)(66946007)(66476007)(86362001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ih6gXcvcdV2lH/hnOb+5pdWSGdpUQm861V+JvN4/jH6Py3x9a2fwfchoE57YpiicU+FxMJpQyXPfnS0wdK3SoHclQqPEKINOrY7Y+xhIVV9XYCLnPK4G8Y6p68uIw5TFPphHNz87oOew8BKrCCEOvTa0lgFvU1uOx2kInU0aiEc/MJtY3U4yZA6wRTpovdKJtE06pxCwzozz0IldcOLbqTHvKuE3Y2t2f3XYKypa28zSz0kyCn7Tc//jhZXBTfLpJbeYL+8Ty3yzLFJqov+yjkHJtTsYK1+iQLq/fC0sdxZoJ7pR04FmF/CRLUND0Uf9jjzbU5ySDJZkkRhJTqurycx+X+LT+AvGZTyFcPqaOnnWR8WmaeYO68Erw0EqlsVzJ0BXRXlKuanATtsLf+yY8bpECwdi6Ad3DgkFx1JdNd8Gr/jDr94Nyv5qG0bxlAPvAwu7soq0N1Imc4wZ21hiqL3e4Ponqh7SolOdc6fadsNH+lW5xak3kZy8gfxOrVat7VP7VnMpLQzuq5PXddB4pg4R90sSWh0m9tsiJSqID1u8Lha/5v3TCMhDotFI4lYXRqqFj8Y7ST7sq0d2GTSUHcyHVh5gitC2UR8TpQKLEJiIgx007CmiD31n0DdyNpQEy3fhAx0DLhg8jTERTBM25/ULTISUOj+/sbfZfmCof14NMJhVVr5jGsrr4fxCnnZYXGDTkSgPLxfVWN5tPuUqISsD1zE8H2ir4mTxPiqomgr4ePSkIayPUq1Q8bQYxVsCLb/ijPKfk/hVMpMAfDJ0q2Kv+ndKShnpdhFwBVYqZUdxOaL+vvpL3vkao0cHOhog8sr9SK7vQicXl3L5TUclJzRbhsKdxUqKJxRayXhpizo1kabZBnfGeEVElLMPzKp+uCdA8jNrZyR2vDIt+lYVV4dqsnWnpDPSDqUc00Gxy9xAI3hnCU9X+XeRBfOO+DuaQf0I124u2pPKXwcDE5uzalF2cj56EH1H71Fe4zTwRAMivKnBL+rrD6esmG1dke5A8vn63nWg05XM8TChEPtyxGxsGN/5acYFTuuP2jytC+XtI2aVbOXgEZWEZCUwRfj7k5eXk+hIhbXu0QVHF1Zba6cMeh7PNO8oVQrA0DBrB4Eg0lg0vQtBZl+sqJSUIViDGWeTvOCifr49bQ1V5s6hV54jpcUjBSRS56RdKy3eX3w79BwZ6IPLUfD5Oorm6OIH3gDgsKq+VgO2w2J2uJ03Jx2ydXG2R6eCrORwrGUk+6AmsVhgIqnG3ZNQ+kHuxBWL+QyTuTEvs1gsuwe1UBoJvR5T6DO+SrNrF3tyl+SS5y/en3l3RVIEk1M0TU/4WkPWcYkUYQkBeKGYQ3PW4RsQbV6QBoFSZdPFhIB1EfVPw7thURSggXtwvGFDk2bUwTHoH7GKOi4r0VmxyQ2VpuYBHXGlTYUPXmrOtB/0SZcTMAok5RCVQyJo2Mxe+KrvF8i/HjGQyv/WI8eZqBOKYLGLD3pZ2NKQam6HEG5kYNFHxnzwp0+jgeWrF3KSnZBeODxrVfYydiODjwDUpGrxh5NeJVJHKO+9Enuc+GkDKcqS1FckQinQcvFsK6Rs9BkOW7r98UpKNMaL/olAn6p6DtfnD6yNJwfQ32Dt92w2KUIIUJqJj0G8paEQrgJbihTqQcKf X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: a446f01d-0f94-44fe-f897-08dbca862727 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 18:16:13.5686 (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: CqHMcAUc6bKZCMmtEMFn+zx0LMPmplMhbZiJlg1u9qjMZ3LQC5MToJ5aDE0F7w1V5gCd0fAQH3xgqy2Gdge4Sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1925 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MIME_BASE64_TEXT,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:17:04 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484041546621185 X-GMAIL-MSGID: 1779484041546621185 In serial_omap_rs485() RS485 support may be deactivated due to a missing RTS GPIO. This is done by nullifying the ports rs485_supported struct. After that however the serial_omap_rs485_supported struct is assigned to the same structure unconditionally, which results in an unintended reactivation of RS485 support. Fix this by callling serial_omap_rs485() after the assignment of rs485_supported. Fixes: e2752ae3cfc9 ("serial: omap: Disallow RS-485 if rts-gpio is not specified") Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/omap-serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 0ead88c5a19a..4f7ee4392034 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1604,10 +1604,6 @@ static int serial_omap_probe(struct platform_device *pdev) dev_info(up->port.dev, "no wakeirq for uart%d\n", up->port.line); - ret = serial_omap_probe_rs485(up, &pdev->dev); - if (ret < 0) - goto err_rs485; - sprintf(up->name, "OMAP UART%d", up->port.line); up->port.mapbase = mem->start; up->port.membase = base; @@ -1622,6 +1618,10 @@ static int serial_omap_probe(struct platform_device *pdev) DEFAULT_CLK_SPEED); } + ret = serial_omap_probe_rs485(up, &pdev->dev); + if (ret < 0) + goto err_rs485; + up->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; up->calc_latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; cpu_latency_qos_add_request(&up->pm_qos_request, up->latency);