From patchwork Wed Jun 22 15:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12891019 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B61DCC433EF for ; Wed, 22 Jun 2022 15:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TD2u1u65Yyo9Y32KryRqqEf+fp6tiSALChts5JWItkM=; b=QRXqa11EZuY/9Q bFAM0CG4vanEmG9PQqcUu6bl/kMroUezBMemyiUuwmSmcEmUWn/CPjf86NP5OoHBQxMlytoYeDLxp A85R82Y7Sw7NBLt8LCPLZaAZYvGjyfAXgqVayWoItNj8tCy7aoUo5YWJstxkQZ+Kdacc+AdG86oEc jgbG1rg6Cv8H8GBOROOr9Y5GUG2griGtT3AJvS9YwYNEdDrYmvZt6dLjS0K5CwqEtCR65AwzJM4jZ lKSGvSW95y+wqPRLi98KyfjLVpV4HvufvzfsjxjMNG3NRJnoi4XhdFkfZpYz2/A/OZ8HRbLMLDRpv 4b7k8Mtwch2691+prVmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o42ai-00BFXl-OC; Wed, 22 Jun 2022 15:48:28 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o42Zs-00BFCF-KU for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2022 15:47:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912840; bh=8IFGxVS1vl5JLWh0yU8Lv5GqvKfBZ2iqkV27iNYuWh0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UVO+cw9CkqDJWgg8c2KKc/7SdSzueQAlaGe6XDfOE7FC4NpxX7octk2+fWE+Kr2RX cXHgaBmUuvmXdJx+w7v9FLCByTAcz+j6Yhz/pu7eulb/7qLAnvZjBr/6B1CPSkw417 /1Z97pBU0JgW3m9r3Okn0lI2i6SCiLlp4KgDKFWc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.22]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MV67o-1oDQn33Qnu-00S3PO; Wed, 22 Jun 2022 17:47:19 +0200 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH 1/8] serial: core: only get RS485 termination gpio if supported Date: Wed, 22 Jun 2022 17:46:52 +0200 Message-Id: <20220622154659.8710-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622154659.8710-1-LinoSanfilippo@gmx.de> References: <20220622154659.8710-1-LinoSanfilippo@g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0zRCVqR3/+b24Tipat2p4JQeCO2DNHEKhY8Zez9COqjyGM42 qLig8Ymt1r+N9gMWHIxgJwW6mlOzTGio/8FARtTR2KY9r1BfawuJj4TXXzNajc581Bq29gAPk JhIj2P1x796luk+pvaaGkX3uh3/LuWAkwwaJjEyRgqH7H2/wvl0kAHuyOkAofTgWl8ci1Eb3i c+IG9X+SYsAf8blcz1YMB3S11J3zwf10zEW47ITQcZIMi6izTpz1k89LO0gNX9cMplBDP5m2o 0SpSlWnxKqbKppyHljPuit5XaqaXHlfpjINBRzqy9EX2Fa6fcBu7KezCLqryGeDqp1yfaiDLG AYKzEY6JlRtf5fj5HJRUwih4kjk0ham0LorujXrvE96jqR1uj0cfWOknw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220622_084737_007549_347B2BC2 X-CRM114-Status: GOOD ( 12.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lino Sanfilippo In uart_get_rs485_mode() only try to get a termination GPIO if RS485 bus termination is supported by the driver. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 1368b0ef7d7f..015f4e1da647 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3384,17 +3384,20 @@ int uart_get_rs485_mode(struct uart_port *port) rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; } - /* - * Disabling termination by default is the safe choice: Else if many - * bus participants enable it, no communication is possible at all. - * Works fine for short cables and users may enable for longer cables. - */ - port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term", - GPIOD_OUT_LOW); - if (IS_ERR(port->rs485_term_gpio)) { - ret = PTR_ERR(port->rs485_term_gpio); - port->rs485_term_gpio = NULL; - return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n"); + if (port->rs485_supported->flags & SER_RS485_TERMINATE_BUS) { + /* + * Disabling termination by default is the safe choice: Else if + * many bus participants enable it, no communication is possible + * at all. Works fine for short cables and users may enable for + * longer cables. + */ + port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term", + GPIOD_OUT_LOW); + if (IS_ERR(port->rs485_term_gpio)) { + ret = PTR_ERR(port->rs485_term_gpio); + port->rs485_term_gpio = NULL; + return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n"); + } } return 0;