mtd: orion_nand.c: add error handling and use resource_size()
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Thu Dec 31 15:59:02 EST 2009
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=e99030609e27abff7e1a868cb56384c678b09984
Commit: e99030609e27abff7e1a868cb56384c678b09984
Parent: 4442241ef6ed4d53c13d1c4b18fd57918bb4c850
Author: H Hartley Sweeten <hartleys at visionengravers.com>
AuthorDate: Mon Dec 14 16:48:34 2009 -0500
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Thu Dec 31 20:47:20 2009 +0000
mtd: orion_nand.c: add error handling and use resource_size()
Use platform_get_resource() to fetch the memory resource and
add error handling for when it is missing. Use resource_size()
for the ioremap().
Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/nand/orion_nand.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index f59c074..9903460 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -74,6 +74,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
struct mtd_info *mtd;
struct nand_chip *nc;
struct orion_nand_data *board;
+ struct resource *res;
void __iomem *io_base;
int ret = 0;
#ifdef CONFIG_MTD_PARTITIONS
@@ -89,8 +90,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
}
mtd = (struct mtd_info *)(nc + 1);
- io_base = ioremap(pdev->resource[0].start,
- pdev->resource[0].end - pdev->resource[0].start + 1);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ err = -ENODEV;
+ goto no_res;
+ }
+
+ io_base = ioremap(res->start, resource_size(res));
if (!io_base) {
printk(KERN_ERR "orion_nand: ioremap failed\n");
ret = -EIO;
More information about the linux-mtd-cvs
mailing list