diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-22 14:58:48 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-05-28 16:27:55 -0400 |
commit | 0c53be9de8f25efadee707132a596276f0a015e4 (patch) | |
tree | aa0c02356a27a1f1531bb1fe486a76f06ba0c0be | |
parent | b7e460624f0f3c31150f3b09e75b0d009e22ba5f (diff) |
mtd: bf5xx_nand: use the managed version of kzalloc
This patch moves data allocated using kzalloc to managed data allocated
using devm_kzalloc and cleans now unnecessary kfrees in probe and remove
functions. Also, the now unnecessary label out_err_hw_init is done away
with and the label out_err_kzalloc is renamed to out_err.
The following Coccinelle semantic patch was used for making the change:
@platform@
identifier p, probefn, removefn;
@@
struct platform_driver p = {
.probe = probefn,
.remove = removefn,
};
@prb@
identifier platform.probefn, pdev;
expression e, e1, e2;
@@
probefn(struct platform_device *pdev, ...) {
<+...
- e = kzalloc(e1, e2)
+ e = devm_kzalloc(&pdev->dev, e1, e2)
...
?-kfree(e);
...+>
}
@rem depends on prb@
identifier platform.removefn;
expression e;
@@
removefn(...) {
<...
- kfree(e);
...>
}
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | drivers/mtd/nand/bf5xx_nand.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c index b7a24946ca26..722898aea7a6 100644 --- a/drivers/mtd/nand/bf5xx_nand.c +++ b/drivers/mtd/nand/bf5xx_nand.c | |||
@@ -679,9 +679,6 @@ static int bf5xx_nand_remove(struct platform_device *pdev) | |||
679 | peripheral_free_list(bfin_nfc_pin_req); | 679 | peripheral_free_list(bfin_nfc_pin_req); |
680 | bf5xx_nand_dma_remove(info); | 680 | bf5xx_nand_dma_remove(info); |
681 | 681 | ||
682 | /* free the common resources */ | ||
683 | kfree(info); | ||
684 | |||
685 | return 0; | 682 | return 0; |
686 | } | 683 | } |
687 | 684 | ||
@@ -742,10 +739,10 @@ static int bf5xx_nand_probe(struct platform_device *pdev) | |||
742 | return -EFAULT; | 739 | return -EFAULT; |
743 | } | 740 | } |
744 | 741 | ||
745 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 742 | info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); |
746 | if (info == NULL) { | 743 | if (info == NULL) { |
747 | err = -ENOMEM; | 744 | err = -ENOMEM; |
748 | goto out_err_kzalloc; | 745 | goto out_err; |
749 | } | 746 | } |
750 | 747 | ||
751 | platform_set_drvdata(pdev, info); | 748 | platform_set_drvdata(pdev, info); |
@@ -790,7 +787,7 @@ static int bf5xx_nand_probe(struct platform_device *pdev) | |||
790 | /* initialise the hardware */ | 787 | /* initialise the hardware */ |
791 | err = bf5xx_nand_hw_init(info); | 788 | err = bf5xx_nand_hw_init(info); |
792 | if (err) | 789 | if (err) |
793 | goto out_err_hw_init; | 790 | goto out_err; |
794 | 791 | ||
795 | /* setup hardware ECC data struct */ | 792 | /* setup hardware ECC data struct */ |
796 | if (hardware_ecc) { | 793 | if (hardware_ecc) { |
@@ -827,9 +824,7 @@ static int bf5xx_nand_probe(struct platform_device *pdev) | |||
827 | 824 | ||
828 | out_err_nand_scan: | 825 | out_err_nand_scan: |
829 | bf5xx_nand_dma_remove(info); | 826 | bf5xx_nand_dma_remove(info); |
830 | out_err_hw_init: | 827 | out_err: |
831 | kfree(info); | ||
832 | out_err_kzalloc: | ||
833 | peripheral_free_list(bfin_nfc_pin_req); | 828 | peripheral_free_list(bfin_nfc_pin_req); |
834 | 829 | ||
835 | return err; | 830 | return err; |