linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>
Subject: Re: [PATCH] gpio: convince line to become input in irq helper
Date: Wed, 22 Jun 2016 23:23:18 +0200	[thread overview]
Message-ID: <CACRpkda3MH7R2HT8ZuagLAiQu7SF2eqFeG8PXfCV5Dz3xFvjSg@mail.gmail.com> (raw)
In-Reply-To: <20160622171227.GQ1256@tuxbot>

On Wed, Jun 22, 2016 at 7:12 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> On Wed 22 Jun 07:33 PDT 2016, Linus Walleij wrote:
>
>> The generic IRQ helper library just checks if the IRQ line is
>> set as input before activating it for interrupts. As we
>> recently started to check things better with .get_dir() it
>> turns out that it's good to try to convince the line to become
>> an input before attempting to lock it as IRQ.
>>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> I really like this.

Thanks :)

>> +     /*
>> +      * If it is possible to switch this GPIO to an input
>> +      * this is a good time to do it.
>> +      */
>> +     if (chip->direction_input) {
>> +             struct gpio_desc *desc;
>> +             int ret;
>> +
>> +             desc = gpiochip_get_desc(chip, d->hwirq);
>> +             if (IS_ERR(desc))
>> +                     return PTR_ERR(desc);
>> +
>> +             ret = chip->direction_input(chip, d->hwirq);
>> +             if (!ret)
>> +                     clear_bit(FLAG_IS_OUT, &desc->flags);
>
> With this updated semantics I think it's a mistake to not propagate this
> error. Clients will not be able to rely on it and have to continue
> configuring their pins as input just to be sure.

OK good point I'll propagate it. But it will only be used by those
driver utilizing the generic IRQchip helper.

It's especially for the usecase where you take an IRQ off a DT
resource without gpiod_to_irq() first.

Yours,
Linus Walleij

      reply	other threads:[~2016-06-22 21:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 14:33 [PATCH] gpio: convince line to become input in irq helper Linus Walleij
2016-06-22 17:12 ` Bjorn Andersson
2016-06-22 21:23   ` Linus Walleij [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=CACRpkda3MH7R2HT8ZuagLAiQu7SF2eqFeG8PXfCV5Dz3xFvjSg@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=acourbot@nvidia.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-gpio@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).