All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V4 1/2] mtd: ixp4xx: Use devm_*() functions
@ 2014-01-03  2:15 Jingoo Han
  2014-01-03  2:16 ` [PATCH V4 2/2] mtd: plat_nand: " Jingoo Han
  2014-01-03 19:11 ` [PATCH V4 1/2] mtd: ixp4xx: " Brian Norris
  0 siblings, 2 replies; 3+ messages in thread
From: Jingoo Han @ 2014-01-03  2:15 UTC (permalink / raw)
  To: 'Brian Norris'
  Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
	'Marc Kleine-Budde'

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

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
Change since v3
- Include err.h in order to prevent possible build errors.

 drivers/mtd/maps/ixp4xx.c |   28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 10debfe..d6b2451 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -13,6 +13,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -162,13 +163,6 @@ static int ixp4xx_flash_remove(struct platform_device *dev)
 		mtd_device_unregister(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)
 		plat->exit();
@@ -194,7 +188,8 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
 			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) {
 		err = -ENOMEM;
 		goto Error;
@@ -220,20 +215,9 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
 	info->map.write = ixp4xx_probe_write16;
 	info->map.copy_from = ixp4xx_copy_from;
 
-	info->res = request_mem_region(dev->resource->start,
-			resource_size(dev->resource),
-			"IXP4XXFlash");
-	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;
+	info->map.virt = devm_ioremap_resource(&dev->dev, dev->resource);
+	if (IS_ERR(info->map.virt)) {
+		err = PTR_ERR(info->map.virt);
 		goto Error;
 	}
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH V4 2/2] mtd: plat_nand: Use devm_*() functions
  2014-01-03  2:15 [PATCH V4 1/2] mtd: ixp4xx: Use devm_*() functions Jingoo Han
@ 2014-01-03  2:16 ` Jingoo Han
  2014-01-03 19:11 ` [PATCH V4 1/2] mtd: ixp4xx: " Brian Norris
  1 sibling, 0 replies; 3+ messages in thread
From: Jingoo Han @ 2014-01-03  2:16 UTC (permalink / raw)
  To: 'Brian Norris'
  Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
	'Vitaly Wool'

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

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
Change since v3
- Include err.h in order to prevent possible build errors.

 drivers/mtd/nand/plat_nand.c |   31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index cad4cdc..d00e3a7 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -9,6 +9,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -52,25 +53,16 @@ static int plat_nand_probe(struct platform_device *pdev)
 		return -ENXIO;
 
 	/* Allocate memory for the device structure (and zero it) */
-	data = kzalloc(sizeof(struct plat_nand_data), GFP_KERNEL);
+	data = devm_kzalloc(&pdev->dev, sizeof(struct plat_nand_data),
+			    GFP_KERNEL);
 	if (!data) {
 		dev_err(&pdev->dev, "failed to allocate device structure.\n");
 		return -ENOMEM;
 	}
 
-	if (!request_mem_region(res->start, resource_size(res),
-				dev_name(&pdev->dev))) {
-		dev_err(&pdev->dev, "request_mem_region failed\n");
-		err = -EBUSY;
-		goto out_free;
-	}
-
-	data->io_base = ioremap(res->start, resource_size(res));
-	if (data->io_base == NULL) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		err = -EIO;
-		goto out_release_io;
-	}
+	data->io_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(data->io_base))
+		return PTR_ERR(data->io_base);
 
 	data->chip.priv = &data;
 	data->mtd.priv = &data->chip;
@@ -122,11 +114,6 @@ static int plat_nand_probe(struct platform_device *pdev)
 out:
 	if (pdata->ctrl.remove)
 		pdata->ctrl.remove(pdev);
-	iounmap(data->io_base);
-out_release_io:
-	release_mem_region(res->start, resource_size(res));
-out_free:
-	kfree(data);
 	return err;
 }
 
@@ -137,16 +124,10 @@ static int plat_nand_remove(struct platform_device *pdev)
 {
 	struct plat_nand_data *data = platform_get_drvdata(pdev);
 	struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev);
-	struct resource *res;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
 	nand_release(&data->mtd);
 	if (pdata->ctrl.remove)
 		pdata->ctrl.remove(pdev);
-	iounmap(data->io_base);
-	release_mem_region(res->start, resource_size(res));
-	kfree(data);
 
 	return 0;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V4 1/2] mtd: ixp4xx: Use devm_*() functions
  2014-01-03  2:15 [PATCH V4 1/2] mtd: ixp4xx: Use devm_*() functions Jingoo Han
  2014-01-03  2:16 ` [PATCH V4 2/2] mtd: plat_nand: " Jingoo Han
@ 2014-01-03 19:11 ` Brian Norris
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Norris @ 2014-01-03 19:11 UTC (permalink / raw)
  To: Jingoo Han
  Cc: linux-mtd, 'David Woodhouse', 'Marc Kleine-Budde'

On Fri, Jan 03, 2014 at 11:15:04AM +0900, Jingoo Han wrote:
> Use devm_*() functions to make cleanup paths simpler.
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
> Change since v3
> - Include err.h in order to prevent possible build errors.

Both compile-tested fine for me now. Pushed to l2-mtd.git. Thanks!

Brian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-03 19:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-03  2:15 [PATCH V4 1/2] mtd: ixp4xx: Use devm_*() functions Jingoo Han
2014-01-03  2:16 ` [PATCH V4 2/2] mtd: plat_nand: " Jingoo Han
2014-01-03 19:11 ` [PATCH V4 1/2] mtd: ixp4xx: " Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.