diff options
Diffstat (limited to 'drivers/usb/serial/omninet.c')
-rw-r--r-- | drivers/usb/serial/omninet.c | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 60f38d5e64fc..45a8c55881d3 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -9,31 +9,6 @@ | |||
9 | * driver | 9 | * driver |
10 | * | 10 | * |
11 | * Please report both successes and troubles to the author at omninet@kroah.com | 11 | * Please report both successes and troubles to the author at omninet@kroah.com |
12 | * | ||
13 | * (05/30/2001) gkh | ||
14 | * switched from using spinlock to a semaphore, which fixes lots of | ||
15 | * problems. | ||
16 | * | ||
17 | * (04/08/2001) gb | ||
18 | * Identify version on module load. | ||
19 | * | ||
20 | * (11/01/2000) Adam J. Richter | ||
21 | * usb_device_id table support | ||
22 | * | ||
23 | * (10/05/2000) gkh | ||
24 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
25 | * core needs it. | ||
26 | * | ||
27 | * (08/28/2000) gkh | ||
28 | * Added locks for SMP safeness. | ||
29 | * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more | ||
30 | * than once. | ||
31 | * Fixed potential race in omninet_write_bulk_callback | ||
32 | * | ||
33 | * (07/19/2000) gkh | ||
34 | * Added module_init and module_exit functions to handle the fact that this | ||
35 | * driver is a loadable module now. | ||
36 | * | ||
37 | */ | 12 | */ |
38 | 13 | ||
39 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
@@ -44,7 +19,6 @@ | |||
44 | #include <linux/tty_driver.h> | 19 | #include <linux/tty_driver.h> |
45 | #include <linux/tty_flip.h> | 20 | #include <linux/tty_flip.h> |
46 | #include <linux/module.h> | 21 | #include <linux/module.h> |
47 | #include <linux/spinlock.h> | ||
48 | #include <linux/uaccess.h> | 22 | #include <linux/uaccess.h> |
49 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
50 | #include <linux/usb/serial.h> | 24 | #include <linux/usb/serial.h> |
@@ -174,12 +148,6 @@ static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
174 | tty_port_tty_set(&wport->port, tty); | 148 | tty_port_tty_set(&wport->port, tty); |
175 | 149 | ||
176 | /* Start reading from the device */ | 150 | /* Start reading from the device */ |
177 | usb_fill_bulk_urb(port->read_urb, serial->dev, | ||
178 | usb_rcvbulkpipe(serial->dev, | ||
179 | port->bulk_in_endpointAddress), | ||
180 | port->read_urb->transfer_buffer, | ||
181 | port->read_urb->transfer_buffer_length, | ||
182 | omninet_read_bulk_callback, port); | ||
183 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 151 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
184 | if (result) | 152 | if (result) |
185 | dev_err(&port->dev, | 153 | dev_err(&port->dev, |
@@ -236,11 +204,6 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
236 | } | 204 | } |
237 | 205 | ||
238 | /* Continue trying to always read */ | 206 | /* Continue trying to always read */ |
239 | usb_fill_bulk_urb(urb, port->serial->dev, | ||
240 | usb_rcvbulkpipe(port->serial->dev, | ||
241 | port->bulk_in_endpointAddress), | ||
242 | urb->transfer_buffer, urb->transfer_buffer_length, | ||
243 | omninet_read_bulk_callback, port); | ||
244 | result = usb_submit_urb(urb, GFP_ATOMIC); | 207 | result = usb_submit_urb(urb, GFP_ATOMIC); |
245 | if (result) | 208 | if (result) |
246 | dev_err(&port->dev, | 209 | dev_err(&port->dev, |
@@ -267,14 +230,10 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
267 | return 0; | 230 | return 0; |
268 | } | 231 | } |
269 | 232 | ||
270 | spin_lock_bh(&wport->lock); | 233 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { |
271 | if (wport->write_urb_busy) { | ||
272 | spin_unlock_bh(&wport->lock); | ||
273 | dbg("%s - already writing", __func__); | 234 | dbg("%s - already writing", __func__); |
274 | return 0; | 235 | return 0; |
275 | } | 236 | } |
276 | wport->write_urb_busy = 1; | ||
277 | spin_unlock_bh(&wport->lock); | ||
278 | 237 | ||
279 | count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; | 238 | count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; |
280 | 239 | ||
@@ -292,10 +251,9 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
292 | /* send the data out the bulk port, always 64 bytes */ | 251 | /* send the data out the bulk port, always 64 bytes */ |
293 | wport->write_urb->transfer_buffer_length = 64; | 252 | wport->write_urb->transfer_buffer_length = 64; |
294 | 253 | ||
295 | wport->write_urb->dev = serial->dev; | ||
296 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 254 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
297 | if (result) { | 255 | if (result) { |
298 | wport->write_urb_busy = 0; | 256 | set_bit(0, &wport->write_urbs_free); |
299 | dev_err(&port->dev, | 257 | dev_err(&port->dev, |
300 | "%s - failed submitting write urb, error %d\n", | 258 | "%s - failed submitting write urb, error %d\n", |
301 | __func__, result); | 259 | __func__, result); |
@@ -314,8 +272,7 @@ static int omninet_write_room(struct tty_struct *tty) | |||
314 | 272 | ||
315 | int room = 0; /* Default: no room */ | 273 | int room = 0; /* Default: no room */ |
316 | 274 | ||
317 | /* FIXME: no consistent locking for write_urb_busy */ | 275 | if (test_bit(0, &wport->write_urbs_free)) |
318 | if (wport->write_urb_busy) | ||
319 | room = wport->bulk_out_size - OMNINET_HEADERLEN; | 276 | room = wport->bulk_out_size - OMNINET_HEADERLEN; |
320 | 277 | ||
321 | dbg("%s - returns %d", __func__, room); | 278 | dbg("%s - returns %d", __func__, room); |
@@ -332,7 +289,7 @@ static void omninet_write_bulk_callback(struct urb *urb) | |||
332 | 289 | ||
333 | dbg("%s - port %0x", __func__, port->number); | 290 | dbg("%s - port %0x", __func__, port->number); |
334 | 291 | ||
335 | port->write_urb_busy = 0; | 292 | set_bit(0, &port->write_urbs_free); |
336 | if (status) { | 293 | if (status) { |
337 | dbg("%s - nonzero write bulk status received: %d", | 294 | dbg("%s - nonzero write bulk status received: %d", |
338 | __func__, status); | 295 | __func__, status); |