USB: serial: ftdi_sio: fix GPIO not working in autosuspend
authorKaroly Pados <pados@pados.hu>
Mon, 14 Jan 2019 12:30:03 +0000 (13:30 +0100)
committerJohan Hovold <johan@kernel.org>
Mon, 14 Jan 2019 13:40:11 +0000 (14:40 +0100)
commita8eda9fa1bd84065b75bfa81bf675a7af9055478
tree941a79177e89f85bae6de6cf2022df85b9902f88
parentb81c2c33eab79dfd3650293b2227ee5c6036585c
USB: serial: ftdi_sio: fix GPIO not working in autosuspend

There is a bug in the current GPIO code for ftdi_sio: it failed to take USB
autosuspend into account. If the device is in autosuspend, calls to
usb_control_msg() fail with -EHOSTUNREACH. Because the standard value for
autosuspend timeout is usually 2-5 seconds, this made it almost impossible
to use the GPIOs on machines that have USB autosuspend enabled. This patch
fixes the issue by acquiring a PM lock on the device for the duration of
the USB transfers. Tested on an FT231X device.

Signed-off-by: Karoly Pados <pados@pados.hu>
[ johan: simplify code somewhat ]
Fixes: ba93cc7da896 ("USB: serial: ftdi_sio: implement GPIO support for FT-X devices")
Cc: stable <stable@vger.kernel.org> # 4.20
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/ftdi_sio.c