Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1608242

Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls

From Linus Walleij <linus.walleij@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls
Date 2017-03-24 10:00 +0100
Message-ID <toteG-7pT-29@gated-at.bofh.it> (permalink)
References (6 earlier) <toac1-2e7-1@gated-at.bofh.it> <tobhL-2SB-7@gated-at.bofh.it> <tocdP-3va-9@gated-at.bofh.it> <tod9U-4dr-7@gated-at.bofh.it> <togr8-6L0-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Mar 23, 2017 at 8:10 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Thu, Mar 23, 2017 at 08:44:41AM -0700, Dmitry Torokhov wrote:
>> On Thu, Mar 23, 2017 at 07:43:25AM -0700, Dmitry Torokhov wrote:
>> > On Thu, Mar 23, 2017 at 02:41:53PM +0100, Linus Walleij wrote:
>> > > On Thu, Mar 23, 2017 at 1:34 PM, Uwe Kleine-König
>> > > <u.kleine-koenig@pengutronix.de> wrote:
>> > >
>> > > > Maybe we can make gpiod_get_optional look like this:
>> > > >
>> > > >         if (!dev->of_node && isnt_a_acpi_device(dev) && !IS_ENABLED(GPIOLIB))
>> > > >                 return NULL;
>> > > >         else
>> > > >                 return -ENOSYS;
>> > > >
>> > > > I don't know how isnt_a_acpi_device looks like, probably it involves
>> > > > CONFIG_ACPI and/or dev->acpi_node.
>> > > >
>> > > > This should be safe and still comfortable for legacy platforms, isn't it?
>> > >
>> > > I like the looks of this.
>> > >
>> > > Can we revert Dmitry's patch and apply something like this instead?
>> > >
>> > > Dmitry, how do you feel about this?
>> >
>> > I frankly do not see the point. It still makes driver code more complex
>
> Note that this code is in the gpio header, and not in driver code. So
> the driver just does
>
>         gpiod = gpiod_get_optional(...)
>         if (IS_ERR(gpiod))
>                 return PTR_ERR(gpiod);
>
> (as it is supposed to do now). I think that's nice.

It does look nice. Compare this to what we must do for optional regulators:

        st->reg = devm_regulator_get_optional(&spi->dev, "vref");
        if (IS_ERR(st->reg)) {
                /* Any other error indicates that the regulator does exist */
                if (PTR_ERR(st->reg) != -ENODEV)
                        return PTR_ERR(st->reg);
                /* Use internal reference */
        }

So for optional regulators we get -ENODEV if we don't have it,
and then proceed on an alternate path, such as using an internal
reference voltage.

However the fact that regulators and GPIO optionals are already
handled differently is creating "cognitive dissonance" or what I
should call it.

Yours,
Linus Walleij

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Linus Walleij <linus.walleij@linaro.org> - 2017-03-16 16:30 +0100
  Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-16 17:40 +0100
    Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-20 11:00 +0100
      Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-20 11:20 +0100
      Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-20 11:40 +0100
        Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-20 12:00 +0100
          Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-20 12:10 +0100
            Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Linus Walleij <linus.walleij@linaro.org> - 2017-03-23 10:40 +0100
              Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-23 11:20 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-23 11:30 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-23 12:20 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-23 13:10 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-23 13:40 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-23 13:50 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Linus Walleij <linus.walleij@linaro.org> - 2017-03-23 14:50 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-23 15:50 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-23 16:50 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-23 20:20 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-23 21:00 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-24 09:30 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-24 09:40 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-24 10:00 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-24 10:20 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-24 10:50 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-24 11:10 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-24 09:40 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Linus Walleij <linus.walleij@linaro.org> - 2017-03-24 10:00 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-03-23 17:00 +0100
                Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls Linus Walleij <linus.walleij@linaro.org> - 2017-03-23 14:40 +0100
  Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL  calls Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-03-16 17:40 +0100

csiph-web