USB: serial: allow drivers to define bulk buffer sizes

Allow drivers to define custom bulk in/out buffer sizes in struct
usb_serial_driver. If not set, fall back to the default buffer size
which matches the endpoint size.

Three drivers are currently freeing the pre-allocated buffers and
allocating larger ones to achieve this at port probe (ftdi_sio) or even
at port open (ipaq and iuu_phoenix), which needless to say is suboptimal.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Johan Hovold
2010-03-17 23:00:37 +01:00
committed by Greg Kroah-Hartman
parent 317149c655
commit bbcb2b9074
5 changed files with 16 additions and 71 deletions

View File

@ -768,9 +768,6 @@ static const char *ftdi_chip_name[] = {
};
/* Constants for read urb and write urb */
#define BUFSZ 512
/* Used for TIOCMIWAIT */
#define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
#define FTDI_STATUS_B1_MASK (FTDI_RS_BI)
@ -821,6 +818,7 @@ static struct usb_serial_driver ftdi_sio_device = {
.usb_driver = &ftdi_driver,
.id_table = id_table_combined,
.num_ports = 1,
.bulk_in_size = 512,
.probe = ftdi_sio_probe,
.port_probe = ftdi_sio_port_probe,
.port_remove = ftdi_sio_port_remove,
@ -1552,18 +1550,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
if (quirk && quirk->port_probe)
quirk->port_probe(priv);
/* Increase the size of read buffers */
kfree(port->bulk_in_buffer);
port->bulk_in_buffer = kmalloc(BUFSZ, GFP_KERNEL);
if (!port->bulk_in_buffer) {
kfree(priv);
return -ENOMEM;
}
if (port->read_urb) {
port->read_urb->transfer_buffer = port->bulk_in_buffer;
port->read_urb->transfer_buffer_length = BUFSZ;
}
priv->port = port;
/* Free port's existing write urb and transfer buffer. */