Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0de774c authored by Thierry Reding's avatar Thierry Reding Committed by Greg Kroah-Hartman
Browse files

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: default avatarThierry Reding <thierry.reding@avionic-design.de>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a3e2cd7f
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -949,10 +949,9 @@ static int spear_smi_probe(struct platform_device *pdev)


	smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);


	dev->io_base = devm_request_and_ioremap(&pdev->dev, smi_base);
	dev->io_base = devm_ioremap_resource(&pdev->dev, smi_base);
	if (!dev->io_base) {
	if (IS_ERR(dev->io_base)) {
		ret = -EIO;
		ret = PTR_ERR(dev->io_base);
		dev_err(&pdev->dev, "devm_request_and_ioremap fail\n");
		goto err;
		goto err;
	}
	}


+4 −5
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
 * along with this program; if not, write to the Free Software
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 */
#include <linux/err.h>
#include <linux/sizes.h>
#include <linux/sizes.h>


#include <linux/types.h>
#include <linux/types.h>
@@ -55,12 +56,10 @@ static int autcpu12_nvram_probe(struct platform_device *pdev)
	priv->map.bankwidth	= 4;
	priv->map.bankwidth	= 4;
	priv->map.phys		= res->start;
	priv->map.phys		= res->start;
	priv->map.size		= resource_size(res);
	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);
	strcpy((char *)priv->map.name, res->name);
	if (!priv->map.virt) {
	if (IS_ERR(priv->map.virt))
		dev_err(&pdev->dev, "failed to remap mem resource\n");
		return PTR_ERR(priv->map.virt);
		return -EBUSY;
	}


	simple_map_init(&priv->map);
	simple_map_init(&priv->map);


+4 −4
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
 */
 */


#include <linux/err.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/types.h>
#include <linux/kernel.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 = kzalloc(sizeof(struct map_info), GFP_KERNEL);
	ltq_mtd->map->phys = ltq_mtd->res->start;
	ltq_mtd->map->phys = ltq_mtd->res->start;
	ltq_mtd->map->size = resource_size(ltq_mtd->res);
	ltq_mtd->map->size = resource_size(ltq_mtd->res);
	ltq_mtd->map->virt = devm_request_and_ioremap(&pdev->dev, ltq_mtd->res);
	ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res);
	if (!ltq_mtd->map->virt) {
	if (IS_ERR(ltq_mtd->map->virt)) {
		dev_err(&pdev->dev, "failed to remap mem resource\n");
		err = PTR_ERR(ltq_mtd->map->virt);
		err = -EBUSY;
		goto err_out;
		goto err_out;
	}
	}


+13 −20
Original line number Original line Diff line number Diff line
@@ -937,42 +937,35 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
	if (!res)
	if (!res)
		return -EINVAL;
		return -EINVAL;


	host->data_va = devm_request_and_ioremap(&pdev->dev, res);
	host->data_va = devm_ioremap_resource(&pdev->dev, res);
	if (!host->data_va) {
	if (IS_ERR(host->data_va))
		dev_err(&pdev->dev, "data ioremap failed\n");
		return PTR_ERR(host->data_va);
		return -ENOMEM;
	
	}
	host->data_pa = (dma_addr_t)res->start;
	host->data_pa = (dma_addr_t)res->start;


	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
	if (!res)
	if (!res)
		return -EINVAL;
		return -EINVAL;


	host->addr_va = devm_request_and_ioremap(&pdev->dev, res);
	host->addr_va = devm_ioremap_resource(&pdev->dev, res);
	if (!host->addr_va) {
	if (IS_ERR(host->addr_va))
		dev_err(&pdev->dev, "ale ioremap failed\n");
		return PTR_ERR(host->addr_va);
		return -ENOMEM;
	}


	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
	if (!res)
	if (!res)
		return -EINVAL;
		return -EINVAL;


	host->cmd_va = devm_request_and_ioremap(&pdev->dev, res);
	host->cmd_va = devm_ioremap_resource(&pdev->dev, res);
	if (!host->cmd_va) {
	if (IS_ERR(host->cmd_va))
		dev_err(&pdev->dev, "ale ioremap failed\n");
		return PTR_ERR(host->cmd_va);
		return -ENOMEM;
	}


	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs");
	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs");
	if (!res)
	if (!res)
		return -EINVAL;
		return -EINVAL;


	host->regs_va = devm_request_and_ioremap(&pdev->dev, res);
	host->regs_va = devm_ioremap_resource(&pdev->dev, res);
	if (!host->regs_va) {
	if (IS_ERR(host->regs_va))
		dev_err(&pdev->dev, "regs ioremap failed\n");
		return PTR_ERR(host->regs_va);
		return -ENOMEM;
	}


	host->clk = clk_get(&pdev->dev, NULL);
	host->clk = clk_get(&pdev->dev, NULL);
	if (IS_ERR(host->clk)) {
	if (IS_ERR(host->clk)) {
+4 −5
Original line number Original line Diff line number Diff line
@@ -677,11 +677,10 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
		return -ENXIO;
		return -ENXIO;
	}
	}


	host->io_base = devm_request_and_ioremap(&pdev->dev, rc);
	host->io_base = devm_ioremap_resource(&pdev->dev, rc);
	if (host->io_base == NULL) {
	if (IS_ERR(host->io_base))
		dev_err(&pdev->dev, "ioremap failed\n");
		return PTR_ERR(host->io_base);
		return -EIO;
	
	}
	host->io_base_phy = rc->start;
	host->io_base_phy = rc->start;


	mtd = &host->mtd;
	mtd = &host->mtd;
Loading