LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [STAGING] slicoss - use kzalloc
@ 2008-11-04 16:27 Lior Dotan
2008-11-04 22:01 ` Jiri Slaby
0 siblings, 1 reply; 6+ messages in thread
From: Lior Dotan @ 2008-11-04 16:27 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, charrer
[-- Attachment #1: Type: text/plain, Size: 90 bytes --]
This patch uses kzalloc() where applicable.
Signed-off-by: Lior Dotan <liodot@gmail.com>
[-- Attachment #2: slicoss-kzalloc.patch --]
[-- Type: text/plain, Size: 2017 bytes --]
--- b/drivers/staging/slicoss/slicoss.c 2008-11-04 11:53:12.878116772 +0200
+++ a/drivers/staging/slicoss/slicoss.c 2008-11-04 12:08:40.800644774 +0200
@@ -2673,7 +2673,7 @@ static int slic_card_init(struct sliccar
#if SLIC_DUMP_ENABLED
if (!card->dumpbuffer) {
- card->dumpbuffer = kmalloc(DUMP_PAGE_SIZE, GFP_ATOMIC);
+ card->dumpbuffer = kzalloc(DUMP_PAGE_SIZE, GFP_ATOMIC);
ASSERT(card->dumpbuffer);
if (card->dumpbuffer == NULL)
@@ -2683,7 +2683,6 @@ static int slic_card_init(struct sliccar
* Smear the shared memory structure and then obtain
* the PHYSICAL address of this structure
*/
- memset(card->dumpbuffer, 0, DUMP_PAGE_SIZE);
card->dumpbuffer_phys = virt_to_bus(card->dumpbuffer);
card->dumpbuffer_physh = SLIC_GET_ADDR_HIGH(card->dumpbuffer_phys);
card->dumpbuffer_physl = SLIC_GET_ADDR_LOW(card->dumpbuffer_phys);
@@ -2692,7 +2691,7 @@ static int slic_card_init(struct sliccar
* Allocate COMMAND BUFFER
*/
if (!card->cmdbuffer) {
- card->cmdbuffer = kmalloc(sizeof(struct dump_cmd), GFP_ATOMIC);
+ card->cmdbuffer = kzalloc(sizeof(struct dump_cmd), GFP_ATOMIC);
ASSERT(card->cmdbuffer);
if (card->cmdbuffer == NULL)
@@ -2702,7 +2701,6 @@ static int slic_card_init(struct sliccar
* Smear the shared memory structure and then obtain
* the PHYSICAL address of this structure
*/
- memset(card->cmdbuffer, 0, sizeof(struct dump_cmd));
card->cmdbuffer_phys = virt_to_bus(card->cmdbuffer);
card->cmdbuffer_physh = SLIC_GET_ADDR_HIGH(card->cmdbuffer_phys);
card->cmdbuffer_physl = SLIC_GET_ADDR_LOW(card->cmdbuffer_phys);
@@ -2833,9 +2831,8 @@ static u32 slic_card_locate(struct adapt
}
if (!physcard) {
/* no structure allocated for this physical card yet */
- physcard = kmalloc(sizeof(struct physcard *), GFP_ATOMIC);
+ physcard = kzalloc(sizeof(struct physcard *), GFP_ATOMIC);
ASSERT(physcard);
- memset(physcard, 0, sizeof(struct physcard *));
DBG_MSG
("\n%s Allocate a PHYSICALcard:\n PHYSICAL_Card[%p]\n\
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [STAGING] slicoss - use kzalloc
2008-11-04 16:27 [STAGING] slicoss - use kzalloc Lior Dotan
@ 2008-11-04 22:01 ` Jiri Slaby
2008-11-05 9:27 ` Lior Dotan
0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2008-11-04 22:01 UTC (permalink / raw)
To: Lior Dotan; +Cc: gregkh, linux-kernel, charrer
On 11/04/2008 05:27 PM, Lior Dotan wrote:
> This patch uses kzalloc() where applicable.
>
> Signed-off-by: Lior Dotan <liodot@gmail.com>
/drivers/staging/slicoss/slicoss.c
=======================================
--- b/drivers/staging/slicoss/slicoss.c 2008-11-04 11:53:12.878116772 +0200
+++ a/drivers/staging/slicoss/slicoss.c 2008-11-04 12:08:40.800644774 +0200
@@ -2673,8 +2673,8 @@
static·int·slic_card_init(struct·sliccar
#if·SLIC_DUMP_ENABLED
» if·(!card->dumpbuffer)·{
-» » card->dumpbuffer·=·kmalloc(DUMP_PAGE_SIZE,·GFP_ATOMIC);
+» » card->dumpbuffer·=·kzalloc(DUMP_PAGE_SIZE,·GFP_ATOMIC);
» » ASSERT(card->dumpbuffer);
» » if·(card->dumpbuffer·==·NULL)
@@ -2683,8 +2683,7 @@
static·int·slic_card_init(struct·sliccar
» ·*··Smear·the·shared·memory·structure·and·then·obtain
» ·*··the·PHYSICAL·address·of·this·structure
» ·*/
-» memset(card->dumpbuffer,·0,·DUMP_PAGE_SIZE);
It's wrong, the function in called multiple times, the memset was called every
time, now it would be called only for the first time.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [STAGING] slicoss - use kzalloc
2008-11-04 22:01 ` Jiri Slaby
@ 2008-11-05 9:27 ` Lior Dotan
2008-11-05 9:35 ` Jiri Slaby
0 siblings, 1 reply; 6+ messages in thread
From: Lior Dotan @ 2008-11-05 9:27 UTC (permalink / raw)
To: Jiri Slaby, gregkh; +Cc: linux-kernel, charrer
[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]
-------- Original Message --------
Subject: Re: [STAGING] slicoss - use kzalloc
From: Jiri Slaby <jirislaby@gmail.com>
To: Lior Dotan <liodot@gmail.com>
CC: gregkh@suse.de, linux-kernel@vger.kernel.org, charrer@alacritech.com
Date: 11/05/2008 12:01 AM
> On 11/04/2008 05:27 PM, Lior Dotan wrote:
>> This patch uses kzalloc() where applicable.
>>
>> Signed-off-by: Lior Dotan <liodot@gmail.com>
>
> /drivers/staging/slicoss/slicoss.c
> =======================================
> --- b/drivers/staging/slicoss/slicoss.c 2008-11-04 11:53:12.878116772 +0200
> +++ a/drivers/staging/slicoss/slicoss.c 2008-11-04 12:08:40.800644774 +0200
> @@ -2673,8 +2673,8 @@
> static·int·slic_card_init(struct·sliccar
> #if·SLIC_DUMP_ENABLED
> » if·(!card->dumpbuffer)·{
> -» » card->dumpbuffer·=·kmalloc(DUMP_PAGE_SIZE,·GFP_ATOMIC);
> +» » card->dumpbuffer·=·kzalloc(DUMP_PAGE_SIZE,·GFP_ATOMIC);
> » » ASSERT(card->dumpbuffer);
> » » if·(card->dumpbuffer·==·NULL)
> @@ -2683,8 +2683,7 @@
> static·int·slic_card_init(struct·sliccar
> » ·*··Smear·the·shared·memory·structure·and·then·obtain
> » ·*··the·PHYSICAL·address·of·this·structure
> » ·*/
> -» memset(card->dumpbuffer,·0,·DUMP_PAGE_SIZE);
>
>
> It's wrong, the function in called multiple times, the memset was called every
> time, now it would be called only for the first time.
You are right, thanks. Here's a fixed version.
This patch uses kzalloc() where really applicable.
Signed-off-by: Lior Dotan <liodot@gmail.com>
[-- Attachment #2: slicoss-kzalloc.patch --]
[-- Type: text/plain, Size: 571 bytes --]
--- b/drivers/staging/slicoss/slicoss.c 2008-11-05 11:21:13.697789873 +0200
+++ a/drivers/staging/slicoss/slicoss.c 2008-11-05 11:24:00.768399196 +0200
@@ -2833,9 +2833,8 @@ static u32 slic_card_locate(struct adapt
}
if (!physcard) {
/* no structure allocated for this physical card yet */
- physcard = kmalloc(sizeof(struct physcard *), GFP_ATOMIC);
+ physcard = kzalloc(sizeof(struct physcard *), GFP_ATOMIC);
ASSERT(physcard);
- memset(physcard, 0, sizeof(struct physcard *));
DBG_MSG
("\n%s Allocate a PHYSICALcard:\n PHYSICAL_Card[%p]\n\
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [STAGING] slicoss - use kzalloc
2008-11-05 9:27 ` Lior Dotan
@ 2008-11-05 9:35 ` Jiri Slaby
2008-11-05 9:52 ` Lior Dotan
0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2008-11-05 9:35 UTC (permalink / raw)
To: Lior Dotan; +Cc: gregkh, linux-kernel, charrer
On 11/05/2008 10:27 AM, Lior Dotan wrote:
> This patch uses kzalloc() where really applicable.
ack this, but there is another problem.
sizeof(struct physcard *) is wrong size for that allocation, care to send a fix
for this (and revice the rest of allocations)? I wonder how this could work with
SLAB_DEBUG on, maybe nobody tried...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [STAGING] slicoss - use kzalloc
2008-11-05 9:35 ` Jiri Slaby
@ 2008-11-05 9:52 ` Lior Dotan
2008-11-08 14:18 ` Jiri Slaby
0 siblings, 1 reply; 6+ messages in thread
From: Lior Dotan @ 2008-11-05 9:52 UTC (permalink / raw)
To: Jiri Slaby, gregkh; +Cc: linux-kernel, charrer
[-- Attachment #1: Type: text/plain, Size: 599 bytes --]
> On 11/05/2008 10:27 AM, Lior Dotan wrote:
>> This patch uses kzalloc() where really applicable.
>
> ack this, but there is another problem.
>
> sizeof(struct physcard *) is wrong size for that allocation, care to send a fix
> for this (and revice the rest of allocations)? I wonder how this could work with
Fix attached. I only found two other places with the same problem.
> SLAB_DEBUG on, maybe nobody tried...
AFAIK there aren't a lot of testers for this drivers so the few that
does probably didn't try it.
Fix sizeof to use the right type
Signed-off-by: Lior Dotan <liodot@gmail.com>
[-- Attachment #2: slicoss-fix-sizeof.patch --]
[-- Type: text/plain, Size: 1190 bytes --]
--- b/drivers/staging/slicoss/slicoss.c 2008-11-05 11:39:42.017791088 +0200
+++ a/drivers/staging/slicoss/slicoss.c 2008-11-05 11:48:16.237808996 +0200
@@ -323,7 +323,7 @@ static void slic_init_adapter(struct net
index, pslic_handle, adapter->pfree_slic_handles, pslic_handle->next);*/
adapter->pshmem = (struct slic_shmem *)
pci_alloc_consistent(adapter->pcidev,
- sizeof(struct slic_shmem *),
+ sizeof(struct slic_shmem),
&adapter->
phys_shmem);
/*
@@ -1432,7 +1432,7 @@ static void slic_init_cleanup(struct ada
DBG_MSG("adapter[%p] port %d pshmem[%p] FreeShmem ",
adapter, adapter->port, (void *) adapter->pshmem);
pci_free_consistent(adapter->pcidev,
- sizeof(struct slic_shmem *),
+ sizeof(struct slic_shmem),
adapter->pshmem, adapter->phys_shmem);
adapter->pshmem = NULL;
adapter->phys_shmem = (dma_addr_t) NULL;
@@ -2833,7 +2833,7 @@ static u32 slic_card_locate(struct adapt
}
if (!physcard) {
/* no structure allocated for this physical card yet */
- physcard = kzalloc(sizeof(struct physcard *), GFP_ATOMIC);
+ physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
ASSERT(physcard);
DBG_MSG
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [STAGING] slicoss - use kzalloc
2008-11-05 9:52 ` Lior Dotan
@ 2008-11-08 14:18 ` Jiri Slaby
0 siblings, 0 replies; 6+ messages in thread
From: Jiri Slaby @ 2008-11-08 14:18 UTC (permalink / raw)
To: Lior Dotan; +Cc: gregkh, linux-kernel, charrer
On 11/05/2008 10:52 AM, Lior Dotan wrote:
> Fix sizeof to use the right type
Well, next step might be to investigate which allocs might be GFP_KERNEL instead
of GFP_ATOMIC if you want to play with that ;).
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-11-08 14:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-04 16:27 [STAGING] slicoss - use kzalloc Lior Dotan
2008-11-04 22:01 ` Jiri Slaby
2008-11-05 9:27 ` Lior Dotan
2008-11-05 9:35 ` Jiri Slaby
2008-11-05 9:52 ` Lior Dotan
2008-11-08 14:18 ` Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).