[PATCHv2 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,

Mika Westerberg pointed out a fatal flaw in my previous patch series,
and this version fixes that by basically going back to the approach
from my RFCv3 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.

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 introduces a central function to override irq_chip
callbacks. This is the only patch that was changed compared to the first
version of this patch series.

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.

The fifth 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.

Drivers that do not use these helpers will have to call those themselves,
and the final 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.

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.

Regards,

        Hans

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

 Documentation/driver-api/gpio/driver.rst |  23 +++-
 drivers/gpio/gpio-bcm-kona.c             |  14 +-
 drivers/gpio/gpiolib.c                   | 158 ++++++++++++++++-------
 drivers/gpio/gpiolib.h                   |   1 +
 include/linux/gpio/driver.h              |  18 +++
 5 files changed, 158 insertions(+), 56 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