diff options
| author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2014-04-14 04:09:06 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2014-04-14 17:12:42 -0400 |
| commit | 011703835f83626048ab75d4ada9ab8ed269b193 (patch) | |
| tree | 3725a66d6fcf36126b9e6e7143ae4c295305cd84 | |
| parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff) | |
regulator: s2mps11: Move DTS parsing code to separate function
Refactor code for parsing DTS to increase a little code readability. The
behaviour should not change.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
| -rw-r--r-- | drivers/regulator/s2mps11.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index e713c162fbd4..3aba0331fb5d 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
| @@ -565,12 +565,28 @@ static const struct regulator_desc s2mps14_regulators[] = { | |||
| 565 | regulator_desc_s2mps14_buck1235(5), | 565 | regulator_desc_s2mps14_buck1235(5), |
| 566 | }; | 566 | }; |
| 567 | 567 | ||
| 568 | static int s2mps11_pmic_dt_parse(struct platform_device *pdev, | ||
| 569 | struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) | ||
| 570 | { | ||
| 571 | struct device_node *reg_np; | ||
| 572 | |||
| 573 | reg_np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); | ||
| 574 | if (!reg_np) { | ||
| 575 | dev_err(&pdev->dev, "could not find regulators sub-node\n"); | ||
| 576 | return -EINVAL; | ||
| 577 | } | ||
| 578 | |||
| 579 | of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); | ||
| 580 | of_node_put(reg_np); | ||
| 581 | |||
| 582 | return 0; | ||
| 583 | } | ||
| 584 | |||
| 568 | static int s2mps11_pmic_probe(struct platform_device *pdev) | 585 | static int s2mps11_pmic_probe(struct platform_device *pdev) |
| 569 | { | 586 | { |
| 570 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 587 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
| 571 | struct sec_platform_data *pdata = iodev->pdata; | 588 | struct sec_platform_data *pdata = NULL; |
| 572 | struct of_regulator_match *rdata = NULL; | 589 | struct of_regulator_match *rdata = NULL; |
| 573 | struct device_node *reg_np = NULL; | ||
| 574 | struct regulator_config config = { }; | 590 | struct regulator_config config = { }; |
| 575 | struct s2mps11_info *s2mps11; | 591 | struct s2mps11_info *s2mps11; |
| 576 | int i, ret = 0; | 592 | int i, ret = 0; |
| @@ -598,7 +614,8 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
| 598 | }; | 614 | }; |
| 599 | 615 | ||
| 600 | if (!iodev->dev->of_node) { | 616 | if (!iodev->dev->of_node) { |
| 601 | if (pdata) { | 617 | if (iodev->pdata) { |
| 618 | pdata = iodev->pdata; | ||
| 602 | goto common_reg; | 619 | goto common_reg; |
| 603 | } else { | 620 | } else { |
| 604 | dev_err(pdev->dev.parent, | 621 | dev_err(pdev->dev.parent, |
| @@ -614,15 +631,9 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
| 614 | for (i = 0; i < s2mps11->rdev_num; i++) | 631 | for (i = 0; i < s2mps11->rdev_num; i++) |
| 615 | rdata[i].name = regulators[i].name; | 632 | rdata[i].name = regulators[i].name; |
| 616 | 633 | ||
| 617 | reg_np = of_get_child_by_name(iodev->dev->of_node, "regulators"); | 634 | ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11); |
| 618 | if (!reg_np) { | 635 | if (ret) |
| 619 | dev_err(&pdev->dev, "could not find regulators sub-node\n"); | ||
| 620 | ret = -EINVAL; | ||
| 621 | goto out; | 636 | goto out; |
| 622 | } | ||
| 623 | |||
| 624 | of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); | ||
| 625 | of_node_put(reg_np); | ||
| 626 | 637 | ||
| 627 | common_reg: | 638 | common_reg: |
| 628 | platform_set_drvdata(pdev, s2mps11); | 639 | platform_set_drvdata(pdev, s2mps11); |
| @@ -633,7 +644,7 @@ common_reg: | |||
| 633 | for (i = 0; i < s2mps11->rdev_num; i++) { | 644 | for (i = 0; i < s2mps11->rdev_num; i++) { |
| 634 | struct regulator_dev *regulator; | 645 | struct regulator_dev *regulator; |
| 635 | 646 | ||
| 636 | if (!reg_np) { | 647 | if (pdata) { |
| 637 | config.init_data = pdata->regulators[i].initdata; | 648 | config.init_data = pdata->regulators[i].initdata; |
| 638 | config.of_node = pdata->regulators[i].reg_node; | 649 | config.of_node = pdata->regulators[i].reg_node; |
| 639 | } else { | 650 | } else { |
