Commit 8e053ce620c3471332caacd74d0720d409a67503
Committed by
Ye Li
1 parent
cbc0a66982
Exists in
smarc_8mq-imx_v2020.04_5.4.24_2.1.0
and in
3 other branches
MLK-20373-2 dm: serial: introduce puts hook
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)
Showing 2 changed files with 19 additions and 2 deletions Side-by-side Diff
drivers/serial/serial-uclass.c
... | ... | @@ -188,8 +188,17 @@ |
188 | 188 | |
189 | 189 | static void _serial_puts(struct udevice *dev, const char *str) |
190 | 190 | { |
191 | - while (*str) | |
192 | - _serial_putc(dev, *str++); | |
191 | + struct dm_serial_ops *ops = serial_get_ops(dev); | |
192 | + int err; | |
193 | + | |
194 | + if (ops->puts) { | |
195 | + do { | |
196 | + err = ops->puts(dev, str); | |
197 | + } while (err == -EAGAIN); | |
198 | + } else { | |
199 | + while (*str) | |
200 | + _serial_putc(dev, *str++); | |
201 | + } | |
193 | 202 | } |
194 | 203 | |
195 | 204 | static int __serial_getc(struct udevice *dev) |
include/serial.h
... | ... | @@ -184,6 +184,14 @@ |
184 | 184 | */ |
185 | 185 | int (*getc)(struct udevice *dev); |
186 | 186 | /** |
187 | + * puts() - puts a string | |
188 | + * | |
189 | + * @dev: Device pointer | |
190 | + * @str: string to write | |
191 | + * @return 0 if OK, -ve on error | |
192 | + */ | |
193 | + int (*puts)(struct udevice *dev, const char *str); | |
194 | + /** | |
187 | 195 | * putc() - Write a character |
188 | 196 | * |
189 | 197 | * @dev: Device pointer |