summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/generic.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2010-03-17 23:05:53 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 13:21:33 -0700
commit41bd72f9041def8e3334d3e3693862d078f5cb9a (patch)
tree6a63cccfedd49a8a6fd407dd275657fc52e1fb93 /drivers/usb/serial/generic.c
parentf26788da3b342099d2b02d99ba1cb7f154d6ef7b (diff)
downloadtalos-op-linux-41bd72f9041def8e3334d3e3693862d078f5cb9a.tar.gz
talos-op-linux-41bd72f9041def8e3334d3e3693862d078f5cb9a.zip
USB: serial: refactor read urb submission in generic driver
Use the already exported function for submitting the read urb associated with a usb_serial_port. Make sure it returns the result of usb_submit_urb and rename to the more descriptive usb_serial_generic_submit_read_urb. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/generic.c')
-rw-r--r--drivers/usb/serial/generic.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index e1d245aa4a1d..d8dd3a59f56a 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -118,7 +118,6 @@ void usb_serial_generic_deregister(void)
int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)
{
- struct usb_serial *serial = port->serial;
int result = 0;
unsigned long flags;
@@ -131,23 +130,8 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
spin_unlock_irqrestore(&port->lock, flags);
/* if we have a bulk endpoint, start reading from it */
- if (port->bulk_in_size) {
- /* Start reading from the device */
- usb_fill_bulk_urb(port->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev,
- port->bulk_in_endpointAddress),
- port->read_urb->transfer_buffer,
- port->read_urb->transfer_buffer_length,
- ((serial->type->read_bulk_callback) ?
- serial->type->read_bulk_callback :
- usb_serial_generic_read_bulk_callback),
- port);
- result = usb_submit_urb(port->read_urb, GFP_KERNEL);
- if (result)
- dev_err(&port->dev,
- "%s - failed resubmitting read urb, error %d\n",
- __func__, result);
- }
+ if (port->bulk_in_size)
+ result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL);
return result;
}
@@ -418,9 +402,8 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
return chars;
}
-
-void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
- gfp_t mem_flags)
+int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
+ gfp_t mem_flags)
{
struct urb *urb = port->read_urb;
struct usb_serial *serial = port->serial;
@@ -439,11 +422,12 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
result = usb_submit_urb(urb, mem_flags);
if (result && result != -EPERM) {
dev_err(&port->dev,
- "%s - failed resubmitting read urb, error %d\n",
+ "%s - failed submitting read urb, error %d\n",
__func__, result);
}
+ return result;
}
-EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb);
+EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urb);
/* Push data to tty layer and resubmit the bulk read URB */
static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
@@ -471,7 +455,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
tty_flip_buffer_push(tty);
tty_kref_put(tty);
done:
- usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC);
+ usb_serial_generic_submit_read_urb(port, GFP_ATOMIC);
}
void usb_serial_generic_read_bulk_callback(struct urb *urb)
OpenPOWER on IntegriCloud