aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/serial/usb_wwan.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-05-26 19:23:20 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-27 15:04:06 -0700
commitc1c0180340aa73e747744abd7e06239f261d4ade (patch)
treeb2ee0e51075b1394ad96288af1d3082cda43b18e /drivers/usb/serial/usb_wwan.c
parent7436f41283ef2a45f8320ad482edd0aba1bd5843 (diff)
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: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/usb_wwan.c')
-rw-r--r--drivers/usb/serial/usb_wwan.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index ab8c17536534..daaa5d795946 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -411,9 +411,10 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
if (intfdata->send_setup)
intfdata->send_setup(port);
- serial->interface->needs_remote_wakeup = 1;
spin_lock_irq(&intfdata->susp_lock);
portdata->opened = 1;
+ if (++intfdata->open_ports == 1)
+ serial->interface->needs_remote_wakeup = 1;
spin_unlock_irq(&intfdata->susp_lock);
/* this balances a get in the generic USB serial code */
usb_autopm_put_interface(serial->interface);
@@ -448,6 +449,8 @@ void usb_wwan_close(struct usb_serial_port *port)
/* Stop reading/writing urbs */
spin_lock_irq(&intfdata->susp_lock);
portdata->opened = 0;
+ if (--intfdata->open_ports == 0)
+ serial->interface->needs_remote_wakeup = 0;
spin_unlock_irq(&intfdata->susp_lock);
for (;;) {
@@ -466,7 +469,6 @@ void usb_wwan_close(struct usb_serial_port *port)
/* balancing - important as an error cannot be handled*/
usb_autopm_get_interface_no_resume(serial->interface);
- serial->interface->needs_remote_wakeup = 0;
}
EXPORT_SYMBOL(usb_wwan_close);