summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2010-05-13 21:02:01 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 13:21:45 -0700
commit6f6ed696945c9c98fb6e0def32d29411d958a6fa (patch)
treed1221159397f5de2f4bb5985b7eb05cd806a322f /drivers/usb/serial
parent2ff78c0c2b67120c8e503268da3f177cae2228a2 (diff)
downloadop-kernel-dev-6f6ed696945c9c98fb6e0def32d29411d958a6fa.zip
op-kernel-dev-6f6ed696945c9c98fb6e0def32d29411d958a6fa.tar.gz
USB: ir-usb: allow custom bulk buffer size without reallocation
Use usb_serial_driver bulk_in_size and bulk_out_size to make sure buffers of appropriate sizes are allocated in the first place rather than reallocating them at every open. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/ir-usb.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 71bdbe0..aaebb70 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -297,35 +297,10 @@ static int ir_startup(struct usb_serial *serial)
static int ir_open(struct tty_struct *tty, struct usb_serial_port *port)
{
- char *buffer;
int result = 0;
dbg("%s - port %d", __func__, port->number);
- if (buffer_size) {
- /* override the default buffer sizes */
- buffer = kmalloc(buffer_size, GFP_KERNEL);
- if (!buffer) {
- dev_err(&port->dev, "%s - out of memory.\n", __func__);
- return -ENOMEM;
- }
- kfree(port->read_urb->transfer_buffer);
- port->read_urb->transfer_buffer = buffer;
- port->read_urb->transfer_buffer_length = buffer_size;
- port->bulk_in_buffer = buffer;
-
- buffer = kmalloc(buffer_size, GFP_KERNEL);
- if (!buffer) {
- dev_err(&port->dev, "%s - out of memory.\n", __func__);
- return -ENOMEM;
- }
- kfree(port->write_urb->transfer_buffer);
- port->write_urb->transfer_buffer = buffer;
- port->write_urb->transfer_buffer_length = buffer_size;
- port->bulk_out_buffer = buffer;
- port->bulk_out_size = buffer_size;
- }
-
/* Start reading from the device */
usb_fill_bulk_urb(
port->read_urb,
@@ -585,6 +560,11 @@ static int __init ir_init(void)
{
int retval;
+ if (buffer_size) {
+ ir_device.bulk_in_size = buffer_size;
+ ir_device.bulk_out_size = buffer_size;
+ }
+
retval = usb_serial_register(&ir_device);
if (retval)
goto failed_usb_serial_register;
OpenPOWER on IntegriCloud