diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-11-20 01:46:50 -0500 |
---|---|---|
committer | MyungJoo Ham <myungjoo.ham@samsung.com> | 2012-11-21 06:01:17 -0500 |
commit | f4bb5cb54eb97fee9b4e076df8df68b91861b934 (patch) | |
tree | 77c7ce016ce2a5673329813665165da2cb55b37b /drivers/extcon | |
parent | 0b672e9b21942fdfa63519fb66df4a40d6fafe35 (diff) |
extcon: max77693: Use devm_kzalloc
devm_kzalloc() is a device managed function. It makes error handling
and cleanup code a bit simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-max77693.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index d844be3009f6..93ca93f26f4f 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c | |||
@@ -657,11 +657,11 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
657 | int ret, i; | 657 | int ret, i; |
658 | u8 id; | 658 | u8 id; |
659 | 659 | ||
660 | info = kzalloc(sizeof(struct max77693_muic_info), GFP_KERNEL); | 660 | info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info), |
661 | GFP_KERNEL); | ||
661 | if (!info) { | 662 | if (!info) { |
662 | dev_err(&pdev->dev, "failed to allocate memory\n"); | 663 | dev_err(&pdev->dev, "failed to allocate memory\n"); |
663 | ret = -ENOMEM; | 664 | return -ENOMEM; |
664 | goto err_kfree; | ||
665 | } | 665 | } |
666 | info->dev = &pdev->dev; | 666 | info->dev = &pdev->dev; |
667 | info->max77693 = max77693; | 667 | info->max77693 = max77693; |
@@ -672,10 +672,9 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
672 | info->max77693->muic, | 672 | info->max77693->muic, |
673 | &max77693_muic_regmap_config); | 673 | &max77693_muic_regmap_config); |
674 | if (IS_ERR(info->max77693->regmap_muic)) { | 674 | if (IS_ERR(info->max77693->regmap_muic)) { |
675 | ret = PTR_ERR(info->max77693->regmap_muic); | ||
676 | dev_err(max77693->dev, | 675 | dev_err(max77693->dev, |
677 | "failed to allocate register map: %d\n", ret); | 676 | "failed to allocate register map: %d\n", ret); |
678 | goto err_regmap; | 677 | return PTR_ERR(info->max77693->regmap_muic); |
679 | } | 678 | } |
680 | } | 679 | } |
681 | platform_set_drvdata(pdev, info); | 680 | platform_set_drvdata(pdev, info); |
@@ -709,7 +708,8 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
709 | } | 708 | } |
710 | 709 | ||
711 | /* Initialize extcon device */ | 710 | /* Initialize extcon device */ |
712 | info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); | 711 | info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev), |
712 | GFP_KERNEL); | ||
713 | if (!info->edev) { | 713 | if (!info->edev) { |
714 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); | 714 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
715 | ret = -ENOMEM; | 715 | ret = -ENOMEM; |
@@ -720,7 +720,7 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
720 | ret = extcon_dev_register(info->edev, NULL); | 720 | ret = extcon_dev_register(info->edev, NULL); |
721 | if (ret) { | 721 | if (ret) { |
722 | dev_err(&pdev->dev, "failed to register extcon device\n"); | 722 | dev_err(&pdev->dev, "failed to register extcon device\n"); |
723 | goto err_extcon; | 723 | goto err_irq; |
724 | } | 724 | } |
725 | 725 | ||
726 | /* Initialize MUIC register by using platform data */ | 726 | /* Initialize MUIC register by using platform data */ |
@@ -753,7 +753,7 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
753 | MAX77693_MUIC_REG_ID, &id); | 753 | MAX77693_MUIC_REG_ID, &id); |
754 | if (ret < 0) { | 754 | if (ret < 0) { |
755 | dev_err(&pdev->dev, "failed to read revision number\n"); | 755 | dev_err(&pdev->dev, "failed to read revision number\n"); |
756 | goto err_extcon; | 756 | goto err_irq; |
757 | } | 757 | } |
758 | dev_info(info->dev, "device ID : 0x%x\n", id); | 758 | dev_info(info->dev, "device ID : 0x%x\n", id); |
759 | 759 | ||
@@ -765,14 +765,9 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
765 | 765 | ||
766 | return ret; | 766 | return ret; |
767 | 767 | ||
768 | err_extcon: | ||
769 | kfree(info->edev); | ||
770 | err_irq: | 768 | err_irq: |
771 | while (--i >= 0) | 769 | while (--i >= 0) |
772 | free_irq(muic_irqs[i].virq, info); | 770 | free_irq(muic_irqs[i].virq, info); |
773 | err_regmap: | ||
774 | kfree(info); | ||
775 | err_kfree: | ||
776 | return ret; | 771 | return ret; |
777 | } | 772 | } |
778 | 773 | ||
@@ -785,8 +780,6 @@ static int __devexit max77693_muic_remove(struct platform_device *pdev) | |||
785 | free_irq(muic_irqs[i].virq, info); | 780 | free_irq(muic_irqs[i].virq, info); |
786 | cancel_work_sync(&info->irq_work); | 781 | cancel_work_sync(&info->irq_work); |
787 | extcon_dev_unregister(info->edev); | 782 | extcon_dev_unregister(info->edev); |
788 | kfree(info->edev); | ||
789 | kfree(info); | ||
790 | 783 | ||
791 | return 0; | 784 | return 0; |
792 | } | 785 | } |