[U-Boot] [Question of dm serial] Is pending handler optional?

Simon Glass sjg at chromium.org
Thu Oct 23 20:34:23 CEST 2014


Hi Masahiro,

On 23 October 2014 09:29, Masahiro YAMADA <yamada.m at jp.panasonic.com> wrote:
> Hi Simon,
>
> I have questions of driver model serial.
>
>
> The comment block in include/serial.h states .pending is optional
>
> ---------------------------->8-------------------------------
> * pending() - Check if input/output characters are waiting
> *
> * This can be used to return an indication of the number of waiting
> * characters if the driver knows this (e.g. by looking at the FIFO
> * level). It is acceptable to return 1 if an indeterminant number
> * of characters is waiting.
> *
> * This method is optional.
> ----------------------------8<-------------------------------
>
>
> When I was testing my driver model conversion patch,
> I noticed ctrlc() function would not work without .pending handler.
>
>
>
> The function ctrlc() calls tstc()
> and if it returns non-zero value, it also calls getc().
>
>
>
> If .pending handler is not implemented,
> tstc() function always return 1,
> even if no input character is available in UART FIFO;
> As a result, getc() function will get stuck in
>
> do {
>         err = ops->getc(cur_dev);
> } while (err == -EAGAIN);
>
> loop.
>
>
> For example, "help" command does not work.
>
>
> So, .pending is mandatory, isn't it?
>
>
>
> One more question.
>
> The comment says .pending is:
> Check if input/output characters are waiting
>
>
> Should .pending check output buffer? or input only?

Yes it is actually mandatory, since we really don't want drivers to
block in their getc()/putc() methods.

Output character check is required so we can implement flush. E.g.
when we change the baud rate we should flush first.

Regards,
Simon


More information about the U-Boot mailing list