diff options
author | Nishanth Menon <nm@ti.com> | 2016-05-05 20:29:50 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-05-06 13:15:17 -0400 |
commit | 1b42443db670dde5e3cb4261f77b29010b163fc6 (patch) | |
tree | d47fd2056a47f09ad45b2429ef9f6f16d9e747da /drivers/regulator | |
parent | 036d193d3337365e0d69cff9bb2593bfc1210e7b (diff) |
regulator: tps65917/palmas: Simplify multiple dereference of pdata->reg_init[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 allocating and referencing pdata->reg_init[idx] once in
the loop.
While at it, use sizeof(*pointer) when allocating pointer. This allows
for structure name changes with minimal code change.
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 41b4e94a8d7d..3b9206224cd1 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -1492,19 +1492,19 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
1492 | 1492 | ||
1493 | for (idx = 0; idx < ddata->max_reg; idx++) { | 1493 | for (idx = 0; idx < ddata->max_reg; idx++) { |
1494 | static struct of_regulator_match *match; | 1494 | static struct of_regulator_match *match; |
1495 | struct palmas_reg_init *rinit; | ||
1495 | 1496 | ||
1496 | match = &ddata->palmas_matches[idx]; | 1497 | match = &ddata->palmas_matches[idx]; |
1497 | 1498 | ||
1498 | if (!match->init_data || !match->of_node) | 1499 | if (!match->init_data || !match->of_node) |
1499 | continue; | 1500 | continue; |
1500 | 1501 | ||
1502 | rinit = devm_kzalloc(dev, sizeof(*rinit), GFP_KERNEL); | ||
1501 | pdata->reg_data[idx] = match->init_data; | 1503 | pdata->reg_data[idx] = match->init_data; |
1504 | pdata->reg_init[idx] = rinit; | ||
1502 | 1505 | ||
1503 | pdata->reg_init[idx] = devm_kzalloc(dev, | 1506 | rinit->warm_reset = of_property_read_bool(match->of_node, |
1504 | sizeof(struct palmas_reg_init), GFP_KERNEL); | 1507 | "ti,warm-reset"); |
1505 | |||
1506 | pdata->reg_init[idx]->warm_reset = | ||
1507 | of_property_read_bool(match->of_node, "ti,warm-reset"); | ||
1508 | 1508 | ||
1509 | ret = of_property_read_u32(match->of_node, "ti,roof-floor", | 1509 | ret = of_property_read_u32(match->of_node, "ti,roof-floor", |
1510 | &prop); | 1510 | &prop); |
@@ -1533,18 +1533,17 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
1533 | break; | 1533 | break; |
1534 | } | 1534 | } |
1535 | } | 1535 | } |
1536 | pdata->reg_init[idx]->roof_floor = econtrol; | 1536 | rinit->roof_floor = econtrol; |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | ret = of_property_read_u32(match->of_node, "ti,mode-sleep", | 1539 | ret = of_property_read_u32(match->of_node, "ti,mode-sleep", |
1540 | &prop); | 1540 | &prop); |
1541 | if (!ret) | 1541 | if (!ret) |
1542 | pdata->reg_init[idx]->mode_sleep = prop; | 1542 | rinit->mode_sleep = prop; |
1543 | 1543 | ||
1544 | ret = of_property_read_bool(match->of_node, "ti,smps-range"); | 1544 | ret = of_property_read_bool(match->of_node, "ti,smps-range"); |
1545 | if (ret) | 1545 | if (ret) |
1546 | pdata->reg_init[idx]->vsel = | 1546 | rinit->vsel = PALMAS_SMPS12_VOLTAGE_RANGE; |
1547 | PALMAS_SMPS12_VOLTAGE_RANGE; | ||
1548 | 1547 | ||
1549 | if (idx == PALMAS_REG_LDO8) | 1548 | if (idx == PALMAS_REG_LDO8) |
1550 | pdata->enable_ldo8_tracking = of_property_read_bool( | 1549 | pdata->enable_ldo8_tracking = of_property_read_bool( |