aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/digi_acceleport.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-12-10 19:00:30 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 13:00:06 -0500
commit50de36f7af3b1d791c402478210790c582126fe5 (patch)
tree78d3353450be45315bb2ffa1cd7c664c26458c73 /drivers/usb/serial/digi_acceleport.c
parent6013bbbab0dcbc43bcf9dd70beeab2a0b1ec5ea7 (diff)
USB: serial: fix up urb->status usage
Some of the usb-serial drivers are starting to use urb->status in ways they should not be doing. This fixes up some of them to prevent that. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/digi_acceleport.c')
-rw-r--r--drivers/usb/serial/digi_acceleport.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 69f84f0ea6fe..38ba4ea8b6bf 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -635,8 +635,7 @@ static int digi_write_oob_command(struct usb_serial_port *port,
635 635
636 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); 636 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
637 while (count > 0) { 637 while (count > 0) {
638 while (oob_port->write_urb->status == -EINPROGRESS 638 while (oob_priv->dp_write_urb_in_use) {
639 || oob_priv->dp_write_urb_in_use) {
640 cond_wait_interruptible_timeout_irqrestore( 639 cond_wait_interruptible_timeout_irqrestore(
641 &oob_port->write_wait, DIGI_RETRY_TIMEOUT, 640 &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
642 &oob_priv->dp_port_lock, flags); 641 &oob_priv->dp_port_lock, flags);
@@ -699,9 +698,8 @@ static int digi_write_inb_command(struct usb_serial_port *port,
699 698
700 spin_lock_irqsave(&priv->dp_port_lock, flags); 699 spin_lock_irqsave(&priv->dp_port_lock, flags);
701 while (count > 0 && ret == 0) { 700 while (count > 0 && ret == 0) {
702 while ((port->write_urb->status == -EINPROGRESS 701 while (priv->dp_write_urb_in_use &&
703 || priv->dp_write_urb_in_use) 702 time_before(jiffies, timeout)) {
704 && time_before(jiffies, timeout)) {
705 cond_wait_interruptible_timeout_irqrestore( 703 cond_wait_interruptible_timeout_irqrestore(
706 &port->write_wait, DIGI_RETRY_TIMEOUT, 704 &port->write_wait, DIGI_RETRY_TIMEOUT,
707 &priv->dp_port_lock, flags); 705 &priv->dp_port_lock, flags);
@@ -779,8 +777,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
779 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); 777 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
780 spin_lock(&port_priv->dp_port_lock); 778 spin_lock(&port_priv->dp_port_lock);
781 779
782 while (oob_port->write_urb->status == -EINPROGRESS || 780 while (oob_priv->dp_write_urb_in_use) {
783 oob_priv->dp_write_urb_in_use) {
784 spin_unlock(&port_priv->dp_port_lock); 781 spin_unlock(&port_priv->dp_port_lock);
785 cond_wait_interruptible_timeout_irqrestore( 782 cond_wait_interruptible_timeout_irqrestore(
786 &oob_port->write_wait, DIGI_RETRY_TIMEOUT, 783 &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -1168,12 +1165,10 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
1168 1165
1169 /* be sure only one write proceeds at a time */ 1166 /* be sure only one write proceeds at a time */
1170 /* there are races on the port private buffer */ 1167 /* there are races on the port private buffer */
1171 /* and races to check write_urb->status */
1172 spin_lock_irqsave(&priv->dp_port_lock, flags); 1168 spin_lock_irqsave(&priv->dp_port_lock, flags);
1173 1169
1174 /* wait for urb status clear to submit another urb */ 1170 /* wait for urb status clear to submit another urb */
1175 if (port->write_urb->status == -EINPROGRESS || 1171 if (priv->dp_write_urb_in_use) {
1176 priv->dp_write_urb_in_use) {
1177 /* buffer data if count is 1 (probably put_char) if possible */ 1172 /* buffer data if count is 1 (probably put_char) if possible */
1178 if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) { 1173 if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) {
1179 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; 1174 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
@@ -1236,7 +1231,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1236 int ret = 0; 1231 int ret = 0;
1237 int status = urb->status; 1232 int status = urb->status;
1238 1233
1239 dbg("digi_write_bulk_callback: TOP, urb->status=%d", status); 1234 dbg("digi_write_bulk_callback: TOP, status=%d", status);
1240 1235
1241 /* port and serial sanity check */ 1236 /* port and serial sanity check */
1242 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { 1237 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
@@ -1266,8 +1261,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1266 /* try to send any buffered data on this port, if it is open */ 1261 /* try to send any buffered data on this port, if it is open */
1267 spin_lock(&priv->dp_port_lock); 1262 spin_lock(&priv->dp_port_lock);
1268 priv->dp_write_urb_in_use = 0; 1263 priv->dp_write_urb_in_use = 0;
1269 if (port->port.count && port->write_urb->status != -EINPROGRESS 1264 if (port->port.count && priv->dp_out_buf_len > 0) {
1270 && priv->dp_out_buf_len > 0) {
1271 *((unsigned char *)(port->write_urb->transfer_buffer)) 1265 *((unsigned char *)(port->write_urb->transfer_buffer))
1272 = (unsigned char)DIGI_CMD_SEND_DATA; 1266 = (unsigned char)DIGI_CMD_SEND_DATA;
1273 *((unsigned char *)(port->write_urb->transfer_buffer) + 1) 1267 *((unsigned char *)(port->write_urb->transfer_buffer) + 1)
@@ -1305,8 +1299,7 @@ static int digi_write_room(struct tty_struct *tty)
1305 1299
1306 spin_lock_irqsave(&priv->dp_port_lock, flags); 1300 spin_lock_irqsave(&priv->dp_port_lock, flags);
1307 1301
1308 if (port->write_urb->status == -EINPROGRESS || 1302 if (priv->dp_write_urb_in_use)
1309 priv->dp_write_urb_in_use)
1310 room = 0; 1303 room = 0;
1311 else 1304 else
1312 room = port->bulk_out_size - 2 - priv->dp_out_buf_len; 1305 room = port->bulk_out_size - 2 - priv->dp_out_buf_len;
@@ -1322,8 +1315,7 @@ static int digi_chars_in_buffer(struct tty_struct *tty)
1322 struct usb_serial_port *port = tty->driver_data; 1315 struct usb_serial_port *port = tty->driver_data;
1323 struct digi_port *priv = usb_get_serial_port_data(port); 1316 struct digi_port *priv = usb_get_serial_port_data(port);
1324 1317
1325 if (port->write_urb->status == -EINPROGRESS 1318 if (priv->dp_write_urb_in_use) {
1326 || priv->dp_write_urb_in_use) {
1327 dbg("digi_chars_in_buffer: port=%d, chars=%d", 1319 dbg("digi_chars_in_buffer: port=%d, chars=%d",
1328 priv->dp_port_num, port->bulk_out_size - 2); 1320 priv->dp_port_num, port->bulk_out_size - 2);
1329 /* return(port->bulk_out_size - 2); */ 1321 /* return(port->bulk_out_size - 2); */
@@ -1702,7 +1694,7 @@ static int digi_read_inb_callback(struct urb *urb)
1702 /* short/multiple packet check */ 1694 /* short/multiple packet check */
1703 if (urb->actual_length != len + 2) { 1695 if (urb->actual_length != len + 2) {
1704 dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, " 1696 dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, "
1705 "urb->status=%d, port=%d, opcode=%d, len=%d, " 1697 "status=%d, port=%d, opcode=%d, len=%d, "
1706 "actual_length=%d, status=%d\n", __func__, status, 1698 "actual_length=%d, status=%d\n", __func__, status,
1707 priv->dp_port_num, opcode, len, urb->actual_length, 1699 priv->dp_port_num, opcode, len, urb->actual_length,
1708 port_status); 1700 port_status);