From patchwork Wed Jun 22 15:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 584138 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 39B57C43334 for ; Wed, 22 Jun 2022 15:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359557AbiFVPrz (ORCPT ); Wed, 22 Jun 2022 11:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359515AbiFVPrs (ORCPT ); Wed, 22 Jun 2022 11:47:48 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAAF13DDFA; Wed, 22 Jun 2022 08:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655912840; bh=Rq3KFvxDtHALFh/DnfsS+evHIUI8vMe3n1/DQWqfHUk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=XZgcm2aBHskXKxiq1sdoU/43+QwTkbYSXsznvKnZHkWP4CKG+g7l3NCchoiBEIASO B8/Vby+1wlyuEGZz+T0B7DidPFM+D4hvQg39WtlLzGMjgcqMhcv+coNCt8+hT7tYXT e2fKbQAEGRU5lD+ltxxhFJqOb2QaYQCPFtxuIE5w= 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 1MpUZ4-1nL1am2Tt6-00pvse; Wed, 22 Jun 2022 17:47:20 +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 3/8] serial: core: move sanitizing of RS485 delays into own function Date: Wed, 22 Jun 2022 17:46:54 +0200 Message-Id: <20220622154659.8710-4-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:dCXH7+GWeAl4LLMvcxAw/fQZwalG9+Q0N9n2K5X3mltot8aufOr a8QPrBg2BcpkehxEVEfYsj+RupRw8ld0OVbpgqKeJ81SaOV9GahIzZhkoM2P0rT3F4OTHVe n0uYYWPpwxrZ0dPM5Pr/CLtk+ipDxGZuiYItznVAa/DyR5DDAk5rrpIZahEkRnMQiDRQe43 dKYpZ18+7ncDJKL8HCLMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:XHc42tvAbiY=:b4cx0cCtuwlmp9ujNfsxpR y5IqNGaQd0LQFZC+yXxyh236zCMLFJAWsAAB+GTim5bhcEkjZ9gKPTW3Z2XtRlDEYvPRhFmUo l75WPgilFh+ARmzDgTIFaf7oi7YoPPmkeoPjXg+3HffqR1zIRKLqu94dwqKdqD8I0wAGCNn9m LcDdvnD40zPyE4vTjB5oKncTQkWwJInRCFyi5yi5+ZZNbBiPasmjFscX4mlYnR60lelleHkXG Z4lDx4LVYt2uCpYNme/4BuSFcnru083kqjlibTPIYuuLzsu/ahvNwSGRjRmUtBLv+7qrax1cR BbJ4DEghTi8sAU2Uo6Jr9hxz0wBS7qPOgOrUS6Fx13kr2EKe8Zet7zdYT9BM2eQiVy+qmMPsA PwOUteVdaEBKbLugXgHvWG3uI8LesI/2Vfj95jMFYnImRAeCtntmp41b+uGN2uNUDQNQZ9t/Q //fy/5UWrrN+1xVMOPTHhlri30clMjAywBvD9gAZkXHwlJOrVnp74n2oX28MCdiH7+cr4tXrG DxPZE7uZsAC/CMUtjsE2UXRlBxftwTtNkA2lH55IiwxiArIbNpCpRkmFYPpm6plCZgpZtQyBB ctH8Df8PVONbqSy+eFWxHVRsSpDS6tEfym/t+7zeuMF+p73vEN15HkDPKYy6SMLf4+5gZKBbP LZ5dfvzk89iEjIyGSFrmxSWutoryJDD0zPWcrQMwTsY9rQIoyEp7uJ2nErI4KSwUarBa5oMjv DwlWdU+qv5hHLdAI/tjRxq+Ugn7MkdiOiHIVo30HaPB/mfBeY5g4CWfm6wiLcen4aln0gGldq 3c7Xg2fvWhPv4OSW+EUNHeEmDDSpjyBOiH6/J6CBxGbJikVRifSMKaQCBFOvlKMjEy5CUiSlz 6zbKydB1rQ/2NiWJSkR8tyQO15jhvuSKgje8Wxd2+DQzFpkCo9YOcvLNJ66QVlzxQqFfGHkxC XHVxcJ2MWX631NOaGQk1PXbnuc9zv89L1FgFl6T2c2iahVicWl7Ep916xuHV/6WjskNvb+GG0 Y+58/8YDEY9jPkSWX5rYiGo6anGAb7fnSHbL05m3OCP5YgmajBDo2nYnc098DMtvnUd7qykqZ TSJWhF3uQgRTZqa/BJVBTHXcpsYcEv7CH/aXxXGNR46g9o/q1lYYJ+nlw== 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 --- 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 b387376e6fa2..fa6acadd7d0c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1297,27 +1297,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, @@ -1345,9 +1327,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->padding, 0, sizeof(rs485->padding)); }