From patchwork Sun Jul 10 16:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12912575 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 158ACC433EF for ; Sun, 10 Jul 2022 16:46:51 +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=lNPS00PMKWADCvk/PYewuDTG1KZ2Fc0qGWw5vpmZGiI=; b=bJ58L/KqLY/yHR cZLlDZ6Oxgdfwwig1vZrfSz8C3mL2hifJegkAf9SL1WkiTTuh6T3Hm1Ov2Vcm3sZd2qbBiabAedIi IBqVPggFM87uUrkXIutmbyTJGfHfc15GoEyCif+4E6D5hCcvZVA+TU63ZV0dYn+EtIPdZcFqxM2fx N2TKzfhflKa1uCTmfwtdtwVhWyJPudF6plfQcYdqy8v6eWNwdKXEZdUpUNc0G0OP2KhiynpyQ8cq+ /c0jJUeAtPV4pv4mM6fqyzamG9cxxG8mnnr6brfnqHj/PHTSJ6Q6Fern1BXgL+UgVkdE6qQkdELJi PdT8AMa8jp+oEvSuuTjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAa3v-00CXSH-SG; Sun, 10 Jul 2022 16:45:39 +0000 Received: from mout.gmx.net ([212.227.17.21]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAa3P-00CXCX-FZ for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 16:45:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657471497; bh=o+W8ytMepE42gQF0QexTyH8iX1o8DL+6k2p2ZnfEFk0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JMIVFwwesErimfQUonJfmRcoSxOfdrl41iOeYkn1BO35NjjxibV44eIAl+tb1Y5bY LJuzI8zHM8jg9R4z0aodSebEWWHLeJrZk8XBaCzAJVJxtDoh64f9fr+b9VBrLflTdH dJkWplFgOKHx2InAIcKn0m1Jm2ILT4/4u5iVDg38= 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 1MMGNC-1ntbQt1ba2-00JJtC; 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 5/8] serial: core: sanitize RS485 delays read from device tree Date: Sun, 10 Jul 2022 18:44:39 +0200 Message-Id: <20220710164442.2958979-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220710164442.2958979-1-LinoSanfilippo@gmx.de> References: <20220710164442.2958979-1-LinoSan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aAMz55GyuNFqCRI62h5dRcBoBSFi94kEz9K4DVvMy28kfZ1sg5Ft6kkn6CjiHNETI g3LTaj7pWWYnPevaVcOSmNgRAqhQjBri7fBHZT3vgW0jMNZjxKw7ukXsAHaAE2KhEaobt6WTk Sat3kz9IS4RDtj8WbfM9VvA2xpMFPAyN43rHWoV9Mw8J0ZT1xKAWWZfxLJoI9iub/Vu3c5Y/H yLWB/+FZpXkoSA3V/Ni4rwrpv2o4WpygYcVCYM1UiPfvW8mdeTmYEsUuy2N9PlP2dXGD/mZV8 nQw3qgPKB6cvDOP6qie8cAsdpHVSbF8BMoHeZqGkXIx2RxfYuJ0SlSzP+4V4u3u51K9GKMbiu Ot3zsSWaB68U3UUyfKuLXNV/Oannn//xMk1IGYC/5u+ShCNmFd4Yt6B8Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_094508_123245_BAE9865D X-CRM114-Status: GOOD ( 10.75 ) 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 3158f05a328c..ac198d0d4c80 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: