USB: sierra: fix remote wakeup
authorJohan Hovold <jhovold@gmail.com>
Mon, 26 May 2014 17:22:54 +0000 (19:22 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:39 +0000 (13:33 +0100)
commit6513a429cd4d416de148e3d4f5a6432290df83a2
treee3d7eb6608e2d875b22f52de5b347fc649dbe5db
parente4852823d52f1bda6b6dc77d1d4175a36516d832
USB: sierra: fix remote wakeup

commit 80cc0fcbdaeaf10d04ba27779a2d7ceb73d2717a upstream.

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.

Fixes: e6929a9020ac ("USB: support for autosuspend in sierra while
online")

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust indentation]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/serial/sierra.c