diff options
author | Chen-Yu Tsai <wens@csie.org> | 2015-01-09 11:23:44 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-09 12:12:58 -0500 |
commit | 765e8023251d3366b959f2e77e5ed48c597d57a0 (patch) | |
tree | dc5c8bdb445d69f91f59fe5768b18a098a2ef606 /drivers/regulator/axp20x-regulator.c | |
parent | 880fe82dc555c514b5b4b14642f397afddd82860 (diff) |
regulator: axp20x: Migrate to regulator core's simplified DT parsing code
A common simplified DT parsing code for regulators was introduced in
commit a0c7b164ad11 ("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>
Diffstat (limited to 'drivers/regulator/axp20x-regulator.c')
-rw-r--r-- | drivers/regulator/axp20x-regulator.c | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index 441ae01123dd..e4331f5e5d7d 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c | |||
@@ -152,22 +152,6 @@ static const struct regulator_desc axp20x_regulators[] = { | |||
152 | AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), | 152 | AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), |
153 | }; | 153 | }; |
154 | 154 | ||
155 | #define AXP_MATCH(_name, _id) \ | ||
156 | [AXP20X_##_id] = { \ | ||
157 | .name = #_name, \ | ||
158 | .driver_data = (void *) &axp20x_regulators[AXP20X_##_id], \ | ||
159 | } | ||
160 | |||
161 | static struct of_regulator_match axp20x_matches[] = { | ||
162 | AXP_MATCH(dcdc2, DCDC2), | ||
163 | AXP_MATCH(dcdc3, DCDC3), | ||
164 | AXP_MATCH(ldo1, LDO1), | ||
165 | AXP_MATCH(ldo2, LDO2), | ||
166 | AXP_MATCH(ldo3, LDO3), | ||
167 | AXP_MATCH(ldo4, LDO4), | ||
168 | AXP_MATCH(ldo5, LDO5), | ||
169 | }; | ||
170 | |||
171 | static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) | 155 | static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) |
172 | { | 156 | { |
173 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); | 157 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); |
@@ -202,13 +186,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev) | |||
202 | if (!regulators) { | 186 | if (!regulators) { |
203 | dev_warn(&pdev->dev, "regulators node not found\n"); | 187 | dev_warn(&pdev->dev, "regulators node not found\n"); |
204 | } else { | 188 | } else { |
205 | ret = of_regulator_match(&pdev->dev, regulators, axp20x_matches, | ||
206 | ARRAY_SIZE(axp20x_matches)); | ||
207 | if (ret < 0) { | ||
208 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret); | ||
209 | return ret; | ||
210 | } | ||
211 | |||
212 | dcdcfreq = 1500; | 189 | dcdcfreq = 1500; |
213 | of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); | 190 | of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); |
214 | ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); | 191 | ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); |
@@ -242,23 +219,17 @@ static int axp20x_regulator_probe(struct platform_device *pdev) | |||
242 | { | 219 | { |
243 | struct regulator_dev *rdev; | 220 | struct regulator_dev *rdev; |
244 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); | 221 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); |
245 | struct regulator_config config = { }; | 222 | struct regulator_config config = { |
246 | struct regulator_init_data *init_data; | 223 | .dev = pdev->dev.parent, |
224 | .regmap = axp20x->regmap, | ||
225 | }; | ||
247 | int ret, i; | 226 | int ret, i; |
248 | u32 workmode; | 227 | u32 workmode; |
249 | 228 | ||
250 | ret = axp20x_regulator_parse_dt(pdev); | 229 | /* This only sets the dcdc freq. Ignore any errors */ |
251 | if (ret) | 230 | axp20x_regulator_parse_dt(pdev); |
252 | return ret; | ||
253 | 231 | ||
254 | for (i = 0; i < AXP20X_REG_ID_MAX; i++) { | 232 | for (i = 0; i < AXP20X_REG_ID_MAX; i++) { |
255 | init_data = axp20x_matches[i].init_data; | ||
256 | |||
257 | config.dev = pdev->dev.parent; | ||
258 | config.init_data = init_data; | ||
259 | config.regmap = axp20x->regmap; | ||
260 | config.of_node = axp20x_matches[i].of_node; | ||
261 | |||
262 | rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], | 233 | rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], |
263 | &config); | 234 | &config); |
264 | if (IS_ERR(rdev)) { | 235 | if (IS_ERR(rdev)) { |
@@ -268,7 +239,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev) | |||
268 | return PTR_ERR(rdev); | 239 | return PTR_ERR(rdev); |
269 | } | 240 | } |
270 | 241 | ||
271 | ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", | 242 | ret = of_property_read_u32(rdev->dev.of_node, |
243 | "x-powers,dcdc-workmode", | ||
272 | &workmode); | 244 | &workmode); |
273 | if (!ret) { | 245 | if (!ret) { |
274 | if (axp20x_set_dcdc_workmode(rdev, i, workmode)) | 246 | if (axp20x_set_dcdc_workmode(rdev, i, workmode)) |