diff options
author | Nishanth Menon <nm@ti.com> | 2016-05-05 20:29:49 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-05-06 13:15:17 -0400 |
commit | 036d193d3337365e0d69cff9bb2593bfc1210e7b (patch) | |
tree | cff0a27bb78eb07ea041cde2655759ebe341233d | |
parent | e0341f1732237777d65bdda7184ea4b11fb31d53 (diff) |
regulator: tps65917/palmas: Simplify multiple dereference of ddata->palmas_matches[idx]
Converting dt to platform data logic involves picking up information
that is unique per regulator, however we can improve readability of
the code by dereferencing ddata->palmas_matches[idx] once in the loop.
While at it fix reuse of generic palmas_matches common variable
while reporting error for a specific regulator (which may be from
65917/palmas list).
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index c83e06b2cedb..41b4e94a8d7d 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -1491,21 +1491,23 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | for (idx = 0; idx < ddata->max_reg; idx++) { | 1493 | for (idx = 0; idx < ddata->max_reg; idx++) { |
1494 | if (!ddata->palmas_matches[idx].init_data || | 1494 | static struct of_regulator_match *match; |
1495 | !ddata->palmas_matches[idx].of_node) | 1495 | |
1496 | match = &ddata->palmas_matches[idx]; | ||
1497 | |||
1498 | if (!match->init_data || !match->of_node) | ||
1496 | continue; | 1499 | continue; |
1497 | 1500 | ||
1498 | pdata->reg_data[idx] = ddata->palmas_matches[idx].init_data; | 1501 | pdata->reg_data[idx] = match->init_data; |
1499 | 1502 | ||
1500 | pdata->reg_init[idx] = devm_kzalloc(dev, | 1503 | pdata->reg_init[idx] = devm_kzalloc(dev, |
1501 | sizeof(struct palmas_reg_init), GFP_KERNEL); | 1504 | sizeof(struct palmas_reg_init), GFP_KERNEL); |
1502 | 1505 | ||
1503 | pdata->reg_init[idx]->warm_reset = | 1506 | pdata->reg_init[idx]->warm_reset = |
1504 | of_property_read_bool(ddata->palmas_matches[idx].of_node, | 1507 | of_property_read_bool(match->of_node, "ti,warm-reset"); |
1505 | "ti,warm-reset"); | ||
1506 | 1508 | ||
1507 | ret = of_property_read_u32(ddata->palmas_matches[idx].of_node, | 1509 | ret = of_property_read_u32(match->of_node, "ti,roof-floor", |
1508 | "ti,roof-floor", &prop); | 1510 | &prop); |
1509 | /* EINVAL: Property not found */ | 1511 | /* EINVAL: Property not found */ |
1510 | if (ret != -EINVAL) { | 1512 | if (ret != -EINVAL) { |
1511 | int econtrol; | 1513 | int econtrol; |
@@ -1527,27 +1529,26 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
1527 | WARN_ON(1); | 1529 | WARN_ON(1); |
1528 | dev_warn(dev, | 1530 | dev_warn(dev, |
1529 | "%s: Invalid roof-floor option: %u\n", | 1531 | "%s: Invalid roof-floor option: %u\n", |
1530 | palmas_matches[idx].name, prop); | 1532 | match->name, prop); |
1531 | break; | 1533 | break; |
1532 | } | 1534 | } |
1533 | } | 1535 | } |
1534 | pdata->reg_init[idx]->roof_floor = econtrol; | 1536 | pdata->reg_init[idx]->roof_floor = econtrol; |
1535 | } | 1537 | } |
1536 | 1538 | ||
1537 | ret = of_property_read_u32(ddata->palmas_matches[idx].of_node, | 1539 | ret = of_property_read_u32(match->of_node, "ti,mode-sleep", |
1538 | "ti,mode-sleep", &prop); | 1540 | &prop); |
1539 | if (!ret) | 1541 | if (!ret) |
1540 | pdata->reg_init[idx]->mode_sleep = prop; | 1542 | pdata->reg_init[idx]->mode_sleep = prop; |
1541 | 1543 | ||
1542 | ret = of_property_read_bool(ddata->palmas_matches[idx].of_node, | 1544 | ret = of_property_read_bool(match->of_node, "ti,smps-range"); |
1543 | "ti,smps-range"); | ||
1544 | if (ret) | 1545 | if (ret) |
1545 | pdata->reg_init[idx]->vsel = | 1546 | pdata->reg_init[idx]->vsel = |
1546 | PALMAS_SMPS12_VOLTAGE_RANGE; | 1547 | PALMAS_SMPS12_VOLTAGE_RANGE; |
1547 | 1548 | ||
1548 | if (idx == PALMAS_REG_LDO8) | 1549 | if (idx == PALMAS_REG_LDO8) |
1549 | pdata->enable_ldo8_tracking = of_property_read_bool( | 1550 | pdata->enable_ldo8_tracking = of_property_read_bool( |
1550 | ddata->palmas_matches[idx].of_node, | 1551 | match->of_node, |
1551 | "ti,enable-ldo8-tracking"); | 1552 | "ti,enable-ldo8-tracking"); |
1552 | } | 1553 | } |
1553 | 1554 | ||