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

Commit d0f63709 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar Committed by Rohit Vaswani
Browse files

power: smb135x: smb1351: avail of simpler regulator registration api



Change,
a0c7b164 regulator: of: Provide simplified DT parsing method
enables to register a regulator without constructing an regulator_init_data
structure. The regulator_init_data is instantiated within the
registration api and is filled with information by parsing the regualtor
device node.

Avail of this convenience while registering OTG regulators in the
smb135x and smb1351 drivers.

Change-Id: I2eb2866f9941db797ede1676e92bb87b4a23c925
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 89b8a21c
Loading
Loading
Loading
Loading
+18 −30
Original line number Diff line number Diff line
@@ -868,28 +868,18 @@ struct regulator_ops smb1351_chg_otg_reg_ops = {
static int smb1351_regulator_init(struct smb1351_charger *chip)
{
	int rc = 0;
	struct regulator_init_data *init_data;
	struct regulator_config cfg = {};

	init_data = of_get_regulator_init_data(chip->dev, chip->dev->of_node);
	if (!init_data) {
		pr_err("Unable to allocate memory\n");
		return -ENOMEM;
	}

	if (init_data->constraints.name) {
	chip->otg_vreg.rdesc.owner = THIS_MODULE;
	chip->otg_vreg.rdesc.type = REGULATOR_VOLTAGE;
	chip->otg_vreg.rdesc.ops = &smb1351_chg_otg_reg_ops;
		chip->otg_vreg.rdesc.name = init_data->constraints.name;
	chip->otg_vreg.rdesc.name = 
		chip->dev->of_node->name;
	chip->otg_vreg.rdesc.of_match = 
		chip->dev->of_node->name;

	cfg.dev = chip->dev;
		cfg.init_data = init_data;
	cfg.driver_data = chip;
		cfg.of_node = chip->dev->of_node;

		init_data->constraints.valid_ops_mask
			|= REGULATOR_CHANGE_STATUS;

	chip->otg_vreg.rdev = regulator_register(
					&chip->otg_vreg.rdesc, &cfg);
@@ -899,8 +889,6 @@ static int smb1351_regulator_init(struct smb1351_charger *chip)
		if (rc != -EPROBE_DEFER)
			pr_err("OTG reg failed, rc=%d\n", rc);
	}
	}

	return rc;
}

+15 −30
Original line number Diff line number Diff line
@@ -2348,31 +2348,17 @@ wrkarnd_and_input_current_values:
static int smb135x_regulator_init(struct smb135x_chg *chip)
{
	int rc = 0;
	struct regulator_init_data *init_data;
	struct regulator_config cfg = {};

	init_data = of_get_regulator_init_data(chip->dev, chip->dev->of_node);
	if (!init_data) {
		dev_err(chip->dev, "Unable to allocate memory\n");
		return -ENOMEM;
	}

	if (init_data->constraints.name) {
	chip->otg_vreg.rdesc.owner = THIS_MODULE;
	chip->otg_vreg.rdesc.type = REGULATOR_VOLTAGE;
	chip->otg_vreg.rdesc.ops = &smb135x_chg_otg_reg_ops;
		chip->otg_vreg.rdesc.name = init_data->constraints.name;

	chip->otg_vreg.rdesc.name = chip->dev->of_node->name;
	chip->otg_vreg.rdesc.of_match = chip->dev->of_node->name;
	cfg.dev = chip->dev;
		cfg.init_data = init_data;
	cfg.driver_data = chip;
		cfg.of_node = chip->dev->of_node;

		init_data->constraints.valid_ops_mask
			|= REGULATOR_CHANGE_STATUS;

		chip->otg_vreg.rdev = regulator_register(
						&chip->otg_vreg.rdesc, &cfg);
	chip->otg_vreg.rdev = regulator_register(&chip->otg_vreg.rdesc, &cfg);
	if (IS_ERR(chip->otg_vreg.rdev)) {
		rc = PTR_ERR(chip->otg_vreg.rdev);
		chip->otg_vreg.rdev = NULL;
@@ -2380,7 +2366,6 @@ static int smb135x_regulator_init(struct smb135x_chg *chip)
			dev_err(chip->dev,
				"OTG reg failed, rc=%d\n", rc);
	}
	}

	return rc;
}