diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2013-03-15 09:28:51 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-18 05:18:27 -0400 |
commit | 9166902c435b4847c1987188294407b24e76d9e6 (patch) | |
tree | 192d911a7cd76689bf00efcb9d74fb5e20b5e92a /drivers/usb/phy | |
parent | b7fa5c2aec5be083eb2719b405089703608e9bc6 (diff) |
usb: phy: twl4030: use devres API for regulator get and request irq
Used devres APIs devm_request_threaded_irq and devm_regulator_get for
requesting irq and for getting regulator respectively.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy')
-rw-r--r-- | drivers/usb/phy/phy-twl4030-usb.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c index a994715a3101..e14b03e7ad70 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/usb/phy/phy-twl4030-usb.c | |||
@@ -432,7 +432,7 @@ static int twl4030_usb_ldo_init(struct twl4030_usb *twl) | |||
432 | /* Initialize 3.1V regulator */ | 432 | /* Initialize 3.1V regulator */ |
433 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); | 433 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); |
434 | 434 | ||
435 | twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); | 435 | twl->usb3v1 = devm_regulator_get(twl->dev, "usb3v1"); |
436 | if (IS_ERR(twl->usb3v1)) | 436 | if (IS_ERR(twl->usb3v1)) |
437 | return -ENODEV; | 437 | return -ENODEV; |
438 | 438 | ||
@@ -441,18 +441,18 @@ static int twl4030_usb_ldo_init(struct twl4030_usb *twl) | |||
441 | /* Initialize 1.5V regulator */ | 441 | /* Initialize 1.5V regulator */ |
442 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); | 442 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); |
443 | 443 | ||
444 | twl->usb1v5 = regulator_get(twl->dev, "usb1v5"); | 444 | twl->usb1v5 = devm_regulator_get(twl->dev, "usb1v5"); |
445 | if (IS_ERR(twl->usb1v5)) | 445 | if (IS_ERR(twl->usb1v5)) |
446 | goto fail1; | 446 | return -ENODEV; |
447 | 447 | ||
448 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); | 448 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); |
449 | 449 | ||
450 | /* Initialize 1.8V regulator */ | 450 | /* Initialize 1.8V regulator */ |
451 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP); | 451 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP); |
452 | 452 | ||
453 | twl->usb1v8 = regulator_get(twl->dev, "usb1v8"); | 453 | twl->usb1v8 = devm_regulator_get(twl->dev, "usb1v8"); |
454 | if (IS_ERR(twl->usb1v8)) | 454 | if (IS_ERR(twl->usb1v8)) |
455 | goto fail2; | 455 | return -ENODEV; |
456 | 456 | ||
457 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); | 457 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); |
458 | 458 | ||
@@ -461,14 +461,6 @@ static int twl4030_usb_ldo_init(struct twl4030_usb *twl) | |||
461 | TWL4030_PM_MASTER_PROTECT_KEY); | 461 | TWL4030_PM_MASTER_PROTECT_KEY); |
462 | 462 | ||
463 | return 0; | 463 | return 0; |
464 | |||
465 | fail2: | ||
466 | regulator_put(twl->usb1v5); | ||
467 | twl->usb1v5 = NULL; | ||
468 | fail1: | ||
469 | regulator_put(twl->usb3v1); | ||
470 | twl->usb3v1 = NULL; | ||
471 | return -ENODEV; | ||
472 | } | 464 | } |
473 | 465 | ||
474 | static ssize_t twl4030_usb_vbus_show(struct device *dev, | 466 | static ssize_t twl4030_usb_vbus_show(struct device *dev, |
@@ -640,9 +632,9 @@ static int twl4030_usb_probe(struct platform_device *pdev) | |||
640 | * need both handles, otherwise just one suffices. | 632 | * need both handles, otherwise just one suffices. |
641 | */ | 633 | */ |
642 | twl->irq_enabled = true; | 634 | twl->irq_enabled = true; |
643 | status = request_threaded_irq(twl->irq, NULL, twl4030_usb_irq, | 635 | status = devm_request_threaded_irq(twl->dev, twl->irq, NULL, |
644 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | | 636 | twl4030_usb_irq, IRQF_TRIGGER_FALLING | |
645 | IRQF_ONESHOT, "twl4030_usb", twl); | 637 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl); |
646 | if (status < 0) { | 638 | if (status < 0) { |
647 | dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", | 639 | dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", |
648 | twl->irq, status); | 640 | twl->irq, status); |
@@ -663,7 +655,6 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev) | |||
663 | struct twl4030_usb *twl = platform_get_drvdata(pdev); | 655 | struct twl4030_usb *twl = platform_get_drvdata(pdev); |
664 | int val; | 656 | int val; |
665 | 657 | ||
666 | free_irq(twl->irq, twl); | ||
667 | device_remove_file(twl->dev, &dev_attr_vbus); | 658 | device_remove_file(twl->dev, &dev_attr_vbus); |
668 | 659 | ||
669 | /* set transceiver mode to power on defaults */ | 660 | /* set transceiver mode to power on defaults */ |
@@ -685,9 +676,6 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev) | |||
685 | 676 | ||
686 | if (!twl->asleep) | 677 | if (!twl->asleep) |
687 | twl4030_phy_power(twl, 0); | 678 | twl4030_phy_power(twl, 0); |
688 | regulator_put(twl->usb1v5); | ||
689 | regulator_put(twl->usb1v8); | ||
690 | regulator_put(twl->usb3v1); | ||
691 | 679 | ||
692 | return 0; | 680 | return 0; |
693 | } | 681 | } |