X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fserial%2Fusbtty.c;h=2624e6f3adda91a10a8ce7fdeef7548f054123fc;hb=ece444b42b71eb5bce34a24ec584573b3c8c4a98;hp=2bc5c3c83873188fd3f5e0d1b8600b65c36711cb;hpb=ab06bddb04ed4be50a8f9ad5f94fa23953a734e3;p=oweals%2Fu-boot.git diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c index 2bc5c3c838..2624e6f3ad 100644 --- a/drivers/serial/usbtty.c +++ b/drivers/serial/usbtty.c @@ -22,18 +22,14 @@ */ #include - -#ifdef CONFIG_USB_TTY - +#include #include #include #include "usbtty.h" #include "usb_cdc_acm.h" #include "usbdescriptors.h" -#include /* If defined, override Linux identifiers with - * vendor specific ones */ -#if 0 +#ifdef DEBUG #define TTYDBG(fmt,args...)\ serial_printf("[%s] %s %d: "fmt, __FILE__,__FUNCTION__,__LINE__,##args) #else @@ -154,8 +150,7 @@ struct acm_config_desc { /* Slave Interface */ struct usb_interface_descriptor data_class_interface; - struct usb_endpoint_descriptor - data_endpoints[NUM_ENDPOINTS-1] __attribute__((packed)); + struct usb_endpoint_descriptor data_endpoints[NUM_ENDPOINTS-1]; } __attribute__((packed)); static struct acm_config_desc acm_configuration_descriptors[NUM_CONFIGS] = { @@ -284,10 +279,8 @@ static struct rs232_emu rs232_desc={ struct gserial_config_desc { struct usb_configuration_descriptor configuration_desc; - struct usb_interface_descriptor - interface_desc[NUM_GSERIAL_INTERFACES] __attribute__((packed)); - struct usb_endpoint_descriptor - data_endpoints[NUM_ENDPOINTS] __attribute__((packed)); + struct usb_interface_descriptor interface_desc[NUM_GSERIAL_INTERFACES]; + struct usb_endpoint_descriptor data_endpoints[NUM_ENDPOINTS]; } __attribute__((packed)); @@ -437,6 +430,9 @@ int usbtty_getc (void) */ void usbtty_putc (const char c) { + if (!usbtty_configured ()) + return; + buf_push (&usbtty_output, &c, 1); /* If \n, also do \r */ if (c == '\n') @@ -490,8 +486,12 @@ static void __usbtty_puts (const char *str, int len) void usbtty_puts (const char *str) { int n; - int len = strlen (str); + int len; + + if (!usbtty_configured ()) + return; + len = strlen (str); /* add '\r' for each '\n' */ while (len > 0) { n = next_nl_pos (str); @@ -1007,6 +1007,3 @@ void usbtty_poll (void) udc_irq(); } - - -#endif