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);