All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Karoly Pados <pados@pados.hu>
Cc: Johan Hovold <johan@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: USB: serial: cp210x: Fix GPIO in autosuspend
Date: Tue, 15 Jan 2019 09:57:43 +0100	[thread overview]
Message-ID: <20190115085743.GL3691@localhost> (raw)

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@pados.hu>
> ---
>  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

             reply	other threads:[~2019-01-15  8:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15  8:57 Johan Hovold [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-02-07 13:57 USB: serial: cp210x: Fix GPIO in autosuspend Johan Hovold
2019-02-06 21:43 Karoly Pados
2019-02-04 16:09 Johan Hovold
2019-01-15 10:29 Johan Hovold
2019-01-15  9:26 Johan Hovold
2019-01-15  9:17 Karoly Pados
2019-01-14 19:43 Karoly Pados

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190115085743.GL3691@localhost \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pados@pados.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.