Commit 41bd72f9 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

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: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f26788da
...@@ -118,7 +118,6 @@ void usb_serial_generic_deregister(void) ...@@ -118,7 +118,6 @@ void usb_serial_generic_deregister(void)
int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port) int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)
{ {
struct usb_serial *serial = port->serial;
int result = 0; int result = 0;
unsigned long flags; unsigned long flags;
...@@ -131,23 +130,8 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port ...@@ -131,23 +130,8 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
/* if we have a bulk endpoint, start reading from it */ /* if we have a bulk endpoint, start reading from it */
if (port->bulk_in_size) { if (port->bulk_in_size)
/* Start reading from the device */ result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL);
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);
}
return result; return result;
} }
...@@ -418,9 +402,8 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) ...@@ -418,9 +402,8 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
return chars; return chars;
} }
int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
gfp_t mem_flags)
{ {
struct urb *urb = port->read_urb; struct urb *urb = port->read_urb;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -439,11 +422,12 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, ...@@ -439,11 +422,12 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
result = usb_submit_urb(urb, mem_flags); result = usb_submit_urb(urb, mem_flags);
if (result && result != -EPERM) { if (result && result != -EPERM) {
dev_err(&port->dev, dev_err(&port->dev,
"%s - failed resubmitting read urb, error %d\n", "%s - failed submitting read urb, error %d\n",
__func__, result); __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 */ /* Push data to tty layer and resubmit the bulk read URB */
static void flush_and_resubmit_read_urb(struct usb_serial_port *port) 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) ...@@ -471,7 +455,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
tty_kref_put(tty); tty_kref_put(tty);
done: 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) void usb_serial_generic_read_bulk_callback(struct urb *urb)
......
...@@ -69,7 +69,7 @@ static void usb_debug_read_bulk_callback(struct urb *urb) ...@@ -69,7 +69,7 @@ static void usb_debug_read_bulk_callback(struct urb *urb)
memcmp(urb->transfer_buffer, USB_DEBUG_BRK, memcmp(urb->transfer_buffer, USB_DEBUG_BRK,
USB_DEBUG_BRK_SIZE) == 0) { USB_DEBUG_BRK_SIZE) == 0) {
usb_serial_handle_break(port); usb_serial_handle_break(port);
usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC); usb_serial_generic_submit_read_urb(port, GFP_ATOMIC);
return; return;
} }
......
...@@ -321,7 +321,7 @@ extern void usb_serial_generic_disconnect(struct usb_serial *serial); ...@@ -321,7 +321,7 @@ extern void usb_serial_generic_disconnect(struct usb_serial *serial);
extern void usb_serial_generic_release(struct usb_serial *serial); extern void usb_serial_generic_release(struct usb_serial *serial);
extern int usb_serial_generic_register(int debug); extern int usb_serial_generic_register(int debug);
extern void usb_serial_generic_deregister(void); extern void usb_serial_generic_deregister(void);
extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, extern int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
gfp_t mem_flags); gfp_t mem_flags);
extern int usb_serial_handle_sysrq_char(struct tty_struct *tty, extern int usb_serial_handle_sysrq_char(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment