Hi,
Here's a patch against 2.5.1-pre7 that removes the active variable in
the serial port structure in the usb serial drivers, and adds some
documentation to the usb-serial.h file.
thanks,
greg k-h
diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
--- a/drivers/usb/serial/belkin_sa.c Fri Dec 7 21:30:08 2001
+++ b/drivers/usb/serial/belkin_sa.c Fri Dec 7 21:30:08 2001
@@ -211,9 +211,7 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
/*Start reading from the device*/
/* TODO: Look at possibility of submitting mulitple URBs to device to
* enhance buffering. Win trace shows 16 initial read URBs.
@@ -262,7 +260,7 @@
usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->interrupt_in_urb);
}
- port->active = 0;
+ port->open_count = 0;
}
up (&port->sem);
diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
--- a/drivers/usb/serial/cyberjack.c Fri Dec 7 21:30:07 2001
+++ b/drivers/usb/serial/cyberjack.c Fri Dec 7 21:30:07 2001
@@ -156,8 +156,7 @@
++port->open_count;
- if (!port->active) {
- port->active = 1;
+ if (port->open_count == 1) {
/* force low_latency on so that our tty_push actually forces
* the data through, otherwise it is scheduled, and with high
* data rates (like with OHCI) data can get lost.
@@ -201,8 +200,6 @@
usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->interrupt_in_urb);
}
-
- port->active = 0;
port->open_count = 0;
}
diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
--- a/drivers/usb/serial/digi_acceleport.c Fri Dec 7 21:30:08 2001
+++ b/drivers/usb/serial/digi_acceleport.c Fri Dec 7 21:30:08 2001
@@ -14,6 +14,10 @@
* Peter Berger ([EMAIL PROTECTED])
* Al Borchers ([EMAIL PROTECTED])
*
+* (12/03/2001) gkh
+* switched to using port->open_count instead of private version.
+* Removed port->active
+*
* (04/08/2001) gb
* Identify version on module load.
*
@@ -429,7 +433,6 @@
int dp_write_urb_in_use;
unsigned int dp_modem_signals;
wait_queue_head_t dp_modem_change_wait;
- int dp_open_count; /* inc on open, dec on close */
int dp_transmit_idle;
wait_queue_head_t dp_transmit_idle_wait;
int dp_throttled;
@@ -1380,7 +1383,7 @@
/* try to send any buffered data on this port, if it is open */
spin_lock( &priv->dp_port_lock );
priv->dp_write_urb_in_use = 0;
- if( priv->dp_open_count && port->write_urb->status != -EINPROGRESS
+ if( port->open_count && port->write_urb->status != -EINPROGRESS
&& priv->dp_out_buf_len > 0 ) {
*((unsigned char *)(port->write_urb->transfer_buffer))
@@ -1474,7 +1477,7 @@
unsigned long flags = 0;
-dbg( "digi_open: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num,
port->active, priv->dp_open_count );
+dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count );
/* be sure the device is started up */
if( digi_startup_device( port->serial ) != 0 )
@@ -1489,7 +1492,7 @@
}
/* inc module use count before sleeping to wait for closes */
- ++priv->dp_open_count;
+ ++port->open_count;
MOD_INC_USE_COUNT;
/* wait for a close in progress to finish */
@@ -1498,7 +1501,7 @@
&priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
&priv->dp_port_lock, flags );
if( signal_pending(current) ) {
- --priv->dp_open_count;
+ --port->open_count;
MOD_DEC_USE_COUNT;
return( -EINTR );
}
@@ -1507,13 +1510,11 @@
/* if port is already open, just return */
/* be sure exactly one open proceeds */
- if( port->active ) {
+ if( port->open_count != 1) {
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
return( 0 );
}
- /* first open, mark port as active */
- port->active = 1;
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
/* read modem signals automatically whenever they change */
@@ -1554,17 +1555,17 @@
unsigned long flags = 0;
-dbg( "digi_close: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num,
port->active, priv->dp_open_count );
+dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count );
/* do cleanup only after final close on this port */
spin_lock_irqsave( &priv->dp_port_lock, flags );
- if( priv->dp_open_count > 1 ) {
- --priv->dp_open_count;
+ if( port->open_count > 1 ) {
+ --port->open_count;
MOD_DEC_USE_COUNT;
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
return;
- } else if( priv->dp_open_count <= 0 ) {
+ } else if( port->open_count <= 0 ) {
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
return;
}
@@ -1638,10 +1639,9 @@
tty->closing = 0;
spin_lock_irqsave( &priv->dp_port_lock, flags );
- port->active = 0;
priv->dp_write_urb_in_use = 0;
priv->dp_in_close = 0;
- --priv->dp_open_count;
+ --port->open_count;
MOD_DEC_USE_COUNT;
wake_up_interruptible( &priv->dp_close_wait );
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
@@ -1710,8 +1710,6 @@
/* number of regular ports + 1 for the out-of-band port */
for( i=0; i<serial->type->num_ports+1; i++ ) {
- serial->port[i].active = 0;
-
/* allocate port private structure */
priv = serial->port[i].private =
(digi_port_t *)kmalloc( sizeof(digi_port_t),
@@ -1730,7 +1728,6 @@
priv->dp_write_urb_in_use = 0;
priv->dp_modem_signals = 0;
init_waitqueue_head( &priv->dp_modem_change_wait );
- priv->dp_open_count = 0;
priv->dp_transmit_idle = 0;
init_waitqueue_head( &priv->dp_transmit_idle_wait );
priv->dp_throttled = 0;
@@ -1789,9 +1786,9 @@
for( i=0; i<serial->type->num_ports; i++ ) {
priv = serial->port[i].private;
spin_lock_irqsave( &priv->dp_port_lock, flags );
- while( priv->dp_open_count > 0 ) {
+ while( serial->port[i].open_count > 0 ) {
MOD_DEC_USE_COUNT;
- --priv->dp_open_count;
+ --serial->port[i].open_count;
}
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
}
@@ -1883,7 +1880,7 @@
/* do not process callbacks on closed ports */
/* but do continue the read chain */
- if( priv->dp_open_count == 0 )
+ if( port->open_count == 0 )
return( 0 );
/* short/multiple packet check */
@@ -2017,7 +2014,7 @@
if( val & DIGI_READ_INPUT_SIGNALS_CTS ) {
priv->dp_modem_signals |= TIOCM_CTS;
/* port must be open to use tty struct */
- if( priv->dp_open_count
+ if( port->open_count
&& port->tty->termios->c_cflag & CRTSCTS ) {
port->tty->hw_stopped = 0;
digi_wakeup_write( port );
@@ -2025,7 +2022,7 @@
} else {
priv->dp_modem_signals &= ~TIOCM_CTS;
/* port must be open to use tty struct */
- if( priv->dp_open_count
+ if( port->open_count
&& port->tty->termios->c_cflag & CRTSCTS ) {
port->tty->hw_stopped = 1;
}
diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
--- a/drivers/usb/serial/empeg.c Fri Dec 7 21:30:06 2001
+++ b/drivers/usb/serial/empeg.c Fri Dec 7 21:30:06 2001
@@ -161,12 +161,11 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
+ if (port->open_count == 1) {
/* Force default termio settings */
empeg_set_termios (port, NULL) ;
- port->active = 1;
bytes_in = 0;
bytes_out = 0;
@@ -218,7 +217,6 @@
/* shutdown our bulk read */
usb_unlink_urb (port->read_urb);
}
- port->active = 0;
port->open_count = 0;
}
diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c Fri Dec 7 21:30:07 2001
+++ b/drivers/usb/serial/ftdi_sio.c Fri Dec 7 21:30:07 2001
@@ -321,9 +321,7 @@
MOD_INC_USE_COUNT;
++port->open_count;
- if (!port->active){
- port->active = 1;
-
+ if (port->open_count == 1){
/* This will push the characters through immediately rather
than queue a task to deliver them */
port->tty->low_latency = 1;
@@ -404,7 +402,6 @@
usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb);
}
- port->active = 0;
port->open_count = 0;
} else {
/* Send a HUP if necessary */
diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
--- a/drivers/usb/serial/io_edgeport.c Fri Dec 7 21:30:08 2001
+++ b/drivers/usb/serial/io_edgeport.c Fri Dec 7 21:30:08 2001
@@ -987,9 +987,7 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
/* force low_latency on so that our tty_push actually forces the data
through,
otherwise it is scheduled, and with high data rates (like with
OHCI) data
can get lost. */
@@ -1000,7 +998,6 @@
serial = port->serial;
edge_serial = (struct edgeport_serial *)serial->private;
if (edge_serial == NULL) {
- port->active = 0;
port->open_count = 0;
MOD_DEC_USE_COUNT;
return -ENODEV;
@@ -1064,7 +1061,6 @@
if (response < 0) {
err(__FUNCTION__" - error sending open port command");
edge_port->openPending = FALSE;
- port->active = 0;
port->open_count = 0;
MOD_DEC_USE_COUNT;
return -ENODEV;
@@ -1080,7 +1076,6 @@
/* open timed out */
dbg(__FUNCTION__" - open timedout");
edge_port->openPending = FALSE;
- port->active = 0;
port->open_count = 0;
MOD_DEC_USE_COUNT;
return -ENODEV;
@@ -1285,7 +1280,6 @@
if (edge_port->txfifo.fifo) {
kfree(edge_port->txfifo.fifo);
}
- port->active = 0;
port->open_count = 0;
}
diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
--- a/drivers/usb/serial/ir-usb.c Fri Dec 7 21:30:07 2001
+++ b/drivers/usb/serial/ir-usb.c Fri Dec 7 21:30:07 2001
@@ -206,9 +206,7 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
if (buffer_size) {
/* override the default buffer sizes */
buffer = kmalloc (buffer_size, GFP_KERNEL);
@@ -268,7 +266,6 @@
/* shutdown our bulk read */
usb_unlink_urb (port->read_urb);
}
- port->active = 0;
port->open_count = 0;
}
diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
--- a/drivers/usb/serial/keyspan.c Fri Dec 7 21:30:08 2001
+++ b/drivers/usb/serial/keyspan.c Fri Dec 7 21:30:08 2001
@@ -468,7 +468,7 @@
p_priv = (struct keyspan_port_private *)(port->private);
dbg (__FUNCTION__ " urb %d\n", urb == p_priv->out_urbs[1]);
- if (port->active) {
+ if (port->open_count) {
queue_task(&port->tqueue, &tq_immediate);
mark_bh(IMMEDIATE_BH);
}
@@ -880,9 +880,8 @@
MOD_INC_USE_COUNT;
down (&port->sem);
+ already_active = port->open_count;
++port->open_count;
- already_active = port->active;
- port->active = 1;
up (&port->sem);
if (already_active)
@@ -948,18 +947,15 @@
down (&port->sem);
if (--port->open_count <= 0) {
- if (port->active) {
- if (serial->dev) {
- /* Stop reading/writing urbs */
- stop_urb(p_priv->inack_urb);
- stop_urb(p_priv->outcont_urb);
- for (i = 0; i < 2; i++) {
- stop_urb(p_priv->in_urbs[i]);
- stop_urb(p_priv->out_urbs[i]);
- }
+ if (serial->dev) {
+ /* Stop reading/writing urbs */
+ stop_urb(p_priv->inack_urb);
+ stop_urb(p_priv->outcont_urb);
+ for (i = 0; i < 2; i++) {
+ stop_urb(p_priv->in_urbs[i]);
+ stop_urb(p_priv->out_urbs[i]);
}
}
- port->active = 0;
port->open_count = 0;
port->tty = 0;
}
diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
--- a/drivers/usb/serial/keyspan_pda.c Fri Dec 7 21:30:06 2001
+++ b/drivers/usb/serial/keyspan_pda.c Fri Dec 7 21:30:06 2001
@@ -675,9 +675,7 @@
MOD_INC_USE_COUNT;
++port->open_count;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
/* find out how much room is in the Tx ring */
rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
6, /* write_room */
@@ -723,7 +721,6 @@
return rc;
error:
--port->open_count;
- port->active = 0;
MOD_DEC_USE_COUNT;
up (&port->sem);
return rc;
@@ -748,7 +745,6 @@
usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->interrupt_in_urb);
}
- port->active = 0;
port->open_count = 0;
}
diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
--- a/drivers/usb/serial/omninet.c Fri Dec 7 21:30:07 2001
+++ b/drivers/usb/serial/omninet.c Fri Dec 7 21:30:07 2001
@@ -161,14 +161,11 @@
MOD_INC_USE_COUNT;
++port->open_count;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
if( !od ) {
err(__FUNCTION__"- kmalloc(%Zd) failed.", sizeof(struct
omninet_data));
- --port->open_count;
- port->active = 0;
+ port->open_count = 0;
up (&port->sem);
MOD_DEC_USE_COUNT;
return -ENOMEM;
@@ -219,7 +216,6 @@
usb_unlink_urb (port->read_urb);
}
- port->active = 0;
port->open_count = 0;
od = (struct omninet_data *)port->private;
if (od)
diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
--- a/drivers/usb/serial/pl2303.c Fri Dec 7 21:30:06 2001
+++ b/drivers/usb/serial/pl2303.c Fri Dec 7 21:30:06 2001
@@ -371,9 +371,7 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
#define FISH(a,b,c,d)
\
result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0),
\
b, a, c, d, buf, 1, 100);
\
@@ -478,8 +476,6 @@
"(interrupt_in_urb) failed with reason: %d",
result);
}
-
- port->active = 0;
port->open_count = 0;
}
@@ -648,7 +644,7 @@
if (urb->status) {
dbg (__FUNCTION__ " - urb->status = %d", urb->status);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port is closed, exiting.");
return;
}
@@ -680,7 +676,7 @@
}
/* Schedule the next read _if_ we are still open */
- if (port->active) {
+ if (port->open_count) {
urb->dev = serial->dev;
result = usb_submit_urb(urb);
if (result)
diff -Nru a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
--- a/drivers/usb/serial/usb-serial.h Fri Dec 7 21:30:07 2001
+++ b/drivers/usb/serial/usb-serial.h Fri Dec 7 21:30:07 2001
@@ -11,6 +11,10 @@
*
* See Documentation/usb/usb-serial.txt for more information on using this driver
*
+ * (12/03/2001) gkh
+ * removed active from the port structure.
+ * added documentation to the usb_serial_device_type structure
+ *
* (10/10/2001) gkh
* added vendor and product to serial structure. Needed to determine device
* owner when the device is disconnected.
@@ -65,7 +69,6 @@
struct usb_serial *serial; /* pointer back to the owner of this
port */
struct tty_struct * tty; /* the coresponding tty for this port
*/
unsigned char number;
- char active; /* someone has this device open */
unsigned char * interrupt_in_buffer;
struct urb * interrupt_in_urb;
@@ -111,21 +114,40 @@
#define NUM_DONT_CARE (-1)
-/* This structure defines the individual serial converter. */
+/**
+ * usb_serial_device_type - a structure that defines a usb serial device
+ * @name: pointer to a string that describes this device. This string used
+ * in the syslog messages when a device is inserted or removed.
+ * @id_table: pointer to a list of usb_device_id structures that define all
+ * of the devices this structure can support.
+ * @num_interrupt_in: the number of interrupt in endpoints this device will
+ * have.
+ * @num_bulk_in: the number of bulk in endpoints this device will have.
+ * @num_bulk_out: the number of bulk out endpoints this device will have.
+ * @num_ports: the number of different ports this device will have.
+ * @startup: pointer to the driver's startup function. This will be called
+ * when the driver is inserted into the system. Return 0 to continue
+ * on with the initialization sequence. Anything else will abort it.
+ * @shutdown: pointer to the driver's shutdown function. This will be
+ * called when the device is removed from the system.
+ *
+ * This structure is defines a USB Serial device. It provides all of
+ * the information that the USB serial core code needs. If the function
+ * pointers are defined, then the USB serial core code will call them when
+ * the corresponding tty port functions are called. If they are not
+ * called, the generic serial function will be used instead.
+ */
struct usb_serial_device_type {
char *name;
const struct usb_device_id *id_table;
char num_interrupt_in;
char num_bulk_in;
char num_bulk_out;
- char num_ports; /* number of serial ports this device has */
+ char num_ports;
struct list_head driver_list;
- /* function call to make before accepting driver */
- /* return 0 to continue initialization, anything else to abort */
int (*startup) (struct usb_serial *serial);
-
void (*shutdown) (struct usb_serial *serial);
/* serial function calls */
diff -Nru a/drivers/usb/serial/usbserial.c b/drivers/usb/serial/usbserial.c
--- a/drivers/usb/serial/usbserial.c Fri Dec 7 21:30:07 2001
+++ b/drivers/usb/serial/usbserial.c Fri Dec 7 21:30:07 2001
@@ -545,7 +545,7 @@
dbg(__FUNCTION__ " - port %d", port->number);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not opened");
return;
}
@@ -570,7 +570,7 @@
dbg(__FUNCTION__ " - port %d, %d byte(s)", port->number, count);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not opened");
return -EINVAL;
}
@@ -595,7 +595,7 @@
dbg(__FUNCTION__ " - port %d", port->number);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return -EINVAL;
}
@@ -618,7 +618,7 @@
return -ENODEV;
}
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return -EINVAL;
}
@@ -643,7 +643,7 @@
dbg(__FUNCTION__ " - port %d", port->number);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return;
}
@@ -668,7 +668,7 @@
dbg(__FUNCTION__ " - port %d", port->number);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return;
}
@@ -693,7 +693,7 @@
dbg(__FUNCTION__ " - port %d, cmd 0x%.4x", port->number, cmd);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return -ENODEV;
}
@@ -718,7 +718,7 @@
dbg(__FUNCTION__ " - port %d", port->number);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return;
}
@@ -743,7 +743,7 @@
dbg(__FUNCTION__ " - port %d", port->number);
- if (!port->active) {
+ if (!port->open_count) {
dbg (__FUNCTION__ " - port not open");
return;
}
@@ -787,9 +787,7 @@
++port->open_count;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
/* force low_latency on so that our tty_push actually forces the data
through,
otherwise it is scheduled, and with high data rates (like with
OHCI) data
can get lost. */
@@ -798,13 +796,14 @@
/* if we have a bulk interrupt, start reading from it */
if (serial->num_bulk_in) {
/* Start reading from the device */
- FILL_BULK_URB(port->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev,
port->bulk_in_endpointAddress),
- port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length,
- ((serial->type->read_bulk_callback) ?
- serial->type->read_bulk_callback :
- generic_read_bulk_callback),
- port);
+ usb_fill_bulk_urb (port->read_urb, serial->dev,
+ usb_rcvbulkpipe(serial->dev,
+port->bulk_in_endpointAddress),
+ port->read_urb->transfer_buffer,
+ port->read_urb->transfer_buffer_length,
+ ((serial->type->read_bulk_callback) ?
+ serial->type->read_bulk_callback :
+ generic_read_bulk_callback),
+ port);
result = usb_submit_urb(port->read_urb);
if (result)
err(__FUNCTION__ " - failed resubmitting read urb,
error %d", result);
@@ -835,8 +834,6 @@
if (serial->num_bulk_in)
usb_unlink_urb (port->read_urb);
}
-
- port->active = 0;
port->open_count = 0;
}
@@ -879,13 +876,13 @@
usb_serial_debug_data (__FILE__, __FUNCTION__, count,
port->write_urb->transfer_buffer);
/* set up our urb */
- FILL_BULK_URB(port->write_urb, serial->dev,
- usb_sndbulkpipe(serial->dev,
port->bulk_out_endpointAddress),
- port->write_urb->transfer_buffer, count,
- ((serial->type->write_bulk_callback) ?
- serial->type->write_bulk_callback :
- generic_write_bulk_callback),
- port);
+ usb_fill_bulk_urb (port->write_urb, serial->dev,
+ usb_sndbulkpipe (serial->dev,
+ port->bulk_out_endpointAddress),
+ port->write_urb->transfer_buffer, count,
+ ((serial->type->write_bulk_callback) ?
+ serial->type->write_bulk_callback :
+ generic_write_bulk_callback), port);
/* send the data out the bulk port */
result = usb_submit_urb(port->write_urb);
@@ -973,13 +970,14 @@
}
/* Continue trying to always read */
- FILL_BULK_URB(port->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
- port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length,
- ((serial->type->read_bulk_callback) ?
- serial->type->read_bulk_callback :
- generic_read_bulk_callback),
- port);
+ usb_fill_bulk_urb (port->read_urb, serial->dev,
+ usb_rcvbulkpipe (serial->dev,
+ port->bulk_in_endpointAddress),
+ port->read_urb->transfer_buffer,
+ port->read_urb->transfer_buffer_length,
+ ((serial->type->read_bulk_callback) ?
+ serial->type->read_bulk_callback :
+ generic_read_bulk_callback), port);
result = usb_submit_urb(port->read_urb);
if (result)
err(__FUNCTION__ " - failed resubmitting read urb, error %d", result);
@@ -1203,13 +1201,14 @@
err("Couldn't allocate bulk_in_buffer");
goto probe_error;
}
- FILL_BULK_URB(port->read_urb, dev,
- usb_rcvbulkpipe(dev, endpoint->bEndpointAddress),
- port->bulk_in_buffer, buffer_size,
- ((serial->type->read_bulk_callback) ?
- serial->type->read_bulk_callback :
- generic_read_bulk_callback),
- port);
+ usb_fill_bulk_urb (port->read_urb, dev,
+ usb_rcvbulkpipe (dev,
+ endpoint->bEndpointAddress),
+ port->bulk_in_buffer, buffer_size,
+ ((serial->type->read_bulk_callback) ?
+ serial->type->read_bulk_callback :
+ generic_read_bulk_callback),
+ port);
}
for (i = 0; i < num_bulk_out; ++i) {
@@ -1228,13 +1227,14 @@
err("Couldn't allocate bulk_out_buffer");
goto probe_error;
}
- FILL_BULK_URB(port->write_urb, dev,
- usb_sndbulkpipe(dev, endpoint->bEndpointAddress),
- port->bulk_out_buffer, buffer_size,
- ((serial->type->write_bulk_callback) ?
- serial->type->write_bulk_callback :
- generic_write_bulk_callback),
- port);
+ usb_fill_bulk_urb (port->write_urb, dev,
+ usb_sndbulkpipe (dev,
+ endpoint->bEndpointAddress),
+ port->bulk_out_buffer, buffer_size,
+ ((serial->type->write_bulk_callback) ?
+ serial->type->write_bulk_callback :
+ generic_write_bulk_callback),
+ port);
}
for (i = 0; i < num_interrupt_in; ++i) {
@@ -1252,12 +1252,12 @@
err("Couldn't allocate interrupt_in_buffer");
goto probe_error;
}
- FILL_INT_URB(port->interrupt_in_urb, dev,
- usb_rcvintpipe(dev, endpoint->bEndpointAddress),
- port->interrupt_in_buffer, buffer_size,
- serial->type->read_int_callback,
- port,
- endpoint->bInterval);
+ usb_fill_int_urb (port->interrupt_in_urb, dev,
+ usb_rcvintpipe (dev,
+ endpoint->bEndpointAddress),
+ port->interrupt_in_buffer, buffer_size,
+ serial->type->read_int_callback, port,
+ endpoint->bInterval);
}
/* initialize some parts of the port structures */
@@ -1335,7 +1335,7 @@
serial_shutdown (serial);
for (i = 0; i < serial->num_ports; ++i)
- serial->port[i].active = 0;
+ serial->port[i].open_count = 0;
for (i = 0; i < serial->num_bulk_in; ++i) {
port = &serial->port[i];
diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
--- a/drivers/usb/serial/visor.c Fri Dec 7 21:30:06 2001
+++ b/drivers/usb/serial/visor.c Fri Dec 7 21:30:06 2001
@@ -127,7 +127,7 @@
/*
* Version Information
*/
-#define DRIVER_VERSION "v1.6"
+#define DRIVER_VERSION "v1.7"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <[EMAIL PROTECTED]>"
#define DRIVER_DESC "USB HandSpring Visor, Palm m50x, Sony Cli� driver"
@@ -251,8 +251,7 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
- port->active = 1;
+ if (port->open_count == 1) {
bytes_in = 0;
bytes_out = 0;
@@ -262,10 +261,12 @@
port->tty->low_latency = 1;
/* Start reading from the device */
- FILL_BULK_URB(port->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev,
port->bulk_in_endpointAddress),
- port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length,
- visor_read_bulk_callback, port);
+ usb_fill_bulk_urb (port->read_urb, serial->dev,
+ usb_rcvbulkpipe (serial->dev,
+ port->bulk_in_endpointAddress),
+ port->read_urb->transfer_buffer,
+ port->read_urb->transfer_buffer_length,
+ visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb);
if (result)
err(__FUNCTION__ " - failed submitting read urb, error %d",
result);
@@ -314,7 +315,6 @@
/* shutdown our bulk read */
usb_unlink_urb (port->read_urb);
}
- port->active = 0;
port->open_count = 0;
}
up (&port->sem);
@@ -375,8 +375,11 @@
usb_serial_debug_data (__FILE__, __FUNCTION__, transfer_size,
urb->transfer_buffer);
/* build up our urb */
- FILL_BULK_URB (urb, serial->dev, usb_sndbulkpipe(serial->dev,
port->bulk_out_endpointAddress),
- urb->transfer_buffer, transfer_size,
visor_write_bulk_callback, port);
+ usb_fill_bulk_urb (urb, serial->dev,
+ usb_sndbulkpipe (serial->dev,
+ port->bulk_out_endpointAddress),
+ urb->transfer_buffer, transfer_size,
+ visor_write_bulk_callback, port);
urb->transfer_flags |= USB_QUEUE_BULK;
/* send it down the pipe */
@@ -506,10 +509,12 @@
}
/* Continue trying to always read */
- FILL_BULK_URB(port->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
- port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length,
- visor_read_bulk_callback, port);
+ usb_fill_bulk_urb (port->read_urb, serial->dev,
+ usb_rcvbulkpipe (serial->dev,
+ port->bulk_in_endpointAddress),
+ port->read_urb->transfer_buffer,
+ port->read_urb->transfer_buffer_length,
+ visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb);
if (result)
err(__FUNCTION__ " - failed resubmitting read urb, error %d", result);
@@ -647,11 +652,8 @@
dbg (__FUNCTION__);
/* stop reads and writes on all ports */
- for (i=0; i < serial->num_ports; ++i) {
- while (serial->port[i].open_count > 0) {
- visor_close (&serial->port[i], NULL);
- }
- }
+ for (i=0; i < serial->num_ports; ++i)
+ serial->port[i].open_count = 0;
}
diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
--- a/drivers/usb/serial/whiteheat.c Fri Dec 7 21:30:08 2001
+++ b/drivers/usb/serial/whiteheat.c Fri Dec 7 21:30:08 2001
@@ -309,9 +309,7 @@
++port->open_count;
MOD_INC_USE_COUNT;
- if (!port->active) {
- port->active = 1;
-
+ if (port->open_count == 1) {
/* set up some stuff for our command port */
command_port = &port->serial->port[COMMAND_PORT];
if (command_port->private == NULL) {
@@ -391,7 +389,7 @@
/* shutdown our bulk reads and writes */
usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb);
- port->active = 0;
+ port->open_count = 0;
}
MOD_DEC_USE_COUNT;
up (&port->sem);
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel