linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error
Date: Mon, 2 May 2016 12:05:06 +0200	[thread overview]
Message-ID: <CAMuHMdWM_Y_ypisZFUXwec37Nc=8MBqWLmPSktzaNdOPbHmbow@mail.gmail.com> (raw)
In-Reply-To: <CACRpkdZGOe+RaO-cZ+zYSBgzen4hi=C86kLF+MLKvH3ZdNZeqg@mail.gmail.com>

Hi Linus,

On Mon, May 2, 2016 at 11:25 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, May 2, 2016 at 11:10 AM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
>> On Mon, May 2, 2016 at 11:06 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
>>> On Mon, May 2, 2016 at 11:04 AM, Geert Uytterhoeven
>>> <geert@linux-m68k.org> wrote:
>>>
>>>> [silly response deleted]
>>>>
>>>> Scrap it.
>>>
>>> :D
>>>
>>>> The only annoying thing is that 0 cannot easily be propagated upstream as
>>>> an error code, so it has to be tested for explicitly.
>>>
>>> Well with the Big Penguin's clear opinion on the matter there is not
>>> much we can do.
>>>
>>> What about this?
>>>
>>> diff --git a/drivers/tty/serial/serial_mctrl_gpio.c
>>> b/drivers/tty/serial/serial_mctrl_gpio.c
>>> index 02147361eaa9..2297ec781681 100644
>>> --- a/drivers/tty/serial/serial_mctrl_gpio.c
>>> +++ b/drivers/tty/serial/serial_mctrl_gpio.c
>>> @@ -172,6 +172,13 @@ struct mctrl_gpios *mctrl_gpio_init(struct
>>> uart_port *port, unsigned int idx)
>>>                         dev_err(port->dev,
>>>                                 "failed to find corresponding irq for
>>> %s (idx=%d, err=%d)\n",
>>>                                 mctrl_gpios_desc[i].name, idx, ret);
>>> +                       /*
>>> +                        * Satisfy the error code semantics for a missing IRQ,
>>> +                        * 0 means NO_IRQ, but the framework needs to return
>>> +                        * a negative to deal with the error.
>>> +                        */
>>> +                       if (!ret)
>>> +                               ret = -ENOSYS;
>>
>> No, not -ENOSYS, as that triggers my initial problem again (please read the
>> deleted silly response ;-)
>> Checkpatch says: "ENOSYS means 'invalid syscall nr' and nothing else".
>>
>> -EINVAL?

Upon reconsideration, -ENXIO.

> Sure, whatever works with your semantics.
>
> Will you test & send a patch?

This works fine, but I'm a bit reluctant to send out the patches...

gpiod_to_irq() is documented to return a negative error code on failure,
cfr. Documentation/gpio/consumer.txt and drivers/gpio/gpiolib.c.
In fact the check in mctrl_gpio_init() is the only caller that
considers zero as an
error.

Perhaps gpiod_to_irq() should handle .to_irq() returning zero instead?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2016-05-02 10:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29  7:24 [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error Geert Uytterhoeven
2016-05-01  8:48 ` Linus Walleij
2016-05-02  8:03   ` Geert Uytterhoeven
2016-05-02  8:30     ` Linus Walleij
2016-05-02  8:53       ` Geert Uytterhoeven
2016-05-02  9:04         ` Geert Uytterhoeven
2016-05-02  9:06           ` Linus Walleij
2016-05-02  9:10             ` Geert Uytterhoeven
2016-05-02  9:25               ` Linus Walleij
2016-05-02 10:05                 ` Geert Uytterhoeven [this message]
2016-05-02 11:16                   ` 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='CAMuHMdWM_Y_ypisZFUXwec37Nc=8MBqWLmPSktzaNdOPbHmbow@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=geert+renesas@glider.be \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-renesas-soc@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;
as well as URLs for NNTP newsgroup(s).