diff options
author | Axel Lin <axel.lin@ingics.com> | 2019-03-19 03:39:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-03-19 07:54:29 -0400 |
commit | e66264273f5e2a6a12c558d78f829d1ea2383c5e (patch) | |
tree | ed783f3324defc74241e9fed719777b31042ac35 | |
parent | a48f127519d916b9576c213a9ca6b79e7f926d2d (diff) |
regulator: 88pm8607: Convert to regulator core's simplified DT parsing code
Use regulator core's simplified DT parsing code to simply the driver
implementation.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/88pm8607.c | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 753a6a1b30c3..35d767aeeb57 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -235,6 +235,8 @@ static const struct regulator_ops pm8606_preg_ops = { | |||
235 | { \ | 235 | { \ |
236 | .desc = { \ | 236 | .desc = { \ |
237 | .name = "PREG", \ | 237 | .name = "PREG", \ |
238 | .of_match = of_match_ptr("PREG"), \ | ||
239 | .regulators_node = of_match_ptr("regulators"), \ | ||
238 | .ops = &pm8606_preg_ops, \ | 240 | .ops = &pm8606_preg_ops, \ |
239 | .type = REGULATOR_CURRENT, \ | 241 | .type = REGULATOR_CURRENT, \ |
240 | .id = PM8606_ID_PREG, \ | 242 | .id = PM8606_ID_PREG, \ |
@@ -249,6 +251,8 @@ static const struct regulator_ops pm8606_preg_ops = { | |||
249 | { \ | 251 | { \ |
250 | .desc = { \ | 252 | .desc = { \ |
251 | .name = #vreg, \ | 253 | .name = #vreg, \ |
254 | .of_match = of_match_ptr(#vreg), \ | ||
255 | .regulators_node = of_match_ptr("regulators"), \ | ||
252 | .ops = &pm8607_regulator_ops, \ | 256 | .ops = &pm8607_regulator_ops, \ |
253 | .type = REGULATOR_VOLTAGE, \ | 257 | .type = REGULATOR_VOLTAGE, \ |
254 | .id = PM8607_ID_##vreg, \ | 258 | .id = PM8607_ID_##vreg, \ |
@@ -270,6 +274,8 @@ static const struct regulator_ops pm8606_preg_ops = { | |||
270 | { \ | 274 | { \ |
271 | .desc = { \ | 275 | .desc = { \ |
272 | .name = "LDO" #_id, \ | 276 | .name = "LDO" #_id, \ |
277 | .of_match = of_match_ptr("LDO" #_id), \ | ||
278 | .regulators_node = of_match_ptr("regulators"), \ | ||
273 | .ops = &pm8607_regulator_ops, \ | 279 | .ops = &pm8607_regulator_ops, \ |
274 | .type = REGULATOR_VOLTAGE, \ | 280 | .type = REGULATOR_VOLTAGE, \ |
275 | .id = PM8607_ID_LDO##_id, \ | 281 | .id = PM8607_ID_LDO##_id, \ |
@@ -309,36 +315,6 @@ static struct pm8607_regulator_info pm8606_regulator_info[] = { | |||
309 | PM8606_PREG(PREREGULATORB, 5), | 315 | PM8606_PREG(PREREGULATORB, 5), |
310 | }; | 316 | }; |
311 | 317 | ||
312 | #ifdef CONFIG_OF | ||
313 | static int pm8607_regulator_dt_init(struct platform_device *pdev, | ||
314 | struct pm8607_regulator_info *info, | ||
315 | struct regulator_config *config) | ||
316 | { | ||
317 | struct device_node *nproot, *np; | ||
318 | nproot = pdev->dev.parent->of_node; | ||
319 | if (!nproot) | ||
320 | return -ENODEV; | ||
321 | nproot = of_get_child_by_name(nproot, "regulators"); | ||
322 | if (!nproot) { | ||
323 | dev_err(&pdev->dev, "failed to find regulators node\n"); | ||
324 | return -ENODEV; | ||
325 | } | ||
326 | for_each_child_of_node(nproot, np) { | ||
327 | if (of_node_name_eq(np, info->desc.name)) { | ||
328 | config->init_data = | ||
329 | of_get_regulator_init_data(&pdev->dev, np, | ||
330 | &info->desc); | ||
331 | config->of_node = np; | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | of_node_put(nproot); | ||
336 | return 0; | ||
337 | } | ||
338 | #else | ||
339 | #define pm8607_regulator_dt_init(x, y, z) (-1) | ||
340 | #endif | ||
341 | |||
342 | static int pm8607_regulator_probe(struct platform_device *pdev) | 318 | static int pm8607_regulator_probe(struct platform_device *pdev) |
343 | { | 319 | { |
344 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); | 320 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); |
@@ -373,12 +349,11 @@ static int pm8607_regulator_probe(struct platform_device *pdev) | |||
373 | if ((i == PM8607_ID_BUCK3) && chip->buck3_double) | 349 | if ((i == PM8607_ID_BUCK3) && chip->buck3_double) |
374 | info->slope_double = 1; | 350 | info->slope_double = 1; |
375 | 351 | ||
376 | config.dev = &pdev->dev; | 352 | config.dev = chip->dev; |
377 | config.driver_data = info; | 353 | config.driver_data = info; |
378 | 354 | ||
379 | if (pm8607_regulator_dt_init(pdev, info, &config)) | 355 | if (pdata) |
380 | if (pdata) | 356 | config.init_data = pdata; |
381 | config.init_data = pdata; | ||
382 | 357 | ||
383 | if (chip->id == CHIP_PM8607) | 358 | if (chip->id == CHIP_PM8607) |
384 | config.regmap = chip->regmap; | 359 | config.regmap = chip->regmap; |