From patchwork Sun Jul 3 17:00:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12904419 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 1E7B8C433EF for ; Sun, 3 Jul 2022 17:04:55 +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=DZ53VkwIsv5HGG/0PH3KYx/GX0tqE2xeHXWSJZSsUxs=; b=Gt+7wdUQt1R5m2 hfxWHAi/V93LqaDcLF6s3JpulFD6i7bPSbEyajjoqCLauzvtqH3CUME3iZMuP+gUuiPQpQOvdKEQU 9NG2ldA876amSVckeq9hv4p8hSZ8a4RG8AScF7fSXIPwa4SSF7HpVV/5nXDg8dApa9ycJMBVWJvBb L3jxGYfFxlehI+JhBBNR16o4dmB3e5vzIa7gvH4YV5GmO5dVH2G2mKsKRCIQhq8MXP9AjAxqUcGUX /fsF6Lt2lCO1y8Z2MJgEghjMbN0+rvEV4w3wEsFTIr4oZNpn779o6IcBvACtQKV/r7/wqCn+la2t2 MU9QqhgRIj76eicEtQdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o830Z-00HNbA-EP; Sun, 03 Jul 2022 17:03:43 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o82yk-00HMVl-FX for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2022 17:01:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656867691; bh=jkKzvX9K2yUOdQWW1Ju0XywTrAt4odrCEHF4kNehvBc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UsQY0Eai123tThH18I4L+xXnQcNKmJgvkHWxF8zb4fdxOkrVUwgCizd6xALGqoQq5 1spIcHUfMHUlCcc30Axgx7q+OxCdmdaDt14Z1Pp3DQ9bPq6sh8jxy7nD/GQSOUoKcv DmyjNLzs403GFvdxsFfK8t1JpRu9sBolhFuI5kb8= 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 1MTAFh-1o2mQ805Dr-00Uduo; Sun, 03 Jul 2022 19:01:31 +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 3/9] serial: core: move sanitizing of RS485 delays into own function Date: Sun, 3 Jul 2022 19:00:33 +0200 Message-Id: <20220703170039.2058202-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703170039.2058202-1-LinoSanfilippo@gmx.de> References: <20220703170039.2058202-1-LinoS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VUB2dZ+6Sa01/X6y4jwk0e2TSNuuKQaAF7G/dF6mhPBo9S b0/u1M2qPPzWorvxHYU/u4VkBmx3AGXJDAhkTU5nyt3BZ0TimWcKrUq0foNksNwHzhY6vGDC8 l1tHudumo7mx88Chc4dbxNO1o9ogoEvH87HnoKvZ8/qg/iz3ccrHjEzQpBfHg3y4Dt/Y24YxJ +6bCos7IRBbKlgrXReSLDRbXRkENHLoG/a6blFNyh8Kcs2Nhd4IQqVy3bNyGdsyIFqgK4422F 0wA36G1RHePgcNP86hn6/QEQziIrGbx/i+IaKTJ59qU6BrIe6MBZ56vjbu6ll3bDU4lyDW6aV h7Ua8nDsH1H19zG06xBk2LDhaGL5he2BflcVjwwrf+jPZ0WsImSZ4JgsQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220703_100150_880237_0F3C78E3 X-CRM114-Status: GOOD ( 13.78 ) 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 Move the sanitizing of RS485 delays out of uart_sanitize_serial_rs485() into the new function uart_sanitize_serial_rs485_delays(). Signed-off-by: Lino Sanfilippo Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/serial_core.c | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 9c29d031b404..05ed3acad09a 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1302,27 +1302,9 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *r return 0; } -static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs485 *rs485) +static void uart_sanitize_serial_rs485_delays(struct uart_port *port, + struct serial_rs485 *rs485) { - u32 supported_flags = port->rs485_supported->flags; - - if (!(rs485->flags & SER_RS485_ENABLED)) { - memset(rs485, 0, sizeof(*rs485)); - return; - } - - /* 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) == - !(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 (!port->rs485_supported->delay_rts_before_send) { if (rs485->delay_rts_before_send) { dev_warn_ratelimited(port->dev, @@ -1350,9 +1332,33 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 "%s (%d): RTS delay after sending clamped to %u ms\n", port->name, port->line, rs485->delay_rts_after_send); } +} + +static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs485 *rs485) +{ + u32 supported_flags = port->rs485_supported->flags; + + if (!(rs485->flags & SER_RS485_ENABLED)) { + memset(rs485, 0, sizeof(*rs485)); + return; + } + + /* 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) == + !(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; + } rs485->flags &= supported_flags; + uart_sanitize_serial_rs485_delays(port, rs485); + /* Return clean padding area to userspace */ memset(rs485->padding0, 0, sizeof(rs485->padding0)); memset(rs485->padding1, 0, sizeof(rs485->padding1));