]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Revert "regulator: act8865: register all regulators regardless of how many are used"
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 6 Jan 2014 06:35:47 +0000 (17:35 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 6 Jan 2014 06:35:47 +0000 (17:35 +1100)
This reverts commit d04b755273683ed31043563b8a3a2716bd8aa6a9.

drivers/regulator/act8865-regulator.c

index 5e3e1d27032816f7ff1e9a82a0b282041431f10c..f816ad866a430b2a6cf0cd561d7ed6fa6a36b075 100644 (file)
@@ -225,8 +225,8 @@ static int act8865_pdata_from_dt(struct device *dev,
                return matched;
 
        pdata->regulators = devm_kzalloc(dev,
-                               sizeof(struct act8865_regulator_data) *
-                               ARRAY_SIZE(act8865_matches), GFP_KERNEL);
+                               sizeof(struct act8865_regulator_data) * matched,
+                               GFP_KERNEL);
        if (!pdata->regulators) {
                dev_err(dev, "%s: failed to allocate act8865 registor\n",
                                                __func__);
@@ -236,7 +236,10 @@ static int act8865_pdata_from_dt(struct device *dev,
        pdata->num_regulators = matched;
        regulator = pdata->regulators;
 
-       for (i = 0; i < ARRAY_SIZE(act8865_matches); i++) {
+       for (i = 0; i < matched; i++) {
+               if (!act8865_matches[i].init_data)
+                       continue;
+
                regulator->id = i;
                regulator->name = act8865_matches[i].name;
                regulator->platform_data = act8865_matches[i].init_data;
@@ -303,7 +306,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
        }
 
        /* Finally register devices */
-       for (i = 0; i < ARRAY_SIZE(act8865_matches); i++) {
+       for (i = 0; i < pdata->num_regulators; i++) {
 
                id = pdata->regulators[i].id;