aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
authorDavid VomLehn <dvomlehn@cisco.com>2009-08-28 15:54:27 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:34 -0400
commit8e8dce065088833fc418bfa5fbf035cb0726c04c (patch)
tree146ad73ff1ee9439263678c5493a5c2d180ad794 /drivers/usb/serial/usb-serial.c
parent74aee796c613f54e9f089170df548c0b3f15af69 (diff)
USB: use kfifo to buffer usb-generic serial writes
When do_output_char() attempts to write a carriage return/line feed sequence, it first checks to see how much buffer room is available. If there are at least two characters free, it will write the carriage return/line feed with two calls to tty_put_char(). It calls the tty_operation functions write() for devices that don't support the tty_operations function put_char(). If the USB generic serial device's write URB is not in use, it will return the buffer size when asked how much room is available. The write() of the carriage return will cause it to mark the write URB busy, so the subsequent write() of the line feed will be ignored. This patch uses the kfifo infrastructure to implement a write FIFO that accurately returns the amount of space available in the buffer. Signed-off-by: David VomLehn <dvomlehn@cisco.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 45975b4984ea..ff75a3589e7e 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -35,6 +35,7 @@
35#include <linux/serial.h> 35#include <linux/serial.h>
36#include <linux/usb.h> 36#include <linux/usb.h>
37#include <linux/usb/serial.h> 37#include <linux/usb/serial.h>
38#include <linux/kfifo.h>
38#include "pl2303.h" 39#include "pl2303.h"
39 40
40/* 41/*
@@ -625,6 +626,8 @@ static void port_release(struct device *dev)
625 usb_free_urb(port->write_urb); 626 usb_free_urb(port->write_urb);
626 usb_free_urb(port->interrupt_in_urb); 627 usb_free_urb(port->interrupt_in_urb);
627 usb_free_urb(port->interrupt_out_urb); 628 usb_free_urb(port->interrupt_out_urb);
629 if (!IS_ERR(port->write_fifo) && port->write_fifo)
630 kfifo_free(port->write_fifo);
628 kfree(port->bulk_in_buffer); 631 kfree(port->bulk_in_buffer);
629 kfree(port->bulk_out_buffer); 632 kfree(port->bulk_out_buffer);
630 kfree(port->interrupt_in_buffer); 633 kfree(port->interrupt_in_buffer);
@@ -964,6 +967,10 @@ int usb_serial_probe(struct usb_interface *interface,
964 dev_err(&interface->dev, "No free urbs available\n"); 967 dev_err(&interface->dev, "No free urbs available\n");
965 goto probe_error; 968 goto probe_error;
966 } 969 }
970 port->write_fifo = kfifo_alloc(PAGE_SIZE, GFP_KERNEL,
971 &port->lock);
972 if (IS_ERR(port->write_fifo))
973 goto probe_error;
967 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 974 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
968 port->bulk_out_size = buffer_size; 975 port->bulk_out_size = buffer_size;
969 port->bulk_out_endpointAddress = endpoint->bEndpointAddress; 976 port->bulk_out_endpointAddress = endpoint->bEndpointAddress;