From: Johan Hovold <johan@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 2/2] USB: serial: cp210x: use new GPIO line value setter callbacks
Date: Wed, 18 Jun 2025 16:45:16 +0200 [thread overview]
Message-ID: <aFLQ_G0HnGWVSE12@hovoldconsulting.com> (raw)
In-Reply-To: <20250610-gpiochip-set-rv-usb-serial-v1-2-a9343ca109e8@linaro.org>
On Tue, Jun 10, 2025 at 02:43:47PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. Convert the driver to using
> them.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> drivers/usb/serial/cp210x.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
> index 9960ac2b10b719192dfbab0a6e81b2cf80f40d36..caeb2873a60451fb7a9a5b5d25071547b5401d52 100644
> --- a/drivers/usb/serial/cp210x.c
> +++ b/drivers/usb/serial/cp210x.c
> @@ -1504,7 +1504,7 @@ static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
> return !!(mask & BIT(gpio));
> }
>
> -static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
> +static int cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
> {
> struct usb_serial *serial = gpiochip_get_data(gc);
> struct cp210x_serial_private *priv = usb_get_serial_data(serial);
> @@ -1522,8 +1522,8 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
> mask = BIT(gpio);
>
> result = usb_autopm_get_interface(serial->interface);
> - if (result)
> - goto out;
> + if (result < 0)
> + return result;
This is arguably an unrelated change, please keep it as is.
> switch (priv->partnum) {
> case CP210X_PARTNUM_CP2105:
> @@ -1555,11 +1555,8 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
> }
>
> usb_autopm_put_interface(serial->interface);
> -out:
> - if (result < 0) {
> - dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n",
> - result);
> - }
And keep this in place too, and just result if negative.
> +
> + return result < 0 ? result : 0;
And return 0 explicitly here to avoid using the ternary operator.
> }
Johan
prev parent reply other threads:[~2025-06-18 14:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 12:43 [PATCH 0/2] USB: serial: " Bartosz Golaszewski
2025-06-10 12:43 ` [PATCH 1/2] USB: serial: ftdi_sio: " Bartosz Golaszewski
2025-06-10 12:43 ` [PATCH 2/2] USB: serial: cp210x: " Bartosz Golaszewski
2025-06-18 14:45 ` Johan Hovold [this message]
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=aFLQ_G0HnGWVSE12@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=gregkh@linuxfoundation.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®