[PATCH 0/6] gpiolib: track irq enabled/disabled state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hans Verkuil <hans.verkuil@xxxxxxxxx>

Hi all,

This patch series is based on my RFCv3 patch series:
https://www.spinics.net/lists/linux-gpio/msg32168.html
 
The goal is to allow drivers to disable the irq and drive the gpio as an 
output.

Please be gentle with me: I am neither an expert on the gpio internals, nor
on the irq internals.

The first two patches improve the handling of the irq callbacks
irq_request/release_resources(). 
 
While drivers often call gpiochip_lock_as_irq() as needed, none called
try_module_get(chip->gpiodev->owner) as gpiolib does. To simplify those
drivers the first patch adds gpiochip_reqres_irq and gpiochip_relres_irq
functions that such drivers can call instead of gpiochip_lock_as_irq()
to ensure this happens.

The second patch changes the behavior of gpiolib when the irqchip helpers
are used: currently gpiolib just overrides any existing irq_chip 
irq_request/release_resources(), and this patch will remember the
original callback and call it. This required changes to two drivers
that would otherwise go into an infinite loop.

The third patch adds a new flag to remember if the irq is enabled or
not, and allows the direction to be changed to output unless both 
FLAG_USED_AS_IRQ and FLAG_IRQ_IS_ENABLED are set.

The fourth patch overrides the irq_disable and irq_enable hooks when using
the irqchip helpers so gpiolib will know when the irq is enabled/disabled.

Drivers that do not use these helpers will have to call this themselves,
and the fifth patch converts one such driver.

Drivers that do not use the helpers will need to be updated over time so
they call gpiochip_en/disable_irq and gpiochip_reqres/relres_irq, but that 
can be done one by one.

The final patch documents the new gpiochip_en/disable_irq functions.

Note: I have not documented gpiochip_reqres/relres_irq yet. I was wondering
if gpiochip_reqres/relres_irq() shouldn't completely replace
gpiochip_(un)lock_as_irq(). It really does the same, except that reqres/relres
also gets/puts the module. So before documenting this I'd like to know
what others want.

Unfortunately, I could only compile-test this patch series since I don't 
have access to my BeagleBone Black board for the next two weeks.

Linus, as far as I can tell the pinctrl-intel.c and pinctrl-st.c drivers
are the only two that override irq_request/release_resources() AND use
the gliolib irqchip helpers. If I missed any, please let me know.

Regards,

        Hans

Hans Verkuil (6):
  gpiolib: export gpiochip_irq_reqres/relres()
  gpiolib: override irq_request/release_resources hooks
  gpiolib: add flag to indicate if the irq is disabled
  gpiolib: override irq_enable/disable
  gpio-bcm-kona: use new req/relres and dis/enable_irq funcs
  gpio/driver.rst: document gpiochip_disable/enable_irq()

 Documentation/driver-api/gpio/driver.rst |  23 +++-
 drivers/gpio/gpio-bcm-kona.c             |  14 +-
 drivers/gpio/gpiolib.c                   | 162 +++++++++++++++++------
 drivers/gpio/gpiolib.h                   |   1 +
 drivers/pinctrl/intel/pinctrl-intel.c    |  32 -----
 drivers/pinctrl/pinctrl-st.c             |  11 +-
 include/linux/gpio/driver.h              |  32 +++++
 7 files changed, 179 insertions(+), 96 deletions(-)

-- 
2.18.0




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux