[PATCH 2.4] usb serial write fix

From: Paul Fulghum
Date: Mon Nov 01 2004 - 09:58:10 EST


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 oleksiy@xxxxxxxxx
Oleksiy has tested the patch with success.

Signed-off-by: Paul Fulghum <paulkf@xxxxxxxxxxxxx>

--
Paul Fulghum
paulkf@xxxxxxxxxxxxx

--- 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);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/