From patchwork Wed Jun 22 15:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12891021 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 C54AFC43334 for ; Wed, 22 Jun 2022 15:50:04 +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=XACtYyRwM0qAoxED1aqVt6mCFOCq3jkZUTG7JiSnzU0=; b=ikhy1FFOvp3f91 bQi90rmTumOqsLSkOlKJgZ/z4cgDavPhWiqA4MVgrYBj+91P8txuuZjP8/jbZbvhcrm8bjHyXwzKt MPXp29S9+RKQU1sihXGrwm5or+7DopG/ycxDcjR8Zc/zqZoZleAzJOlWXTkWjMQkcXIld16DXbfvi CGQbLG2zLohEt+2jZtRYoNSCeuMwbKhVfezZ51FEuu4ENKdbJIbPKK3tlOmwUGXL8BkQ9feb8dkwB s+BcrQwMCTtRWc6I3H9oI0v1mQhSx+cNjhw9D1mLyP9x0z/IBZ7lWcEKvRfL3m1PQQSwt+aCTsBDE f/elyOEWXXW//EzmGhcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o42bJ-00BFpn-P7; Wed, 22 Jun 2022 15:49:05 +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 1o42Zs-00BFCE-KQ for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2022 15:47:39 +0000 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-LinoSanfilipp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7MkdiOiHIVo30HaPB/mfBeY5g4CWfm6wiLcen4aln0gGldq 3c7Xg2fvWhPv4OSW+EUNHeEmDDSpjyBOiH6/J6CBxGbJikVRifSMKaQCBFOvlKMjEy5CUiSlz 6zbKydB1rQ/2NiWJSkR8tyQO15jhvuSKgje8Wxd2+DQzFpkCo9YOcvLNJ66QVlzxQqFfGHkxC XHVxcJ2MWX631NOaGQk1PXbnuc9zv89L1FgFl6T2c2iahVicWl7Ep916xuHV/6WjskNvb+GG0 Y+58/8YDEY9jPkSWX5rYiGo6anGAb7fnSHbL05m3OCP5YgmajBDo2nYnc098DMtvnUd7qykqZ TSJWhF3uQgRTZqa/BJVBTHXcpsYcEv7CH/aXxXGNR46g9o/q1lYYJ+nlw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220622_084737_013062_68A34089 X-CRM114-Status: GOOD ( 13.05 ) 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 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)); }