]> www.infradead.org Git - users/willy/pagecache.git/commit
gpio: cdev: put emitting the line state events on a workqueue
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 18 Oct 2024 09:10:14 +0000 (11:10 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 22 Oct 2024 06:59:09 +0000 (08:59 +0200)
commit40b7c49950bd56c984b1f6722f865b922879260e
treed19a18490204a4047eec5e32ddeaaf085af0bef3
parent7b9b77a8bba9c1fd7bad3310dbf2cf382e1f8c25
gpio: cdev: put emitting the line state events on a workqueue

In order to allow line state notifications to be emitted from atomic
context (for instance: from gpiod_direction_input/output()), we must
stop calling any sleeping functions in lineinfo_changed_notify(). To
that end let's use the new workqueue.

Let's atomically allocate small structures containing the required data
and fill it with information immediately upon being notified about the
change except for the pinctrl state which will be retrieved later from
process context. We can pretty reliably do this as pin functions are
typically set once per boot.

Let's make sure to bump the reference count of GPIO device and the GPIO
character device file descriptor to keep both alive until the event was
queued.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-6-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib-cdev.c