diff mbox

[U-Boot,1/7] dm: serial: fix a bug of console putc

Message ID 1413969242-29481-2-git-send-email-yamada.m@jp.panasonic.com
State Not Applicable
Delegated to: Simon Glass
Headers show

Commit Message

Masahiro Yamada Oct. 22, 2014, 9:13 a.m. UTC
Without this commit, functions such as printf(), puts() stop working
after the console is ready (= after GD_FLG_DEVINIT is set in
console_init_r() function).

The function serial_putc() is called to print a character before the
console is available, while serial_stub_putc() is used on the console.

The cause of the problem is that the error handling of ops->putc
handler is missing from serial_stub_putc(); it should behave
like serial_putc().

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 drivers/serial/serial-uclass.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Simon Glass Oct. 22, 2014, 11:36 p.m. UTC | #1
Hi Masahiro,

On 22 October 2014 03:13, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> Without this commit, functions such as printf(), puts() stop working
> after the console is ready (= after GD_FLG_DEVINIT is set in
> console_init_r() function).
>
> The function serial_putc() is called to print a character before the
> console is available, while serial_stub_putc() is used on the console.
>
> The cause of the problem is that the error handling of ops->putc
> handler is missing from serial_stub_putc(); it should behave
> like serial_putc().
>
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> ---
>
>  drivers/serial/serial-uclass.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 6dde4ea..163308b 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -127,8 +127,13 @@ void serial_stub_putc(struct stdio_dev *sdev, const char ch)
>  {
>         struct udevice *dev = sdev->priv;
>         struct dm_serial_ops *ops = serial_get_ops(dev);
> +       int err;
>
> -       ops->putc(dev, ch);
> +       do {
> +               err = ops->putc(cur_dev, ch);
> +       } while (err == -EAGAIN);
> +       if (ch == '\n')
> +               serial_putc('\r');
>  }
>
>  void serial_stub_puts(struct stdio_dev *sdev, const char *str)
> --
> 1.9.1
>

Sorry for the bug, but I did fix it some weeks OK. Please see this patch:

http://patchwork.ozlabs.org/patch/395725/

I recommend basing on dm/working if you are sending new patches
because code there is generally on its way upstream ahead of your
patch.

I will see if I can start using dm/testing more, as that is really its
intended purpose.

Regards,
Simon
Masahiro Yamada Oct. 23, 2014, 1:28 p.m. UTC | #2
Hi Simon,


On Wed, 22 Oct 2014 17:36:06 -0600
Simon Glass <sjg@chromium.org> wrote:

> >  drivers/serial/serial-uclass.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> > index 6dde4ea..163308b 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -127,8 +127,13 @@ void serial_stub_putc(struct stdio_dev *sdev, const char ch)
> >  {
> >         struct udevice *dev = sdev->priv;
> >         struct dm_serial_ops *ops = serial_get_ops(dev);
> > +       int err;
> >
> > -       ops->putc(dev, ch);
> > +       do {
> > +               err = ops->putc(cur_dev, ch);
> > +       } while (err == -EAGAIN);
> > +       if (ch == '\n')
> > +               serial_putc('\r');
> >  }
> >
> >  void serial_stub_puts(struct stdio_dev *sdev, const char *str)
> > --
> > 1.9.1
> >
> 
> Sorry for the bug, but I did fix it some weeks OK. Please see this patch:
> 
> http://patchwork.ozlabs.org/patch/395725/


Hmm, I checked it out, but I am afraid serial_stub_putc() is still buggy.


Please check this:
http://patchwork.ozlabs.org/patch/402479/


Best Regards
Masahiro Yamada
diff mbox

Patch

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 6dde4ea..163308b 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -127,8 +127,13 @@  void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
 	struct udevice *dev = sdev->priv;
 	struct dm_serial_ops *ops = serial_get_ops(dev);
+	int err;
 
-	ops->putc(dev, ch);
+	do {
+		err = ops->putc(cur_dev, ch);
+	} while (err == -EAGAIN);
+	if (ch == '\n')
+		serial_putc('\r');
 }
 
 void serial_stub_puts(struct stdio_dev *sdev, const char *str)