From patchwork Thu Sep 28 22:12:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 728501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26368E743D0 for ; Thu, 28 Sep 2023 22:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232584AbjI1WNx (ORCPT ); Thu, 28 Sep 2023 18:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232527AbjI1WNv (ORCPT ); Thu, 28 Sep 2023 18:13:51 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FE3D1A1; Thu, 28 Sep 2023 15:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1695939214; x=1696544014; i=linosanfilippo@gmx.de; bh=m4weqzXnsQgnMts6TFaFYqbOaRUWzpTcPEjf6E+HoPM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=O2K6GDBcsvy/X7k3qNvCuY6yHPhAHspkfoSpIamF6aP3/YSxuXb6rvD/AAePbgSvoGI5tOJSqXY IpHIdujPHZdGZ5S5pF4pG6zBlOf+rZcpMrzyGugN+b1QSHSIsMRbPKamFt2Xzjk5LWXaeYeFXO7Vl TL8QL04aV3NiQtKqIacdorilnWlCXDTz5jPNtPz2+VXufzhDl2EWzKklwyzwTlHqmVmT1QzyW8jlK YpkjfOGXvpJhBoB+S5D23WTqbEyf6dIIUxcdIxooHPZwVn3owJFsz+hYsXPyRg/DjTrwV2wcWz6FV R9ezsBBaQGlvjvnDiV6I4DqAat2TB7PrarDg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.21.41]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MVvL5-1rAufz2U8D-00RrSh; Fri, 29 Sep 2023 00:13:34 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, ilpo.jarvinen@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH 6/6] serial: imx: do not set RS485 enabled if it is not supported Date: Fri, 29 Sep 2023 00:12:46 +0200 Message-Id: <20230928221246.13689-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928221246.13689-1-LinoSanfilippo@gmx.de> References: <20230928221246.13689-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:+P81Kmr4hyoqergClf8xEE8mnhWpYVoCtypzwglXZWjyGqQWYLH RQKuksnXluP2TFFn63tcKtyOy8tLk5h25mkqMuMACecbLZ/rnIOLR3pyzsfY+N/+ye2fuUr /umOamJl3sJpsfNyWime4++fMNirZ3gwGxenxVq1c4BpOUi40fBiAHlhMpZioQZGNpt15bB r/qBmq/LmoQCrbla6OjHw== UI-OutboundReport: notjunk:1;M01:P0:SaxcjmS9I4U=;tOhBjxhnZQ7yIMQ44q84IDoko7I +6nOqPJefUEWR6mxq0+Ty2mlVmTeSscj5yL8lvJitdT+bw23I5tjS8Ff066yzD5TqNCH5MfxA MCLe/k2zmw9QLMRM49RZEYLutlLz1Hio6BPmmb79N/ToG7DjC6nq5w42twqAwpr1KSTmF83Rv AgW7W0m60pAKjDY4URiPB5FVuTEpNT5o59ej5f7+divlzQq8NPDR083xAvqdxBGpxpLByGlPq eEnLAP6c9RVP/xkKImXpfTr2un23yJoXskFBsv2sBCwgrkdD3x20ChAvmRE9IRVI4CDSB+IRq vVTpd9NcB0rbIbq/+Ezbca2DMrNfoHh1tkXUKYFoPKT9PLIeY1cYVWx7/yt46ETTlF9qYSq34 4XQPdjqcsqNRGkC0Jva2murcKazTu9W92UGWpc6YutjcZ3DgSihzQ1UYqdnT4e2jnbdc7GQLq p36J3m8PcqpTHa26HmqjjD3c3PFfoIh8rhmDh/JiuJNEZOYXzhoX2gbELHwn6KuDB8jCvy/aV n7oPv4sMZYqoYcZ+keA3VCC7khwrmuja7voUpF5eo0ocA9rP4FLwEtwxGcotStxD/wyKTgeRA qbSMAp3xh3z+5DzO3VZT5ghVQOWRsfJ4uSMetn76wXkK1ZOChx2O41Iyt/Am751pFl1YkK85m XVlqaYthFaPe9xIeQfctlBY+AzbiXAmb/Fe2KIMmxYUIXxEiFNu5klZJZMV6xzLO6Ddh/noL7 X1F/MzRQKcVec6S1tFrX2RNP+uYD8ypt6qGJdnAtipfu8ppGrxUK4WQKgIq4ZymroQzzI1Rwn OGFQfDavflKn2vd12dd1uD/ThLPTNLFtZ+ekkzID9rCik9laKWfUPvXtz1xUYvqBGlfAgdatj uTnJV20CDfx5MOugZYxknlDxSH3qNoKjypubfh7PaE4qVCSmuJDU9CeWdV17VAEDllccuYpno UYS4LPQtjjsvM72QBWS0jL/8+7k= Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lino Sanfilippo If the imx driver cannot support RS485 it sets the UARTS rs485_supported structure to NULL. But it still calls uart_get_rs485_mode() which may set the RS485_ENABLED flag. The flag however is evaluated by the serial core in uart_configure_port() at port startup and thus may lead to an attempt to configure RS485 even if it is not supported. Avoid this by calling uart_get_rs485_mode() only if RS485 is actually supported by the driver. Remove also a check for an error condition that is not possible any more now. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index edb2ec6a5567..87689abc21bd 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2326,16 +2326,14 @@ static int imx_uart_probe(struct platform_device *pdev) return ret; } - ret = uart_get_rs485_mode(&sport->port); - if (ret) { - clk_disable_unprepare(sport->clk_ipg); - return ret; + if (sport->port.rs485_supported.flags & SER_RS485_ENABLED) { + ret = uart_get_rs485_mode(&sport->port); + if (ret) { + clk_disable_unprepare(sport->clk_ipg); + 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