From patchwork Sun Jul 10 16:44:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 589328 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 AF3CDC433EF for ; Sun, 10 Jul 2022 16:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiGJQp6 (ORCPT ); Sun, 10 Jul 2022 12:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiGJQpa (ORCPT ); Sun, 10 Jul 2022 12:45:30 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7CF413E89; Sun, 10 Jul 2022 09:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471497; bh=+8xtH88YOOLsZPGBk+8MayK28Z9P5RAmhj5fFk999no=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jfm793oRyRcXyfwlGzzOSIU31lMCstduoZgtZd0UDoy0z+B5C3QRzOLGIlORDil6b qvxegme7Ka1Hv3wlD93nO6+bUBtCavSHMobIl9rHPyFhkliQWVwxDw1gR/6MqZJZf8 uH1e/HXkrx20TgZODby3FbHz4LW+Oom5bjieN/ag= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mz9Z5-1nNa8Z3urr-00wFbb; Sun, 10 Jul 2022 18:44:57 +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 v4 4/8] serial: core: move sanitizing of RS485 delays into own function Date: Sun, 10 Jul 2022 18:44:38 +0200 Message-Id: <20220710164442.2958979-5-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/B4QTguHrmwHQ+n+io6jRV1yTm9GIglViqwMlUnseveP4s/0FGJ YhcgE0zBR36vqgdwY71AnhhcetsI6YPnFolco3+Dj9YsbfJ06w/3ihOZPLvvrAyK90ilfAg OHkxi+xJqlgXlApudIfuir6Ja+uv1y1YvLCWFUMkaKPi0CE+37rYz4c7UQwMlnP3kAMTHgp 9l0lzRsfN0qa1Pqkmx6gw== X-UI-Out-Filterresults: notjunk:1;V03:K0:AMXfJa/0vG0=:VlvViT77U1oKOJG19IuxGQ AGz6OUxHm27Lcg2N7oS9RUGSgs1kX9+p6+gsuEQxXDCkw/QTvqUplQRdNPHBZSt5mP5e+WwsZ x+NsaH25xoXM1WsRIYZdNUJLxfqWxEoS59lSaqXtRK/3bBF8gdjKG4KWvfotsABrM5iSE0C1q MkmbtLQUMVnaBuOa9Hoglv9N/xfzLI37Cfg5hIxdG+MbO9blic1qAXog0cWBCRPK/W+x66duB 2jT/+Odd8Ft5twBvffNQSQGQmSyl4S5DsrSDdZ9BXqdMSPC/8CBkyaYLcHksXcEMZmBdRhDi+ gLEiP4f69GalR5U5xt61fsYq/HUm/c4D+DvvlxSvhXeLpXSs7wHQq5DnFConnW/uwnd12PQxQ CD3bKEsf9/7LwysRiy9zL2dYrjj/VkPWdxfhBbB/SO6LRxAj8mv39l+mdAb927kpAyxd2p+/V MNPo95t2yt8kwP/iYX6/SvFlInubnZUS59DmWVXFDvKoC4zFtTO4c1XJLor7cbPZe4BPRBLR5 L1h/X0BML9eeH4Q+OsegGEQdYXXdtebCUpYrLAZZ+GuxhOh3atUYHlRjgjf1gATfN+6U9dfP+ mhFo0l1S2cKpzS5zqr0Psgwf4wsDand6JEB6cr6eXIMEzly3VQmAL2QQbdCfNJOgRAmbdMm4i VfyhUnzY6I8PWxP9GkAeMscM0PDzwidgTwaFaT986uh2+7QMIUUeUlIwBjTb6Y3BaTOm4kRBG wxLsQGjxv609NKiYlB+em/agJ3s4J6rF0eAAeL4ERC5YGItU110r0lUOCOZwDShvL/CZ+2aau DvD3Ln93fvmxv6OEoIizJNlefXJNDQKQ9rbwo/fbygUkoNMtcfgfoB0Lj0NbK6hsIRIkbKlpc 6Eldz5GWPruXZU2J+aMhFvqN7q0/cD7eqzzXffUNIsGRZDEw+ISlxPzzR5Oa6PuOFbR/wB6CX hgwiYyABhy3VHow6zpXdW4YmGB+zv7Rm+UY6vM+oeYwm3AVHePtD7JQrdSQLFgdm81gsMvtc3 R/w5KKj39M0ugXlmLQSxat7A+GJ1LuvQI3Fgl1F9gl8pIubr8smD8P+UazWx4b8aDb6e6Su9u 7WJQCHZ7ukMVMMRMLpRKvwBzayiaRuBNhQQkjMzPkNMYppidAAGf7+ebg== Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.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 047ec51dbd41..3158f05a328c 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));