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

Commit b874f41c authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown
Browse files

regulator: max8952: Use managed regulator registration



Use managed devm_regulator_register to simplify the driver probe and
driver remove functions. This allows removing from state container the
pointer to regulator_dev returned on registering the regulator.

Patch also removes from state container pointer to 'struct device' as it
is not used anywhere outside of max8952_pmic_probe() function.

Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 7752d964
Loading
Loading
Loading
Loading
+8 −13
Original line number Original line Diff line number Diff line
@@ -48,9 +48,7 @@ enum {


struct max8952_data {
struct max8952_data {
	struct i2c_client	*client;
	struct i2c_client	*client;
	struct device		*dev;
	struct max8952_platform_data *pdata;
	struct max8952_platform_data *pdata;
	struct regulator_dev	*rdev;


	bool vid0;
	bool vid0;
	bool vid1;
	bool vid1;
@@ -197,6 +195,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
	struct max8952_platform_data *pdata = dev_get_platdata(&client->dev);
	struct max8952_platform_data *pdata = dev_get_platdata(&client->dev);
	struct regulator_config config = { };
	struct regulator_config config = { };
	struct max8952_data *max8952;
	struct max8952_data *max8952;
	struct regulator_dev *rdev;


	int ret = 0, err = 0;
	int ret = 0, err = 0;


@@ -217,10 +216,9 @@ static int max8952_pmic_probe(struct i2c_client *client,
		return -ENOMEM;
		return -ENOMEM;


	max8952->client = client;
	max8952->client = client;
	max8952->dev = &client->dev;
	max8952->pdata = pdata;
	max8952->pdata = pdata;


	config.dev = max8952->dev;
	config.dev = &client->dev;
	config.init_data = pdata->reg_data;
	config.init_data = pdata->reg_data;
	config.driver_data = max8952;
	config.driver_data = max8952;
	config.of_node = client->dev.of_node;
	config.of_node = client->dev.of_node;
@@ -229,11 +227,11 @@ static int max8952_pmic_probe(struct i2c_client *client,
	if (pdata->reg_data->constraints.boot_on)
	if (pdata->reg_data->constraints.boot_on)
		config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
		config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;


	max8952->rdev = regulator_register(&regulator, &config);
	rdev = devm_regulator_register(&client->dev, &regulator, &config);


	if (IS_ERR(max8952->rdev)) {
	if (IS_ERR(rdev)) {
		ret = PTR_ERR(max8952->rdev);
		ret = PTR_ERR(rdev);
		dev_err(max8952->dev, "regulator init failed (%d)\n", ret);
		dev_err(&client->dev, "regulator init failed (%d)\n", ret);
		return ret;
		return ret;
	}
	}


@@ -261,7 +259,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
		err = 3;
		err = 3;


	if (err) {
	if (err) {
		dev_warn(max8952->dev, "VID0/1 gpio invalid: "
		dev_warn(&client->dev, "VID0/1 gpio invalid: "
				"DVS not available.\n");
				"DVS not available.\n");
		max8952->vid0 = 0;
		max8952->vid0 = 0;
		max8952->vid1 = 0;
		max8952->vid1 = 0;
@@ -272,7 +270,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
		/* Disable Pulldown of EN only */
		/* Disable Pulldown of EN only */
		max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x60);
		max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x60);


		dev_err(max8952->dev, "DVS modes disabled because VID0 and VID1"
		dev_err(&client->dev, "DVS modes disabled because VID0 and VID1"
				" do not have proper controls.\n");
				" do not have proper controls.\n");
	} else {
	} else {
		/*
		/*
@@ -319,9 +317,6 @@ static int max8952_pmic_remove(struct i2c_client *client)
{
{
	struct max8952_data *max8952 = i2c_get_clientdata(client);
	struct max8952_data *max8952 = i2c_get_clientdata(client);
	struct max8952_platform_data *pdata = max8952->pdata;
	struct max8952_platform_data *pdata = max8952->pdata;
	struct regulator_dev *rdev = max8952->rdev;

	regulator_unregister(rdev);


	gpio_free(pdata->gpio_vid0);
	gpio_free(pdata->gpio_vid0);
	gpio_free(pdata->gpio_vid1);
	gpio_free(pdata->gpio_vid1);