Skip to content

Commit a067419

Browse files
author
Bartosz Golaszewski
committed
gpiolib: add a second blocking notifier to struct gpio_device
Add a new blocking notifier to struct gpio_device and use it to notify subscribers about the GPIO device being unregistered from the device model. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Kent Gibson <[email protected]>
1 parent e82bbd6 commit a067419

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

drivers/gpio/gpiolib-cdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,4 +2748,5 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt)
27482748
void gpiolib_cdev_unregister(struct gpio_device *gdev)
27492749
{
27502750
cdev_device_del(&gdev->chrdev, &gdev->dev);
2751+
blocking_notifier_call_chain(&gdev->device_notifier, 0, NULL);
27512752
}

drivers/gpio/gpiolib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
848848
spin_unlock_irqrestore(&gpio_lock, flags);
849849

850850
BLOCKING_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier);
851+
BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier);
851852
init_rwsem(&gdev->sem);
852853

853854
#ifdef CONFIG_PINCTRL

drivers/gpio/gpiolib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
* @list: links gpio_device:s together for traversal
4242
* @line_state_notifier: used to notify subscribers about lines being
4343
* requested, released or reconfigured
44+
* @device_notifier: used to notify character device wait queues about the GPIO
45+
* device being unregistered
4446
* @sem: protects the structure from a NULL-pointer dereference of @chip by
4547
* user-space operations when the device gets unregistered during
4648
* a hot-unplug event
@@ -65,6 +67,7 @@ struct gpio_device {
6567
void *data;
6668
struct list_head list;
6769
struct blocking_notifier_head line_state_notifier;
70+
struct blocking_notifier_head device_notifier;
6871
struct rw_semaphore sem;
6972

7073
#ifdef CONFIG_PINCTRL

0 commit comments

Comments
 (0)