diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-08-21 04:54:09 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-09-29 10:07:21 -0400 |
commit | 6f32a3e2853da194bd541fa107645d71c4eaaef9 (patch) | |
tree | 89adaf224c566a6c36895972b628afb2f8984406 /drivers/mtd/nand/s3c2410.c | |
parent | c83d29f008fbf093b192985b424e19cb16d4b75c (diff) |
mtd: s3c2410: Use devm_* functions
devm_* functions are device managed functions and make cleanup code
simpler and smaller.
devm_kzalloc, devm_clk_get and devm_request_and_ioremap functions
are used.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/s3c2410.c')
-rw-r--r-- | drivers/mtd/nand/s3c2410.c | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 8ae9399fb4c8..90a630a6f0b9 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -97,9 +97,8 @@ enum s3c_nand_clk_state { | |||
97 | * @mtds: An array of MTD instances on this controoler. | 97 | * @mtds: An array of MTD instances on this controoler. |
98 | * @platform: The platform data for this board. | 98 | * @platform: The platform data for this board. |
99 | * @device: The platform device we bound to. | 99 | * @device: The platform device we bound to. |
100 | * @area: The IO area resource that came from request_mem_region(). | ||
101 | * @clk: The clock resource for this controller. | 100 | * @clk: The clock resource for this controller. |
102 | * @regs: The area mapped for the hardware registers described by @area. | 101 | * @regs: The area mapped for the hardware registers. |
103 | * @sel_reg: Pointer to the register controlling the NAND selection. | 102 | * @sel_reg: Pointer to the register controlling the NAND selection. |
104 | * @sel_bit: The bit in @sel_reg to select the NAND chip. | 103 | * @sel_bit: The bit in @sel_reg to select the NAND chip. |
105 | * @mtd_count: The number of MTDs created from this controller. | 104 | * @mtd_count: The number of MTDs created from this controller. |
@@ -116,7 +115,6 @@ struct s3c2410_nand_info { | |||
116 | 115 | ||
117 | /* device info */ | 116 | /* device info */ |
118 | struct device *device; | 117 | struct device *device; |
119 | struct resource *area; | ||
120 | struct clk *clk; | 118 | struct clk *clk; |
121 | void __iomem *regs; | 119 | void __iomem *regs; |
122 | void __iomem *sel_reg; | 120 | void __iomem *sel_reg; |
@@ -716,29 +714,12 @@ static int s3c24xx_nand_remove(struct platform_device *pdev) | |||
716 | pr_debug("releasing mtd %d (%p)\n", mtdno, ptr); | 714 | pr_debug("releasing mtd %d (%p)\n", mtdno, ptr); |
717 | nand_release(&ptr->mtd); | 715 | nand_release(&ptr->mtd); |
718 | } | 716 | } |
719 | |||
720 | kfree(info->mtds); | ||
721 | } | 717 | } |
722 | 718 | ||
723 | /* free the common resources */ | 719 | /* free the common resources */ |
724 | 720 | ||
725 | if (!IS_ERR(info->clk)) { | 721 | if (!IS_ERR(info->clk)) |
726 | s3c2410_nand_clk_set_state(info, CLOCK_DISABLE); | 722 | s3c2410_nand_clk_set_state(info, CLOCK_DISABLE); |
727 | clk_put(info->clk); | ||
728 | } | ||
729 | |||
730 | if (info->regs != NULL) { | ||
731 | iounmap(info->regs); | ||
732 | info->regs = NULL; | ||
733 | } | ||
734 | |||
735 | if (info->area != NULL) { | ||
736 | release_resource(info->area); | ||
737 | kfree(info->area); | ||
738 | info->area = NULL; | ||
739 | } | ||
740 | |||
741 | kfree(info); | ||
742 | 723 | ||
743 | return 0; | 724 | return 0; |
744 | } | 725 | } |
@@ -933,7 +914,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) | |||
933 | 914 | ||
934 | pr_debug("s3c2410_nand_probe(%p)\n", pdev); | 915 | pr_debug("s3c2410_nand_probe(%p)\n", pdev); |
935 | 916 | ||
936 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 917 | info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); |
937 | if (info == NULL) { | 918 | if (info == NULL) { |
938 | dev_err(&pdev->dev, "no memory for flash info\n"); | 919 | dev_err(&pdev->dev, "no memory for flash info\n"); |
939 | err = -ENOMEM; | 920 | err = -ENOMEM; |
@@ -947,7 +928,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) | |||
947 | 928 | ||
948 | /* get the clock source and enable it */ | 929 | /* get the clock source and enable it */ |
949 | 930 | ||
950 | info->clk = clk_get(&pdev->dev, "nand"); | 931 | info->clk = devm_clk_get(&pdev->dev, "nand"); |
951 | if (IS_ERR(info->clk)) { | 932 | if (IS_ERR(info->clk)) { |
952 | dev_err(&pdev->dev, "failed to get clock\n"); | 933 | dev_err(&pdev->dev, "failed to get clock\n"); |
953 | err = -ENOENT; | 934 | err = -ENOENT; |
@@ -959,22 +940,14 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) | |||
959 | /* allocate and map the resource */ | 940 | /* allocate and map the resource */ |
960 | 941 | ||
961 | /* currently we assume we have the one resource */ | 942 | /* currently we assume we have the one resource */ |
962 | res = pdev->resource; | 943 | res = pdev->resource; |
963 | size = resource_size(res); | 944 | size = resource_size(res); |
964 | 945 | ||
965 | info->area = request_mem_region(res->start, size, pdev->name); | 946 | info->device = &pdev->dev; |
966 | 947 | info->platform = plat; | |
967 | if (info->area == NULL) { | 948 | info->cpu_type = cpu_type; |
968 | dev_err(&pdev->dev, "cannot reserve register region\n"); | ||
969 | err = -ENOENT; | ||
970 | goto exit_error; | ||
971 | } | ||
972 | |||
973 | info->device = &pdev->dev; | ||
974 | info->platform = plat; | ||
975 | info->regs = ioremap(res->start, size); | ||
976 | info->cpu_type = cpu_type; | ||
977 | 949 | ||
950 | info->regs = devm_request_and_ioremap(&pdev->dev, res); | ||
978 | if (info->regs == NULL) { | 951 | if (info->regs == NULL) { |
979 | dev_err(&pdev->dev, "cannot reserve register region\n"); | 952 | dev_err(&pdev->dev, "cannot reserve register region\n"); |
980 | err = -EIO; | 953 | err = -EIO; |
@@ -997,7 +970,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) | |||
997 | /* allocate our information */ | 970 | /* allocate our information */ |
998 | 971 | ||
999 | size = nr_sets * sizeof(*info->mtds); | 972 | size = nr_sets * sizeof(*info->mtds); |
1000 | info->mtds = kzalloc(size, GFP_KERNEL); | 973 | info->mtds = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); |
1001 | if (info->mtds == NULL) { | 974 | if (info->mtds == NULL) { |
1002 | dev_err(&pdev->dev, "failed to allocate mtd storage\n"); | 975 | dev_err(&pdev->dev, "failed to allocate mtd storage\n"); |
1003 | err = -ENOMEM; | 976 | err = -ENOMEM; |