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

USB: usb_wwan: fix remote wakeup

Make sure that needs_remote_wake up is always set when there are open
ports.

Currently close() would unconditionally set needs_remote_wakeup to 0
even though there might still be open ports. This could lead to blocked
input and possibly dropped data on devices that do not support remote
wakeup (and which must therefore not be runtime suspended while open).

Add an open_ports counter (protected by the susp_lock) and only clear
needs_remote_wakeup when the last port is closed.

Note that there are currently no multi-port drivers using the usb_wwan
implementation.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7436f412
...@@ -39,6 +39,7 @@ struct usb_wwan_intf_private { ...@@ -39,6 +39,7 @@ struct usb_wwan_intf_private {
spinlock_t susp_lock; spinlock_t susp_lock;
unsigned int suspended:1; unsigned int suspended:1;
int in_flight; int in_flight;
unsigned int open_ports;
int (*send_setup) (struct usb_serial_port *port); int (*send_setup) (struct usb_serial_port *port);
void *private; void *private;
}; };
......
...@@ -411,9 +411,10 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -411,9 +411,10 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
if (intfdata->send_setup) if (intfdata->send_setup)
intfdata->send_setup(port); intfdata->send_setup(port);
serial->interface->needs_remote_wakeup = 1;
spin_lock_irq(&intfdata->susp_lock); spin_lock_irq(&intfdata->susp_lock);
portdata->opened = 1; portdata->opened = 1;
if (++intfdata->open_ports == 1)
serial->interface->needs_remote_wakeup = 1;
spin_unlock_irq(&intfdata->susp_lock); spin_unlock_irq(&intfdata->susp_lock);
/* this balances a get in the generic USB serial code */ /* this balances a get in the generic USB serial code */
usb_autopm_put_interface(serial->interface); usb_autopm_put_interface(serial->interface);
...@@ -448,6 +449,8 @@ void usb_wwan_close(struct usb_serial_port *port) ...@@ -448,6 +449,8 @@ void usb_wwan_close(struct usb_serial_port *port)
/* Stop reading/writing urbs */ /* Stop reading/writing urbs */
spin_lock_irq(&intfdata->susp_lock); spin_lock_irq(&intfdata->susp_lock);
portdata->opened = 0; portdata->opened = 0;
if (--intfdata->open_ports == 0)
serial->interface->needs_remote_wakeup = 0;
spin_unlock_irq(&intfdata->susp_lock); spin_unlock_irq(&intfdata->susp_lock);
for (;;) { for (;;) {
...@@ -466,7 +469,6 @@ void usb_wwan_close(struct usb_serial_port *port) ...@@ -466,7 +469,6 @@ void usb_wwan_close(struct usb_serial_port *port)
/* balancing - important as an error cannot be handled*/ /* balancing - important as an error cannot be handled*/
usb_autopm_get_interface_no_resume(serial->interface); usb_autopm_get_interface_no_resume(serial->interface);
serial->interface->needs_remote_wakeup = 0;
} }
EXPORT_SYMBOL(usb_wwan_close); EXPORT_SYMBOL(usb_wwan_close);
......
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