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>
This commit is contained in:
Peng Fan 2018-11-15 13:13:14 +08:00
parent ddb393c451
commit aa08894ff4
2 changed files with 19 additions and 2 deletions

View File

@ -182,8 +182,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)

View File

@ -97,6 +97,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
*