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>,
'John Crispin' <blogic@openwrt.org>,
'Thomas Langer' <thomas.langer@lantiq.com>
Subject: [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc()
Date: Fri, 20 Dec 2013 13:58:52 +0900 [thread overview]
Message-ID: <001201cefd40$2db34260$8919c720$%han@samsung.com> (raw)
In-Reply-To: <000f01cefd3f$60ef8540$22ce8fc0$%han@samsung.com>
Use devm_kzalloc() to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/maps/lantiq-flash.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
index d7ac65d..4b197c6 100644
--- a/drivers/mtd/maps/lantiq-flash.c
+++ b/drivers/mtd/maps/lantiq-flash.c
@@ -123,7 +123,7 @@ ltq_mtd_probe(struct platform_device *pdev)
return -ENODEV;
}
- ltq_mtd = kzalloc(sizeof(struct ltq_mtd), GFP_KERNEL);
+ ltq_mtd = devm_kzalloc(&pdev->dev, sizeof(struct ltq_mtd), GFP_KERNEL);
platform_set_drvdata(pdev, ltq_mtd);
ltq_mtd->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -133,7 +133,8 @@ ltq_mtd_probe(struct platform_device *pdev)
goto err_out;
}
- ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
+ ltq_mtd->map = devm_kzalloc(&pdev->dev, sizeof(struct map_info),
+ GFP_KERNEL);
ltq_mtd->map->phys = ltq_mtd->res->start;
ltq_mtd->map->size = resource_size(ltq_mtd->res);
ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res);
@@ -178,9 +179,7 @@ ltq_mtd_probe(struct platform_device *pdev)
err_destroy:
map_destroy(ltq_mtd->mtd);
err_free:
- kfree(ltq_mtd->map);
err_out:
- kfree(ltq_mtd);
return err;
}
@@ -189,13 +188,9 @@ ltq_mtd_remove(struct platform_device *pdev)
{
struct ltq_mtd *ltq_mtd = platform_get_drvdata(pdev);
- if (ltq_mtd) {
- if (ltq_mtd->mtd) {
- mtd_device_unregister(ltq_mtd->mtd);
- map_destroy(ltq_mtd->mtd);
- }
- kfree(ltq_mtd->map);
- kfree(ltq_mtd);
+ if (ltq_mtd && ltq_mtd->mtd) {
+ mtd_device_unregister(ltq_mtd->mtd);
+ map_destroy(ltq_mtd->mtd);
}
return 0;
}
--
1.7.10.4
next prev parent reply other threads:[~2013-12-20 4:59 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 ` [PATCH 2/8] mtd: ixp4xx: " Jingoo Han
2014-01-03 1:19 ` Brian Norris
2013-12-20 4:58 ` Jingoo Han [this message]
2013-12-20 6:03 ` [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc() 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='001201cefd40$2db34260$8919c720$%han@samsung.com' \
--to=jg1.han@samsung.com \
--cc=blogic@openwrt.org \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=thomas.langer@lantiq.com \
/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