Commit aa08894ff41b37f951e2875291763987b13fff85
1 parent
ddb393c451
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
5 other branches
MLK-20373-2 dm: serial: introduce puts hook
Introduce puts hook for dm serial driver. 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>
Showing 2 changed files with 19 additions and 2 deletions Side-by-side Diff
drivers/serial/serial-uclass.c
... | ... | @@ -182,8 +182,17 @@ |
182 | 182 | |
183 | 183 | static void _serial_puts(struct udevice *dev, const char *str) |
184 | 184 | { |
185 | - while (*str) | |
186 | - _serial_putc(dev, *str++); | |
185 | + struct dm_serial_ops *ops = serial_get_ops(dev); | |
186 | + int err; | |
187 | + | |
188 | + if (ops->puts) { | |
189 | + do { | |
190 | + err = ops->puts(dev, str); | |
191 | + } while (err == -EAGAIN); | |
192 | + } else { | |
193 | + while (*str) | |
194 | + _serial_putc(dev, *str++); | |
195 | + } | |
187 | 196 | } |
188 | 197 | |
189 | 198 | static int __serial_getc(struct udevice *dev) |
include/serial.h
... | ... | @@ -98,6 +98,14 @@ |
98 | 98 | */ |
99 | 99 | int (*getc)(struct udevice *dev); |
100 | 100 | /** |
101 | + * puts() - puts a string | |
102 | + * | |
103 | + * @dev: Device pointer | |
104 | + * @str: string to write | |
105 | + * @return 0 if OK, -ve on error | |
106 | + */ | |
107 | + int (*puts)(struct udevice *dev, const char *str); | |
108 | + /** | |
101 | 109 | * putc() - Write a character |
102 | 110 | * |
103 | 111 | * @dev: Device pointer |