Commit 5b7c1178 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

USB: sierra: error handling in runtime PM

resumption of devices can fail. Errors must be handled.
Signed-off-by: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9a91aedc
...@@ -373,7 +373,10 @@ static int sierra_send_setup(struct usb_serial_port *port) ...@@ -373,7 +373,10 @@ static int sierra_send_setup(struct usb_serial_port *port)
if (!do_send) if (!do_send)
return 0; return 0;
usb_autopm_get_interface(serial->interface); retval = usb_autopm_get_interface(serial->interface);
if (retval < 0)
return retval;
retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
0x22, 0x21, val, interface, NULL, 0, USB_CTRL_SET_TIMEOUT); 0x22, 0x21, val, interface, NULL, 0, USB_CTRL_SET_TIMEOUT);
usb_autopm_put_interface(serial->interface); usb_autopm_put_interface(serial->interface);
...@@ -808,8 +811,12 @@ static void sierra_close(struct usb_serial_port *port) ...@@ -808,8 +811,12 @@ static void sierra_close(struct usb_serial_port *port)
mutex_lock(&serial->disc_mutex); mutex_lock(&serial->disc_mutex);
if (!serial->disconnected) { if (!serial->disconnected) {
serial->interface->needs_remote_wakeup = 0; serial->interface->needs_remote_wakeup = 0;
usb_autopm_get_interface(serial->interface); /* odd error handling due to pm counters */
if (!usb_autopm_get_interface(serial->interface))
sierra_send_setup(port); sierra_send_setup(port);
else
usb_autopm_get_interface_no_resume(serial->interface);
} }
mutex_unlock(&serial->disc_mutex); mutex_unlock(&serial->disc_mutex);
spin_lock_irq(&intfdata->susp_lock); spin_lock_irq(&intfdata->susp_lock);
...@@ -862,6 +869,7 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -862,6 +869,7 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)
/* get rid of everything as in close */ /* get rid of everything as in close */
sierra_close(port); sierra_close(port);
/* restore balance for autopm */ /* restore balance for autopm */
if (!serial->disconnected)
usb_autopm_put_interface(serial->interface); usb_autopm_put_interface(serial->interface);
return err; return err;
} }
......
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