MLK-20373-2 dm: serial: introduce puts hook
authorPeng Fan <peng.fan@nxp.com>
Thu, 15 Nov 2018 05:13:14 +0000 (13:13 +0800)
committerYe Li <ye.li@nxp.com>
Thu, 29 Apr 2021 07:56:18 +0000 (00:56 -0700)
Introduce puts hook for dm serial driver.

Change-Id: I75423998c7d8db20949bae6ac46a094dc62c9612
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Flynn xu <flynn.xu@nxp.com>
(cherry picked from commit bb986d4ff2124285ec0d99a51a2702a53f485813)
(cherry picked from commit c2cf89d2035598ca2601bb405cece474ed337817)

drivers/serial/serial-uclass.c
include/serial.h

index 8a87eed..95d1842 100644 (file)
@@ -200,8 +200,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)
index 6d1e62c..117f2a9 100644 (file)
@@ -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
         *