Skip to contentSkip to conversation

regulator: add unset_regulator_supplies to fix regulator_unregister

PATCH Applied Mike Rapoport 3 participants 3 messages Jan 22, 2009 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: add unset_regulator_supplies to fix regulator_unregister

Currently regulator_unregister does not clear regulator <--> consumer mapping.
This patch introduces unset_regulator_supplies that clear the map.

---
 drivers/regulator/core.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/regulator/core.c +14 -0
index f511a40..ab1beec 100644
@@ -817,6 +817,19 @@ static void unset_consumer_device_supply(struct regulator_dev *rdev,
 	}
 }
 
+static void unset_regulator_supplies(struct regulator_dev *rdev)
+{
+	struct regulator_map *node, *n;
+
+	list_for_each_entry_safe(node, n, &regulator_map_list, list) {
+		if (rdev == node->regulator) {
+			list_del(&node->list);
+			kfree(node);
+			return;
+		}
+	}
+}
+
 #define REG_STR_SIZE	32
 
 static struct regulator *create_regulator(struct regulator_dev *rdev,
@@ -1945,6 +1958,7 @@ void regulator_unregister(struct regulator_dev *rdev)
 		return;
 
 	mutex_lock(&regulator_list_mutex);
+	unset_regulator_supplies(rdev);
 	list_del(&rdev->list);
 	if (rdev->supply)
 		sysfs_remove_link(&rdev->dev.kobj, "supply");
Signature · 7 lines
1.5.6.4



-- 
Sincerely yours,
Mike.
#2 lore raw
In reply to Mike Rapoport
Quoted 9 lines · Mike Rapoport

Currently regulator_unregister does not clear regulator <--> consumer mapping.
This patch introduces unset_regulator_supplies that clear the map.

---
 drivers/regulator/core.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

Applied.

Thanks

Liam