regulator: axp20x: Migrate to regulator core's simplified DT parsing code

A common simplified DT parsing code for regulators was introduced in
commit a0c7b164ad ("regulator: of: Provide simplified DT parsing
method"). This is very similar to our own code, so get rid of ours
and use the common code.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Chen-Yu Tsai 2015-01-10 00:23:44 +08:00 committed by Mark Brown
parent 880fe82dc5
commit 765e802325
1 changed files with 8 additions and 36 deletions

View File

@ -152,22 +152,6 @@ static const struct regulator_desc axp20x_regulators[] = {
AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
}; };
#define AXP_MATCH(_name, _id) \
[AXP20X_##_id] = { \
.name = #_name, \
.driver_data = (void *) &axp20x_regulators[AXP20X_##_id], \
}
static struct of_regulator_match axp20x_matches[] = {
AXP_MATCH(dcdc2, DCDC2),
AXP_MATCH(dcdc3, DCDC3),
AXP_MATCH(ldo1, LDO1),
AXP_MATCH(ldo2, LDO2),
AXP_MATCH(ldo3, LDO3),
AXP_MATCH(ldo4, LDO4),
AXP_MATCH(ldo5, LDO5),
};
static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
{ {
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
@ -202,13 +186,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
if (!regulators) { if (!regulators) {
dev_warn(&pdev->dev, "regulators node not found\n"); dev_warn(&pdev->dev, "regulators node not found\n");
} else { } else {
ret = of_regulator_match(&pdev->dev, regulators, axp20x_matches,
ARRAY_SIZE(axp20x_matches));
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
return ret;
}
dcdcfreq = 1500; dcdcfreq = 1500;
of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
@ -242,23 +219,17 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
{ {
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { }; struct regulator_config config = {
struct regulator_init_data *init_data; .dev = pdev->dev.parent,
.regmap = axp20x->regmap,
};
int ret, i; int ret, i;
u32 workmode; u32 workmode;
ret = axp20x_regulator_parse_dt(pdev); /* This only sets the dcdc freq. Ignore any errors */
if (ret) axp20x_regulator_parse_dt(pdev);
return ret;
for (i = 0; i < AXP20X_REG_ID_MAX; i++) { for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
init_data = axp20x_matches[i].init_data;
config.dev = pdev->dev.parent;
config.init_data = init_data;
config.regmap = axp20x->regmap;
config.of_node = axp20x_matches[i].of_node;
rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
&config); &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
@ -268,7 +239,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", ret = of_property_read_u32(rdev->dev.of_node,
"x-powers,dcdc-workmode",
&workmode); &workmode);
if (!ret) { if (!ret) {
if (axp20x_set_dcdc_workmode(rdev, i, workmode)) if (axp20x_set_dcdc_workmode(rdev, i, workmode))