X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fserial%2Fusbtty.c;h=182385e499d015cfdbef3d74135977d9d1627678;hb=57f9bb9404e0578b4701ff900fdfa884d84c74b0;hp=75f0ec31bbfb9a6faedeaf9cf137ea1212ceefd5;hpb=746667f1e56bf08d03e66a178df3c4f4f6c806e1;p=u-boot diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c index 75f0ec31bb..182385e499 100644 --- a/drivers/serial/usbtty.c +++ b/drivers/serial/usbtty.c @@ -434,11 +434,12 @@ void usbtty_putc(struct stdio_dev *dev, const char c) if (!usbtty_configured ()) return; - buf_push (&usbtty_output, &c, 1); /* If \n, also do \r */ if (c == '\n') buf_push (&usbtty_output, "\r", 1); + buf_push(&usbtty_output, &c, 1); + /* Poll at end to handle new data... */ if ((usbtty_output.size + 2) >= usbtty_output.totalsize) { usbtty_poll (); @@ -498,8 +499,8 @@ void usbtty_puts(struct stdio_dev *dev, const char *str) n = next_nl_pos (str); if (str[n] == '\n') { - __usbtty_puts (str, n + 1); - __usbtty_puts ("\r", 1); + __usbtty_puts("\r", 1); + __usbtty_puts(str, n + 1); str += (n + 1); len -= (n + 1); } else { @@ -524,10 +525,10 @@ int drv_usbtty_init (void) char * tt; int snlen; - /* Ger seiral number */ - if (!(sn = getenv("serial#"))) { + /* Get serial number */ + sn = env_get("serial#"); + if (!sn) sn = "000000000000"; - } snlen = strlen(sn); if (snlen > sizeof(serial_number) - 1) { printf ("Warning: serial number %s is too long (%d > %lu)\n", @@ -539,10 +540,9 @@ int drv_usbtty_init (void) /* Decide on which type of UDC device to be. */ - - if(!(tt = getenv("usbtty"))) { + tt = env_get("usbtty"); + if (!tt) tt = "generic"; - } usbtty_init_terminal_type(strcmp(tt,"cdc_acm")); /* prepare buffers... */ @@ -849,6 +849,13 @@ static int write_buffer (circbuf_t * buf) struct urb *current_urb = NULL; current_urb = next_urb (device_instance, endpoint); + + if (!current_urb) { + TTYERR ("current_urb is NULL, buf->size %d\n", + buf->size); + return 0; + } + /* TX data still exists - send it now */ if(endpoint->sent < current_urb->actual_length){ @@ -870,12 +877,6 @@ static int write_buffer (circbuf_t * buf) */ while (buf->size > 0) { - if (!current_urb) { - TTYERR ("current_urb is NULL, buf->size %d\n", - buf->size); - return total; - } - dest = (char*)current_urb->buffer + current_urb->actual_length;