[PATCH] dm: serial: introduce puts hook

Peng Fan peng.fan at nxp.com
Sun May 3 15:04:57 CEST 2020


Introduce puts hook for dm serial driver.

Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/serial/serial-uclass.c | 13 +++++++++++--
 include/serial.h               |  8 ++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 7703c67492..b6a7502ac8 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -189,8 +189,17 @@ static void _serial_putc(struct udevice *dev, char ch)
 
 static void _serial_puts(struct udevice *dev, const char *str)
 {
-	while (*str)
-		_serial_putc(dev, *str++);
+	struct dm_serial_ops *ops = serial_get_ops(dev);
+	int err;
+
+	if (ops->puts) {
+		do {
+			err = ops->puts(dev, str);
+		} while (err == -EAGAIN);
+	} else {
+		while (*str)
+			_serial_putc(dev, *str++);
+	}
 }
 
 static int __serial_getc(struct udevice *dev)
diff --git a/include/serial.h b/include/serial.h
index 54b21a0470..0b40b27526 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -186,6 +186,14 @@ struct dm_serial_ops {
 	 * @return character (0..255), -ve on error
 	 */
 	int (*getc)(struct udevice *dev);
+	/**
+	 * puts() - puts a string
+	 *
+	 * @dev: Device pointer
+	 * @str: string to write
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*puts)(struct udevice *dev, const char *str);
 	/**
 	 * putc() - Write a character
 	 *
-- 
2.16.4



More information about the U-Boot mailing list