mtd: gpmi: use devm_ioremap_resource
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Tue Jan 28 00:59:03 EST 2014
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=87a9d69892836fc9cf738fa8960a0c29cf8e3f16
Commit: 87a9d69892836fc9cf738fa8960a0c29cf8e3f16
Parent: ccce417734dd4eb1703483d419f7739133ca9f91
Author: Huang Shijie <b32955 at freescale.com>
AuthorDate: Thu Nov 14 14:25:48 2013 +0800
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Fri Jan 3 11:22:19 2014 -0800
mtd: gpmi: use devm_ioremap_resource
Use the devm_ioremap_resource to simplify the code.
[Note: as a side effect, this adds a missing call to request_memory().]
Signed-off-by: Huang Shijie <b32955 at freescale.com>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 36ef60a..1f99038 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -486,16 +486,9 @@ static int acquire_register_block(struct gpmi_nand_data *this,
void __iomem *p;
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name);
- if (!r) {
- pr_err("Can't get resource for %s\n", res_name);
- return -ENODEV;
- }
-
- p = ioremap(r->start, resource_size(r));
- if (!p) {
- pr_err("Can't remap %s\n", res_name);
- return -ENOMEM;
- }
+ p = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
if (!strcmp(res_name, GPMI_NAND_GPMI_REGS_ADDR_RES_NAME))
res->gpmi_regs = p;
@@ -507,17 +500,6 @@ static int acquire_register_block(struct gpmi_nand_data *this,
return 0;
}
-static void release_register_block(struct gpmi_nand_data *this)
-{
- struct resources *res = &this->resources;
- if (res->gpmi_regs)
- iounmap(res->gpmi_regs);
- if (res->bch_regs)
- iounmap(res->bch_regs);
- res->gpmi_regs = NULL;
- res->bch_regs = NULL;
-}
-
static int acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h)
{
struct platform_device *pdev = this->pdev;
@@ -665,13 +647,11 @@ exit_clock:
exit_dma_channels:
release_bch_irq(this);
exit_regs:
- release_register_block(this);
return ret;
}
static void release_resources(struct gpmi_nand_data *this)
{
- release_register_block(this);
release_bch_irq(this);
release_dma_channels(this);
}
More information about the linux-mtd-cvs
mailing list