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 AD4D3C19F2A for ; Thu, 11 Aug 2022 12:41:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93F878494A; Thu, 11 Aug 2022 14:40:19 +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="eoHwNQk7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A0CB284927; Thu, 11 Aug 2022 14:40:00 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (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 107D184929 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 AB232B81F66; Thu, 11 Aug 2022 12:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8125C433D6; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221591; bh=NzZPjYSynYm+bnCpiFJPgL2sn5prybThKOb2y7ZLxZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eoHwNQk7541TMfKmlubt+TxyHc28OrVJWdu+eIlBuDUQqZR0npmVfRiMskWhUnifU yo5BAY8IZXSFssJg9E6lvNVZ6PXLHzHksZVx65Dk2dgEpxcCqEf3etbaBHxctf+t9L 2ot/J00ueLwosxywW5BOvuYxMzwwVKjtBez9dFB7AoAkka5yKe5YskI5rlfcqFQhBW ZqibHD/AbL8aIsQgRBY2+hOrKksBfSXcV22vcH/uD/D2gdkMa0d0ARjIrw7+pPfWP6 Jv7wnLcMSkTAzHH1R1AiL1F8kZxdz3uv59mYawQKyOoVPUQoisoo3yBB94oZ3VbxoD UnIxH8ZXvsRjg== Received: by pali.im (Postfix) id 4674F2777; 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 3/6] serial: Implement flush callback Date: Thu, 11 Aug 2022 14:39:22 +0200 Message-Id: <20220811123925.23981-4-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 UART drivers have putc/puts functions which just put characters into HW transmit queue and do not wait until all data are transmitted. Implement flush callback via serial driver's pending(false) callback which waits until HW transmit all characters from the queue. Signed-off-by: Pali Rohár --- drivers/serial/serial-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 4b7819fa473b..71ea88e31c9f 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -238,6 +238,18 @@ static void _serial_puts(struct udevice *dev, const char *str) } while (*str); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void _serial_flush(struct udevice *dev) +{ + struct dm_serial_ops *ops = serial_get_ops(dev); + + if (!ops->pending) + return; + while (ops->pending(dev, false) > 0) + ; +} +#endif + static int __serial_getc(struct udevice *dev) { struct dm_serial_ops *ops = serial_get_ops(dev); @@ -412,6 +424,13 @@ static void serial_stub_puts(struct stdio_dev *sdev, const char *str) _serial_puts(sdev->priv, str); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void serial_stub_flush(struct stdio_dev *sdev) +{ + _serial_flush(sdev->priv); +} +#endif + static int serial_stub_getc(struct stdio_dev *sdev) { return _serial_getc(sdev->priv); @@ -571,6 +590,9 @@ static int serial_post_probe(struct udevice *dev) sdev.priv = dev; sdev.putc = serial_stub_putc; sdev.puts = serial_stub_puts; +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + sdev.flush = serial_stub_flush; +#endif sdev.getc = serial_stub_getc; sdev.tstc = serial_stub_tstc; -- 2.20.1