Skip to contentSkip to conversation

gpio: sim: lock hog configfs items if present

PATCH Applied Bartosz Golaszewski 2 participants 3 messages Feb 3, 2025 – Feb 5, 2025 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: sim: lock hog configfs items if present

From: Bartosz Golaszewski <[email protected]>

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")
---
 drivers/gpio/gpio-sim.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpio/gpio-sim.c +7 -4
index a086087ada17..b843682b47e9 100644
@@ -1028,6 +1028,7 @@ 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
@@ -1036,12 +1037,14 @@ gpio_sim_device_lockup_configfs(struct gpio_sim_device *dev, bool lock)
 	 */
 	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);
 		}
 	}
 }
Signature · 1 line
2.45.2
Tested-by on v1 1/1
#1 lore raw
Quoted 45 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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")
---
 drivers/gpio/gpio-sim.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpio/gpio-sim.c +7 -4
index a086087ada17..b843682b47e9 100644
@@ -1028,6 +1028,7 @@ 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
@@ -1036,12 +1037,14 @@ gpio_sim_device_lockup_configfs(struct gpio_sim_device *dev, bool lock)
 	 */
 	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);
 		}
 	}
 }
Signature · 1 line
2.45.2

Thanks for spotting this and the fix.

author Applied
#2 lore raw
In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Quoted 4 lines · Bartosz Golaszewski

Depending on the user config, the leaf entry may be the hog directory, not line. Check it and lock the correct item.

Applied, thanks!

[1/1] gpio: sim: lock hog configfs items if present

      commit: 015b7dae084fa95465ff89f6cbf15fe49906a370

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>