]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/regulator/palmas-regulator.c
regulator: tps65917/palmas: Simplify multiple dereference of ddata->palmas_matches...
[mirror_ubuntu-zesty-kernel.git] / drivers / regulator / palmas-regulator.c
index 6efc7ee8aea30f8ea1307e7e84b91a9901899808..41b4e94a8d7de13ad67d197bceff51fbdf32f76e 100644 (file)
@@ -944,6 +944,8 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
                        if (id == PALMAS_REG_LDO9) {
                                desc->ops = &palmas_ops_ldo9;
                                desc->bypass_reg = desc->enable_reg;
+                               desc->bypass_val_on =
+                                               PALMAS_LDO9_CTRL_LDO_BYPASS_EN;
                                desc->bypass_mask =
                                                PALMAS_LDO9_CTRL_LDO_BYPASS_EN;
                        }
@@ -1055,6 +1057,8 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
                            id == TPS65917_REG_LDO2) {
                                desc->ops = &tps65917_ops_ldo_1_2;
                                desc->bypass_reg = desc->enable_reg;
+                               desc->bypass_val_on =
+                                               TPS65917_LDO1_CTRL_BYPASS_EN;
                                desc->bypass_mask =
                                                TPS65917_LDO1_CTRL_BYPASS_EN;
                        }
@@ -1206,6 +1210,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
                                desc->enable_mask = SMPS10_BOOST_EN;
                        desc->bypass_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
                                                            PALMAS_SMPS10_CTRL);
+                       desc->bypass_val_on = SMPS10_BYPASS_EN;
                        desc->bypass_mask = SMPS10_BYPASS_EN;
                        desc->min_uV = 3750000;
                        desc->uV_step = 1250000;
@@ -1486,21 +1491,23 @@ static void palmas_dt_to_pdata(struct device *dev,
        }
 
        for (idx = 0; idx < ddata->max_reg; idx++) {
-               if (!ddata->palmas_matches[idx].init_data ||
-                   !ddata->palmas_matches[idx].of_node)
+               static struct of_regulator_match *match;
+
+               match = &ddata->palmas_matches[idx];
+
+               if (!match->init_data || !match->of_node)
                        continue;
 
-               pdata->reg_data[idx] = ddata->palmas_matches[idx].init_data;
+               pdata->reg_data[idx] = match->init_data;
 
                pdata->reg_init[idx] = devm_kzalloc(dev,
                                sizeof(struct palmas_reg_init), GFP_KERNEL);
 
                pdata->reg_init[idx]->warm_reset =
-                       of_property_read_bool(ddata->palmas_matches[idx].of_node,
-                                             "ti,warm-reset");
+                       of_property_read_bool(match->of_node, "ti,warm-reset");
 
-               ret = of_property_read_u32(ddata->palmas_matches[idx].of_node,
-                                          "ti,roof-floor", &prop);
+               ret = of_property_read_u32(match->of_node, "ti,roof-floor",
+                                          &prop);
                /* EINVAL: Property not found */
                if (ret != -EINVAL) {
                        int econtrol;
@@ -1522,27 +1529,26 @@ static void palmas_dt_to_pdata(struct device *dev,
                                        WARN_ON(1);
                                        dev_warn(dev,
                                                 "%s: Invalid roof-floor option: %u\n",
-                                            palmas_matches[idx].name, prop);
+                                                match->name, prop);
                                        break;
                                }
                        }
                        pdata->reg_init[idx]->roof_floor = econtrol;
                }
 
-               ret = of_property_read_u32(ddata->palmas_matches[idx].of_node,
-                                          "ti,mode-sleep", &prop);
+               ret = of_property_read_u32(match->of_node, "ti,mode-sleep",
+                                          &prop);
                if (!ret)
                        pdata->reg_init[idx]->mode_sleep = prop;
 
-               ret = of_property_read_bool(ddata->palmas_matches[idx].of_node,
-                                           "ti,smps-range");
+               ret = of_property_read_bool(match->of_node, "ti,smps-range");
                if (ret)
                        pdata->reg_init[idx]->vsel =
                                PALMAS_SMPS12_VOLTAGE_RANGE;
 
                if (idx == PALMAS_REG_LDO8)
                        pdata->enable_ldo8_tracking = of_property_read_bool(
-                                               ddata->palmas_matches[idx].of_node,
+                                               match->of_node,
                                                "ti,enable-ldo8-tracking");
        }