Commit 71c149b9 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: sierra: refactor delayed-urb submission

Refactor and clean up delayed-urb submission at resume.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7d8825be
...@@ -981,43 +981,66 @@ static int sierra_suspend(struct usb_serial *serial, pm_message_t message) ...@@ -981,43 +981,66 @@ static int sierra_suspend(struct usb_serial *serial, pm_message_t message)
return 0; return 0;
} }
static int sierra_resume(struct usb_serial *serial) /* Caller must hold susp_lock. */
static int sierra_submit_delayed_urbs(struct usb_serial_port *port)
{ {
struct usb_serial_port *port; struct sierra_port_private *portdata = usb_get_serial_port_data(port);
struct sierra_intf_private *intfdata = usb_get_serial_data(serial); struct sierra_intf_private *intfdata;
struct sierra_port_private *portdata;
struct urb *urb; struct urb *urb;
int ec = 0; int ec = 0;
int i, err; int err;
spin_lock_irq(&intfdata->susp_lock); intfdata = usb_get_serial_data(port->serial);
for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i];
portdata = usb_get_serial_port_data(port);
if (!portdata || !portdata->opened) for (;;) {
continue; urb = usb_get_from_anchor(&portdata->delayed);
if (!urb)
break;
while ((urb = usb_get_from_anchor(&portdata->delayed))) {
usb_anchor_urb(urb, &portdata->active); usb_anchor_urb(urb, &portdata->active);
intfdata->in_flight++; intfdata->in_flight++;
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) { if (err) {
dev_err(&port->dev, dev_err(&port->dev, "%s - submit urb failed: %d",
"%s - submit urb failed: %d",
__func__, err); __func__, err);
ec++; ec++;
intfdata->in_flight--; intfdata->in_flight--;
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
kfree(urb->transfer_buffer); kfree(urb->transfer_buffer);
usb_free_urb(urb); usb_free_urb(urb);
spin_lock(&portdata->lock); spin_lock(&portdata->lock);
portdata->outstanding_urbs--; portdata->outstanding_urbs--;
spin_unlock(&portdata->lock); spin_unlock(&portdata->lock);
continue;
} }
} }
if (ec)
return -EIO;
return 0;
}
static int sierra_resume(struct usb_serial *serial)
{
struct usb_serial_port *port;
struct sierra_intf_private *intfdata = usb_get_serial_data(serial);
struct sierra_port_private *portdata;
int ec = 0;
int i, err;
spin_lock_irq(&intfdata->susp_lock);
for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i];
portdata = usb_get_serial_port_data(port);
if (!portdata || !portdata->opened)
continue;
err = sierra_submit_delayed_urbs(port);
if (err)
ec++;
err = sierra_submit_rx_urbs(port, GFP_ATOMIC); err = sierra_submit_rx_urbs(port, GFP_ATOMIC);
if (err) if (err)
ec++; ec++;
......
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