#include "u_serial.h"
+#define ACM_LOG "USB_ACM"
/*
* This component encapsulates the TTY layer glue needed to provide basic
*/
#define QUEUE_SIZE 16
#define WRITE_BUF_SIZE 8192 /* TX only */
+#define REQ_BUF_SIZE 4096
/* circular buffer */
struct gs_buf {
struct usb_ep *in = port->port_usb->in;
int status = 0;
bool do_tty_wake = false;
+ static unsigned int skip = 0;
+ static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 10);
while (!list_empty(pool)) {
struct usb_request *req;
break;
req = list_entry(pool->next, struct usb_request, list);
- len = gs_send_packet(port, req->buf, in->maxpacket);
+ len = gs_send_packet(port, req->buf, REQ_BUF_SIZE);
if (len == 0) {
wake_up_interruptible(&port->drain_wait);
break;
port->port_num, len, *((u8 *)req->buf),
*((u8 *)req->buf+1), *((u8 *)req->buf+2));
+ if (__ratelimit(&ratelimit)) {
+ printk( ACM_LOG \
+ "%s: ttyGS%d: tx len=%d, 0x%02x 0x%02x 0x%02x ...\n", \
+ __func__, port->port_num, len, *((u8 *)req->buf), \
+ *((u8 *)req->buf+1), *((u8 *)req->buf+2));
+ if (skip > 0) {
+ printk( ACM_LOG "%s Too many data, skipped %d bytes", __func__, skip);
+ skip = 0;
+ }
+ } else
+ skip += req->actual;
+
/* Drop lock while we call out of driver; completions
* could be issued while we do so. Disconnection may
* happen too; maybe immediately before we queue this!
struct list_head *queue = &port->read_queue;
bool disconnect = false;
bool do_push = false;
+ static unsigned int skip = 0;
+ static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 10);
/* hand any queued data to the tty */
spin_lock_irq(&port->port_lock);
break;
}
+ if (__ratelimit(&ratelimit)) {
+ printk( ACM_LOG \
+ "%s: ttyGS%d: actual=%d, n_read=%d 0x%02x 0x%02x 0x%02x ...\n", \
+ __func__, port->port_num, req->actual, port->n_read,
+ *((u8 *)req->buf), *((u8 *)req->buf+1), *((u8 *)req->buf+2));
+ if (skip > 0) {
+ printk( ACM_LOG "%s Too many data, skipped %d bytes", __func__, skip);
+ skip = 0;
+ }
+ } else
+ skip += req->actual;
+
/* push data to (open) tty */
if (req->actual) {
char *packet = req->buf;
* be as speedy as we might otherwise be.
*/
for (i = 0; i < n; i++) {
- req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC);
+ req = gs_alloc_req(ep, REQ_BUF_SIZE, GFP_ATOMIC);
if (!req)
return list_empty(head) ? -ENOMEM : 0;
req->complete = fn;
pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file);
+ printk( ACM_LOG \
+ "gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file);
+
status = 0;
exit_unlock_port:
pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file);
+ printk( ACM_LOG \
+ "gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file);
+
/* mark port as closing but in use; we can drop port lock
* and sleep if necessary
*/
struct gs_port *port = tty->driver_data;
unsigned long flags;
int status;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return -EINVAL;
+ }
+ //ALPS00423739
pr_vdebug("gs_write: ttyGS%d (%p) writing %d bytes\n",
port->port_num, tty, count);
unsigned long flags;
int status;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return -EINVAL;
+ }
+ //ALPS00423739
+
pr_vdebug("gs_put_char: (%d,%p) char=0x%x, called from %pf\n",
port->port_num, tty, ch, __builtin_return_address(0));
struct gs_port *port = tty->driver_data;
unsigned long flags;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return;
+ }
+ //ALPS00423739
+
pr_vdebug("gs_flush_chars: (%d,%p)\n", port->port_num, tty);
spin_lock_irqsave(&port->port_lock, flags);
unsigned long flags;
int room = 0;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return -EINVAL;
+ }
+ //ALPS00423739
+
spin_lock_irqsave(&port->port_lock, flags);
if (port->port_usb)
room = gs_buf_space_avail(&port->port_write_buf);
unsigned long flags;
int chars = 0;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return -EINVAL;
+ }
+ //ALPS00423739
+
spin_lock_irqsave(&port->port_lock, flags);
chars = gs_buf_data_avail(&port->port_write_buf);
spin_unlock_irqrestore(&port->port_lock, flags);
struct gs_port *port = tty->driver_data;
unsigned long flags;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return;
+ }
+ //ALPS00423739
+
spin_lock_irqsave(&port->port_lock, flags);
if (port->port_usb) {
/* Kickstart read queue processing. We don't do xon/xoff,
int status = 0;
struct gserial *gser;
+ //ALPS00423739
+ if(!port)
+ {
+ printk("ERROR!!! port is closed!! %s, line %d: port = %p\n", __func__, __LINE__, port);
+ /*abort immediately after disconnect */
+ return -EINVAL;
+ }
+ //ALPS00423739
+
pr_vdebug("gs_break_ctl: ttyGS%d, send break (%d) \n",
port->port_num, duration);
tty_dev = tty_port_register_device(&ports[port_num].port->port,
gs_tty_driver, port_num, NULL);
+
if (IS_ERR(tty_dev)) {
struct gs_port *port;
pr_err("%s: failed to register tty for port %d, err %ld\n",