aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@avionic-design.de>2013-01-21 05:09:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-25 15:21:47 -0500
commitb0de774c6334dccdcd43a7ef46155a1f3a52a954 (patch)
treed845a8ea2c8f5d556591829ec1829f216ad0cbb1
parenta3e2cd7f24ba7521169943ace3d14b567487ea29 (diff)
mtd: Convert to devm_ioremap_resource()
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>
-rw-r--r--drivers/mtd/devices/spear_smi.c7
-rw-r--r--drivers/mtd/maps/autcpu12-nvram.c9
-rw-r--r--drivers/mtd/maps/lantiq-flash.c8
-rw-r--r--drivers/mtd/nand/fsmc_nand.c33
-rw-r--r--drivers/mtd/nand/lpc32xx_mlc.c9
-rw-r--r--drivers/mtd/nand/lpc32xx_slc.c8
-rw-r--r--drivers/mtd/nand/mxc_nand.c12
-rw-r--r--drivers/mtd/nand/s3c2410.c7
-rw-r--r--drivers/mtd/nand/txx9ndfmc.c7
9 files changed, 44 insertions, 56 deletions
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 2aabd96bf0ff..8a82b8bc21e1 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -949,10 +949,9 @@ static int spear_smi_probe(struct platform_device *pdev)
949 949
950 smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); 950 smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
951 951
952 dev->io_base = devm_request_and_ioremap(&pdev->dev, smi_base); 952 dev->io_base = devm_ioremap_resource(&pdev->dev, smi_base);
953 if (!dev->io_base) { 953 if (IS_ERR(dev->io_base)) {
954 ret = -EIO; 954 ret = PTR_ERR(dev->io_base);
955 dev_err(&pdev->dev, "devm_request_and_ioremap fail\n");
956 goto err; 955 goto err;
957 } 956 }
958 957
diff --git a/drivers/mtd/maps/autcpu12-nvram.c b/drivers/mtd/maps/autcpu12-nvram.c
index a2dc2ae4b24e..c3525d2a2fa8 100644
--- a/drivers/mtd/maps/autcpu12-nvram.c
+++ b/drivers/mtd/maps/autcpu12-nvram.c
@@ -16,6 +16,7 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19#include <linux/err.h>
19#include <linux/sizes.h> 20#include <linux/sizes.h>
20 21
21#include <linux/types.h> 22#include <linux/types.h>
@@ -55,12 +56,10 @@ static int autcpu12_nvram_probe(struct platform_device *pdev)
55 priv->map.bankwidth = 4; 56 priv->map.bankwidth = 4;
56 priv->map.phys = res->start; 57 priv->map.phys = res->start;
57 priv->map.size = resource_size(res); 58 priv->map.size = resource_size(res);
58 priv->map.virt = devm_request_and_ioremap(&pdev->dev, res); 59 priv->map.virt = devm_ioremap_resource(&pdev->dev, res);
59 strcpy((char *)priv->map.name, res->name); 60 strcpy((char *)priv->map.name, res->name);
60 if (!priv->map.virt) { 61 if (IS_ERR(priv->map.virt))
61 dev_err(&pdev->dev, "failed to remap mem resource\n"); 62 return PTR_ERR(priv->map.virt);
62 return -EBUSY;
63 }
64 63
65 simple_map_init(&priv->map); 64 simple_map_init(&priv->map);
66 65
diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
index 3c3c791eb96a..d1da6ede3845 100644
--- a/drivers/mtd/maps/lantiq-flash.c
+++ b/drivers/mtd/maps/lantiq-flash.c
@@ -7,6 +7,7 @@
7 * Copyright (C) 2010 John Crispin <blogic@openwrt.org> 7 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
8 */ 8 */
9 9
10#include <linux/err.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/types.h> 12#include <linux/types.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -136,10 +137,9 @@ ltq_mtd_probe(struct platform_device *pdev)
136 ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL); 137 ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
137 ltq_mtd->map->phys = ltq_mtd->res->start; 138 ltq_mtd->map->phys = ltq_mtd->res->start;
138 ltq_mtd->map->size = resource_size(ltq_mtd->res); 139 ltq_mtd->map->size = resource_size(ltq_mtd->res);
139 ltq_mtd->map->virt = devm_request_and_ioremap(&pdev->dev, ltq_mtd->res); 140 ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res);
140 if (!ltq_mtd->map->virt) { 141 if (IS_ERR(ltq_mtd->map->virt)) {
141 dev_err(&pdev->dev, "failed to remap mem resource\n"); 142 err = PTR_ERR(ltq_mtd->map->virt);
142 err = -EBUSY;
143 goto err_out; 143 goto err_out;
144 } 144 }
145 145
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 67e62d3d495c..c543cc09f193 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -937,42 +937,35 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
937 if (!res) 937 if (!res)
938 return -EINVAL; 938 return -EINVAL;
939 939
940 host->data_va = devm_request_and_ioremap(&pdev->dev, res); 940 host->data_va = devm_ioremap_resource(&pdev->dev, res);
941 if (!host->data_va) { 941 if (IS_ERR(host->data_va))
942 dev_err(&pdev->dev, "data ioremap failed\n"); 942 return PTR_ERR(host->data_va);
943 return -ENOMEM; 943
944 }
945 host->data_pa = (dma_addr_t)res->start; 944 host->data_pa = (dma_addr_t)res->start;
946 945
947 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr"); 946 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
948 if (!res) 947 if (!res)
949 return -EINVAL; 948 return -EINVAL;
950 949
951 host->addr_va = devm_request_and_ioremap(&pdev->dev, res); 950 host->addr_va = devm_ioremap_resource(&pdev->dev, res);
952 if (!host->addr_va) { 951 if (IS_ERR(host->addr_va))
953 dev_err(&pdev->dev, "ale ioremap failed\n"); 952 return PTR_ERR(host->addr_va);
954 return -ENOMEM;
955 }
956 953
957 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd"); 954 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
958 if (!res) 955 if (!res)
959 return -EINVAL; 956 return -EINVAL;
960 957
961 host->cmd_va = devm_request_and_ioremap(&pdev->dev, res); 958 host->cmd_va = devm_ioremap_resource(&pdev->dev, res);
962 if (!host->cmd_va) { 959 if (IS_ERR(host->cmd_va))
963 dev_err(&pdev->dev, "ale ioremap failed\n"); 960 return PTR_ERR(host->cmd_va);
964 return -ENOMEM;
965 }
966 961
967 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs"); 962 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs");
968 if (!res) 963 if (!res)
969 return -EINVAL; 964 return -EINVAL;
970 965
971 host->regs_va = devm_request_and_ioremap(&pdev->dev, res); 966 host->regs_va = devm_ioremap_resource(&pdev->dev, res);
972 if (!host->regs_va) { 967 if (IS_ERR(host->regs_va))
973 dev_err(&pdev->dev, "regs ioremap failed\n"); 968 return PTR_ERR(host->regs_va);
974 return -ENOMEM;
975 }
976 969
977 host->clk = clk_get(&pdev->dev, NULL); 970 host->clk = clk_get(&pdev->dev, NULL);
978 if (IS_ERR(host->clk)) { 971 if (IS_ERR(host->clk)) {
diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
index f182befa7360..0ca22ae9135c 100644
--- a/drivers/mtd/nand/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/lpc32xx_mlc.c
@@ -677,11 +677,10 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
677 return -ENXIO; 677 return -ENXIO;
678 } 678 }
679 679
680 host->io_base = devm_request_and_ioremap(&pdev->dev, rc); 680 host->io_base = devm_ioremap_resource(&pdev->dev, rc);
681 if (host->io_base == NULL) { 681 if (IS_ERR(host->io_base))
682 dev_err(&pdev->dev, "ioremap failed\n"); 682 return PTR_ERR(host->io_base);
683 return -EIO; 683
684 }
685 host->io_base_phy = rc->start; 684 host->io_base_phy = rc->start;
686 685
687 mtd = &host->mtd; 686 mtd = &host->mtd;
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index 030b78c62895..be94ed5abefb 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -778,11 +778,9 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
778 } 778 }
779 host->io_base_dma = rc->start; 779 host->io_base_dma = rc->start;
780 780
781 host->io_base = devm_request_and_ioremap(&pdev->dev, rc); 781 host->io_base = devm_ioremap_resource(&pdev->dev, rc);
782 if (host->io_base == NULL) { 782 if (IS_ERR(host->io_base))
783 dev_err(&pdev->dev, "ioremap failed\n"); 783 return PTR_ERR(host->io_base);
784 return -ENOMEM;
785 }
786 784
787 if (pdev->dev.of_node) 785 if (pdev->dev.of_node)
788 host->ncfg = lpc32xx_parse_dt(&pdev->dev); 786 host->ncfg = lpc32xx_parse_dt(&pdev->dev);
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 45204e41a028..60ac5b98b718 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1437,9 +1437,9 @@ static int mxcnd_probe(struct platform_device *pdev)
1437 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1437 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1438 if (!res) 1438 if (!res)
1439 return -ENODEV; 1439 return -ENODEV;
1440 host->regs_ip = devm_request_and_ioremap(&pdev->dev, res); 1440 host->regs_ip = devm_ioremap_resource(&pdev->dev, res);
1441 if (!host->regs_ip) 1441 if (IS_ERR(host->regs_ip))
1442 return -ENOMEM; 1442 return PTR_ERR(host->regs_ip);
1443 1443
1444 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1444 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1445 } else { 1445 } else {
@@ -1449,9 +1449,9 @@ static int mxcnd_probe(struct platform_device *pdev)
1449 if (!res) 1449 if (!res)
1450 return -ENODEV; 1450 return -ENODEV;
1451 1451
1452 host->base = devm_request_and_ioremap(&pdev->dev, res); 1452 host->base = devm_ioremap_resource(&pdev->dev, res);
1453 if (!host->base) 1453 if (IS_ERR(host->base))
1454 return -ENOMEM; 1454 return PTR_ERR(host->base);
1455 1455
1456 host->main_area0 = host->base; 1456 host->main_area0 = host->base;
1457 1457
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index df954b4dcba2..d65afd23e171 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -952,10 +952,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev)
952 info->platform = plat; 952 info->platform = plat;
953 info->cpu_type = cpu_type; 953 info->cpu_type = cpu_type;
954 954
955 info->regs = devm_request_and_ioremap(&pdev->dev, res); 955 info->regs = devm_ioremap_resource(&pdev->dev, res);
956 if (info->regs == NULL) { 956 if (IS_ERR(info->regs)) {
957 dev_err(&pdev->dev, "cannot reserve register region\n"); 957 err = PTR_ERR(info->regs);
958 err = -EIO;
959 goto exit_error; 958 goto exit_error;
960 } 959 }
961 960
diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c
index e3d7266e256f..e1e8748aa47b 100644
--- a/drivers/mtd/nand/txx9ndfmc.c
+++ b/drivers/mtd/nand/txx9ndfmc.c
@@ -9,6 +9,7 @@
9 * (C) Copyright TOSHIBA CORPORATION 2004-2007 9 * (C) Copyright TOSHIBA CORPORATION 2004-2007
10 * All Rights Reserved. 10 * All Rights Reserved.
11 */ 11 */
12#include <linux/err.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/slab.h> 14#include <linux/slab.h>
14#include <linux/module.h> 15#include <linux/module.h>
@@ -286,9 +287,9 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
286 drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL); 287 drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL);
287 if (!drvdata) 288 if (!drvdata)
288 return -ENOMEM; 289 return -ENOMEM;
289 drvdata->base = devm_request_and_ioremap(&dev->dev, res); 290 drvdata->base = devm_ioremap_resource(&dev->dev, res);
290 if (!drvdata->base) 291 if (IS_ERR(drvdata->base))
291 return -EBUSY; 292 return PTR_ERR(drvdata->base);
292 293
293 hold = plat->hold ?: 20; /* tDH */ 294 hold = plat->hold ?: 20; /* tDH */
294 spw = plat->spw ?: 90; /* max(tREADID, tWP, tRP) */ 295 spw = plat->spw ?: 90; /* max(tREADID, tWP, tRP) */