From mboxrd@z Thu Jan 1 00:00:00 1970 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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92089ECAAA1 for ; Mon, 5 Sep 2022 09:32:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B5FEB84899; Mon, 5 Sep 2022 11:31:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="QYq7D+yP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4373582105; Mon, 5 Sep 2022 11:31:49 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A792C84870 for ; Mon, 5 Sep 2022 11:31:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6A7B1611A3; Mon, 5 Sep 2022 09:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0C84C433D6; Mon, 5 Sep 2022 09:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662370301; bh=ouGbNogD4NCqcRlW9gQ/KfhTiVZ4a2bD++BL/4TH2u0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QYq7D+yPOm/BvdbxtKu/p52H/2xSPKnP16aTW60jwuZQJZaZCyPpz7l1ttuqTJ8V5 N+TwsCczYjbDvnpzfx9dCwPFkIjShDpaWzx/71eQprAF84jA9US6tAEZfognh4gCsY Gt90Q9nq7glFr42MXV8MOMC36kvC3MQqiuOjMYqi/NjefkwAa3ltDaDizgnpKj+bBv a7rWRBbcFqsGF3vbIkuo7kEBcgX7VD/mg3ls1Uq5znzTgToALmtEYal+kxWq/9TwkQ Wb8ZXKoZx7F5hCffcLmaRVnx2kWXsT828He4fGPi4cjwHyode4NrE6LYrHLlpVVk6V GKu7jEF48ZdHg== Received: by pali.im (Postfix) id 324124E13; Mon, 5 Sep 2022 11:31:39 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v3 4/6] serial: Implement serial_flush() function for console flush() fallback Date: Mon, 5 Sep 2022 11:31:19 +0200 Message-Id: <20220905093121.11630-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220905093121.11630-1-pali@kernel.org> References: <20220905093121.11630-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Like in all other console functions, implement also serial_flush() function as a fallback int console flush() function. Flush support is available only when config option CONSOLE_FLUSH_SUPPORT is enabled. So when it is disabled then provides just empty static inline function serial_flush(). Signed-off-by: Pali Rohár --- common/console.c | 3 +++ common/stdio.c | 8 ++++++++ drivers/serial/serial-uclass.c | 10 ++++++++++ include/serial.h | 5 +++++ 4 files changed, 26 insertions(+) diff --git a/common/console.c b/common/console.c index 0abfc224b53b..e4dc1da44a35 100644 --- a/common/console.c +++ b/common/console.c @@ -797,6 +797,9 @@ void flush(void) if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fflush(stdout); + } else { + /* Send directly to the handler */ + serial_flush(); } } #endif diff --git a/common/stdio.c b/common/stdio.c index 92161a0df87d..13083842cbd9 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -87,6 +87,13 @@ static void stdio_serial_puts(struct stdio_dev *dev, const char *s) serial_puts(s); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void stdio_serial_flush(struct stdio_dev *dev) +{ + serial_flush(); +} +#endif + static int stdio_serial_getc(struct stdio_dev *dev) { return serial_getc(); @@ -112,6 +119,7 @@ static void drv_system_init (void) dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT; dev.putc = stdio_serial_putc; dev.puts = stdio_serial_puts; + STDIO_DEV_ASSIGN_FLUSH(&dev, stdio_serial_flush); dev.getc = stdio_serial_getc; dev.tstc = stdio_serial_tstc; stdio_register (&dev); diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index be6502f3d24c..f028da0900cd 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -327,6 +327,16 @@ void serial_puts(const char *str) _serial_puts(gd->cur_serial_dev, str); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void serial_flush(void) +{ + if (!gd->cur_serial_dev) + return; + + _serial_flush(gd->cur_serial_dev); +} +#endif + int serial_getc(void) { if (!gd->cur_serial_dev) diff --git a/include/serial.h b/include/serial.h index 8c2e7adbc321..f9009d4046e3 100644 --- a/include/serial.h +++ b/include/serial.h @@ -362,6 +362,11 @@ void serial_setbrg(void); void serial_putc(const char ch); void serial_putc_raw(const char ch); void serial_puts(const char *str); +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void serial_flush(void); +#else +static inline void serial_flush(void) {} +#endif int serial_getc(void); int serial_tstc(void); -- 2.20.1