On Mon, Jan 14, 2019 at 08:43:52PM +0100, Karoly Pados wrote: > Current GPIO code in cp210x fails to take USB autosuspend into account, > making it practically impossible to use GPIOs with autosuspend enabled > without user configuration. Fix this like for ftdi_sio in a previous patch. > Tested on a CP2102N. > > Signed-off-by: Karoly Pados <pados@xxxxxxxx> > --- > drivers/usb/serial/cp210x.c | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c > index c0777a374a88..8f974eabce63 100644 > --- a/drivers/usb/serial/cp210x.c > +++ b/drivers/usb/serial/cp210x.c > @@ -598,9 +598,15 @@ static int cp210x_read_vendor_block(struct usb_serial *serial, u8 type, u16 val, > void *dmabuf; > int result; > > + result = usb_autopm_get_interface(serial->interface); > + if (result) > + return result; > + > @@ -702,9 +709,15 @@ static int cp210x_write_vendor_block(struct usb_serial *serial, u8 type, > void *dmabuf; > int result; > > + result = usb_autopm_get_interface(serial->interface); > + if (result) > + return result; > + I think it's better to add the autopm call to gpio210x_gpio_get/set only. This will allow for a simpler patch, and keeps the autopm handling confined to the gpio paths. > @@ -1383,6 +1397,7 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) > } else { > u16 wIndex = buf.state << 8 | buf.mask; > > + usb_autopm_get_interface(serial->interface); Also make sure to always check for errors from autopm_get(). > result = usb_control_msg(serial->dev, > usb_sndctrlpipe(serial->dev, 0), > CP210X_VENDOR_SPECIFIC, Thanks, Johan