From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls
Date: Fri, 3 Mar 2017 20:44:14 +0100 [thread overview]
Message-ID: <20170303194414.n76tr3oa2mlrzjre@pengutronix.de> (raw)
In-Reply-To: <CAMuHMdXFrwa2jCVDb+8ecqgARLG0oGrPp9pLs0b6vEiWeKJ+uA@mail.gmail.com>
Hello Geert,
On Fri, Mar 03, 2017 at 08:21:05PM +0100, Geert Uytterhoeven wrote:
> > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> > index 91e7dddbf72c..2f4cdd4e7b4f 100644
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -3022,7 +3022,7 @@ static int sci_probe_single(struct platform_device *dev,
> > return ret;
> >
> > sciport->gpios = mctrl_gpio_init(&sciport->port, 0);
> > - if (IS_ERR(sciport->gpios) && PTR_ERR(sciport->gpios) != -ENOSYS)
> > + if (IS_ERR(sciport->gpios))
> > return PTR_ERR(sciport->gpios);
>
> Now the sh-sci driver fails to probe on legacy platforms where GPIOLIB=n.
> The check for -ENOSYS made it succeed before.
That's right, intended and the only option that's save (for some
definition of save; the obvious downside is that there is no
/dev/tty$whatever for you).
Ignoring -ENOSYS is only ok if your device doesn't have a cts-gpio. If
it has, ignoring -ENOSYS hides bugs because the driver sends data while
it shouldn't or cannot signal the other side that it should stop (or
start) a transmission.
So the options are:
- enable GPIOLIB (maybe enforce that by letting the driver select it)
- introduce a CONFIG_HALFGPIOLIB that makes gpiod_get_optional and
mctrl_gpio_init return only then -ENOSYS if there is a gpio specified
and NULL otherwise.
> > Then mctrl_gpio_to_gpiod isn't called. I don't have a machine to test
> > this, but I think currently this makes the machine barf to continue
> > here because with sciport->gpios = ERR_PTR(-ENOSYS) calling
> >
> > mctrl_gpio_to_gpiod(sciport->gpios, ...)
> >
> > is a bad idea.
>
> If sciport->gpios == ERR_PTR(-ENOSYS), CONFIG_GPIOLIB is not enabled, the
> feature is not available, and mctrl_gpio_to_gpiod() will not
> dereference the error
> pointer.
Ah, makes sense.
> >> Perhaps mctrl_gpio_to_gpiod() should always return NULL if !CONFIG_GPIOLIB?
> >
> > No, mctrl_gpio_to_gpiod is right. You are only supposed to call it if
> > mctrl_gpio_init succeeded.
>
> Then I have to add checks for sciport->gpios == ERR_PTR(-ENOSYS)...
No, ignoring -ENOSYS is wrong.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2017-03-03 19:44 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 14:22 [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Richard Genoud
2017-03-03 18:58 ` Geert Uytterhoeven
2017-03-03 19:12 ` Uwe Kleine-König
2017-03-03 19:21 ` Geert Uytterhoeven
2017-03-03 19:44 ` Uwe Kleine-König [this message]
2017-03-04 15:35 ` Geert Uytterhoeven
2017-03-04 17:48 ` Uwe Kleine-König
2017-03-06 8:49 ` Geert Uytterhoeven
2017-03-06 8:58 ` Uwe Kleine-König
2017-03-06 9:09 ` Geert Uytterhoeven
2017-03-06 9:30 ` Uwe Kleine-König
2017-03-06 9:53 ` Geert Uytterhoeven
2017-03-06 10:02 ` Uwe Kleine-König
2017-03-14 15:32 ` Linus Walleij
2017-03-16 15:18 ` Linus Walleij
2017-03-16 16:37 ` Uwe Kleine-König
2017-03-16 16:38 ` Geert Uytterhoeven
2017-03-20 9:56 ` Geert Uytterhoeven
2017-03-20 10:03 ` Geert Uytterhoeven
2017-03-20 10:31 ` Uwe Kleine-König
2017-03-20 10:38 ` Geert Uytterhoeven
2017-03-20 11:07 ` Uwe Kleine-König
2017-03-23 9:32 ` Linus Walleij
2017-03-23 10:10 ` Uwe Kleine-König
2017-03-23 10:20 ` Geert Uytterhoeven
2017-03-23 11:11 ` Uwe Kleine-König
2017-03-23 12:03 ` Geert Uytterhoeven
2017-03-23 12:34 ` Uwe Kleine-König
2017-03-23 12:44 ` Geert Uytterhoeven
2017-03-23 13:41 ` Linus Walleij
2017-03-23 14:43 ` Dmitry Torokhov
2017-03-23 15:44 ` Dmitry Torokhov
2017-03-23 19:10 ` Uwe Kleine-König
2017-03-23 19:58 ` Dmitry Torokhov
2017-03-24 8:00 ` Uwe Kleine-König
2017-03-24 8:29 ` Geert Uytterhoeven
2017-03-24 8:39 ` Uwe Kleine-König
2017-03-24 8:59 ` Geert Uytterhoeven
2017-03-24 9:15 ` Uwe Kleine-König
2017-03-24 9:44 ` Geert Uytterhoeven
2017-03-24 10:01 ` Uwe Kleine-König
2017-03-24 8:58 ` Linus Walleij
2017-03-23 15:55 ` Dmitry Torokhov
2017-03-23 13:37 ` 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=20170303194414.n76tr3oa2mlrzjre@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.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).