From patchwork Sun Jul 10 15:03:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912554 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 E4EADC433EF for ; Sun, 10 Jul 2022 15:04:53 +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=jmhVMnGL0syRmpEf3ST5flj5TGuu7aM411slt3bQ6WQ=; b=1dpoRRFjP2mHEJ lN0iAD7fZm4rf/6qDUY/U9DwicAaccn1AyyUNC2nQMsRdbB+sbEYASuBC+SpRnaBCbW1L/c/MjmBI 0Ow+vlFgVD7eYj9QNEES2vz4z8HwSE6jFd72BmTs/HRQo7l7uvOcM3TcbjfGlcCBA0XWlZR3RaEzX 7RlwrCaFxVa8VK03mEcbqbu34JjDFFQVb0auItJbjwrQmHml9jyc5022xl748whFXf82vo7pVyQfd G2SA5LnkUaXx8POLnzh/FaE/lhGOisjed626B9CpKu5Jv8S6Ubx2bACRksO341MjlUCioiFVWaISi +esqIbk7hTcB29T3GaKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAYTS-00C8FH-Jn; Sun, 10 Jul 2022 15:03:54 +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 1oAYTF-00C89T-Uc for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:03:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657465411; bh=+fmYvZVXamDwJB1kParFdNMn3bLBWfn1dkqM/yC5mIQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=f9oarPSz50faR9fqgIqFdwEidGXgoWiiLKWRC8ZULN3yoLiaufw6nG5kbt+oUY5my ernFkTEptbd0oqiSAuky8iZkJ6Qjh86ns1mtZcbN/XELLhzUfBH8NTExnKhkXY/xmf oE/9MejjkU+jrQl8GsTTUCTPNPl+TKpFruPAZYH4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.243]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M4s4r-1oBNoa1hUV-001xh4; Sun, 10 Jul 2022 17:03: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 v3 5/8] serial: core: sanitize RS485 delays read from device tree Date: Sun, 10 Jul 2022 17:03:19 +0200 Message-Id: <20220710150322.2846170-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> References: <20220710150322.2846170-1-LinoSanfilippo@gmx.de> MIME-Version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dLvkVJIAvv4KvZYrExz9Se+QTIQyuwNdG2KCgl9dLMcQ0E54Z7833OF0addm +HZ+unJ3aBN4JwK0bbNyWdiVJeKOFuQtJg4cYUgMlMixszlj7QyWOI/hWw97ecSkz2s9g5moR IF1BZ8Bz4C3RnpPbShCN2ITZdf4XbEPtdzpLN+EtbWyw/xHfRJdWgTdfrdkC7MOBbtwpGUQv3 EHz477JHLFq9991NlTGBWBpD0nsV/S7Z5IjD/0eIdAo++v/vBU+JI7d8G9oCXzXRRGLf/ceKt jy43ZKwSWX/FvD9ZpfQzKIcKf7PejunyIniEwWMwMhuwH22VnNG0o29v7VHqSQ5voVHWRkLo0 QsGYqT7FG3ROLCNFyUAzuWjl50V6qTEGzJhXrQtzDYVl7F/FvOwC1yY9g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_080342_535631_A1DAFB78 X-CRM114-Status: GOOD ( 10.86 ) 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 Currently the RTS delays set via device tree are not clamped to a maximum value although the device tree bindings documentation for RS485 claims that only a maximum of 1000 msecs is allowed. So clamp the values to avoid arbitrary high delay settings. However clamp the values to 100 instead of 1000 msecs to be consistent which the maximum that is allowed when setting the delays from userspace via the UART ioctl TIOCSRS485. Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 5943cb35556f..2c4d52b37596 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3395,6 +3395,8 @@ int uart_get_rs485_mode(struct uart_port *port) rs485conf->delay_rts_after_send = 0; } + uart_sanitize_serial_rs485_delays(port, rs485conf); + /* * Clear full-duplex and enabled flags, set RTS polarity to active high * to get to a defined state with the following properties: