dm: serial: introduce puts hook
PATCH 1/1 dm: serial: introduce puts hook
Introduce puts hook for dm serial driver.
--- drivers/serial/serial-uclass.c | 13 +++++++++++-- include/serial.h | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/serial/serial-uclass.c +11 -2
@@ -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)
include/serial.h +8 -0
@@ -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 *
Signature · 1 line
2.16.4
PATCH 1/1 dm: serial: introduce puts hook
Hi Peng,
Quoted 8 lines · Peng Fan
Introduce puts hook for dm serial driver.
Signed-off-by Peng Fan <[email protected]>--- drivers/serial/serial-uclass.c | 13 +++++++++++-- include/serial.h | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-)
I'm just wondering why we need this? Isn't serial_putc() enough?
Regards,
Simon
PATCH 1/1 dm: serial: introduce puts hook
Hi Simon,
Quoted 8 lines
Subject: Re: [PATCH] dm: serial: introduce puts hook
Hi Peng,
Quoted 3 lines · Peng Fan
Introduce puts hook for dm serial driver.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/serial/serial-uclass.c | 13 +++++++++++-- include/serial.h | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-)I'm just wondering why we need this? Isn't
serial_putc()enough?
This is to let u-boot could run in a XEN hypervisor DomU virtual machine. It is low efficiently if each time, we use putc to let xen dom0 print uboot log.
We could pass a string, not a char to improve performance.
Thanks,
Peng.
Quoted 3 lines
Regards,
Simon
PATCH 1/1 dm: serial: introduce puts hook
Hi Peng,
Quoted 17 lines · Peng Fan
Hi Simon,
Quoted 14 lines
Subject: Re: [PATCH] dm: serial: introduce puts hook
Hi Peng,
Quoted 8 lines · Peng Fan
Introduce puts hook for dm serial driver.
Signed-off-by Peng Fan <[email protected]>--- drivers/serial/serial-uclass.c | 13 +++++++++++-- include/serial.h | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 1 line
I'm just wondering why we need this? Isn't
serial_putc()enough?This is to let u-boot could run in a XEN hypervisor DomU virtual machine. It is low efficiently if each time, we use putc to let xen dom0 print uboot log.
OK that is the sort of thing that should be in the commit message :-)
Quoted 2 lines
We could pass a string, not a char to improve performance.
If we are going to do that, I think it would be better to add a write() call, with a length. It should return the number of bytes written, since sometimes the port might be full.
The uclass itself needs a serial_write() call which would then fall back to writing characters if the driver doesn't have the write method.
Also should have a test.
Regards,
Simon