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

Commit ed0b272e authored by Jingoo Han's avatar Jingoo Han Committed by Brian Norris
Browse files

mtd: ixp4xx: Use devm_*() functions



Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent bb13bec7
Loading
Loading
Loading
Loading
+6 −22
Original line number Original line Diff line number Diff line
@@ -13,6 +13,7 @@
 *
 *
 */
 */


#include <linux/err.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/init.h>
@@ -162,13 +163,6 @@ static int ixp4xx_flash_remove(struct platform_device *dev)
		mtd_device_unregister(info->mtd);
		mtd_device_unregister(info->mtd);
		map_destroy(info->mtd);
		map_destroy(info->mtd);
	}
	}
	if (info->map.virt)
		iounmap(info->map.virt);

	if (info->res) {
		release_resource(info->res);
		kfree(info->res);
	}


	if (plat->exit)
	if (plat->exit)
		plat->exit();
		plat->exit();
@@ -194,7 +188,8 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
			return err;
			return err;
	}
	}


	info = kzalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
	info = devm_kzalloc(&dev->dev, sizeof(struct ixp4xx_flash_info),
			    GFP_KERNEL);
	if(!info) {
	if(!info) {
		err = -ENOMEM;
		err = -ENOMEM;
		goto Error;
		goto Error;
@@ -220,20 +215,9 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
	info->map.write = ixp4xx_probe_write16;
	info->map.write = ixp4xx_probe_write16;
	info->map.copy_from = ixp4xx_copy_from;
	info->map.copy_from = ixp4xx_copy_from;


	info->res = request_mem_region(dev->resource->start,
	info->map.virt = devm_ioremap_resource(&dev->dev, dev->resource);
			resource_size(dev->resource),
	if (IS_ERR(info->map.virt)) {
			"IXP4XXFlash");
		err = PTR_ERR(info->map.virt);
	if (!info->res) {
		printk(KERN_ERR "IXP4XXFlash: Could not reserve memory region\n");
		err = -ENOMEM;
		goto Error;
	}

	info->map.virt = ioremap(dev->resource->start,
				 resource_size(dev->resource));
	if (!info->map.virt) {
		printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n");
		err = -EIO;
		goto Error;
		goto Error;
	}
	}