Subject: [PATCH 003/008] [RESUBMIT] USB: serial: adding sierra_submit_rx_urbs() function From: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> The following is summary of changes we have made to sierra.c driver in [PATCH 003/008] from the series dealing with improving urb handling: - Added new function sierra_submit_rx_urbs() that handles the submission of receive urbs and interrupt urbs (if any) during the interface activation. This function is to be called by sierra_open(). Added a second parameter to pass the memory allocation (as suggested by Oliver Neukum) so that this function can be used in post_reset() and resume(). Signed-off-by: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> --- drivers/usb/serial/sierra.c | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) --- a/drivers/usb/serial/sierra.c 2009-05-06 12:59:47.000000000 -0700 +++ b/drivers/usb/serial/sierra.c 2009-05-06 14:07:46.000000000 -0700 @@ -617,6 +617,43 @@ static void sierra_stop_rx_urbs(struct u usb_kill_urb(port->interrupt_in_urb); } +static int sierra_submit_rx_urbs(struct usb_serial_port *port, gfp_t mem_flags) +{ + int ok_cnt; + int err = -EINVAL; + int i; + struct urb *urb; + struct sierra_port_private *portdata = usb_get_serial_port_data(port); + + ok_cnt = 0; + for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) { + urb = portdata->in_urbs[i]; + if (!urb) + continue; + err = usb_submit_urb(urb, mem_flags); + if (err) { + dev_err(&port->dev, "%s: submit urb failed: %d\n", + __func__, err); + } else { + ok_cnt++; + } + } + + if (ok_cnt && port->interrupt_in_urb) { + err = usb_submit_urb(port->interrupt_in_urb, mem_flags); + if (err) { + dev_err(&port->dev, "%s: submit intr urb failed: %d\n", + __func__, err); + } + } + + if (ok_cnt > 0) /* at least one rx urb submitted */ + return 0; + else + return err; +} + + static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html