From patchwork Tue Sep 20 05:20:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 12981362 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 DC12EECAAD8 for ; Tue, 20 Sep 2022 05:22:25 +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=PEJfazJhFYtGl+xiS6EOS4s2Z5pMtLcMgy2DWspT8PI=; b=MliKXP6xns0cPB 628yqKEeameoarksXE4htzfo6UtI7BKZnzXG1SfDcqZQtIJwxdZY9TnN1W/Sl8UseigZJjtnE3TTb zomMVSOx7JCeN7hHxoqbL24liOiIq0dP34Nkpxqb7Wd3BxuYSJ7tD9Fp3tQAKz9LbM3sL3TWcm0u5 LjBBTIfRrP3aTWnF3h31ACV/AKnxsDSgosr+owOOdqEufi5bflWkkYBenVBxQk05QnP5Lx6LLCMS8 siQ+oVnBkArGXaz2duDJZCcHYUDhjccMz1O4kaVkExyeQ5CVqKmdFyC7+a/jwGb51MvAAFdvUVi0x sEA8ReB9Jy+sw4lCoG0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaVhJ-000ego-PS; Tue, 20 Sep 2022 05:21:29 +0000 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaVh2-000eSy-Oz for linux-arm-kernel@lists.infradead.org; Tue, 20 Sep 2022 05:21:15 +0000 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 917321F889; Tue, 20 Sep 2022 05:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1663651250; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rG/RuZqj0s6o1zZB075A45sdYsusSoWW/nWCKNRy+j4=; b=0TndwT8Irvaz65JK4PQuLXA1r9Or8dZzulSYgk2LY2iwFTvi19BGbyyDQYc00DxXR8FV4e V0UcEoDgnI+REjHvJ99LV/EFyoDCG8/+RAwfZJ6GDQ5eKEq7G+rra3bQYsPuaItDkh7lJw oEsXw5lAULbrQZ3jeh0S9PEjplNBIuw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1663651250; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rG/RuZqj0s6o1zZB075A45sdYsusSoWW/nWCKNRy+j4=; b=PfuLgrKsT+5LTJiq5qsWX4ileX2mTCDLaxn0ajGoYDfynzGLB4suDo083oJ0IvMz4hn2Aj p6tfxM5GAjIclJCA== Received: from localhost.localdomain (unknown [10.100.201.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5BB6B2C142; Tue, 20 Sep 2022 05:20:50 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 01/10] tty: serial: move and cleanup vt8500_tx_empty() Date: Tue, 20 Sep 2022 07:20:41 +0200 Message-Id: <20220920052049.20507-2-jslaby@suse.cz> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220920052049.20507-1-jslaby@suse.cz> References: <20220920052049.20507-1-jslaby@suse.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220919_222113_000748_D2D3970D X-CRM114-Status: GOOD ( 12.82 ) 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 Make vt8500_tx_empty() more readable by introducing a new local variable and move the function before handle_tx(). That way we can reuse it in there too. Cc: Signed-off-by: Jiri Slaby Reviewed-by: Ilpo Järvinen --- Notes: [v3] this is new in v3 -- extracted as a separate change from later patches drivers/tty/serial/vt8500_serial.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 508ad7afa6de..10fbdb09965f 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -187,6 +187,13 @@ static void handle_rx(struct uart_port *port) tty_flip_buffer_push(tport); } +static unsigned int vt8500_tx_empty(struct uart_port *port) +{ + unsigned int idx = vt8500_read(port, VT8500_URFIDX) & 0x1f; + + return idx < 16 ? TIOCSER_TEMT : 0; +} + static void handle_tx(struct uart_port *port) { struct circ_buf *xmit = &port->state->xmit; @@ -201,7 +208,7 @@ static void handle_tx(struct uart_port *port) return; } - while ((vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16) { + while (vt8500_tx_empty(port)) { if (uart_circ_empty(xmit)) break; @@ -260,12 +267,6 @@ static irqreturn_t vt8500_irq(int irq, void *dev_id) return IRQ_HANDLED; } -static unsigned int vt8500_tx_empty(struct uart_port *port) -{ - return (vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16 ? - TIOCSER_TEMT : 0; -} - static unsigned int vt8500_get_mctrl(struct uart_port *port) { unsigned int usr; From patchwork Tue Sep 20 05:20:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 12981361 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 6CDDEECAAD8 for ; Tue, 20 Sep 2022 05:22:23 +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=/Okp07N8AVKIfrW3q4nYuMNum/5quiuCBtj1pSlAcwU=; b=iVP8cT/HKd/ftS sFwnnhoEmzPHpTHfHENLIGxrOTgWH/6eQVgidzfzobPPDQ7GNw6T19vaAfBBMQDuESfs+Yq1q+z90 0n1orQcuMVhyXrOaLAJszV5vIx107V7GU3M7Sn4FEHTXOTOsM6c8ADOKQJMX6khDIm5hHLOl+Ybsx KaIZmARMY08Fd/0oAY8ssH9tAo6XrjQgcHghhU7R3AjbiHz4FN6dNf7ZpxXB0REfU26SYDdMHgf0I 19LwV1Awamgnh5FrGgH2DJkMmRm3pd0VInGIx8CrKmvXbD+z/LBCYLZJoT3K6stRK93DTm1mZoU8v P77LaX+arA4gb0Qf2w1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaVhB-000ed0-F3; Tue, 20 Sep 2022 05:21:21 +0000 Received: from smtp-out2.suse.de ([195.135.220.29]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaVh3-000eTI-0D for linux-arm-kernel@lists.infradead.org; Tue, 20 Sep 2022 05:21:15 +0000 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4B4371F8A8; Tue, 20 Sep 2022 05:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1663651252; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3DR+e5tUXrU5pDouwWQoOJcV84hEa4+bOrdcoGBahis=; b=AHlZ6BHmkCZhxrHKia31hETrcgXlk+z2qr1mmJoKqGy8iCeLFN5pmRIKSo6tvoGDZ+MsxV EGPlgFVnH9amtpbWjXAvi3U72/FyvTcEtWVA1poFSDX+sxjzNKR1QrW4VyDyzNMxLUnZV9 //Lmah+LrAYoJ6uR/44KRIvELBy9zh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1663651252; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3DR+e5tUXrU5pDouwWQoOJcV84hEa4+bOrdcoGBahis=; b=3KvSp9eNVo6hma1f/FIQVS47Gx+6sERkSqqH6QPNc8c3rEaFCIC3sAOFTTchzZYbg4zyld yOSEBD2qbOiPeoAA== Received: from localhost.localdomain (unknown [10.100.201.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6DF7E2C142; Tue, 20 Sep 2022 05:20:51 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Vladimir Zapolskiy , linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 05/10] tty: serial: extract tx_ready() from __serial_lpc32xx_tx() Date: Tue, 20 Sep 2022 07:20:45 +0200 Message-Id: <20220920052049.20507-6-jslaby@suse.cz> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220920052049.20507-1-jslaby@suse.cz> References: <20220920052049.20507-1-jslaby@suse.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220919_222113_224663_A7ADCA70 X-CRM114-Status: GOOD ( 12.67 ) 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 The condition in __serial_lpc32xx_tx()'s loop is barely readable. Extract it to a separate function. This will make the cleanup in the next patches easier too. Cc: Vladimir Zapolskiy Cc: Signed-off-by: Jiri Slaby Reviewed-by: Ilpo Järvinen --- Notes: [v4] this is new in v4 -- extracted as a separate change drivers/tty/serial/lpc32xx_hs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index 0d5ef7df27d0..ed47f4768338 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c @@ -278,6 +278,13 @@ static void __serial_lpc32xx_rx(struct uart_port *port) static void serial_lpc32xx_stop_tx(struct uart_port *port); +static bool serial_lpc32xx_tx_ready(struct uart_port *port) +{ + u32 level = readl(LPC32XX_HSUART_LEVEL(port->membase)); + + return LPC32XX_HSU_TX_LEV(level) < 64; +} + static void __serial_lpc32xx_tx(struct uart_port *port) { struct circ_buf *xmit = &port->state->xmit; @@ -293,8 +300,7 @@ static void __serial_lpc32xx_tx(struct uart_port *port) goto exit_tx; /* Transfer data */ - while (LPC32XX_HSU_TX_LEV(readl( - LPC32XX_HSUART_LEVEL(port->membase))) < 64) { + while (serial_lpc32xx_tx_ready(port)) { writel((u32) xmit->buf[xmit->tail], LPC32XX_HSUART_FIFO(port->membase)); xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);