usb serial write fix
PATCH 1/1 usb serial write fix
Fix usb serial write path in post_helper to check return code from component driver write routine and
resubmit if necessary. The post helper introduced in 2.4.27-pre6 can lose write data if component device write is busy.
This was previously reported as a problem with the pl2303 driver running PPP by [email protected] Oleksiy has tested the patch with success.
Signed-off-by Paul Fulghum <[email protected]>
Signature · 26 lines
Paul Fulghum [email protected] --- linux-2.4.28-pre4/drivers/usb/serial/usbserial.c 2004-08-07 18:26:05.000000000 -0500 +++ b/drivers/usb/serial/usbserial.c 2004-11-01 08:29:07.000000000 -0600 @@ -508,8 +508,18 @@ static void post_helper(void *arg) down(&port->sem); dbg("%s - port %d len %d backlog %d", __FUNCTION__, port->number, job->len, port->write_backlog); - if (port->tty != NULL) - __serial_write(port, 0, job->buff, job->len); + if (port->tty != NULL) { + int rc; + int sent = 0; + while (sent < job->len) { + rc = __serial_write(port, 0, job->buff + sent, job->len - sent); + if ((rc < 0) || signal_pending(current)) + break; + sent += rc; + if ((sent < job->len) && current->need_resched) + schedule(); + } + } up(&port->sem); spin_lock_irqsave(&post_lock, flags);