aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/wm831x-ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/wm831x-ldo.c')
-rw-r--r--drivers/regulator/wm831x-ldo.c75
1 files changed, 19 insertions, 56 deletions
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 1432b26ef2e9..46d6700467b5 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -63,10 +63,8 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data)
63 */ 63 */
64 64
65static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { 65static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = {
66 { .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 14, 66 REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000),
67 .uV_step = 50000 }, 67 REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000),
68 { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
69 .uV_step = 100000 },
70}; 68};
71 69
72static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, 70static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
@@ -279,7 +277,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
279 config.driver_data = ldo; 277 config.driver_data = ldo;
280 config.regmap = wm831x->regmap; 278 config.regmap = wm831x->regmap;
281 279
282 ldo->regulator = regulator_register(&ldo->desc, &config); 280 ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc,
281 &config);
283 if (IS_ERR(ldo->regulator)) { 282 if (IS_ERR(ldo->regulator)) {
284 ret = PTR_ERR(ldo->regulator); 283 ret = PTR_ERR(ldo->regulator);
285 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", 284 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n",
@@ -288,39 +287,26 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
288 } 287 }
289 288
290 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 289 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
291 ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, 290 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
292 IRQF_TRIGGER_RISING, ldo->name, 291 wm831x_ldo_uv_irq,
293 ldo); 292 IRQF_TRIGGER_RISING, ldo->name,
293 ldo);
294 if (ret != 0) { 294 if (ret != 0) {
295 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 295 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
296 irq, ret); 296 irq, ret);
297 goto err_regulator; 297 goto err;
298 } 298 }
299 299
300 platform_set_drvdata(pdev, ldo); 300 platform_set_drvdata(pdev, ldo);
301 301
302 return 0; 302 return 0;
303 303
304err_regulator:
305 regulator_unregister(ldo->regulator);
306err: 304err:
307 return ret; 305 return ret;
308} 306}
309 307
310static int wm831x_gp_ldo_remove(struct platform_device *pdev)
311{
312 struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
313
314 free_irq(wm831x_irq(ldo->wm831x,
315 platform_get_irq_byname(pdev, "UV")), ldo);
316 regulator_unregister(ldo->regulator);
317
318 return 0;
319}
320
321static struct platform_driver wm831x_gp_ldo_driver = { 308static struct platform_driver wm831x_gp_ldo_driver = {
322 .probe = wm831x_gp_ldo_probe, 309 .probe = wm831x_gp_ldo_probe,
323 .remove = wm831x_gp_ldo_remove,
324 .driver = { 310 .driver = {
325 .name = "wm831x-ldo", 311 .name = "wm831x-ldo",
326 .owner = THIS_MODULE, 312 .owner = THIS_MODULE,
@@ -332,10 +318,8 @@ static struct platform_driver wm831x_gp_ldo_driver = {
332 */ 318 */
333 319
334static const struct regulator_linear_range wm831x_aldo_ranges[] = { 320static const struct regulator_linear_range wm831x_aldo_ranges[] = {
335 { .min_uV = 1000000, .max_uV = 1650000, .min_sel = 0, .max_sel = 12, 321 REGULATOR_LINEAR_RANGE(1000000, 0, 12, 50000),
336 .uV_step = 50000 }, 322 REGULATOR_LINEAR_RANGE(1700000, 13, 31, 100000),
337 { .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31,
338 .uV_step = 100000 },
339}; 323};
340 324
341static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, 325static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
@@ -505,7 +489,8 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
505 config.driver_data = ldo; 489 config.driver_data = ldo;
506 config.regmap = wm831x->regmap; 490 config.regmap = wm831x->regmap;
507 491
508 ldo->regulator = regulator_register(&ldo->desc, &config); 492 ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc,
493 &config);
509 if (IS_ERR(ldo->regulator)) { 494 if (IS_ERR(ldo->regulator)) {
510 ret = PTR_ERR(ldo->regulator); 495 ret = PTR_ERR(ldo->regulator);
511 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", 496 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n",
@@ -514,38 +499,25 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
514 } 499 }
515 500
516 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 501 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
517 ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, 502 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
518 IRQF_TRIGGER_RISING, ldo->name, ldo); 503 wm831x_ldo_uv_irq,
504 IRQF_TRIGGER_RISING, ldo->name, ldo);
519 if (ret != 0) { 505 if (ret != 0) {
520 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 506 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
521 irq, ret); 507 irq, ret);
522 goto err_regulator; 508 goto err;
523 } 509 }
524 510
525 platform_set_drvdata(pdev, ldo); 511 platform_set_drvdata(pdev, ldo);
526 512
527 return 0; 513 return 0;
528 514
529err_regulator:
530 regulator_unregister(ldo->regulator);
531err: 515err:
532 return ret; 516 return ret;
533} 517}
534 518
535static int wm831x_aldo_remove(struct platform_device *pdev)
536{
537 struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
538
539 free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")),
540 ldo);
541 regulator_unregister(ldo->regulator);
542
543 return 0;
544}
545
546static struct platform_driver wm831x_aldo_driver = { 519static struct platform_driver wm831x_aldo_driver = {
547 .probe = wm831x_aldo_probe, 520 .probe = wm831x_aldo_probe,
548 .remove = wm831x_aldo_remove,
549 .driver = { 521 .driver = {
550 .name = "wm831x-aldo", 522 .name = "wm831x-aldo",
551 .owner = THIS_MODULE, 523 .owner = THIS_MODULE,
@@ -663,7 +635,8 @@ static int wm831x_alive_ldo_probe(struct platform_device *pdev)
663 config.driver_data = ldo; 635 config.driver_data = ldo;
664 config.regmap = wm831x->regmap; 636 config.regmap = wm831x->regmap;
665 637
666 ldo->regulator = regulator_register(&ldo->desc, &config); 638 ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc,
639 &config);
667 if (IS_ERR(ldo->regulator)) { 640 if (IS_ERR(ldo->regulator)) {
668 ret = PTR_ERR(ldo->regulator); 641 ret = PTR_ERR(ldo->regulator);
669 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", 642 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n",
@@ -679,18 +652,8 @@ err:
679 return ret; 652 return ret;
680} 653}
681 654
682static int wm831x_alive_ldo_remove(struct platform_device *pdev)
683{
684 struct wm831x_ldo *ldo = platform_get_drvdata(pdev);
685
686 regulator_unregister(ldo->regulator);
687
688 return 0;
689}
690
691static struct platform_driver wm831x_alive_ldo_driver = { 655static struct platform_driver wm831x_alive_ldo_driver = {
692 .probe = wm831x_alive_ldo_probe, 656 .probe = wm831x_alive_ldo_probe,
693 .remove = wm831x_alive_ldo_remove,
694 .driver = { 657 .driver = {
695 .name = "wm831x-alive-ldo", 658 .name = "wm831x-alive-ldo",
696 .owner = THIS_MODULE, 659 .owner = THIS_MODULE,