Commit e9903060 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by David Woodhouse

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 4442241e
...@@ -74,6 +74,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -74,6 +74,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
struct mtd_info *mtd; struct mtd_info *mtd;
struct nand_chip *nc; struct nand_chip *nc;
struct orion_nand_data *board; struct orion_nand_data *board;
struct resource *res;
void __iomem *io_base; void __iomem *io_base;
int ret = 0; int ret = 0;
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
...@@ -89,8 +90,13 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -89,8 +90,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
} }
mtd = (struct mtd_info *)(nc + 1); mtd = (struct mtd_info *)(nc + 1);
io_base = ioremap(pdev->resource[0].start, res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
pdev->resource[0].end - pdev->resource[0].start + 1); if (!res) {
err = -ENODEV;
goto no_res;
}
io_base = ioremap(res->start, resource_size(res));
if (!io_base) { if (!io_base) {
printk(KERN_ERR "orion_nand: ioremap failed\n"); printk(KERN_ERR "orion_nand: ioremap failed\n");
ret = -EIO; ret = -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment