gpio: eic-sprd: use atomic notifiers to notify all chips about irqs
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 4 Sep 2023 12:33:20 +0000 (14:33 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 11 Sep 2023 09:17:06 +0000 (11:17 +0200)
commitb32415652a4d250c51c1f1cc59a02c58e7141417
treec4fc4b8062688840cbd3806d5410658580c4367a
parentf4e840238c4c956fec196894d3d853f4e5abe509
gpio: eic-sprd: use atomic notifiers to notify all chips about irqs

Calling gpiochip_find() from interrupt handler in this driver is an
abuse of the GPIO API. It only happens to work because nobody added a
might_sleep() to it and the lock used by GPIOLIB is a spinlock.

Both will soon be changed as we're limiting both the number of
interfaces allowed to be called from atomic context as well as making
struct gpio_chip private to the GPIO code that owns it. We'll also
switch to protecting the global GPIO device list with a mutex as there
is no reason to allow changes to it from interrupt handlers.

Instead of iterating over all SPRD chips and looking up each
corresponding GPIO chip, let's make each SPRD GPIO controller register
with a notifier chain. The chain will be called at interrupt so that
every chip that already probed will be notified. The rest of the
interrupt handling remains the same. This should result in faster code as
we're avoiding iterating over the list of all GPIO devices.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Chunyan Zhang <zhang.lyra@gmail.com>
Tested-by: Wenhua Lin <wenhua.lin@unisoc.com>
drivers/gpio/gpio-eic-sprd.c