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

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

regulator: tps51632: Ensure [base|max]_voltage_uV pdata settings are valid



If pdata->base_voltage_uV is missing or the settings of pdata->base_voltage_uV
and pdata->max_voltage_uV are out of range, TPS51632_VOLT_VSEL macro
returns wrong vsel.

Thus add checking [base|max]_voltage_uV pdata settings in probe.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 9997f3ff
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -242,6 +242,21 @@ static int __devinit tps51632_probe(struct i2c_client *client,
		return -EINVAL;
		return -EINVAL;
	}
	}


	if (pdata->enable_pwm_dvfs) {
		if ((pdata->base_voltage_uV < TPS51632_MIN_VOLATGE) ||
		    (pdata->base_voltage_uV > TPS51632_MAX_VOLATGE)) {
			dev_err(&client->dev, "Invalid base_voltage_uV setting\n");
			return -EINVAL;
		}

		if ((pdata->max_voltage_uV) &&
		    ((pdata->max_voltage_uV < TPS51632_MIN_VOLATGE) ||
		     (pdata->max_voltage_uV > TPS51632_MAX_VOLATGE))) {
			dev_err(&client->dev, "Invalid max_voltage_uV setting\n");
			return -EINVAL;
		}
	}

	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
	if (!tps) {
	if (!tps) {
		dev_err(&client->dev, "Memory allocation failed\n");
		dev_err(&client->dev, "Memory allocation failed\n");