Skip to contentSkip to conversation

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

PATCH Applied Axel Lin 3 participants 3 messages Nov 30, 2012 – Dec 2, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/regulator/tps51632-regulator.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/regulator/tps51632-regulator.c +15 -0
index 523b1e5..ab21133 100644
@@ -236,6 +236,21 @@ static int tps51632_probe(struct i2c_client *client,
 		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);
 	if (!tps) {
 		dev_err(&client->dev, "Memory allocation failed\n");
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Axel Lin

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.

Looks good.

Applied
#2 lore raw
In reply to Axel Lin
Quoted 3 lines · Axel Lin

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.

Applied, thanks.