[PATCH v3 26/29] serial: dm: Add support for puts

Simon Glass sjg at chromium.org
Mon Mar 28 08:35:12 CEST 2022


On Tue, 22 Mar 2022 at 15:00, Sean Anderson <sean.anderson at seco.com> wrote:
>
> Some serial drivers can be vastly more efficient when printing multiple
> characters at once. Non-DM serial has had a puts option for these sorts
> of drivers; implement it for DM serial as well.
>
> Because we have to add carriage returns, we can't just pass the whole
> string directly to the serial driver. Instead, we print up to the
> newline, then print a carriage return, and then continue on. This is
> less efficient, but it is better than printing each character
> individually. It also avoids having to allocate memory just to add a few
> characters.
>
> Drivers may perform short writes (such as filling a FIFO) and return the
> number of characters written in len. We loop over them in the same way
> that _serial_putc loops over putc.
>
> This results in around sizeof(void *) growth for all boards with
> DM_SERIAL. The full implementation takes around 140 bytes.
>
> Signed-off-by: Sean Anderson <sean.anderson at seco.com>
> ---
>
> Changes in v3:
> - Add a config for puts to reduce the impact on the (vast majority) of
>   boards which don't need it.
> - Fix null pointer dereference in _serial_puts caused by a missing
>   return.
> - Make puts return the number of characters written on success, instead
>   of reusing the len parameter.
>
> Changes in v2:
> - New
>
>  drivers/serial/Kconfig         | 13 +++++++++++++
>  drivers/serial/serial-uclass.c | 26 ++++++++++++++++++++++++--
>  include/serial.h               | 18 ++++++++++++++++++
>  3 files changed, 55 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list