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: 584560 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 6B35DCCA485 for ; Wed, 22 Jun 2022 15:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359564AbiFVPr4 (ORCPT ); Wed, 22 Jun 2022 11:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359501AbiFVPrp (ORCPT ); Wed, 22 Jun 2022 11:47:45 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854893A5DF; Wed, 22 Jun 2022 08:47:44 -0700 (PDT) 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@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Wzux1oUdzW1pI7nfCPbfxqcmfleiTwvPyv2n9VmmFzCZ2/Dzw4V a9Sc1f4YAFcUhRs4jBHdjixFcdb4xPhKK3ZFyjOXGeX5mUGXETzXZFsgQollNQX2ZipkO0Q FLHbM5HCIlp9mdDiEjp6G0/1hrXNMpyVW3d/PTsBFcRH7g4mKyZo2oehzc2ZOQqK4PLZzvI b8zkGeTTbxKpW3/DZSMkQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ObLfviULXH8=:BUFD+zu2z8GYzeCsOjHWqD TyrqkX/lOCzkMy+RY/45i+3vUB7nd6K/wkPEAO5Rk6LnO1Two+tFsknemhrIkMUslMU2HJjrB AngOpKEV9nuDk4BvfIxTxtla/g8Xijq4dLm7dOBTpkM0vIoyxl8Xq81UYsuvSf1GLMBLjMRCx POAfAQyBT4leaA9Bt10Qw3FdewKrpRIC3mu6MM7VBZV6ymYjH3Q8NEC6J3U5hDAEu9ikf4hRr Rxi+VwJAACFftmCWGdZYiLO4Ywl7rSxNg6JRkeRcazh3LGy63GZ8puI6a5BjdMkOCe+MivsyH BMyiNZNEpSRZ1TvxKQu/6xacUAARfzOQ07LAKGj33rOHWUkL/o0K5RzidoBT3z/Ljox+cWwJq KCSaiCBIayfV7PUypWK5DCRHcYUPn0xH7PTKEJnSTgeLebkRxX0nQPmDuYV1ZIiMH7U8G2esi THgibLABCTPmhUBirAKgG8Vayb7V98jM91f8fC2FGtWLhHCS9OuJJ/+VAMi9IXKsEPTTLTfqy P8Bi80biXYRow0sXFmCOuGVrFtgYvnqkeawk4d+3IthSwfWTwquTZQ8XjLtjRUmycFKAbPtaP DSO8EISdXnralXN46F/wan3dwQJEXupLfpYykI6eomP2X7REeSh3/lJUD430R61RKpJlbcaXD uaIxC6SGMNq8zA/yqTfR6B8wcj8sD7XrOTkao0xOd6ldEMh9Hl+oOYmEdayJ+xTOA4ac1NQoa W/tGmX7kBrfUHa1boVKgWXmqP0zRCVqR3/+b24Tipat2p4JQeCO2DNHEKhY8Zez9COqjyGM42 qLig8Ymt1r+N9gMWHIxgJwW6mlOzTGio/8FARtTR2KY9r1BfawuJj4TXXzNajc581Bq29gAPk JhIj2P1x796luk+pvaaGkX3uh3/LuWAkwwaJjEyRgqH7H2/wvl0kAHuyOkAofTgWl8ci1Eb3i c+IG9X+SYsAf8blcz1YMB3S11J3zwf10zEW47ITQcZIMi6izTpz1k89LO0gNX9cMplBDP5m2o 0SpSlWnxKqbKppyHljPuit5XaqaXHlfpjINBRzqy9EX2Fa6fcBu7KezCLqryGeDqp1yfaiDLG AYKzEY6JlRtf5fj5HJRUwih4kjk0ham0LorujXrvE96jqR1uj0cfWOknw== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.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;