* [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion
@ 2005-10-01 5:00 Deepak Saxena
2005-10-01 7:46 ` Artem B. Bityutskiy
2005-10-03 15:57 ` Christoph Lameter
0 siblings, 2 replies; 6+ messages in thread
From: Deepak Saxena @ 2005-10-01 5:00 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-mtd, linux-kernel
We have the API, so use it.
Signed-off-by: Deepak Saxena <dsaxena@plexity.net>
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
--- a/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -123,14 +123,13 @@ static int bast_flash_probe(struct devic
struct resource *res;
int err = 0;
- info = kmalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) {
printk(KERN_ERR PFX "no memory for flash info\n");
err = -ENOMEM;
goto exit_error;
}
- memzero(info, sizeof(*info));
dev_set_drvdata(dev, info);
res = pdev->resource; /* assume that the flash has one resource */
diff --git a/drivers/mtd/maps/epxa10db-flash.c b/drivers/mtd/maps/epxa10db-flash.c
--- a/drivers/mtd/maps/epxa10db-flash.c
+++ b/drivers/mtd/maps/epxa10db-flash.c
@@ -142,8 +142,7 @@ static int __init epxa_default_partition
printk("Using default partitions for %s\n",BOARD_NAME);
npartitions=1;
- parts = kmalloc(npartitions*sizeof(*parts)+strlen(name), GFP_KERNEL);
- memzero(parts,npartitions*sizeof(*parts)+strlen(name));
+ parts = kzalloc(npartitions*sizeof(*parts)+strlen(name), GFP_KERNEL);
if (!parts) {
ret = -ENOMEM;
goto out;
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -168,12 +168,11 @@ static int ixp2000_flash_probe(struct de
return -EIO;
}
- info = kmalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL);
+ info = kzalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL);
if(!info) {
err = -ENOMEM;
goto Error;
}
- memzero(info, sizeof(struct ixp2000_flash_info));
dev_set_drvdata(&dev->dev, info);
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -153,12 +153,11 @@ static int ixp4xx_flash_probe(struct dev
return err;
}
- info = kmalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
+ info = kzalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
if(!info) {
err = -ENOMEM;
goto Error;
}
- memzero(info, sizeof(struct ixp4xx_flash_info));
dev_set_drvdata(&dev->dev, info);
--
Deepak Saxena - dsaxena@plexity.net - http://www.plexity.net
Even a stopped clock gives the right time twice a day.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion
2005-10-01 5:00 [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion Deepak Saxena
@ 2005-10-01 7:46 ` Artem B. Bityutskiy
2005-10-01 8:00 ` Deepak Saxena
2005-10-03 15:57 ` Christoph Lameter
1 sibling, 1 reply; 6+ messages in thread
From: Artem B. Bityutskiy @ 2005-10-01 7:46 UTC (permalink / raw)
To: dsaxena; +Cc: Linus Torvalds, linux-mtd, linux-kernel
On Fri, 2005-09-30 at 22:00 -0700, Deepak Saxena wrote:
> We have the API, so use it.
>
> Signed-off-by: Deepak Saxena <dsaxena@plexity.net>
>
Well, does it really hurt if one does kmalloc() + memset(zero) instead? Is it worth fixing this? Doubts.
--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion
2005-10-01 7:46 ` Artem B. Bityutskiy
@ 2005-10-01 8:00 ` Deepak Saxena
2005-10-01 8:04 ` Artem B. Bityutskiy
0 siblings, 1 reply; 6+ messages in thread
From: Deepak Saxena @ 2005-10-01 8:00 UTC (permalink / raw)
To: Artem B. Bityutskiy; +Cc: Linus Torvalds, linux-mtd, linux-kernel
On Oct 01 2005, at 11:46, Artem B. Bityutskiy was caught saying:
> On Fri, 2005-09-30 at 22:00 -0700, Deepak Saxena wrote:
> > We have the API, so use it.
> >
> > Signed-off-by: Deepak Saxena <dsaxena@plexity.net>
> >
> Well, does it really hurt if one does kmalloc() + memset(zero) instead? Is it worth fixing this? Doubts.
I see it more as an API usage cleanup then a "fix" of any sort.
~Deepak
--
Deepak Saxena - dsaxena@plexity.net - http://www.plexity.net
Even a stopped clock gives the right time twice a day.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion
2005-10-01 8:00 ` Deepak Saxena
@ 2005-10-01 8:04 ` Artem B. Bityutskiy
2005-10-02 12:07 ` Jörn Engel
0 siblings, 1 reply; 6+ messages in thread
From: Artem B. Bityutskiy @ 2005-10-01 8:04 UTC (permalink / raw)
To: dsaxena; +Cc: Linus Torvalds, linux-mtd, linux-kernel
Deepak Saxena wrote:
> I see it more as an API usage cleanup then a "fix" of any sort.
>
Well, actually it may be helpful in only future, for example, if it is
known that the allocated memory is zero-filled already, memzero() may be
avoided at all.
--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion
2005-10-01 8:04 ` Artem B. Bityutskiy
@ 2005-10-02 12:07 ` Jörn Engel
0 siblings, 0 replies; 6+ messages in thread
From: Jörn Engel @ 2005-10-02 12:07 UTC (permalink / raw)
To: Artem B. Bityutskiy; +Cc: Linus Torvalds, linux-mtd, linux-kernel
On Sat, 1 October 2005 12:04:59 +0400, Artem B. Bityutskiy wrote:
> Deepak Saxena wrote:
> >I see it more as an API usage cleanup then a "fix" of any sort.
> >
> Well, actually it may be helpful in only future, for example, if it is
> known that the allocated memory is zero-filled already, memzero() may be
> avoided at all.
Even today, kzalloc() takes less code than kmalloc() + memset().
Shrinks your binary size by a tiny amount.
Jörn
--
Mundie uses a textbook tactic of manipulation: start with some
reasonable talk, and lead the audience to an unreasonable conclusion.
-- Bruce Perens
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion
2005-10-01 5:00 [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion Deepak Saxena
2005-10-01 7:46 ` Artem B. Bityutskiy
@ 2005-10-03 15:57 ` Christoph Lameter
1 sibling, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2005-10-03 15:57 UTC (permalink / raw)
To: Deepak Saxena; +Cc: Linus Torvalds, linux-mtd, linux-kernel
On Fri, 30 Sep 2005, Deepak Saxena wrote:
> We have the API, so use it.
Ummm. There is a patch in Andrew's tree that allows the use of __GFP_ZERO
with slabs in the same way as the page allocator. With that functionality
kmalloc_node will also be able to zero stuff.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-10-03 15:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-01 5:00 [PATCH] [MTD] kmalloc + memzero -> kzalloc conversion Deepak Saxena
2005-10-01 7:46 ` Artem B. Bityutskiy
2005-10-01 8:00 ` Deepak Saxena
2005-10-01 8:04 ` Artem B. Bityutskiy
2005-10-02 12:07 ` Jörn Engel
2005-10-03 15:57 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox