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: 587075 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 E559BCCA47F for ; Sun, 3 Jul 2022 17:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232443AbiGCRCQ (ORCPT ); Sun, 3 Jul 2022 13:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbiGCRB6 (ORCPT ); Sun, 3 Jul 2022 13:01:58 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7936E624F; Sun, 3 Jul 2022 10:01:57 -0700 (PDT) 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-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qyH35UB6OgK9aAsVjM0R4uFEO6UXYWIXW/DoeHKNA3Jzn0ON7NF HlAakeLXfnswVxGUTkH0ckJFuTnc+GsUF8aIYaQ7io/vr3twlSjDNY3Wx4d4v+TQn45uEER ZEHHM141I6Px3YC7/bZyXYZp/b4YwMH6iPkrbwd52ZGMdVAg3c5tthynG4o1aSqjAWElLtz AB0lmeed15siiWjKhy3zg== X-UI-Out-Filterresults: notjunk:1;V03:K0:BTn1/O5BXtw=:l42TZAJHEvnFUeUpI7Ge7Q hrCdO5OC+J2dpYG9om6hc2QquHWMenwZyiETFBSuH+hlir4rmNazsfv8ni7W8Oadc2FGfioLk 2kFzGyusvkL6DGEPyv1mMUWqYji3MQBMBTt8iqPQIRoZgfaocUuZMPrWFAH+7HDyBaGV/QqkF 1gwF6KAg39pz7GXcQlM16Z0VXvPf+UMOg5Dc3xjWeBhn/YwW8K2CmrVzGOyvYfSLeGfcetQiF yl5O2NjXCUqz1UaaA13uNAZRa7dcMbrHA3qA5tPWrw7ZRGzvsklRW6A7CHsxgIywIhEpSf8fu Qj9nOTbNqFghDSxg+10vFYndBtImo2XnVQHmtlhylF8k9rF4QdOcRKNgj/wRvLfE78SrEFqY4 mwh5qOpcCfYARxPg9veH+ClBMnH8oukL5ZYIN1ga2+K+q7M/zrtC6EwMVYk3KOkfDxCXErEon BpelQo/l+MQH9FXHULf3f/BwdGT6vy0nbhYUwel3IjjF0GuFuivgO0R9YWS/knYXk3e6DbncK K6570yZiW4t3lW+ZN3xqxSiw/OvuTwtVgQds/V+ru9mFfb6WNduBxB8iGMGtdt9RffC/7unRf +y925rk5IXM1xmjZ8rXwlwckvFGNypCmhktkulKzjaqwj+uOgdD7+2lNhhoyw18gUccC37PqB 60ncuGo4B2ymiQsSa0pE5Ld5ddqz/g0ss9e4X8e3D0KQhGJQe1uBPvpA6uqA83Ujv1UOI0zqs kEnwPo9SXeRecy2j7lTm9K39f6IVUB2dZ+6Sa01/X6y4jwk0e2TSNuuKQaAF7G/dF6mhPBo9S b0/u1M2qPPzWorvxHYU/u4VkBmx3AGXJDAhkTU5nyt3BZ0TimWcKrUq0foNksNwHzhY6vGDC8 l1tHudumo7mx88Chc4dbxNO1o9ogoEvH87HnoKvZ8/qg/iz3ccrHjEzQpBfHg3y4Dt/Y24YxJ +6bCos7IRBbKlgrXReSLDRbXRkENHLoG/a6blFNyh8Kcs2Nhd4IQqVy3bNyGdsyIFqgK4422F 0wA36G1RHePgcNP86hn6/QEQziIrGbx/i+IaKTJ59qU6BrIe6MBZ56vjbu6ll3bDU4lyDW6aV h7Ua8nDsH1H19zG06xBk2LDhaGL5he2BflcVjwwrf+jPZ0WsImSZ4JgsQ== 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 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));