Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c92f5dd2 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

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: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 9c9588a7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev,
				    struct regulator_config *config)
{
	struct device_node *nproot, *np;
	nproot = pdev->dev.parent->of_node;
	nproot = of_node_get(pdev->dev.parent->of_node);
	if (!nproot)
		return -ENODEV;
	nproot = of_find_node_by_name(nproot, "regulators");
@@ -388,6 +388,7 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev,
			break;
		}
	}
	of_node_put(nproot);
	return 0;
}
#else
+3 −2
Original line number Diff line number Diff line
@@ -395,9 +395,9 @@ static int da9052_regulator_probe(struct platform_device *pdev)
		config.init_data = pdata->regulators[pdev->id];
	} else {
#ifdef CONFIG_OF
		struct device_node *nproot = da9052->dev->of_node;
		struct device_node *np;
		struct device_node *nproot, *np;

		nproot = of_node_get(da9052->dev->of_node);
		if (!nproot)
			return -ENODEV;

@@ -414,6 +414,7 @@ static int da9052_regulator_probe(struct platform_device *pdev)
				break;
			}
		}
		of_node_put(nproot);
#endif
	}

+4 −3
Original line number Diff line number Diff line
@@ -224,11 +224,11 @@ static struct of_regulator_match max8907_matches[] = {

static int max8907_regulator_parse_dt(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.parent->of_node;
	struct device_node *regulators;
	struct device_node *np, *regulators;
	int ret;

	if (!pdev->dev.parent->of_node)
	np = of_node_get(pdev->dev.parent->of_node);
	if (!np)
		return 0;

	regulators = of_find_node_by_name(np, "regulators");
@@ -239,6 +239,7 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev)

	ret = of_regulator_match(&pdev->dev, regulators, max8907_matches,
				 ARRAY_SIZE(max8907_matches));
	of_node_put(regulators);
	if (ret < 0) {
		dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
			ret);
+2 −1
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev,
{
	struct device_node *nproot, *np;
	int rcount;
	nproot = pdev->dev.parent->of_node;
	nproot = of_node_get(pdev->dev.parent->of_node);
	if (!nproot)
		return -ENODEV;
	np = of_find_node_by_name(nproot, "regulators");
@@ -263,6 +263,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev,

	rcount = of_regulator_match(&pdev->dev, np,
				&max8925_regulator_matches[ridx], 1);
	of_node_put(np);
	if (rcount < 0)
		return -ENODEV;
	config->init_data =	max8925_regulator_matches[ridx].init_data;
+3 −1
Original line number Diff line number Diff line
@@ -960,7 +960,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
	struct max8997_regulator_data *rdata;
	unsigned int i, dvs_voltage_nr = 1, ret;

	pmic_np = iodev->dev->of_node;
	pmic_np = of_node_get(iodev->dev->of_node);
	if (!pmic_np) {
		dev_err(&pdev->dev, "could not find pmic sub-node\n");
		return -ENODEV;
@@ -980,6 +980,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
	rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
				pdata->num_regulators, GFP_KERNEL);
	if (!rdata) {
		of_node_put(regulators_np);
		dev_err(&pdev->dev, "could not allocate memory for regulator data\n");
		return -ENOMEM;
	}
@@ -1002,6 +1003,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
		rdata->reg_node = reg_np;
		rdata++;
	}
	of_node_put(regulators_np);

	if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL))
		pdata->buck1_gpiodvs = true;
Loading