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 12E11C19F2A for ; Thu, 11 Aug 2022 12:40:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59D5B8493C; Thu, 11 Aug 2022 14:40:16 +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="ERZ9PjIs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 87ED184927; Thu, 11 Aug 2022 14:39:58 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (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 175CF8492A for ; Thu, 11 Aug 2022 14:39:53 +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 ams.source.kernel.org (Postfix) with ESMTPS id B4942B81F6A; Thu, 11 Aug 2022 12:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AB36C43140; Thu, 11 Aug 2022 12:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221591; bh=COivyKfD0deTjW8yQa9Q/Yb20efHqBjH3gxzB69H61U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERZ9PjIs9ERONw1nZBdT9UW/cCuV/OIppzkgvBf3YgjRjloaji25VTXgyKG54E8lt KQm9HJlM3VyaS1i/5epUxZEbeMvPIFKshtiYiYl6LrgXztzqjE2YTAbOScCzUlu7Ic cVLgPFZVz+nHDU0dyRf++gb38SHOkF4WMocu4V60LhExViNI0dkn3NUkHt+vVr0AK3 1D6SUmW49N4oIk/Axfj4diI/OlbU2hHJwmzX/4EFdIY+lwKhGL81Obf+tGhUucY+33 KhSvg/1GkUa52Sv85J1+8j2w0PMWzBo2Oqb8TLGA+b7qtm73jYvYtNbpDm4PFkOv4u 3ybDwawJOvnAw== Received: by pali.im (Postfix) id C9C922779; Thu, 11 Aug 2022 14:39:48 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 4/6] serial: Implement serial_flush() function for console flush() fallback Date: Thu, 11 Aug 2022 14:39:23 +0200 Message-Id: <20220811123925.23981-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-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 | 10 ++++++++++ drivers/serial/serial-uclass.c | 10 ++++++++++ include/serial.h | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/common/console.c b/common/console.c index 42415e34d16f..72ed7cd3b3b4 100644 --- a/common/console.c +++ b/common/console.c @@ -790,6 +790,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..b49a02f16f46 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,9 @@ static void drv_system_init (void) dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT; dev.putc = stdio_serial_putc; dev.puts = stdio_serial_puts; +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + dev.flush = stdio_serial_flush; +#endif 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 71ea88e31c9f..4e32270d4660 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 e6051e0a7faf..4e951f0c5f52 100644 --- a/include/serial.h +++ b/include/serial.h @@ -386,6 +386,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