From: Johan Hovold <johan@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
Jiri Slaby <jslaby@suse.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] tty: serial: cpm_uart: Fix behaviour for non existing GPIOs
Date: Mon, 8 Jun 2020 08:41:05 +0200 [thread overview]
Message-ID: <20200608064105.GL19480@localhost> (raw)
In-Reply-To: <bafd8df9e743c433196c727293c5015620fae2b8.1591428452.git.christophe.leroy@csgroup.eu>
On Sat, Jun 06, 2020 at 07:30:21AM +0000, Christophe Leroy wrote:
> devm_gpiod_get_index() doesn't return NULL but -ENOENT when the
> requested GPIO doesn't exist, leading to the following messages:
>
> [ 2.742468] gpiod_direction_input: invalid GPIO (errorpointer)
> [ 2.748147] can't set direction for gpio #2: -2
> [ 2.753081] gpiod_direction_input: invalid GPIO (errorpointer)
> [ 2.758724] can't set direction for gpio #3: -2
> [ 2.763666] gpiod_direction_output: invalid GPIO (errorpointer)
> [ 2.769394] can't set direction for gpio #4: -2
> [ 2.774341] gpiod_direction_input: invalid GPIO (errorpointer)
> [ 2.779981] can't set direction for gpio #5: -2
> [ 2.784545] ff000a20.serial: ttyCPM1 at MMIO 0xfff00a20 (irq = 39, base_baud = 8250000) is a CPM UART
>
> Use IS_ERR_OR_NULL() to properly check gpiod validity.
Why check for NULL at all?
> Fixes: 97cbaf2c829b ("tty: serial: cpm_uart: Convert to use GPIO descriptors")
> Cc: stable@vger.kernel.org
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
> index a04f74d2e854..3cbe24802296 100644
> --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
> +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
> @@ -1217,7 +1217,7 @@ static int cpm_uart_init_port(struct device_node *np,
>
> gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS);
>
> - if (gpiod) {
> + if (!IS_ERR_OR_NULL(gpiod)) {
> if (i == GPIO_RTS || i == GPIO_DTR)
> ret = gpiod_direction_output(gpiod, 0);
> else
Johan
next prev parent reply other threads:[~2020-06-08 6:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-06 7:30 [PATCH] tty: serial: cpm_uart: Fix behaviour for non existing GPIOs Christophe Leroy
2020-06-08 6:41 ` Johan Hovold [this message]
2020-06-10 11:18 ` Linus Walleij
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=20200608064105.GL19480@localhost \
--to=johan@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).