aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/opticon.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/usb/serial/opticon.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/usb/serial/opticon.c')
-rw-r--r--drivers/usb/serial/opticon.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 80f59b6350cb..ed01f3b2de8c 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/tty_driver.h> 15#include <linux/tty_driver.h>
16#include <linux/slab.h>
16#include <linux/tty_flip.h> 17#include <linux/tty_flip.h>
17#include <linux/serial.h> 18#include <linux/serial.h>
18#include <linux/module.h> 19#include <linux/module.h>
@@ -22,7 +23,7 @@
22 23
23static int debug; 24static int debug;
24 25
25static struct usb_device_id id_table[] = { 26static const struct usb_device_id id_table[] = {
26 { USB_DEVICE(0x065a, 0x0009) }, 27 { USB_DEVICE(0x065a, 0x0009) },
27 { }, 28 { },
28}; 29};
@@ -55,7 +56,6 @@ static void opticon_bulk_callback(struct urb *urb)
55 int status = urb->status; 56 int status = urb->status;
56 struct tty_struct *tty; 57 struct tty_struct *tty;
57 int result; 58 int result;
58 int available_room = 0;
59 int data_length; 59 int data_length;
60 60
61 dbg("%s - port %d", __func__, port->number); 61 dbg("%s - port %d", __func__, port->number);
@@ -96,13 +96,9 @@ static void opticon_bulk_callback(struct urb *urb)
96 /* real data, send it to the tty layer */ 96 /* real data, send it to the tty layer */
97 tty = tty_port_tty_get(&port->port); 97 tty = tty_port_tty_get(&port->port);
98 if (tty) { 98 if (tty) {
99 available_room = tty_buffer_request_room(tty, 99 tty_insert_flip_string(tty, data,
100 data_length); 100 data_length);
101 if (available_room) { 101 tty_flip_buffer_push(tty);
102 tty_insert_flip_string(tty, data,
103 available_room);
104 tty_flip_buffer_push(tty);
105 }
106 tty_kref_put(tty); 102 tty_kref_put(tty);
107 } 103 }
108 } else { 104 } else {
@@ -120,7 +116,7 @@ static void opticon_bulk_callback(struct urb *urb)
120 } 116 }
121 } else { 117 } else {
122 dev_dbg(&priv->udev->dev, 118 dev_dbg(&priv->udev->dev,
123 "Improper ammount of data received from the device, " 119 "Improper amount of data received from the device, "
124 "%d bytes", urb->actual_length); 120 "%d bytes", urb->actual_length);
125 } 121 }
126 122
@@ -217,7 +213,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
217 spin_lock_irqsave(&priv->lock, flags); 213 spin_lock_irqsave(&priv->lock, flags);
218 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 214 if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
219 spin_unlock_irqrestore(&priv->lock, flags); 215 spin_unlock_irqrestore(&priv->lock, flags);
220 dbg("%s - write limit hit\n", __func__); 216 dbg("%s - write limit hit", __func__);
221 return 0; 217 return 0;
222 } 218 }
223 priv->outstanding_urbs++; 219 priv->outstanding_urbs++;
@@ -288,7 +284,7 @@ static int opticon_write_room(struct tty_struct *tty)
288 spin_lock_irqsave(&priv->lock, flags); 284 spin_lock_irqsave(&priv->lock, flags);
289 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 285 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
290 spin_unlock_irqrestore(&priv->lock, flags); 286 spin_unlock_irqrestore(&priv->lock, flags);
291 dbg("%s - write limit hit\n", __func__); 287 dbg("%s - write limit hit", __func__);
292 return 0; 288 return 0;
293 } 289 }
294 spin_unlock_irqrestore(&priv->lock, flags); 290 spin_unlock_irqrestore(&priv->lock, flags);
@@ -501,12 +497,13 @@ static int opticon_resume(struct usb_interface *intf)
501 struct usb_serial_port *port = serial->port[0]; 497 struct usb_serial_port *port = serial->port[0];
502 int result; 498 int result;
503 499
504 mutex_lock(&port->mutex); 500 mutex_lock(&port->port.mutex);
505 if (port->port.count) 501 /* This is protected by the port mutex against close/open */
502 if (test_bit(ASYNCB_INITIALIZED, &port->port.flags))
506 result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO); 503 result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO);
507 else 504 else
508 result = 0; 505 result = 0;
509 mutex_unlock(&port->mutex); 506 mutex_unlock(&port->port.mutex);
510 return result; 507 return result;
511} 508}
512 509