diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-01-27 08:16:56 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-30 05:50:27 -0500 |
commit | c92f5dd2c42fa61e0ef810fad4584b184ea2d50e (patch) | |
tree | c0d7f598b23259342ea4e912607156fb7acef2d2 /drivers/regulator | |
parent | 9c9588a7326bdebf49f5d205dd4243c0d1df73d5 (diff) |
regulator: Add missing of_node_put()
of_find_node_by_name() returns a node pointer with refcount incremented, use
of_node_put() on it when done.
of_find_node_by_name() will call of_node_put() against from parameter,
thus we also need to call of_node_get(from) before calling
of_find_node_by_name().
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/88pm8607.c | 3 | ||||
-rw-r--r-- | drivers/regulator/da9052-regulator.c | 5 | ||||
-rw-r--r-- | drivers/regulator/max8907-regulator.c | 7 | ||||
-rw-r--r-- | drivers/regulator/max8925-regulator.c | 3 | ||||
-rw-r--r-- | drivers/regulator/max8997.c | 4 | ||||
-rw-r--r-- | drivers/regulator/mc13xxx-regulator-core.c | 7 | ||||
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 2 | ||||
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 6 |
8 files changed, 26 insertions, 11 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 2b557119adad..e99a3e48b880 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -372,7 +372,7 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev, | |||
372 | struct regulator_config *config) | 372 | struct regulator_config *config) |
373 | { | 373 | { |
374 | struct device_node *nproot, *np; | 374 | struct device_node *nproot, *np; |
375 | nproot = pdev->dev.parent->of_node; | 375 | nproot = of_node_get(pdev->dev.parent->of_node); |
376 | if (!nproot) | 376 | if (!nproot) |
377 | return -ENODEV; | 377 | return -ENODEV; |
378 | nproot = of_find_node_by_name(nproot, "regulators"); | 378 | nproot = of_find_node_by_name(nproot, "regulators"); |
@@ -388,6 +388,7 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev, | |||
388 | break; | 388 | break; |
389 | } | 389 | } |
390 | } | 390 | } |
391 | of_node_put(nproot); | ||
391 | return 0; | 392 | return 0; |
392 | } | 393 | } |
393 | #else | 394 | #else |
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index d0963090442d..29d194c8a310 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c | |||
@@ -395,9 +395,9 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
395 | config.init_data = pdata->regulators[pdev->id]; | 395 | config.init_data = pdata->regulators[pdev->id]; |
396 | } else { | 396 | } else { |
397 | #ifdef CONFIG_OF | 397 | #ifdef CONFIG_OF |
398 | struct device_node *nproot = da9052->dev->of_node; | 398 | struct device_node *nproot, *np; |
399 | struct device_node *np; | ||
400 | 399 | ||
400 | nproot = of_node_get(da9052->dev->of_node); | ||
401 | if (!nproot) | 401 | if (!nproot) |
402 | return -ENODEV; | 402 | return -ENODEV; |
403 | 403 | ||
@@ -414,6 +414,7 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
414 | break; | 414 | break; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | of_node_put(nproot); | ||
417 | #endif | 418 | #endif |
418 | } | 419 | } |
419 | 420 | ||
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c index d40cf7fdb546..4568c15fa78d 100644 --- a/drivers/regulator/max8907-regulator.c +++ b/drivers/regulator/max8907-regulator.c | |||
@@ -224,11 +224,11 @@ static struct of_regulator_match max8907_matches[] = { | |||
224 | 224 | ||
225 | static int max8907_regulator_parse_dt(struct platform_device *pdev) | 225 | static int max8907_regulator_parse_dt(struct platform_device *pdev) |
226 | { | 226 | { |
227 | struct device_node *np = pdev->dev.parent->of_node; | 227 | struct device_node *np, *regulators; |
228 | struct device_node *regulators; | ||
229 | int ret; | 228 | int ret; |
230 | 229 | ||
231 | if (!pdev->dev.parent->of_node) | 230 | np = of_node_get(pdev->dev.parent->of_node); |
231 | if (!np) | ||
232 | return 0; | 232 | return 0; |
233 | 233 | ||
234 | regulators = of_find_node_by_name(np, "regulators"); | 234 | regulators = of_find_node_by_name(np, "regulators"); |
@@ -239,6 +239,7 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev) | |||
239 | 239 | ||
240 | ret = of_regulator_match(&pdev->dev, regulators, max8907_matches, | 240 | ret = of_regulator_match(&pdev->dev, regulators, max8907_matches, |
241 | ARRAY_SIZE(max8907_matches)); | 241 | ARRAY_SIZE(max8907_matches)); |
242 | of_node_put(regulators); | ||
242 | if (ret < 0) { | 243 | if (ret < 0) { |
243 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", | 244 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", |
244 | ret); | 245 | ret); |
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index 446a85445553..0d5f64a805a0 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -252,7 +252,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev, | |||
252 | { | 252 | { |
253 | struct device_node *nproot, *np; | 253 | struct device_node *nproot, *np; |
254 | int rcount; | 254 | int rcount; |
255 | nproot = pdev->dev.parent->of_node; | 255 | nproot = of_node_get(pdev->dev.parent->of_node); |
256 | if (!nproot) | 256 | if (!nproot) |
257 | return -ENODEV; | 257 | return -ENODEV; |
258 | np = of_find_node_by_name(nproot, "regulators"); | 258 | np = of_find_node_by_name(nproot, "regulators"); |
@@ -263,6 +263,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev, | |||
263 | 263 | ||
264 | rcount = of_regulator_match(&pdev->dev, np, | 264 | rcount = of_regulator_match(&pdev->dev, np, |
265 | &max8925_regulator_matches[ridx], 1); | 265 | &max8925_regulator_matches[ridx], 1); |
266 | of_node_put(np); | ||
266 | if (rcount < 0) | 267 | if (rcount < 0) |
267 | return -ENODEV; | 268 | return -ENODEV; |
268 | config->init_data = max8925_regulator_matches[ridx].init_data; | 269 | config->init_data = max8925_regulator_matches[ridx].init_data; |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 836908ce505e..5abd0d3288f0 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -960,7 +960,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
960 | struct max8997_regulator_data *rdata; | 960 | struct max8997_regulator_data *rdata; |
961 | unsigned int i, dvs_voltage_nr = 1, ret; | 961 | unsigned int i, dvs_voltage_nr = 1, ret; |
962 | 962 | ||
963 | pmic_np = iodev->dev->of_node; | 963 | pmic_np = of_node_get(iodev->dev->of_node); |
964 | if (!pmic_np) { | 964 | if (!pmic_np) { |
965 | dev_err(&pdev->dev, "could not find pmic sub-node\n"); | 965 | dev_err(&pdev->dev, "could not find pmic sub-node\n"); |
966 | return -ENODEV; | 966 | return -ENODEV; |
@@ -980,6 +980,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
980 | rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * | 980 | rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * |
981 | pdata->num_regulators, GFP_KERNEL); | 981 | pdata->num_regulators, GFP_KERNEL); |
982 | if (!rdata) { | 982 | if (!rdata) { |
983 | of_node_put(regulators_np); | ||
983 | dev_err(&pdev->dev, "could not allocate memory for regulator data\n"); | 984 | dev_err(&pdev->dev, "could not allocate memory for regulator data\n"); |
984 | return -ENOMEM; | 985 | return -ENOMEM; |
985 | } | 986 | } |
@@ -1002,6 +1003,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
1002 | rdata->reg_node = reg_np; | 1003 | rdata->reg_node = reg_np; |
1003 | rdata++; | 1004 | rdata++; |
1004 | } | 1005 | } |
1006 | of_node_put(regulators_np); | ||
1005 | 1007 | ||
1006 | if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL)) | 1008 | if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL)) |
1007 | pdata->buck1_gpiodvs = true; | 1009 | pdata->buck1_gpiodvs = true; |
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 2ecf1d8b6a94..5d2ab2ea0c8c 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c | |||
@@ -175,6 +175,7 @@ int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) | |||
175 | for_each_child_of_node(parent, child) | 175 | for_each_child_of_node(parent, child) |
176 | num++; | 176 | num++; |
177 | 177 | ||
178 | of_node_put(parent); | ||
178 | return num; | 179 | return num; |
179 | } | 180 | } |
180 | EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt); | 181 | EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt); |
@@ -197,8 +198,11 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | |||
197 | 198 | ||
198 | data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators, | 199 | data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators, |
199 | GFP_KERNEL); | 200 | GFP_KERNEL); |
200 | if (!data) | 201 | if (!data) { |
202 | of_node_put(parent); | ||
201 | return NULL; | 203 | return NULL; |
204 | } | ||
205 | |||
202 | p = data; | 206 | p = data; |
203 | 207 | ||
204 | for_each_child_of_node(parent, child) { | 208 | for_each_child_of_node(parent, child) { |
@@ -217,6 +221,7 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | |||
217 | } | 221 | } |
218 | } | 222 | } |
219 | } | 223 | } |
224 | of_node_put(parent); | ||
220 | 225 | ||
221 | *num_parsed = parsed; | 226 | *num_parsed = parsed; |
222 | return data; | 227 | return data; |
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index c9e912f583bc..cbaf22627bd3 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -527,6 +527,7 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
527 | u32 prop; | 527 | u32 prop; |
528 | int idx, ret; | 528 | int idx, ret; |
529 | 529 | ||
530 | node = of_node_get(node); | ||
530 | regulators = of_find_node_by_name(node, "regulators"); | 531 | regulators = of_find_node_by_name(node, "regulators"); |
531 | if (!regulators) { | 532 | if (!regulators) { |
532 | dev_info(dev, "regulator node not found\n"); | 533 | dev_info(dev, "regulator node not found\n"); |
@@ -535,6 +536,7 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
535 | 536 | ||
536 | ret = of_regulator_match(dev, regulators, palmas_matches, | 537 | ret = of_regulator_match(dev, regulators, palmas_matches, |
537 | PALMAS_NUM_REGS); | 538 | PALMAS_NUM_REGS); |
539 | of_node_put(regulators); | ||
538 | if (ret < 0) { | 540 | if (ret < 0) { |
539 | dev_err(dev, "Error parsing regulator init data: %d\n", ret); | 541 | dev_err(dev, "Error parsing regulator init data: %d\n", ret); |
540 | return; | 542 | return; |
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index b0e4c0bc85c3..6ba6931ac855 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -964,8 +964,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( | |||
964 | { | 964 | { |
965 | struct tps65910_board *pmic_plat_data; | 965 | struct tps65910_board *pmic_plat_data; |
966 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); | 966 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); |
967 | struct device_node *np = pdev->dev.parent->of_node; | 967 | struct device_node *np, *regulators; |
968 | struct device_node *regulators; | ||
969 | struct of_regulator_match *matches; | 968 | struct of_regulator_match *matches; |
970 | unsigned int prop; | 969 | unsigned int prop; |
971 | int idx = 0, ret, count; | 970 | int idx = 0, ret, count; |
@@ -978,6 +977,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( | |||
978 | return NULL; | 977 | return NULL; |
979 | } | 978 | } |
980 | 979 | ||
980 | np = of_node_get(pdev->dev.parent->of_node); | ||
981 | regulators = of_find_node_by_name(np, "regulators"); | 981 | regulators = of_find_node_by_name(np, "regulators"); |
982 | if (!regulators) { | 982 | if (!regulators) { |
983 | dev_err(&pdev->dev, "regulator node not found\n"); | 983 | dev_err(&pdev->dev, "regulator node not found\n"); |
@@ -994,11 +994,13 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( | |||
994 | matches = tps65911_matches; | 994 | matches = tps65911_matches; |
995 | break; | 995 | break; |
996 | default: | 996 | default: |
997 | of_node_put(regulators); | ||
997 | dev_err(&pdev->dev, "Invalid tps chip version\n"); | 998 | dev_err(&pdev->dev, "Invalid tps chip version\n"); |
998 | return NULL; | 999 | return NULL; |
999 | } | 1000 | } |
1000 | 1001 | ||
1001 | ret = of_regulator_match(&pdev->dev, regulators, matches, count); | 1002 | ret = of_regulator_match(&pdev->dev, regulators, matches, count); |
1003 | of_node_put(regulators); | ||
1002 | if (ret < 0) { | 1004 | if (ret < 0) { |
1003 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", | 1005 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", |
1004 | ret); | 1006 | ret); |