public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Jingoo Han <jg1.han@samsung.com>
To: 'Brian Norris' <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org, 'Jingoo Han' <jg1.han@samsung.com>,
	'David Woodhouse' <dwmw2@infradead.org>,
	'Marc Kleine-Budde' <mkl@blackshift.org>
Subject: [PATCH 2/8] mtd: ixp4xx: Use devm_*() functions
Date: Fri, 20 Dec 2013 13:56:58 +0900	[thread overview]
Message-ID: <001101cefd3f$e99a17c0$bcce4740$%han@samsung.com> (raw)
In-Reply-To: <000f01cefd3f$60ef8540$22ce8fc0$%han@samsung.com>

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

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/mtd/maps/ixp4xx.c |   27 +++++----------------------
 1 file changed, 5 insertions(+), 22 deletions(-)

diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 10debfe..5f42916 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -162,13 +162,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 +187,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 +214,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

  reply	other threads:[~2013-12-20  4:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20  4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
2013-12-20  4:56 ` Jingoo Han [this message]
2014-01-03  1:19   ` [PATCH 2/8] mtd: ixp4xx: " Brian Norris
2013-12-20  4:58 ` [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc() Jingoo Han
2013-12-20  6:03   ` John Crispin
2013-12-20  7:14     ` Jingoo Han
2013-12-20  5:00 ` [PATCH 4/8] mtd: denali_dt: Use devm_clk_get() Jingoo Han
2013-12-20  5:01 ` [PATCH 5/8] mtd: lpc32xx_slc: Use devm_*() functions Jingoo Han
2013-12-20  5:02 ` [PATCH 6/8] mtd: nuc900_nand: " Jingoo Han
2013-12-20  5:04 ` [PATCH 7/8] mtd: plat_nand: " Jingoo Han
2014-01-03  1:17   ` Brian Norris
2014-01-03  1:21     ` Brian Norris
2014-01-03  1:27     ` Jingoo Han
2014-01-03 18:16       ` Brian Norris
2013-12-20  5:05 ` [PATCH 8/8] mtd: tmio_nand: " Jingoo Han

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001101cefd3f$e99a17c0$bcce4740$%han@samsung.com' \
    --to=jg1.han@samsung.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mkl@blackshift.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox