diff options
author | Johan Hovold <jhovold@gmail.com> | 2010-03-17 18:05:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:33 -0400 |
commit | 41bd72f9041def8e3334d3e3693862d078f5cb9a (patch) | |
tree | 6a63cccfedd49a8a6fd407dd275657fc52e1fb93 /drivers/usb/serial/generic.c | |
parent | f26788da3b342099d2b02d99ba1cb7f154d6ef7b (diff) |
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.c | 32 |
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) | |||
118 | 118 | ||
119 | int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port) | 119 | int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port) |
120 | { | 120 | { |
121 | struct usb_serial *serial = port->serial; | ||
122 | int result = 0; | 121 | int result = 0; |
123 | unsigned long flags; | 122 | unsigned long flags; |
124 | 123 | ||
@@ -131,23 +130,8 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port | |||
131 | spin_unlock_irqrestore(&port->lock, flags); | 130 | spin_unlock_irqrestore(&port->lock, flags); |
132 | 131 | ||
133 | /* if we have a bulk endpoint, start reading from it */ | 132 | /* if we have a bulk endpoint, start reading from it */ |
134 | if (port->bulk_in_size) { | 133 | if (port->bulk_in_size) |
135 | /* Start reading from the device */ | 134 | result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL); |
136 | usb_fill_bulk_urb(port->read_urb, serial->dev, | ||
137 | usb_rcvbulkpipe(serial->dev, | ||
138 | port->bulk_in_endpointAddress), | ||
139 | port->read_urb->transfer_buffer, | ||
140 | port->read_urb->transfer_buffer_length, | ||
141 | ((serial->type->read_bulk_callback) ? | ||
142 | serial->type->read_bulk_callback : | ||
143 | usb_serial_generic_read_bulk_callback), | ||
144 | port); | ||
145 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | ||
146 | if (result) | ||
147 | dev_err(&port->dev, | ||
148 | "%s - failed resubmitting read urb, error %d\n", | ||
149 | __func__, result); | ||
150 | } | ||
151 | 135 | ||
152 | return result; | 136 | return result; |
153 | } | 137 | } |
@@ -418,9 +402,8 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) | |||
418 | return chars; | 402 | return chars; |
419 | } | 403 | } |
420 | 404 | ||
421 | 405 | int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, | |
422 | void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, | 406 | gfp_t mem_flags) |
423 | gfp_t mem_flags) | ||
424 | { | 407 | { |
425 | struct urb *urb = port->read_urb; | 408 | struct urb *urb = port->read_urb; |
426 | struct usb_serial *serial = port->serial; | 409 | struct usb_serial *serial = port->serial; |
@@ -439,11 +422,12 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, | |||
439 | result = usb_submit_urb(urb, mem_flags); | 422 | result = usb_submit_urb(urb, mem_flags); |
440 | if (result && result != -EPERM) { | 423 | if (result && result != -EPERM) { |
441 | dev_err(&port->dev, | 424 | dev_err(&port->dev, |
442 | "%s - failed resubmitting read urb, error %d\n", | 425 | "%s - failed submitting read urb, error %d\n", |
443 | __func__, result); | 426 | __func__, result); |
444 | } | 427 | } |
428 | return result; | ||
445 | } | 429 | } |
446 | EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb); | 430 | EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urb); |
447 | 431 | ||
448 | /* Push data to tty layer and resubmit the bulk read URB */ | 432 | /* Push data to tty layer and resubmit the bulk read URB */ |
449 | static void flush_and_resubmit_read_urb(struct usb_serial_port *port) | 433 | 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 | tty_flip_buffer_push(tty); | 455 | tty_flip_buffer_push(tty); |
472 | tty_kref_put(tty); | 456 | tty_kref_put(tty); |
473 | done: | 457 | done: |
474 | usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC); | 458 | usb_serial_generic_submit_read_urb(port, GFP_ATOMIC); |
475 | } | 459 | } |
476 | 460 | ||
477 | void usb_serial_generic_read_bulk_callback(struct urb *urb) | 461 | void usb_serial_generic_read_bulk_callback(struct urb *urb) |