diff options
| author | Beniamino Galvani <b.galvani@gmail.com> | 2014-10-08 17:19:08 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2014-10-20 07:23:59 -0400 |
| commit | 9075cceaac1c8d8a4cf43bebfd342bd61442967e (patch) | |
| tree | 8dfacc9fc8d947a2acf108183e9467eb4f84efd8 | |
| parent | f114040e3ea6e07372334ade75d1ee0775c355e1 (diff) | |
regulator: rn5t618: Convert to new style DT parsing
Use the simplified DT parsing method to remove some duplicated
code.
Since this is a MFD subdevice and its device object doesn't have an
associated DT node, the configuration instance used to register the
regulators has been changed to point to the parent device.
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | drivers/regulator/rn5t618-regulator.c | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/drivers/regulator/rn5t618-regulator.c b/drivers/regulator/rn5t618-regulator.c index e58d79aeb393..b85ceb8ff911 100644 --- a/drivers/regulator/rn5t618-regulator.c +++ b/drivers/regulator/rn5t618-regulator.c | |||
| @@ -31,6 +31,8 @@ static struct regulator_ops rn5t618_reg_ops = { | |||
| 31 | #define REG(rid, ereg, emask, vreg, vmask, min, max, step) \ | 31 | #define REG(rid, ereg, emask, vreg, vmask, min, max, step) \ |
| 32 | [RN5T618_##rid] = { \ | 32 | [RN5T618_##rid] = { \ |
| 33 | .name = #rid, \ | 33 | .name = #rid, \ |
| 34 | .of_match = of_match_ptr(#rid), \ | ||
| 35 | .regulators_node = of_match_ptr("regulators"), \ | ||
| 34 | .id = RN5T618_##rid, \ | 36 | .id = RN5T618_##rid, \ |
| 35 | .type = REGULATOR_VOLTAGE, \ | 37 | .type = REGULATOR_VOLTAGE, \ |
| 36 | .owner = THIS_MODULE, \ | 38 | .owner = THIS_MODULE, \ |
| @@ -60,60 +62,15 @@ static struct regulator_desc rn5t618_regulators[] = { | |||
| 60 | REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), | 62 | REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), |
| 61 | }; | 63 | }; |
| 62 | 64 | ||
| 63 | static struct of_regulator_match rn5t618_matches[] = { | ||
| 64 | [RN5T618_DCDC1] = { .name = "DCDC1" }, | ||
| 65 | [RN5T618_DCDC2] = { .name = "DCDC2" }, | ||
| 66 | [RN5T618_DCDC3] = { .name = "DCDC3" }, | ||
| 67 | [RN5T618_LDO1] = { .name = "LDO1" }, | ||
| 68 | [RN5T618_LDO2] = { .name = "LDO2" }, | ||
| 69 | [RN5T618_LDO3] = { .name = "LDO3" }, | ||
| 70 | [RN5T618_LDO4] = { .name = "LDO4" }, | ||
| 71 | [RN5T618_LDO5] = { .name = "LDO5" }, | ||
| 72 | [RN5T618_LDORTC1] = { .name = "LDORTC1" }, | ||
| 73 | [RN5T618_LDORTC2] = { .name = "LDORTC2" }, | ||
| 74 | }; | ||
| 75 | |||
| 76 | static int rn5t618_regulator_parse_dt(struct platform_device *pdev) | ||
| 77 | { | ||
| 78 | struct device_node *np, *regulators; | ||
| 79 | int ret; | ||
| 80 | |||
| 81 | np = of_node_get(pdev->dev.parent->of_node); | ||
| 82 | if (!np) | ||
| 83 | return 0; | ||
| 84 | |||
| 85 | regulators = of_get_child_by_name(np, "regulators"); | ||
| 86 | if (!regulators) { | ||
| 87 | dev_err(&pdev->dev, "regulators node not found\n"); | ||
| 88 | return -EINVAL; | ||
| 89 | } | ||
| 90 | |||
| 91 | ret = of_regulator_match(&pdev->dev, regulators, rn5t618_matches, | ||
| 92 | ARRAY_SIZE(rn5t618_matches)); | ||
| 93 | of_node_put(regulators); | ||
| 94 | if (ret < 0) { | ||
| 95 | dev_err(&pdev->dev, "error parsing regulator init data: %d\n", | ||
| 96 | ret); | ||
| 97 | } | ||
| 98 | |||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | static int rn5t618_regulator_probe(struct platform_device *pdev) | 65 | static int rn5t618_regulator_probe(struct platform_device *pdev) |
| 103 | { | 66 | { |
| 104 | struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); | 67 | struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); |
| 105 | struct regulator_config config = { }; | 68 | struct regulator_config config = { }; |
| 106 | struct regulator_dev *rdev; | 69 | struct regulator_dev *rdev; |
| 107 | int ret, i; | 70 | int i; |
| 108 | |||
| 109 | ret = rn5t618_regulator_parse_dt(pdev); | ||
| 110 | if (ret) | ||
| 111 | return ret; | ||
| 112 | 71 | ||
| 113 | for (i = 0; i < RN5T618_REG_NUM; i++) { | 72 | for (i = 0; i < RN5T618_REG_NUM; i++) { |
| 114 | config.dev = &pdev->dev; | 73 | config.dev = pdev->dev.parent; |
| 115 | config.init_data = rn5t618_matches[i].init_data; | ||
| 116 | config.of_node = rn5t618_matches[i].of_node; | ||
| 117 | config.regmap = rn5t618->regmap; | 74 | config.regmap = rn5t618->regmap; |
| 118 | 75 | ||
| 119 | rdev = devm_regulator_register(&pdev->dev, | 76 | rdev = devm_regulator_register(&pdev->dev, |
