Subject: [PATCH 02/10] usb-serial: generic driver port.


Ports the generic driver from write_urb_busy spin_lock to
usb_serial_write_urb_lock() functions.

Signed-off-by: Luiz Capitulino <[email protected]>

drivers/usb/serial/generic.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff -Nparu -X /home/lcapitulino/kernels/dontdiff a/drivers/usb/serial/generic.c a~/drivers/usb/serial/generic.c
--- a/drivers/usb/serial/generic.c 2005-12-04 01:44:18.000000000 -0200
+++ a~/drivers/usb/serial/generic.c 2005-12-04 14:05:26.000000000 -0200
@@ -175,14 +175,10 @@ int usb_serial_generic_write(struct usb_

/* only do something if we have a bulk out endpoint */
if (serial->num_bulk_out) {
- spin_lock(&port->lock);
- if (port->write_urb_busy) {
- spin_unlock(&port->lock);
+ if (usb_serial_write_urb_lock(port)) {
dbg("%s - already writing", __FUNCTION__);
return 0;
}
- port->write_urb_busy = 1;
- spin_unlock(&port->lock);

count = (count > port->bulk_out_size) ? port->bulk_out_size : count;

@@ -200,12 +196,12 @@ int usb_serial_generic_write(struct usb_
usb_serial_generic_write_bulk_callback), port);

/* send the data out the bulk port */
- port->write_urb_busy = 1;
+ usb_serial_write_urb_lock(port);
result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
if (result) {
dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
/* don't have to grab the lock here, as we will retry if != 0 */
- port->write_urb_busy = 0;
+ usb_serial_write_urb_unlock(port);
} else
result = count;

@@ -224,7 +220,7 @@ int usb_serial_generic_write_room (struc
dbg("%s - port %d", __FUNCTION__, port->number);

if (serial->num_bulk_out) {
- if (!(port->write_urb_busy))
+ if (!(usb_serial_write_urb_locked(port)))
room = port->bulk_out_size;
}

@@ -240,7 +236,7 @@ int usb_serial_generic_chars_in_buffer (
dbg("%s - port %d", __FUNCTION__, port->number);

if (serial->num_bulk_out) {
- if (port->write_urb_busy)
+ if (usb_serial_write_urb_locked(port))
chars = port->write_urb->transfer_buffer_length;
}

@@ -299,7 +295,7 @@ void usb_serial_generic_write_bulk_callb

dbg("%s - port %d", __FUNCTION__, port->number);

- port->write_urb_busy = 0;
+ usb_serial_write_urb_unlock(port);
if (urb->status) {
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
return;


--
Luiz Fernando N. Capitulino