]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: sim: lock hog configfs items if present
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 3 Feb 2025 11:01:23 +0000 (12:01 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 5 Feb 2025 13:37:01 +0000 (14:37 +0100)
Depending on the user config, the leaf entry may be the hog directory,
not line. Check it and lock the correct item.

Fixes: 8bd76b3d3f3a ("gpio: sim: lock up configfs that an instantiated device depends on")
Tested-by: Koichiro Den <koichiro.den@canonical.com>
Link: https://lore.kernel.org/r/20250203110123.87701-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-sim.c

index a086087ada177102971ed15e490d2d9621c07675..b6c230fab8404d9ecc62eebdc0bcae8c4e648c25 100644 (file)
@@ -1028,20 +1028,23 @@ gpio_sim_device_lockup_configfs(struct gpio_sim_device *dev, bool lock)
        struct configfs_subsystem *subsys = dev->group.cg_subsys;
        struct gpio_sim_bank *bank;
        struct gpio_sim_line *line;
+       struct config_item *item;
 
        /*
-        * The device only needs to depend on leaf line entries. This is
+        * The device only needs to depend on leaf entries. This is
         * sufficient to lock up all the configfs entries that the
         * instantiated, alive device depends on.
         */
        list_for_each_entry(bank, &dev->bank_list, siblings) {
                list_for_each_entry(line, &bank->line_list, siblings) {
+                       item = line->hog ? &line->hog->item
+                                        : &line->group.cg_item;
+
                        if (lock)
-                               WARN_ON(configfs_depend_item_unlocked(
-                                               subsys, &line->group.cg_item));
+                               WARN_ON(configfs_depend_item_unlocked(subsys,
+                                                                     item));
                        else
-                               configfs_undepend_item_unlocked(
-                                               &line->group.cg_item);
+                               configfs_undepend_item_unlocked(item);
                }
        }
 }