From: Himangi Saraogi <himangi774@gmail.com>
To: Brian Norris <computersforpeace@gmail.com>,
Prabhakar Kushwaha <prabhakar@freescale.com>,
Sachin Kamat <sachin.kamat@linaro.org>,
Aaron Sierra <asierra@xes-inc.com>,
Artem Bityutskiy <artem.bityutskiy@linux.intel.com>,
Joe Schultz <jschultz@xes-inc.com>,
linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH] mtd: fsl_ifc_nand: use devm_ functions consistently
Date: Sun, 3 Aug 2014 15:47:07 +0530 [thread overview]
Message-ID: <20140803101707.GA8018@himangi-Dell> (raw)
Use devm_kzalloc for all calls to kzalloc and not just the first. Use
devm functions for other allocations as well. The calls to free the
allocated memory in the remove function are done away with.
The semantic match that finds the inconsistency is as follows:
// <smpl>
@@
@@
*devm_kzalloc(...)
...
*kzalloc(...)
// </smpl>
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
Not compile tested.
drivers/mtd/nand/fsl_ifc_nand.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index 2338124..b403a77 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -995,11 +995,6 @@ static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
{
nand_release(&priv->mtd);
- kfree(priv->mtd.name);
-
- if (priv->vbase)
- iounmap(priv->vbase);
-
ifc_nand_ctrl->chips[priv->bank] = NULL;
return 0;
@@ -1062,7 +1057,8 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
mutex_lock(&fsl_ifc_nand_mutex);
if (!fsl_ifc_ctrl_dev->nand) {
- ifc_nand_ctrl = kzalloc(sizeof(*ifc_nand_ctrl), GFP_KERNEL);
+ ifc_nand_ctrl = devm_kzalloc(&dev->dev, sizeof(*ifc_nand_ctrl),
+ GFP_KERNEL);
if (!ifc_nand_ctrl) {
mutex_unlock(&fsl_ifc_nand_mutex);
return -ENOMEM;
@@ -1085,7 +1081,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
priv->ctrl = fsl_ifc_ctrl_dev;
priv->dev = &dev->dev;
- priv->vbase = ioremap(res.start, resource_size(&res));
+ priv->vbase = devm_ioremap(&dev->dev, res.start, resource_size(&res));
if (!priv->vbase) {
dev_err(priv->dev, "%s: failed to map chip region\n", __func__);
ret = -ENOMEM;
@@ -1104,7 +1100,8 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
IFC_NAND_EVTER_INTR_FTOERIR_EN |
IFC_NAND_EVTER_INTR_WPERIR_EN,
&ifc->ifc_nand.nand_evter_intr_en);
- priv->mtd.name = kasprintf(GFP_KERNEL, "%llx.flash", (u64)res.start);
+ priv->mtd.name = devm_kasprintf(&dev->dev, GFP_KERNEL, "%llx.flash",
+ (u64)res.start);
if (!priv->mtd.name) {
ret = -ENOMEM;
goto err;
@@ -1148,10 +1145,8 @@ static int fsl_ifc_nand_remove(struct platform_device *dev)
mutex_lock(&fsl_ifc_nand_mutex);
ifc_nand_ctrl->counter--;
- if (!ifc_nand_ctrl->counter) {
+ if (!ifc_nand_ctrl->counter)
fsl_ifc_ctrl_dev->nand = NULL;
- kfree(ifc_nand_ctrl);
- }
mutex_unlock(&fsl_ifc_nand_mutex);
return 0;
--
1.9.1
next reply other threads:[~2014-08-03 10:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-03 10:17 Himangi Saraogi [this message]
2014-09-28 0:53 ` [PATCH] mtd: fsl_ifc_nand: use devm_ functions consistently Brian Norris
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=20140803101707.GA8018@himangi-Dell \
--to=himangi774@gmail.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=asierra@xes-inc.com \
--cc=computersforpeace@gmail.com \
--cc=jschultz@xes-inc.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=prabhakar@freescale.com \
--cc=sachin.kamat@linaro.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