linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>, linux-gpio@vger.kernel.org
Subject: Re: how to request gpiochip line which is only valid as an interrupt?
Date: Wed, 12 Jun 2024 11:19:40 +0200	[thread overview]
Message-ID: <20240612111940.6cdce4f5@dellmb> (raw)
In-Reply-To: <20240612105555.70323f9c@dellmb>

Dear Andy,

On Wed, 12 Jun 2024 10:55:55 +0200
Marek Behún <kabel@kernel.org> wrote:

> Originally, I used the low-level irq_create_mapping(), passing it the
> gpiochip's IRQ domain, something like:
> 
>   irq =  irq_create_mapping(mcu->gc.irq.domain, TRNG_HWIRQ);
> 
> Andy said [1] that
> 
>   This looks like some workaround against existing gpiod_to_irq(). Why
>   do you need this?
> 
> I should not poke into gpiolib's internals like that.
> 
> So I changed it to
> 
>   irq = gpiod_to_irq(gpiochip_get_desc(&mcu->gc, TRNG_HWIRQ));

I think the original code 

  irq = irq_create_mapping(mcu->gc.irq.domain, TRNG_HWIRQ);

should be used. The trng part of the driver is interested in the
interrupt, it does not care if the interrupt is provided via a GPIO
chip.

The mcu device is a gpio-controller, but also an interrupt-controller.
That the interrupts are provided via gpiolib is irrelevant.

So I think that what we did back in April, changing to gpiod_to_irq(),
is not actually correct, from semantic point of view.

For example if some other driver wanted to use a MCU interrupt, it
would have simply used:
  of_get_irq()
not referring to gpio descriptors at all, i.e. not something like
  gpiod_to_irq(gpiod_find_and_request())

(I do actually have code prepared for another driver that will use
an interrupt provided by the MCU.)

What do you think?

Marek

      parent reply	other threads:[~2024-06-12  9:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10 14:01 how to request gpiochip line which is only valid as an interrupt? Marek Behún
2024-06-11  9:03 ` Marek Behún
2024-06-11 19:22   ` Bartosz Golaszewski
2024-06-12  8:55     ` Marek Behún
2024-06-12  9:03       ` Marek Behún
2024-06-12 12:30         ` Bartosz Golaszewski
2024-06-12 13:32           ` Marek Behún
2024-06-12  9:19       ` Marek Behún [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=20240612111940.6cdce4f5@dellmb \
    --to=kabel@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --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).