Commit 9075ccea authored by Beniamino Galvani's avatar Beniamino Galvani Committed by Mark Brown

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: default avatarBeniamino Galvani <b.galvani@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f114040e
......@@ -31,6 +31,8 @@ static struct regulator_ops rn5t618_reg_ops = {
#define REG(rid, ereg, emask, vreg, vmask, min, max, step) \
[RN5T618_##rid] = { \
.name = #rid, \
.of_match = of_match_ptr(#rid), \
.regulators_node = of_match_ptr("regulators"), \
.id = RN5T618_##rid, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
......@@ -60,60 +62,15 @@ static struct regulator_desc rn5t618_regulators[] = {
REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
};
static struct of_regulator_match rn5t618_matches[] = {
[RN5T618_DCDC1] = { .name = "DCDC1" },
[RN5T618_DCDC2] = { .name = "DCDC2" },
[RN5T618_DCDC3] = { .name = "DCDC3" },
[RN5T618_LDO1] = { .name = "LDO1" },
[RN5T618_LDO2] = { .name = "LDO2" },
[RN5T618_LDO3] = { .name = "LDO3" },
[RN5T618_LDO4] = { .name = "LDO4" },
[RN5T618_LDO5] = { .name = "LDO5" },
[RN5T618_LDORTC1] = { .name = "LDORTC1" },
[RN5T618_LDORTC2] = { .name = "LDORTC2" },
};
static int rn5t618_regulator_parse_dt(struct platform_device *pdev)
{
struct device_node *np, *regulators;
int ret;
np = of_node_get(pdev->dev.parent->of_node);
if (!np)
return 0;
regulators = of_get_child_by_name(np, "regulators");
if (!regulators) {
dev_err(&pdev->dev, "regulators node not found\n");
return -EINVAL;
}
ret = of_regulator_match(&pdev->dev, regulators, rn5t618_matches,
ARRAY_SIZE(rn5t618_matches));
of_node_put(regulators);
if (ret < 0) {
dev_err(&pdev->dev, "error parsing regulator init data: %d\n",
ret);
}
return 0;
}
static int rn5t618_regulator_probe(struct platform_device *pdev)
{
struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { };
struct regulator_dev *rdev;
int ret, i;
ret = rn5t618_regulator_parse_dt(pdev);
if (ret)
return ret;
int i;
for (i = 0; i < RN5T618_REG_NUM; i++) {
config.dev = &pdev->dev;
config.init_data = rn5t618_matches[i].init_data;
config.of_node = rn5t618_matches[i].of_node;
config.dev = pdev->dev.parent;
config.regmap = rn5t618->regmap;
rdev = devm_regulator_register(&pdev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment