]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mtd: Convert to devm_ioremap_resource()
authorThierry Reding <thierry.reding@avionic-design.de>
Mon, 21 Jan 2013 10:09:12 +0000 (11:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Jan 2013 20:21:47 +0000 (12:21 -0800)
Convert all uses of devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit
error messages can be removed from the failure code paths.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/devices/spear_smi.c
drivers/mtd/maps/autcpu12-nvram.c
drivers/mtd/maps/lantiq-flash.c
drivers/mtd/nand/fsmc_nand.c
drivers/mtd/nand/lpc32xx_mlc.c
drivers/mtd/nand/lpc32xx_slc.c
drivers/mtd/nand/mxc_nand.c
drivers/mtd/nand/s3c2410.c
drivers/mtd/nand/txx9ndfmc.c

index 2aabd96bf0fff57381efb499a83d88d4c17e476d..8a82b8bc21e185d7f62ca331d93f532470bb4399 100644 (file)
@@ -949,10 +949,9 @@ static int spear_smi_probe(struct platform_device *pdev)
 
        smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-       dev->io_base = devm_request_and_ioremap(&pdev->dev, smi_base);
-       if (!dev->io_base) {
-               ret = -EIO;
-               dev_err(&pdev->dev, "devm_request_and_ioremap fail\n");
+       dev->io_base = devm_ioremap_resource(&pdev->dev, smi_base);
+       if (IS_ERR(dev->io_base)) {
+               ret = PTR_ERR(dev->io_base);
                goto err;
        }
 
index a2dc2ae4b24e69cc234a8946b9f1033a1e8fd7aa..c3525d2a2fa889f3cf17ee9b83efbde7e9029a06 100644 (file)
@@ -16,6 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <linux/err.h>
 #include <linux/sizes.h>
 
 #include <linux/types.h>
@@ -55,12 +56,10 @@ static int autcpu12_nvram_probe(struct platform_device *pdev)
        priv->map.bankwidth     = 4;
        priv->map.phys          = res->start;
        priv->map.size          = resource_size(res);
-       priv->map.virt          = devm_request_and_ioremap(&pdev->dev, res);
+       priv->map.virt = devm_ioremap_resource(&pdev->dev, res);
        strcpy((char *)priv->map.name, res->name);
-       if (!priv->map.virt) {
-               dev_err(&pdev->dev, "failed to remap mem resource\n");
-               return -EBUSY;
-       }
+       if (IS_ERR(priv->map.virt))
+               return PTR_ERR(priv->map.virt);
 
        simple_map_init(&priv->map);
 
index 3c3c791eb96a0e0c7876eb15524fbbe95c47fc07..d1da6ede3845bfdac001dffb036422d1107bdcd9 100644 (file)
@@ -7,6 +7,7 @@
  *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -136,10 +137,9 @@ ltq_mtd_probe(struct platform_device *pdev)
        ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
        ltq_mtd->map->phys = ltq_mtd->res->start;
        ltq_mtd->map->size = resource_size(ltq_mtd->res);
-       ltq_mtd->map->virt = devm_request_and_ioremap(&pdev->dev, ltq_mtd->res);
-       if (!ltq_mtd->map->virt) {
-               dev_err(&pdev->dev, "failed to remap mem resource\n");
-               err = -EBUSY;
+       ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res);
+       if (IS_ERR(ltq_mtd->map->virt)) {
+               err = PTR_ERR(ltq_mtd->map->virt);
                goto err_out;
        }
 
index 67e62d3d495cce93a4d633937466c4c6a9524177..c543cc09f1936e5a7181282186ffdeea0b059646 100644 (file)
@@ -937,42 +937,35 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
        if (!res)
                return -EINVAL;
 
-       host->data_va = devm_request_and_ioremap(&pdev->dev, res);
-       if (!host->data_va) {
-               dev_err(&pdev->dev, "data ioremap failed\n");
-               return -ENOMEM;
-       }
+       host->data_va = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(host->data_va))
+               return PTR_ERR(host->data_va);
+       
        host->data_pa = (dma_addr_t)res->start;
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
        if (!res)
                return -EINVAL;
 
-       host->addr_va = devm_request_and_ioremap(&pdev->dev, res);
-       if (!host->addr_va) {
-               dev_err(&pdev->dev, "ale ioremap failed\n");
-               return -ENOMEM;
-       }
+       host->addr_va = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(host->addr_va))
+               return PTR_ERR(host->addr_va);
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
        if (!res)
                return -EINVAL;
 
-       host->cmd_va = devm_request_and_ioremap(&pdev->dev, res);
-       if (!host->cmd_va) {
-               dev_err(&pdev->dev, "ale ioremap failed\n");
-               return -ENOMEM;
-       }
+       host->cmd_va = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(host->cmd_va))
+               return PTR_ERR(host->cmd_va);
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs");
        if (!res)
                return -EINVAL;
 
-       host->regs_va = devm_request_and_ioremap(&pdev->dev, res);
-       if (!host->regs_va) {
-               dev_err(&pdev->dev, "regs ioremap failed\n");
-               return -ENOMEM;
-       }
+       host->regs_va = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(host->regs_va))
+               return PTR_ERR(host->regs_va);
 
        host->clk = clk_get(&pdev->dev, NULL);
        if (IS_ERR(host->clk)) {
index f182befa73607bfcf180c3063f2f486e602fd404..0ca22ae9135c6cb9162f06c43f2b316e029e0bab 100644 (file)
@@ -677,11 +677,10 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
-       host->io_base = devm_request_and_ioremap(&pdev->dev, rc);
-       if (host->io_base == NULL) {
-               dev_err(&pdev->dev, "ioremap failed\n");
-               return -EIO;
-       }
+       host->io_base = devm_ioremap_resource(&pdev->dev, rc);
+       if (IS_ERR(host->io_base))
+               return PTR_ERR(host->io_base);
+       
        host->io_base_phy = rc->start;
 
        mtd = &host->mtd;
index 030b78c6289555ad28ff5adb89e09fd9f5df4490..be94ed5abefb74aebde118529cf5eca82abe876e 100644 (file)
@@ -778,11 +778,9 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
        }
        host->io_base_dma = rc->start;
 
-       host->io_base = devm_request_and_ioremap(&pdev->dev, rc);
-       if (host->io_base == NULL) {
-               dev_err(&pdev->dev, "ioremap failed\n");
-               return -ENOMEM;
-       }
+       host->io_base = devm_ioremap_resource(&pdev->dev, rc);
+       if (IS_ERR(host->io_base))
+               return PTR_ERR(host->io_base);
 
        if (pdev->dev.of_node)
                host->ncfg = lpc32xx_parse_dt(&pdev->dev);
index 45204e41a028c66bb1b7c510842f5af704234f6a..60ac5b98b7183cc3bbdf7817ed0ecca237c1ba79 100644 (file)
@@ -1437,9 +1437,9 @@ static int mxcnd_probe(struct platform_device *pdev)
                res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                if (!res)
                        return -ENODEV;
-               host->regs_ip = devm_request_and_ioremap(&pdev->dev, res);
-               if (!host->regs_ip)
-                       return -ENOMEM;
+               host->regs_ip = devm_ioremap_resource(&pdev->dev, res);
+               if (IS_ERR(host->regs_ip))
+                       return PTR_ERR(host->regs_ip);
 
                res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
        } else {
@@ -1449,9 +1449,9 @@ static int mxcnd_probe(struct platform_device *pdev)
        if (!res)
                return -ENODEV;
 
-       host->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!host->base)
-               return -ENOMEM;
+       host->base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(host->base))
+               return PTR_ERR(host->base);
 
        host->main_area0 = host->base;
 
index df954b4dcba238339892792d33bd48e5251cb1b0..d65afd23e171c16587dffd4fd0044121eb43313a 100644 (file)
@@ -952,10 +952,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev)
        info->platform  = plat;
        info->cpu_type  = cpu_type;
 
-       info->regs      = devm_request_and_ioremap(&pdev->dev, res);
-       if (info->regs == NULL) {
-               dev_err(&pdev->dev, "cannot reserve register region\n");
-               err = -EIO;
+       info->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(info->regs)) {
+               err = PTR_ERR(info->regs);
                goto exit_error;
        }
 
index e3d7266e256f2f5601aa6117bab6669964c0d604..e1e8748aa47b263c2f4349b49e5e0f715236d0f5 100644 (file)
@@ -9,6 +9,7 @@
  * (C) Copyright TOSHIBA CORPORATION 2004-2007
  * All Rights Reserved.
  */
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -286,9 +287,9 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
        drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL);
        if (!drvdata)
                return -ENOMEM;
-       drvdata->base = devm_request_and_ioremap(&dev->dev, res);
-       if (!drvdata->base)
-               return -EBUSY;
+       drvdata->base = devm_ioremap_resource(&dev->dev, res);
+       if (IS_ERR(drvdata->base))
+               return PTR_ERR(drvdata->base);
 
        hold = plat->hold ?: 20; /* tDH */
        spw = plat->spw ?: 90; /* max(tREADID, tWP, tRP) */