]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
regulator: tps51632: Ensure [base|max]_voltage_uV pdata settings are valid
authorAxel Lin <axel.lin@ingics.com>
Fri, 30 Nov 2012 08:52:49 +0000 (16:52 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 2 Dec 2012 15:15:14 +0000 (00:15 +0900)
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: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/tps51632-regulator.c

index e88bfe48303ae8825674284b34cbd9e475392a8d..dc7023ebea87166f52e8ba030270954e91f6d12f 100644 (file)
@@ -242,6 +242,21 @@ static int __devinit 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");