Patchwork [1/2] mtd: docprobe: use kzalloc instead

login
register
mail settings
Submitter Artem Bityutskiy
Date Dec. 29, 2011, 3:47 p.m.
Message ID <1325173626-6739-1-git-send-email-dedekind1@gmail.com>
Download mbox | patch
Permalink /patch/133557/
State New
Headers show

Comments

Artem Bityutskiy - Dec. 29, 2011, 3:47 p.m.
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Instead of calling 'kmalloc()' and them 'memeset(0)', use 'kzalloc()'.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 drivers/mtd/devices/docprobe.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
Thomas Petazzoni - Dec. 29, 2011, 9:31 p.m.
Le Thu, 29 Dec 2011 17:47:05 +0200,
Artem Bityutskiy <dedekind1@gmail.com> a écrit :

> +		mtd = kzmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);

I guess you mean kzalloc() and not kzmalloc().

Thomas
Artem Bityutskiy - Dec. 29, 2011, 9:38 p.m.
On Thu, 2011-12-29 at 22:31 +0100, Thomas Petazzoni wrote:
> Le Thu, 29 Dec 2011 17:47:05 +0200,
> Artem Bityutskiy <dedekind1@gmail.com> a écrit :
> 
> > +		mtd = kzmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);
> 
> I guess you mean kzalloc() and not kzmalloc().

Yes, I have actually had fixed that but then sent the bogus patcy
version, thanks!

Artem.

Patch

diff --git a/drivers/mtd/devices/docprobe.c b/drivers/mtd/devices/docprobe.c
index 45116bb..31b84aa 100644
--- a/drivers/mtd/devices/docprobe.c
+++ b/drivers/mtd/devices/docprobe.c
@@ -241,8 +241,7 @@  static void __init DoC_Probe(unsigned long physadr)
 			return;
 		}
 		docfound = 1;
-		mtd = kmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);
-
+		mtd = kzmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);
 		if (!mtd) {
 			printk(KERN_WARNING "Cannot allocate memory for data structures. Dropping.\n");
 			iounmap(docptr);
@@ -250,10 +249,6 @@  static void __init DoC_Probe(unsigned long physadr)
 		}
 
 		this = (struct DiskOnChip *)(&mtd[1]);
-
-		memset((char *)mtd,0, sizeof(struct mtd_info));
-		memset((char *)this, 0, sizeof(struct DiskOnChip));
-
 		mtd->priv = this;
 		this->virtadr = docptr;
 		this->physadr = physadr;