Commit e1127c36 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB serial drivers

changes due to open_count being handled by the usb-serial core code.
parent 9fb1cce0
...@@ -191,9 +191,6 @@ static void belkin_sa_shutdown (struct usb_serial *serial) ...@@ -191,9 +191,6 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */ /* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
belkin_sa_close (&serial->port[i], NULL);
}
/* My special items, the standard routines free my urbs */ /* My special items, the standard routines free my urbs */
if (serial->port[i].private) if (serial->port[i].private)
kfree(serial->port[i].private); kfree(serial->port[i].private);
...@@ -207,9 +204,6 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) ...@@ -207,9 +204,6 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__" port %d", port->number); dbg(__FUNCTION__" port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
/*Start reading from the device*/ /*Start reading from the device*/
/* TODO: Look at possibility of submitting mulitple URBs to device to /* TODO: Look at possibility of submitting mulitple URBs to device to
* enhance buffering. Win trace shows 16 initial read URBs. * enhance buffering. Win trace shows 16 initial read URBs.
...@@ -225,7 +219,6 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) ...@@ -225,7 +219,6 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (retval) if (retval)
err(" usb_submit_urb(read int) failed"); err(" usb_submit_urb(read int) failed");
}
exit: exit:
return retval; return retval;
...@@ -245,17 +238,12 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) ...@@ -245,17 +238,12 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__" port %d", port->number); dbg(__FUNCTION__" port %d", port->number);
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
/* shutdown our bulk reads and writes */ /* shutdown our bulk reads and writes */
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->interrupt_in_urb); usb_unlink_urb (port->interrupt_in_urb);
} }
port->open_count = 0;
}
} /* belkin_sa_close */ } /* belkin_sa_close */
......
...@@ -130,11 +130,7 @@ static void cyberjack_shutdown (struct usb_serial *serial) ...@@ -130,11 +130,7 @@ static void cyberjack_shutdown (struct usb_serial *serial)
dbg (__FUNCTION__); dbg (__FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
cyberjack_close (&serial->port[i], NULL);
}
/* My special items, the standard routines free my urbs */ /* My special items, the standard routines free my urbs */
if (serial->port[i].private) if (serial->port[i].private)
kfree(serial->port[i].private); kfree(serial->port[i].private);
...@@ -151,9 +147,6 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) ...@@ -151,9 +147,6 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__ " - port %d", port->number); dbg(__FUNCTION__ " - port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
/* force low_latency on so that our tty_push actually forces /* force low_latency on so that our tty_push actually forces
* the data through, otherwise it is scheduled, and with high * the data through, otherwise it is scheduled, and with high
* data rates (like with OHCI) data can get lost. * data rates (like with OHCI) data can get lost.
...@@ -175,7 +168,6 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) ...@@ -175,7 +168,6 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
if (result) if (result)
err(" usb_submit_urb(read int) failed"); err(" usb_submit_urb(read int) failed");
dbg(__FUNCTION__ " - usb_submit_urb(int urb)"); dbg(__FUNCTION__ " - usb_submit_urb(int urb)");
}
return result; return result;
} }
...@@ -184,17 +176,12 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp) ...@@ -184,17 +176,12 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
{ {
dbg(__FUNCTION__ " - port %d", port->number); dbg(__FUNCTION__ " - port %d", port->number);
--port->open_count;
if (port->open_count <= 0) {
if (port->serial->dev) { if (port->serial->dev) {
/* shutdown any bulk reads that might be going on */ /* shutdown any bulk reads that might be going on */
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->interrupt_in_urb); usb_unlink_urb (port->interrupt_in_urb);
} }
port->open_count = 0;
}
} }
static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
......
...@@ -1490,28 +1490,17 @@ dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_cou ...@@ -1490,28 +1490,17 @@ dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_cou
return( -EAGAIN ); return( -EAGAIN );
} }
/* inc module use count before sleeping to wait for closes */
++port->open_count;
/* wait for a close in progress to finish */ /* wait for a close in progress to finish */
while( priv->dp_in_close ) { while( priv->dp_in_close ) {
cond_wait_interruptible_timeout_irqrestore( cond_wait_interruptible_timeout_irqrestore(
&priv->dp_close_wait, DIGI_RETRY_TIMEOUT, &priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
&priv->dp_port_lock, flags ); &priv->dp_port_lock, flags );
if( signal_pending(current) ) { if( signal_pending(current) ) {
--port->open_count;
return( -EINTR ); return( -EINTR );
} }
spin_lock_irqsave( &priv->dp_port_lock, flags ); spin_lock_irqsave( &priv->dp_port_lock, flags );
} }
/* if port is already open, just return */
/* be sure exactly one open proceeds */
if( port->open_count != 1) {
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
return( 0 );
}
spin_unlock_irqrestore( &priv->dp_port_lock, flags ); spin_unlock_irqrestore( &priv->dp_port_lock, flags );
/* read modem signals automatically whenever they change */ /* read modem signals automatically whenever they change */
...@@ -1557,14 +1546,6 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co ...@@ -1557,14 +1546,6 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co
/* do cleanup only after final close on this port */ /* do cleanup only after final close on this port */
spin_lock_irqsave( &priv->dp_port_lock, flags ); spin_lock_irqsave( &priv->dp_port_lock, flags );
if( port->open_count > 1 ) {
--port->open_count;
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
return;
} else if( port->open_count <= 0 ) {
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
return;
}
priv->dp_in_close = 1; priv->dp_in_close = 1;
spin_unlock_irqrestore( &priv->dp_port_lock, flags ); spin_unlock_irqrestore( &priv->dp_port_lock, flags );
...@@ -1637,7 +1618,6 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co ...@@ -1637,7 +1618,6 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co
spin_lock_irqsave( &priv->dp_port_lock, flags ); spin_lock_irqsave( &priv->dp_port_lock, flags );
priv->dp_write_urb_in_use = 0; priv->dp_write_urb_in_use = 0;
priv->dp_in_close = 0; priv->dp_in_close = 0;
--port->open_count;
wake_up_interruptible( &priv->dp_close_wait ); wake_up_interruptible( &priv->dp_close_wait );
spin_unlock_irqrestore( &priv->dp_port_lock, flags ); spin_unlock_irqrestore( &priv->dp_port_lock, flags );
...@@ -1765,8 +1745,6 @@ static void digi_shutdown( struct usb_serial *serial ) ...@@ -1765,8 +1745,6 @@ static void digi_shutdown( struct usb_serial *serial )
{ {
int i; int i;
struct digi_port *priv;
unsigned long flags;
dbg( "digi_shutdown: TOP, in_interrupt()=%d", in_interrupt() ); dbg( "digi_shutdown: TOP, in_interrupt()=%d", in_interrupt() );
...@@ -1777,16 +1755,6 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%d", in_interrupt() ); ...@@ -1777,16 +1755,6 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%d", in_interrupt() );
usb_unlink_urb( serial->port[i].write_urb ); usb_unlink_urb( serial->port[i].write_urb );
} }
/* dec module use count */
for( i=0; i<serial->type->num_ports; i++ ) {
priv = serial->port[i].private;
spin_lock_irqsave( &priv->dp_port_lock, flags );
while( serial->port[i].open_count > 0 ) {
--serial->port[i].open_count;
}
spin_unlock_irqrestore( &priv->dp_port_lock, flags );
}
/* free the private data structures for all ports */ /* free the private data structures for all ports */
/* number of regular ports + 1 for the out-of-band port */ /* number of regular ports + 1 for the out-of-band port */
for( i=0; i<serial->type->num_ports+1; i++ ) for( i=0; i<serial->type->num_ports+1; i++ )
......
...@@ -157,10 +157,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) ...@@ -157,10 +157,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__ " - port %d", port->number); dbg(__FUNCTION__ " - port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
/* Force default termio settings */ /* Force default termio settings */
empeg_set_termios (port, NULL) ; empeg_set_termios (port, NULL) ;
...@@ -185,8 +181,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) ...@@ -185,8 +181,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
if (result) if (result)
err(__FUNCTION__ " - failed submitting read urb, error %d", result); err(__FUNCTION__ " - failed submitting read urb, error %d", result);
}
return result; return result;
} }
...@@ -204,16 +198,10 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp) ...@@ -204,16 +198,10 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
if (!serial) if (!serial)
return; return;
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
/* shutdown our bulk read */ /* shutdown our bulk read */
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
port->open_count = 0;
}
/* Uncomment the following line if you want to see some statistics in your syslog */ /* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
} }
...@@ -491,17 +479,7 @@ static int empeg_startup (struct usb_serial *serial) ...@@ -491,17 +479,7 @@ static int empeg_startup (struct usb_serial *serial)
static void empeg_shutdown (struct usb_serial *serial) static void empeg_shutdown (struct usb_serial *serial)
{ {
int i;
dbg (__FUNCTION__); dbg (__FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
empeg_close (&serial->port[i], NULL);
}
}
} }
......
...@@ -294,14 +294,8 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial) ...@@ -294,14 +294,8 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial)
static void ftdi_sio_shutdown (struct usb_serial *serial) static void ftdi_sio_shutdown (struct usb_serial *serial)
{ {
dbg (__FUNCTION__); dbg (__FUNCTION__);
/* stop reads and writes on all ports */
while (serial->port[0].open_count > 0) {
ftdi_sio_close (&serial->port[0], NULL);
}
if (serial->port[0].private){ if (serial->port[0].private){
kfree(serial->port[0].private); kfree(serial->port[0].private);
serial->port[0].private = NULL; serial->port[0].private = NULL;
...@@ -319,9 +313,6 @@ static int ftdi_sio_open (struct usb_serial_port *port, struct file *filp) ...@@ -319,9 +313,6 @@ static int ftdi_sio_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__); dbg(__FUNCTION__);
++port->open_count;
if (port->open_count == 1){
/* This will push the characters through immediately rather /* This will push the characters through immediately rather
than queue a task to deliver them */ than queue a task to deliver them */
port->tty->low_latency = 1; port->tty->low_latency = 1;
...@@ -357,7 +348,6 @@ static int ftdi_sio_open (struct usb_serial_port *port, struct file *filp) ...@@ -357,7 +348,6 @@ static int ftdi_sio_open (struct usb_serial_port *port, struct file *filp)
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err(__FUNCTION__ " - failed submitting read urb, error %d", result); err(__FUNCTION__ " - failed submitting read urb, error %d", result);
}
return result; return result;
} /* ftdi_sio_open */ } /* ftdi_sio_open */
...@@ -371,9 +361,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp) ...@@ -371,9 +361,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp)
dbg( __FUNCTION__); dbg( __FUNCTION__);
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
if (c_cflag & HUPCL){ if (c_cflag & HUPCL){
/* Disable flow control */ /* Disable flow control */
...@@ -400,13 +387,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp) ...@@ -400,13 +387,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp)
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
port->open_count = 0;
} else {
/* Send a HUP if necessary */
if (!(port->tty->termios->c_cflag & CLOCAL)){
tty_hangup(port->tty);
}
}
} /* ftdi_sio_close */ } /* ftdi_sio_close */
......
...@@ -987,9 +987,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -987,9 +987,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
if (edge_port == NULL) if (edge_port == NULL)
return -ENODEV; return -ENODEV;
++port->open_count;
if (port->open_count == 1) {
/* force low_latency on so that our tty_push actually forces the data through, /* 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 otherwise it is scheduled, and with high data rates (like with OHCI) data
can get lost. */ can get lost. */
...@@ -1000,7 +997,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -1000,7 +997,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
serial = port->serial; serial = port->serial;
edge_serial = (struct edgeport_serial *)serial->private; edge_serial = (struct edgeport_serial *)serial->private;
if (edge_serial == NULL) { if (edge_serial == NULL) {
port->open_count = 0;
return -ENODEV; return -ENODEV;
} }
if (edge_serial->interrupt_in_buffer == NULL) { if (edge_serial->interrupt_in_buffer == NULL) {
...@@ -1062,7 +1058,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -1062,7 +1058,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
if (response < 0) { if (response < 0) {
err(__FUNCTION__" - error sending open port command"); err(__FUNCTION__" - error sending open port command");
edge_port->openPending = FALSE; edge_port->openPending = FALSE;
port->open_count = 0;
return -ENODEV; return -ENODEV;
} }
...@@ -1076,7 +1071,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -1076,7 +1071,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
/* open timed out */ /* open timed out */
dbg(__FUNCTION__" - open timedout"); dbg(__FUNCTION__" - open timedout");
edge_port->openPending = FALSE; edge_port->openPending = FALSE;
port->open_count = 0;
return -ENODEV; return -ENODEV;
} }
...@@ -1103,7 +1097,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -1103,7 +1097,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
} }
dbg(__FUNCTION__"(%d) - Initialize TX fifo to %d bytes", port->number, edge_port->maxTxCredits); dbg(__FUNCTION__"(%d) - Initialize TX fifo to %d bytes", port->number, edge_port->maxTxCredits);
}
dbg(__FUNCTION__" exited"); dbg(__FUNCTION__" exited");
...@@ -1234,9 +1227,6 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ...@@ -1234,9 +1227,6 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
if ((edge_serial == NULL) || (edge_port == NULL)) if ((edge_serial == NULL) || (edge_port == NULL))
return; return;
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
// block until tx is empty // block until tx is empty
block_until_tx_empty(edge_port); block_until_tx_empty(edge_port);
...@@ -1279,8 +1269,6 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ...@@ -1279,8 +1269,6 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
if (edge_port->txfifo.fifo) { if (edge_port->txfifo.fifo) {
kfree(edge_port->txfifo.fifo); kfree(edge_port->txfifo.fifo);
} }
port->open_count = 0;
}
dbg(__FUNCTION__" exited"); dbg(__FUNCTION__" exited");
} }
...@@ -3027,9 +3015,6 @@ static void edge_shutdown (struct usb_serial *serial) ...@@ -3027,9 +3015,6 @@ static void edge_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */ /* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
edge_close (&serial->port[i], NULL);
}
kfree (serial->port[i].private); kfree (serial->port[i].private);
serial->port[i].private = NULL; serial->port[i].private = NULL;
} }
......
...@@ -123,9 +123,6 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -123,9 +123,6 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__ " - port %d", port->number); dbg(__FUNCTION__ " - port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
bytes_in = 0; bytes_in = 0;
bytes_out = 0; bytes_out = 0;
priv = (struct ipaq_private *)kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); priv = (struct ipaq_private *)kmalloc(sizeof(struct ipaq_private), GFP_KERNEL);
...@@ -210,7 +207,6 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -210,7 +207,6 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
if (result < 0) { if (result < 0) {
err(__FUNCTION__ " - failed doing control urb, error %d", result); err(__FUNCTION__ " - failed doing control urb, error %d", result);
} }
}
return result; return result;
...@@ -237,10 +233,6 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) ...@@ -237,10 +233,6 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
if (!serial) if (!serial)
return; return;
--port->open_count;
if (port->open_count <= 0) {
/* /*
* shut down bulk read and write * shut down bulk read and write
*/ */
...@@ -250,9 +242,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) ...@@ -250,9 +242,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
ipaq_destroy_lists(port); ipaq_destroy_lists(port);
kfree(priv); kfree(priv);
port->private = NULL; port->private = NULL;
port->open_count = 0;
}
/* Uncomment the following line if you want to see some statistics in your syslog */ /* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
} }
...@@ -507,16 +497,7 @@ static int ipaq_startup(struct usb_serial *serial) ...@@ -507,16 +497,7 @@ static int ipaq_startup(struct usb_serial *serial)
static void ipaq_shutdown(struct usb_serial *serial) static void ipaq_shutdown(struct usb_serial *serial)
{ {
int i;
dbg (__FUNCTION__); dbg (__FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
ipaq_close(&serial->port[i], NULL);
}
}
} }
static int __init ipaq_init(void) static int __init ipaq_init(void)
......
...@@ -283,9 +283,6 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -283,9 +283,6 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
++port->open_count;
if (port->open_count == 1) {
if (buffer_size) { if (buffer_size) {
/* override the default buffer sizes */ /* override the default buffer sizes */
buffer = kmalloc (buffer_size, GFP_KERNEL); buffer = kmalloc (buffer_size, GFP_KERNEL);
...@@ -321,7 +318,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -321,7 +318,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err("%s - failed submitting read urb, error %d", __FUNCTION__, result); err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
}
return result; return result;
} }
...@@ -338,16 +335,10 @@ static void ir_close (struct usb_serial_port *port, struct file * filp) ...@@ -338,16 +335,10 @@ static void ir_close (struct usb_serial_port *port, struct file * filp)
if (!serial) if (!serial)
return; return;
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
/* shutdown our bulk read */ /* shutdown our bulk read */
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
port->open_count = 0;
}
} }
static int ir_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) static int ir_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
......
...@@ -852,7 +852,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) ...@@ -852,7 +852,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
struct keyspan_serial_private *s_priv; struct keyspan_serial_private *s_priv;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
const struct keyspan_device_details *d_details; const struct keyspan_device_details *d_details;
int i, already_active, err; int i, err;
struct urb *urb; struct urb *urb;
s_priv = (struct keyspan_serial_private *)(serial->private); s_priv = (struct keyspan_serial_private *)(serial->private);
...@@ -861,12 +861,6 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) ...@@ -861,12 +861,6 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
dbg("keyspan_open called for port%d.\n", port->number); dbg("keyspan_open called for port%d.\n", port->number);
already_active = port->open_count;
++port->open_count;
if (already_active)
return 0;
p_priv = (struct keyspan_port_private *)(port->private); p_priv = (struct keyspan_port_private *)(port->private);
/* Set some sane defaults */ /* Set some sane defaults */
...@@ -924,7 +918,6 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) ...@@ -924,7 +918,6 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
p_priv->out_flip = 0; p_priv->out_flip = 0;
p_priv->in_flip = 0; p_priv->in_flip = 0;
if (--port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
/* Stop reading/writing urbs */ /* Stop reading/writing urbs */
stop_urb(p_priv->inack_urb); stop_urb(p_priv->inack_urb);
...@@ -934,9 +927,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) ...@@ -934,9 +927,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
stop_urb(p_priv->out_urbs[i]); stop_urb(p_priv->out_urbs[i]);
} }
} }
port->open_count = 0;
port->tty = 0; port->tty = 0;
}
} }
...@@ -1762,9 +1753,6 @@ static void keyspan_shutdown (struct usb_serial *serial) ...@@ -1762,9 +1753,6 @@ static void keyspan_shutdown (struct usb_serial *serial)
/* Now free per port private data */ /* Now free per port private data */
for (i = 0; i < serial->num_ports; i++) { for (i = 0; i < serial->num_ports; i++) {
port = &serial->port[i]; port = &serial->port[i];
while (port->open_count > 0) {
--port->open_count;
}
kfree(port->private); kfree(port->private);
} }
} }
......
...@@ -662,9 +662,6 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) ...@@ -662,9 +662,6 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
int rc = 0; int rc = 0;
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
++port->open_count;
if (port->open_count == 1) {
/* find out how much room is in the Tx ring */ /* find out how much room is in the Tx ring */
rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
6, /* write_room */ 6, /* write_room */
...@@ -703,11 +700,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) ...@@ -703,11 +700,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
goto error; goto error;
} }
}
return rc;
error: error:
--port->open_count;
return rc; return rc;
} }
...@@ -716,9 +709,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp) ...@@ -716,9 +709,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
/* the normal serial device seems to always shut off DTR and RTS now */ /* the normal serial device seems to always shut off DTR and RTS now */
if (port->tty->termios->c_cflag & HUPCL) if (port->tty->termios->c_cflag & HUPCL)
...@@ -728,8 +718,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp) ...@@ -728,8 +718,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->interrupt_in_urb); usb_unlink_urb (port->interrupt_in_urb);
} }
port->open_count = 0;
}
} }
...@@ -805,9 +793,6 @@ static void keyspan_pda_shutdown (struct usb_serial *serial) ...@@ -805,9 +793,6 @@ static void keyspan_pda_shutdown (struct usb_serial *serial)
{ {
dbg (__FUNCTION__); dbg (__FUNCTION__);
while (serial->port[0].open_count > 0) {
keyspan_pda_close (&serial->port[0], NULL);
}
kfree(serial->port[0].private); kfree(serial->port[0].private);
} }
......
...@@ -317,9 +317,6 @@ static void klsi_105_shutdown (struct usb_serial *serial) ...@@ -317,9 +317,6 @@ static void klsi_105_shutdown (struct usb_serial *serial)
struct klsi_105_private *priv = struct klsi_105_private *priv =
(struct klsi_105_private*) serial->port[i].private; (struct klsi_105_private*) serial->port[i].private;
unsigned long flags; unsigned long flags;
while (serial->port[i].open_count > 0) {
klsi_105_close (&serial->port[i], NULL);
}
if (priv) { if (priv) {
/* kill our write urb pool */ /* kill our write urb pool */
...@@ -355,16 +352,12 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -355,16 +352,12 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = (struct klsi_105_private *)port->private; struct klsi_105_private *priv = (struct klsi_105_private *)port->private;
int retval = 0; int retval = 0;
dbg(__FUNCTION__" port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
int rc; int rc;
int i; int i;
unsigned long line_state; unsigned long line_state;
dbg(__FUNCTION__" port %d", port->number);
/* force low_latency on so that our tty_push actually forces /* force low_latency on so that our tty_push actually forces
* the data through * the data through
* port->tty->low_latency = 1; */ * port->tty->low_latency = 1; */
...@@ -432,7 +425,6 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -432,7 +425,6 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
retval = 0; retval = 0;
} else } else
retval = rc; retval = rc;
}
exit: exit:
return retval; return retval;
...@@ -444,6 +436,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) ...@@ -444,6 +436,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
struct usb_serial *serial; struct usb_serial *serial;
struct klsi_105_private *priv struct klsi_105_private *priv
= (struct klsi_105_private *)port->private; = (struct klsi_105_private *)port->private;
int rc;
dbg(__FUNCTION__" port %d", port->number); dbg(__FUNCTION__" port %d", port->number);
serial = get_usb_serial (port, __FUNCTION__); serial = get_usb_serial (port, __FUNCTION__);
...@@ -451,11 +444,8 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) ...@@ -451,11 +444,8 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
if(!serial) if(!serial)
return; return;
--port->open_count;
if (port->open_count <= 0) {
/* send READ_OFF */ /* send READ_OFF */
int rc = usb_control_msg(serial->dev, rc = usb_control_msg (serial->dev,
usb_sndctrlpipe(serial->dev, 0), usb_sndctrlpipe(serial->dev, 0),
KL5KUSB105A_SIO_CONFIGURE, KL5KUSB105A_SIO_CONFIGURE,
USB_TYPE_VENDOR | USB_DIR_OUT, USB_TYPE_VENDOR | USB_DIR_OUT,
...@@ -473,9 +463,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) ...@@ -473,9 +463,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
/* FIXME */ /* FIXME */
/* wgg - do I need this? I think so. */ /* wgg - do I need this? I think so. */
usb_unlink_urb (port->interrupt_in_urb); usb_unlink_urb (port->interrupt_in_urb);
port->open_count = 0;
info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out); info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out);
}
} /* klsi_105_close */ } /* klsi_105_close */
......
...@@ -324,9 +324,6 @@ static void mct_u232_shutdown (struct usb_serial *serial) ...@@ -324,9 +324,6 @@ static void mct_u232_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */ /* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
mct_u232_close (&serial->port[i], NULL);
}
/* My special items, the standard routines free my urbs */ /* My special items, the standard routines free my urbs */
if (serial->port[i].private) if (serial->port[i].private)
kfree(serial->port[i].private); kfree(serial->port[i].private);
...@@ -341,9 +338,6 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) ...@@ -341,9 +338,6 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__" port %d", port->number); dbg(__FUNCTION__" port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
/* Compensate for a hardware bug: although the Sitecom U232-P25 /* Compensate for a hardware bug: although the Sitecom U232-P25
* device reports a maximum output packet size of 32 bytes, * device reports a maximum output packet size of 32 bytes,
* it seems to be able to accept only 16 bytes (and that's what * it seems to be able to accept only 16 bytes (and that's what
...@@ -393,8 +387,6 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) ...@@ -393,8 +387,6 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
if (retval) if (retval)
err(" usb_submit_urb(read int) failed"); err(" usb_submit_urb(read int) failed");
}
exit: exit:
return 0; return 0;
} /* mct_u232_open */ } /* mct_u232_open */
...@@ -404,17 +396,12 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp) ...@@ -404,17 +396,12 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
{ {
dbg(__FUNCTION__" port %d", port->number); dbg(__FUNCTION__" port %d", port->number);
--port->open_count;
if (port->open_count <= 0) {
if (port->serial->dev) { if (port->serial->dev) {
/* shutdown our urbs */ /* shutdown our urbs */
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->interrupt_in_urb); usb_unlink_urb (port->interrupt_in_urb);
} }
port->open_count = 0;
}
} /* mct_u232_close */ } /* mct_u232_close */
......
...@@ -157,13 +157,9 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) ...@@ -157,13 +157,9 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
if (!serial) if (!serial)
return -ENODEV; return -ENODEV;
++port->open_count;
if (port->open_count == 1) {
od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
if( !od ) { if( !od ) {
err(__FUNCTION__"- kmalloc(%Zd) failed.", sizeof(struct omninet_data)); err(__FUNCTION__"- kmalloc(%Zd) failed.", sizeof(struct omninet_data));
port->open_count = 0;
return -ENOMEM; return -ENOMEM;
} }
...@@ -179,7 +175,6 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) ...@@ -179,7 +175,6 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err(__FUNCTION__ " - failed submitting read urb, error %d", result); err(__FUNCTION__ " - failed submitting read urb, error %d", result);
}
return result; return result;
} }
...@@ -199,20 +194,15 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) ...@@ -199,20 +194,15 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
if (!serial) if (!serial)
return; return;
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
wport = &serial->port[1]; wport = &serial->port[1];
usb_unlink_urb (wport->write_urb); usb_unlink_urb (wport->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
port->open_count = 0;
od = (struct omninet_data *)port->private; od = (struct omninet_data *)port->private;
if (od) if (od)
kfree(od); kfree(od);
}
} }
...@@ -377,10 +367,6 @@ static void omninet_write_bulk_callback (struct urb *urb) ...@@ -377,10 +367,6 @@ static void omninet_write_bulk_callback (struct urb *urb)
static void omninet_shutdown (struct usb_serial *serial) static void omninet_shutdown (struct usb_serial *serial)
{ {
dbg (__FUNCTION__); dbg (__FUNCTION__);
while (serial->port[0].open_count > 0) {
omninet_close (&serial->port[0], NULL);
}
} }
......
...@@ -367,9 +367,6 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp) ...@@ -367,9 +367,6 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
dbg (__FUNCTION__ " - port %d", port->number); dbg (__FUNCTION__ " - port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
#define FISH(a,b,c,d) \ #define FISH(a,b,c,d) \
result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0), \ result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0), \
b, a, c, d, buf, 1, 100); \ b, a, c, d, buf, 1, 100); \
...@@ -417,7 +414,6 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp) ...@@ -417,7 +414,6 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
pl2303_close (port, NULL); pl2303_close (port, NULL);
return -EPROTO; return -EPROTO;
} }
}
return 0; return 0;
} }
...@@ -437,8 +433,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp) ...@@ -437,8 +433,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
dbg (__FUNCTION__ " - port %d", port->number); dbg (__FUNCTION__ " - port %d", port->number);
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
c_cflag = port->tty->termios->c_cflag; c_cflag = port->tty->termios->c_cflag;
if (c_cflag & HUPCL) { if (c_cflag & HUPCL) {
...@@ -469,8 +463,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp) ...@@ -469,8 +463,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
"(interrupt_in_urb) failed with reason: %d", "(interrupt_in_urb) failed with reason: %d",
result); result);
} }
port->open_count = 0;
}
} }
static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value) static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
...@@ -577,12 +569,8 @@ static void pl2303_shutdown (struct usb_serial *serial) ...@@ -577,12 +569,8 @@ static void pl2303_shutdown (struct usb_serial *serial)
dbg (__FUNCTION__); dbg (__FUNCTION__);
/* stop everything on all ports */
for (i = 0; i < serial->num_ports; ++i) for (i = 0; i < serial->num_ports; ++i)
while (serial->port[i].open_count > 0) {
pl2303_close (&serial->port[i], NULL);
kfree (serial->port[i].private); kfree (serial->port[i].private);
}
} }
......
...@@ -268,19 +268,19 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) ...@@ -268,19 +268,19 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__ " - port %d", port->number); dbg(__FUNCTION__ " - port %d", port->number);
if (!port->read_urb) { if (!port->read_urb) {
/* this is needed for some brain dead Sony devices */
err ("Device lied about number of ports, please use a lower one."); err ("Device lied about number of ports, please use a lower one.");
return -ENODEV; return -ENODEV;
} }
++port->open_count;
if (port->open_count == 1) {
bytes_in = 0; bytes_in = 0;
bytes_out = 0; bytes_out = 0;
/* 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 * Force low_latency on so that our tty_push actually forces the data
can get lost. */ * through, otherwise it is scheduled, and with high data rates (like
* with OHCI) data can get lost.
*/
port->tty->low_latency = 1; port->tty->low_latency = 1;
/* Start reading from the device */ /* Start reading from the device */
...@@ -293,7 +293,6 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) ...@@ -293,7 +293,6 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err(__FUNCTION__ " - failed submitting read urb, error %d", result); err(__FUNCTION__ " - failed submitting read urb, error %d", result);
}
return result; return result;
} }
...@@ -313,9 +312,6 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) ...@@ -313,9 +312,6 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
if (!serial) if (!serial)
return; return;
--port->open_count;
if (port->open_count <= 0) {
if (serial->dev) { if (serial->dev) {
/* only send a shutdown message if the /* only send a shutdown message if the
* device is still here */ * device is still here */
...@@ -334,8 +330,6 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) ...@@ -334,8 +330,6 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
/* shutdown our bulk read */ /* shutdown our bulk read */
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
port->open_count = 0;
}
/* Uncomment the following line if you want to see some statistics in your syslog */ /* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
} }
...@@ -655,16 +649,9 @@ static int clie_3_5_startup (struct usb_serial *serial) ...@@ -655,16 +649,9 @@ static int clie_3_5_startup (struct usb_serial *serial)
static void visor_shutdown (struct usb_serial *serial) static void visor_shutdown (struct usb_serial *serial)
{ {
int i;
dbg (__FUNCTION__); dbg (__FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i)
serial->port[i].open_count = 0;
} }
static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
{ {
dbg(__FUNCTION__ " - port %d, cmd 0x%.4x", port->number, cmd); dbg(__FUNCTION__ " - port %d, cmd 0x%.4x", port->number, cmd);
......
...@@ -306,9 +306,6 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -306,9 +306,6 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
dbg(__FUNCTION__" - port %d", port->number); dbg(__FUNCTION__" - port %d", port->number);
++port->open_count;
if (port->open_count == 1) {
/* set up some stuff for our command port */ /* set up some stuff for our command port */
command_port = &port->serial->port[COMMAND_PORT]; command_port = &port->serial->port[COMMAND_PORT];
if (command_port->private == NULL) { if (command_port->private == NULL) {
...@@ -316,7 +313,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -316,7 +313,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
if (info == NULL) { if (info == NULL) {
err(__FUNCTION__ " - out of memory"); err(__FUNCTION__ " - out of memory");
retval = -ENOMEM; retval = -ENOMEM;
goto error_exit; goto exit;
} }
init_waitqueue_head(&info->wait_command); init_waitqueue_head(&info->wait_command);
...@@ -328,7 +325,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -328,7 +325,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
retval = usb_submit_urb (command_port->read_urb, GFP_KERNEL); retval = usb_submit_urb (command_port->read_urb, GFP_KERNEL);
if (retval) { if (retval) {
err(__FUNCTION__ " - failed submitting read urb, error %d", retval); err(__FUNCTION__ " - failed submitting read urb, error %d", retval);
goto error_exit; goto exit;
} }
} }
...@@ -337,7 +334,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -337,7 +334,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
retval = usb_submit_urb(port->read_urb, GFP_KERNEL); retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (retval) { if (retval) {
err(__FUNCTION__ " - failed submitting read urb, error %d", retval); err(__FUNCTION__ " - failed submitting read urb, error %d", retval);
goto error_exit; goto exit;
} }
/* send an open port command */ /* send an open port command */
...@@ -345,19 +342,13 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -345,19 +342,13 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
open_command.port = port->number - port->serial->minor + 1; open_command.port = port->number - port->serial->minor + 1;
retval = whiteheat_send_cmd (port->serial, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command)); retval = whiteheat_send_cmd (port->serial, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command));
if (retval) if (retval)
goto error_exit; goto exit;
/* Need to do device specific setup here (control lines, baud rate, etc.) */ /* Need to do device specific setup here (control lines, baud rate, etc.) */
/* FIXME!!! */ /* FIXME!!! */
}
dbg(__FUNCTION__ " - exit");
return retval;
error_exit: exit:
--port->open_count; dbg(__FUNCTION__ " - exit, retval = %d", retval);
dbg(__FUNCTION__ " - error_exit");
return retval; return retval;
} }
...@@ -368,9 +359,6 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) ...@@ -368,9 +359,6 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
dbg(__FUNCTION__ " - port %d", port->number); dbg(__FUNCTION__ " - port %d", port->number);
--port->open_count;
if (port->open_count <= 0) {
/* send a close command to the port */ /* send a close command to the port */
/* firmware uses 1 based port numbering */ /* firmware uses 1 based port numbering */
close_command.port = port->number - port->serial->minor + 1; close_command.port = port->number - port->serial->minor + 1;
...@@ -382,8 +370,6 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) ...@@ -382,8 +370,6 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
/* shutdown our bulk reads and writes */ /* shutdown our bulk reads and writes */
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
port->open_count = 0;
}
} }
...@@ -642,17 +628,9 @@ static int whiteheat_real_startup (struct usb_serial *serial) ...@@ -642,17 +628,9 @@ static int whiteheat_real_startup (struct usb_serial *serial)
static void whiteheat_real_shutdown (struct usb_serial *serial) static void whiteheat_real_shutdown (struct usb_serial *serial)
{ {
struct usb_serial_port *command_port; struct usb_serial_port *command_port;
int i;
dbg(__FUNCTION__); dbg(__FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i].open_count > 0) {
whiteheat_close (&serial->port[i], NULL);
}
}
/* free up our private data for our command port */ /* free up our private data for our command port */
command_port = &serial->port[COMMAND_PORT]; command_port = &serial->port[COMMAND_PORT];
if (command_port->private != NULL) { if (command_port->private != NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment