All of lore.kernel.org
 help / color / mirror / Atom feed
* gpio ->to_irq
@ 2022-05-11  8:53 Dvorkin Dmitry
  2022-05-11 10:25 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Dvorkin Dmitry @ 2022-05-11  8:53 UTC (permalink / raw)
  To: linux-gpio

[-- Attachment #1: Type: text/plain, Size: 914 bytes --]

Hello!

I have a question about gpiochip ->to_irq().

Kernel call gpio_to_irq() requests IRQ for the pin, previously taken by 
*gpio_request().

But for sysfs when user does echo "pin#" > /sys/class/gpio/export  
gpio_to_irq() is also called at the time of export there:

https://elixir.bootlin.com/linux/v5.4.100/source/drivers/gpio/gpiolib-sysfs.c#L171

and there

https://elixir.bootlin.com/linux/v5.4.100/source/drivers/gpio/gpiolib-sysfs.c#L378

It is a problem for my driver. I have 120 pins and only 7 dynamically 
muxed GPIO irqs.

So when somebody requests gpio_to_irq() I am creating the mux to the 
first free gpio IRQ. But When user just exports GPIO pin using "old" 
sysfs kernel interface in the filesystem, it should not be done.

How can I see if gpio_to_irq() has been called by sysfs to prevent 
unnecessary dynamic muxing? Or there another way to get rid of this 
wrong behavior in my driver?


[-- Attachment #2: dvorkin.vcf --]
[-- Type: text/x-vcard, Size: 391 bytes --]

BEGIN:VCARD
VERSION:4.0
EMAIL;PREF=1:dvorkin@tibbo.com
EMAIL:dvorkindmitry@gmail.com
FN:Dmitry Dvorkin
NICKNAME:dv
ORG:Tibbo Technology Inc.;
TITLE:Embedded Linux Architect
N:Dvorkin;Dmitry;;;
ADR:;;9F-3\, No.31, Lane 169, Kang-Ning St., Hsi-Chih;New Taipei City;;2218
 0;Taiwan
TEL;VALUE=TEXT:+79190546388
URL;VALUE=URL:https://tibbo.com/
UID:1c58210f-ac8c-4337-b391-0bde146d2d83
END:VCARD

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gpio ->to_irq
  2022-05-11  8:53 gpio ->to_irq Dvorkin Dmitry
@ 2022-05-11 10:25 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2022-05-11 10:25 UTC (permalink / raw)
  To: Dvorkin Dmitry, Bartosz Golaszewski; +Cc: open list:GPIO SUBSYSTEM

On Wed, May 11, 2022 at 12:03 PM Dvorkin Dmitry <dvorkin@tibbo.com> wrote:
>
> Hello!
>
> I have a question about gpiochip ->to_irq().
>
> Kernel call gpio_to_irq() requests IRQ for the pin, previously taken by
> *gpio_request().
>
> But for sysfs when user does echo "pin#" > /sys/class/gpio/export
> gpio_to_irq() is also called at the time of export there:
>
> https://elixir.bootlin.com/linux/v5.4.100/source/drivers/gpio/gpiolib-sysfs.c#L171
>
> and there
>
> https://elixir.bootlin.com/linux/v5.4.100/source/drivers/gpio/gpiolib-sysfs.c#L378
>
> It is a problem for my driver.

It's much easier to answer if you may share the source code of your
driver. Ideally if there is a publicly available datasheet on the
hardware in question.

> I have 120 pins and only 7 dynamically
> muxed GPIO irqs.
>
> So when somebody requests gpio_to_irq() I am creating the mux to the
> first free gpio IRQ. But When user just exports GPIO pin using "old"
> sysfs kernel interface in the filesystem, it should not be done.
>
> How can I see if gpio_to_irq() has been called by sysfs to prevent
> unnecessary dynamic muxing? Or there another way to get rid of this
> wrong behavior in my driver?

Generally speaking nobody should call gpio_to_irq() in the new code.
This is a legacy interface that mustn't be used.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-11 10:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  8:53 gpio ->to_irq Dvorkin Dmitry
2022-05-11 10:25 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.