mbox series

[RFCv2,0/4] gpiolib: chain irq callbacks

Message ID 20180827130620.96232-1-hverkuil@xs4all.nl
Headers show
Series gpiolib: chain irq callbacks | expand

Message

Hans Verkuil Aug. 27, 2018, 1:06 p.m. UTC
From: Hans Verkuil <hans.verkuil@cisco.com>

Hi all,

This is the second RFC patch series which attempts 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.

This patch lets gpiolib override the irq_chip's irq_request/release_resources,
irq_startup/shutdown and irq_en/disable hooks.

The old hooks (if any) are stored and called by gpiolib after taking care
of the gpiolib-specific code.

As a result, the gpiochip_(un)lock_as_irq functions can become static and can
be removed from all drivers.

Reviewing the removal of those calls in drivers should be fairly easy.

The first patch implements the chaining of the irq callbacks. Compared
to the first RFC patch I posted I added code to do the same for the
startup/shutdown hooks since those also implicitly enable/disable irqs.
If they are NULL, then the irq code will call the irq_en/disable hooks,
so only override the startup/shutdown hooks when non-NULL.

I do have one question: can the same struct irq_chip be added to different
struct gpio_chip instances? Right now when the gpiolib hooks are installed
for the irq_chip I check if that was already done.

If the same irq_chip can be used for multiple gpio_chips, then I will need
to count the irq_chip references and only remove the installed hooks when
the last reference is removed. If this isn't possible, then I wonder if
I need to keep a WARN_ON if someone attempts to do this.

This first patch keeps the gpiochip_(un)lock_as_irq functions as stubs,
so the second patch can remove all the calls safely. The third patch
removes these stubs and the fourth patch removes the corresponding
documentation.

Should the second patch be split up in one patch per driver? Or perhaps
one patch per subsystem (gpio/pinctrl/hid)?

This patch series has been tested on my BeagleBone Black board with the
tda998x driver and I tested the sysfs API as well.

Regards,

        Hans

Hans Verkuil (4):
  gpiolib: (un)mark gpio as irq when dis/enabling irq
  gpio: remove gpiochip_(un)lock_as_irq() from drivers
  gpiolib: remove gpiochip_(un)lock_as_irq
  gpio/driver.rst: drop gpiochip_(un)lock_as_irq section

 Documentation/driver-api/gpio/driver.rst |  19 ---
 drivers/gpio/gpio-bcm-kona.c             |  24 ----
 drivers/gpio/gpio-dwapb.c                |  27 -----
 drivers/gpio/gpio-em.c                   |  24 ----
 drivers/gpio/gpio-tegra.c                |  19 ---
 drivers/gpio/gpio-thunderx.c             |  15 +--
 drivers/gpio/gpio-uniphier.c             |  20 ----
 drivers/gpio/gpio-vr41xx.c               |  11 --
 drivers/gpio/gpio-xgene-sb.c             |  10 --
 drivers/gpio/gpiolib-acpi.c              |  13 +--
 drivers/gpio/gpiolib-sysfs.c             |  18 +--
 drivers/gpio/gpiolib.c                   | 142 ++++++++++++++++-------
 drivers/hid/hid-cp2112.c                 |  14 +--
 drivers/pinctrl/intel/pinctrl-intel.c    |  32 -----
 drivers/pinctrl/mediatek/mtk-eint.c      |   9 --
 drivers/pinctrl/pinctrl-st.c             |  10 +-
 drivers/pinctrl/samsung/pinctrl-exynos.c |  10 --
 drivers/pinctrl/stm32/pinctrl-stm32.c    |  16 ---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c    |  19 ---
 include/linux/gpio.h                     |  13 ---
 include/linux/gpio/driver.h              |  11 +-
 21 files changed, 119 insertions(+), 357 deletions(-)