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

Commit 884ea557 authored by Sachin Kamat's avatar Sachin Kamat Committed by Mark Brown
Browse files

regulator: tps6586x: Use devm_regulator_register



devm_* simplifies the code.

Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 4aac198d
Loading
Loading
Loading
Loading
+6 −25
Original line number Original line Diff line number Diff line
@@ -379,15 +379,14 @@ static int tps6586x_regulator_probe(struct platform_device *pdev)
		ri = find_regulator_info(id);
		ri = find_regulator_info(id);
		if (!ri) {
		if (!ri) {
			dev_err(&pdev->dev, "invalid regulator ID specified\n");
			dev_err(&pdev->dev, "invalid regulator ID specified\n");
			err = -EINVAL;
			return -EINVAL;
			goto fail;
		}
		}


		err = tps6586x_regulator_preinit(pdev->dev.parent, ri);
		err = tps6586x_regulator_preinit(pdev->dev.parent, ri);
		if (err) {
		if (err) {
			dev_err(&pdev->dev,
			dev_err(&pdev->dev,
				"regulator %d preinit failed, e %d\n", id, err);
				"regulator %d preinit failed, e %d\n", id, err);
			goto fail;
			return err;
		}
		}


		config.dev = pdev->dev.parent;
		config.dev = pdev->dev.parent;
@@ -397,12 +396,12 @@ static int tps6586x_regulator_probe(struct platform_device *pdev)
		if (tps6586x_reg_matches)
		if (tps6586x_reg_matches)
			config.of_node = tps6586x_reg_matches[id].of_node;
			config.of_node = tps6586x_reg_matches[id].of_node;


		rdev[id] = regulator_register(&ri->desc, &config);
		rdev[id] = devm_regulator_register(&pdev->dev, &ri->desc,
						   &config);
		if (IS_ERR(rdev[id])) {
		if (IS_ERR(rdev[id])) {
			dev_err(&pdev->dev, "failed to register regulator %s\n",
			dev_err(&pdev->dev, "failed to register regulator %s\n",
					ri->desc.name);
					ri->desc.name);
			err = PTR_ERR(rdev[id]);
			return PTR_ERR(rdev[id]);
			goto fail;
		}
		}


		if (reg_data) {
		if (reg_data) {
@@ -411,30 +410,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev)
			if (err < 0) {
			if (err < 0) {
				dev_err(&pdev->dev,
				dev_err(&pdev->dev,
					"Slew rate config failed, e %d\n", err);
					"Slew rate config failed, e %d\n", err);
				regulator_unregister(rdev[id]);
				return err;
				goto fail;
			}
			}
		}
		}
	}
	}


	platform_set_drvdata(pdev, rdev);
	platform_set_drvdata(pdev, rdev);
	return 0;
	return 0;

fail:
	while (--id >= 0)
		regulator_unregister(rdev[id]);
	return err;
}

static int tps6586x_regulator_remove(struct platform_device *pdev)
{
	struct regulator_dev **rdev = platform_get_drvdata(pdev);
	int id = TPS6586X_ID_MAX_REGULATOR;

	while (--id >= 0)
		regulator_unregister(rdev[id]);

	return 0;
}
}


static struct platform_driver tps6586x_regulator_driver = {
static struct platform_driver tps6586x_regulator_driver = {
@@ -443,7 +425,6 @@ static struct platform_driver tps6586x_regulator_driver = {
		.owner	= THIS_MODULE,
		.owner	= THIS_MODULE,
	},
	},
	.probe		= tps6586x_regulator_probe,
	.probe		= tps6586x_regulator_probe,
	.remove		= tps6586x_regulator_remove,
};
};


static int __init tps6586x_regulator_init(void)
static int __init tps6586x_regulator_init(void)