From patchwork Sun Jul 3 17:00:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12904413 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 00BC9CCA473 for ; Sun, 3 Jul 2022 17:03:28 +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=4aOYTDE025Fb/Qj2ZQ5QgmtaniUm7u0EC7YyIVqXVCE=; b=mkvjJiUawxD6oI wBfjaFK58GdM+Pqa00LX3EH67UHWBKsvAOdgyr9I2/wv4NnFViCsiIT9rEazW3sTraf6ODlhgUhmp wO0N1KqBxFEcODlqtIX5zoLghxr49STB5Rckmoxk3q3RuOmyb0bT0U2vrVZOxELXel+wzDrQwgaF4 yCWHK9WpfBoAcZ30Q4G6LmHx0/MWZ1ORlUvrdmQ6MRO/gXb3QSVpEtGVbSQNtdZA6mmhQjc9rV9iQ IF20AtgEomnb8jj8obmtJ8vUAKpVig89p5KQ4BOvPrwhXxZxSSnLEdzN9KSFiBlHIjp5xU2Xwdl+Z MIIIHzz0mGf3AawtIETw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yi-00HMVH-ON; Sun, 03 Jul 2022 17:01:48 +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 1o82ye-00HMR6-Az for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867690; bh=C3f07IvyTVhB+y3Q1h44bhbt9vRcIn4vLfeS+jIHjl4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UWg1iEGo6CeHvfMMIMMD9CoHT0jbVNvQN+at0B7mf3usRzdY1V7YQN10p7whaduf4 Td0bpGFkBiZCRpROiY5W9x73UZkSpbeA/t5AzYKFhrP1WuM814C9xzxTtXsZBNGIlP dB6pbCgMy25/R0iizdNEA/ic2poIFkzPTjOdMz2Y= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.210]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxlzI-1nPIwu0lH4-00zFlf; Sun, 03 Jul 2022 19:01:30 +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 v2 1/9] serial: core: only get RS485 termination GPIO if supported Date: Sun, 3 Jul 2022 19:00:31 +0200 Message-Id: <20220703170039.2058202-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-Lin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ssGUHiiFbvIXtIjXANGBuKKR3JQThK4EKpyEHyvBXHmYHbBQ4QFmrWFx/HB+hWf9 VooZW9sgqranC7d3CHKIJ6IBt9HA+ydMKIq3+u0mPzFYpkTdvhKJqih3OaIZkZANrEYjs3Xr2 zd7aPMjN3lQs7ttcS+cemVL5/cx9y/LJP5E/g/9CVfMM8AhBdJP4CLr+PxKss/ytWIlCqii5E EDNU0mxEcx5tReyg3e4RgSrdRGbbaa5HXY63IXXyVxSzzist7x5o7vBAo6+lj2HWffuBFWOwB fFo9DUBgMHR2hBERTyicsUi/ugli6rcL9njTgY6kT+7WAY6X5l5nhNYoKyG7cTe6R2et0jLTK txuTm8H+E62W532aldkf+I/PVpgRHLb3mFLe5nGofHYGJQXaamKq3z1DQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100144_874238_4583C687 X-CRM114-Status: GOOD ( 14.33 ) 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. This prevents from allocating and holding a GPIO descriptor for the drivers lifetimg that will never be used. Signed-off-by: Lino Sanfilippo --- NOTE: This patch follows the design decision that "rs485_supported" is set by the driver at initialization and cannot be modified afterwards. However the better approach would be to let the serial core modify the termination GPIO support setting based on the existence of a termination GPIO. If "rs485_supported" is not a read-only value any more in future the logic implemented in this patch should be adjusted accordingly. drivers/tty/serial/serial_core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 85ef7ef00b82..3768663dfa4d 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3404,6 +3404,16 @@ int uart_get_rs485_mode(struct uart_port *port) */ port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term", GPIOD_OUT_LOW); + + if (port->rs485_term_gpio && + !(port->rs485_supported->flags & SER_RS485_TERMINATE_BUS)) { + dev_warn(port->dev, + "%s (%d): RS485 termination gpio not supported by driver\n", + port->name, port->line); + devm_gpiod_put(dev, port->rs485_term_gpio); + port->rs485_term_gpio = NULL; + } + if (IS_ERR(port->rs485_term_gpio)) { ret = PTR_ERR(port->rs485_term_gpio); port->rs485_term_gpio = NULL;