aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2014-04-03 10:32:17 -0400
committerMark Brown <broonie@linaro.org>2014-04-14 12:01:24 -0400
commit63c7c9e16c8e92cc069854f2babdf82d2d38e4c7 (patch)
treecefd292824e43e2923f82316275e803fb5ddab7a
parent3764806440149ea9024dff039497d1e45d6ed027 (diff)
regulator: core: Get and put regulator of_node
Currently the regulator core does not take an additional reference to the of_node it is passed. This means that the caller must ensure that the of_node is valid for the duration of the regulator's existance. It is reasonable for the framework to assume it is passed a valid of_node but seems onerous for it to assume the caller will keep the node valid for the life-time of the regulator, especially when devm_regulator_register is used and there will likely be no code in the driver called at the point it would be safe to put the of_node. This patch adds an additional of_node_get when the regulator is registered and an of_node_put when it is unregistered in the core. This means individual drivers are free to put their of_node references at the end of probe letting the regulator core handling it from there. This simplifies code on the driver side. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9a09f3cdbabb..b97ffd2365d3 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3447,7 +3447,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
3447 3447
3448 /* register with sysfs */ 3448 /* register with sysfs */
3449 rdev->dev.class = &regulator_class; 3449 rdev->dev.class = &regulator_class;
3450 rdev->dev.of_node = config->of_node; 3450 rdev->dev.of_node = of_node_get(config->of_node);
3451 rdev->dev.parent = dev; 3451 rdev->dev.parent = dev;
3452 dev_set_name(&rdev->dev, "regulator.%d", 3452 dev_set_name(&rdev->dev, "regulator.%d",
3453 atomic_inc_return(&regulator_no) - 1); 3453 atomic_inc_return(&regulator_no) - 1);
@@ -3589,6 +3589,7 @@ void regulator_unregister(struct regulator_dev *rdev)
3589 list_del(&rdev->list); 3589 list_del(&rdev->list);
3590 kfree(rdev->constraints); 3590 kfree(rdev->constraints);
3591 regulator_ena_gpio_free(rdev); 3591 regulator_ena_gpio_free(rdev);
3592 of_node_put(rdev->dev.of_node);
3592 device_unregister(&rdev->dev); 3593 device_unregister(&rdev->dev);
3593 mutex_unlock(&regulator_list_mutex); 3594 mutex_unlock(&regulator_list_mutex);
3594} 3595}