aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/pxa3xx_nand.c
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2013-04-17 12:38:10 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-08-05 15:47:27 -0400
commit0ddd846f56a7648b9e70fb94a2b93b5b8b6ae335 (patch)
tree7d809713c6292c31707259d05496aff214e78cf4 /drivers/mtd/nand/pxa3xx_nand.c
parent4c073cd26e0835ae9c807a6188272e09d3087d85 (diff)
mtd: nand: pxa3xx: Use devm_ioremap_resource
Using the new devm_ioremap_resource() we can greatly simplify resource handling. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> 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/pxa3xx_nand.c')
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c31
1 files changed, 4 insertions, 27 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 873eba56ff60..98b3cea078ce 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1108,30 +1108,16 @@ static int alloc_nand_resource(struct platform_device *pdev)
1108 } 1108 }
1109 1109
1110 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1110 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1111 if (r == NULL) { 1111 info->mmio_base = devm_ioremap_resource(&pdev->dev, r);
1112 dev_err(&pdev->dev, "no IO memory resource defined\n"); 1112 if (IS_ERR(info->mmio_base)) {
1113 ret = -ENODEV; 1113 ret = PTR_ERR(info->mmio_base);
1114 goto fail_put_clk; 1114 goto fail_put_clk;
1115 } 1115 }
1116
1117 r = request_mem_region(r->start, resource_size(r), pdev->name);
1118 if (r == NULL) {
1119 dev_err(&pdev->dev, "failed to request memory resource\n");
1120 ret = -EBUSY;
1121 goto fail_put_clk;
1122 }
1123
1124 info->mmio_base = ioremap(r->start, resource_size(r));
1125 if (info->mmio_base == NULL) {
1126 dev_err(&pdev->dev, "ioremap() failed\n");
1127 ret = -ENODEV;
1128 goto fail_free_res;
1129 }
1130 info->mmio_phys = r->start; 1116 info->mmio_phys = r->start;
1131 1117
1132 ret = pxa3xx_nand_init_buff(info); 1118 ret = pxa3xx_nand_init_buff(info);
1133 if (ret) 1119 if (ret)
1134 goto fail_free_io; 1120 goto fail_put_clk;
1135 1121
1136 /* initialize all interrupts to be disabled */ 1122 /* initialize all interrupts to be disabled */
1137 disable_int(info, NDSR_MASK); 1123 disable_int(info, NDSR_MASK);
@@ -1155,10 +1141,6 @@ fail_free_buf:
1155 info->data_buff, info->data_buff_phys); 1141 info->data_buff, info->data_buff_phys);
1156 } else 1142 } else
1157 kfree(info->data_buff); 1143 kfree(info->data_buff);
1158fail_free_io:
1159 iounmap(info->mmio_base);
1160fail_free_res:
1161 release_mem_region(r->start, resource_size(r));
1162fail_put_clk: 1144fail_put_clk:
1163 clk_disable(info->clk); 1145 clk_disable(info->clk);
1164 clk_put(info->clk); 1146 clk_put(info->clk);
@@ -1169,7 +1151,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
1169{ 1151{
1170 struct pxa3xx_nand_info *info = platform_get_drvdata(pdev); 1152 struct pxa3xx_nand_info *info = platform_get_drvdata(pdev);
1171 struct pxa3xx_nand_platform_data *pdata; 1153 struct pxa3xx_nand_platform_data *pdata;
1172 struct resource *r;
1173 int irq, cs; 1154 int irq, cs;
1174 1155
1175 if (!info) 1156 if (!info)
@@ -1188,10 +1169,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
1188 } else 1169 } else
1189 kfree(info->data_buff); 1170 kfree(info->data_buff);
1190 1171
1191 iounmap(info->mmio_base);
1192 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1193 release_mem_region(r->start, resource_size(r));
1194
1195 clk_disable(info->clk); 1172 clk_disable(info->clk);
1196 clk_put(info->clk); 1173 clk_put(info->clk);
1197 1174