gpio: add SRCU infrastructure to struct gpio_device
[linux-2.6-microblaze.git] / drivers / gpio / gpiolib.c
index 40052de..4e0c6df 100644 (file)
@@ -680,6 +680,7 @@ static void gpiodev_release(struct device *dev)
        ida_free(&gpio_ida, gdev->id);
        kfree_const(gdev->label);
        kfree(gdev->descs);
+       cleanup_srcu_struct(&gdev->srcu);
        kfree(gdev);
 }
 
@@ -948,6 +949,10 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
        BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier);
        init_rwsem(&gdev->sem);
 
+       ret = init_srcu_struct(&gdev->srcu);
+       if (ret)
+               goto err_remove_from_list;
+
 #ifdef CONFIG_PINCTRL
        INIT_LIST_HEAD(&gdev->pin_ranges);
 #endif
@@ -955,15 +960,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
        if (gc->names) {
                ret = gpiochip_set_desc_names(gc);
                if (ret)
-                       goto err_remove_from_list;
+                       goto err_cleanup_gdev_srcu;
        }
        ret = gpiochip_set_names(gc);
        if (ret)
-               goto err_remove_from_list;
+               goto err_cleanup_gdev_srcu;
 
        ret = gpiochip_init_valid_mask(gc);
        if (ret)
-               goto err_remove_from_list;
+               goto err_cleanup_gdev_srcu;
 
        ret = of_gpiochip_add(gc);
        if (ret)
@@ -1038,6 +1043,8 @@ err_remove_of_chip:
 err_free_gpiochip_mask:
        gpiochip_remove_pin_ranges(gc);
        gpiochip_free_valid_mask(gc);
+err_cleanup_gdev_srcu:
+       cleanup_srcu_struct(&gdev->srcu);
 err_remove_from_list:
        scoped_guard(mutex, &gpio_devices_lock)
                list_del_rcu(&gdev->list);