Skip to contentSkip to conversation

staging: cxt1e1: use kzalloc instead of kmalloc/memset 0

PATCH In review Daeseok Youn 2 participants 3 messages Mar 5, 2014 – Mar 6, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: cxt1e1: use kzalloc instead of kmalloc/memset 0

---
 drivers/staging/cxt1e1/sbecom_inline_linux.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/cxt1e1/sbecom_inline_linux.h +2 -4
index ba3ff3e..6dd1b55 100644
@@ -46,11 +46,9 @@ void        pci_write_32 (u_int32_t *p, u_int32_t v);
 static inline void *
 OS_kmalloc (size_t size)
 {
-    char       *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
+	char *ptr = kzalloc(size, GFP_KERNEL | GFP_DMA);
 
-    if (ptr)
-        memset (ptr, 0, size);
-    return ptr;
+	return ptr;
 }
 
 static inline void
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 12 lines · Daeseok Youn
---
 drivers/staging/cxt1e1/sbecom_inline_linux.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/cxt1e1/sbecom_inline_linux.h +0 -0
index ba3ff3e..6dd1b55 100644
@@ -46,11 +46,9 @@ void        pci_write_32 (u_int32_t *p, u_int32_t v);
 static inline void *

drivers/staging/cxt1e1/sbecom_inline_linux.h void pci_write_32 (u_int32_t *p, u_int32_t v); · line 52

Quoted 10 lines
drivers/staging/cxt1e1/sbecom_inline_linux.h +2 -4
 OS_kmalloc (size_t size)
 {
-    char       *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
+	char *ptr = kzalloc(size, GFP_KERNEL | GFP_DMA);
 
-    if (ptr)
-        memset (ptr, 0, size);
-    return ptr;
+	return ptr;
 }

It would probably be even better to get rid of this function altogether and replace all calls to it by kmalloc/kzalloc.

Quoted 1 line

From a quick look at the users of OS_kmalloc, it also looks like GFP_DMA

isn't needed for all of them.

Cheers
Tobias

#2 lore raw

Thanks for review.

OK. I will try to change all of OS_kmalloc to kmalloc/kzalloc. And I also check GFP_DMA flag in kmalloc/kzalloc.

Regards,
Daeseok Youn

2014-03-05 19:04 GMT+09:00 Tobias Klauser <[email protected]>:

Quoted 32 lines · Daeseok Youn
Quoted 12 lines
---
 drivers/staging/cxt1e1/sbecom_inline_linux.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/cxt1e1/sbecom_inline_linux.h +0 -0
index ba3ff3e..6dd1b55 100644
@@ -46,11 +46,9 @@ void        pci_write_32 (u_int32_t *p, u_int32_t v);
 static inline void *

drivers/staging/cxt1e1/sbecom_inline_linux.h void pci_write_32 (u_int32_t *p, u_int32_t v); · line 52

Quoted 10 lines
drivers/staging/cxt1e1/sbecom_inline_linux.h +2 -4
 OS_kmalloc (size_t size)
 {
-    char       *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
+     char *ptr = kzalloc(size, GFP_KERNEL | GFP_DMA);
 
-    if (ptr)
-        memset (ptr, 0, size);
-    return ptr;
+     return ptr;
 }

It would probably be even better to get rid of this function altogether and replace all calls to it by kmalloc/kzalloc.

From a quick look at the users of OS_kmalloc, it also looks like GFP_DMA isn't needed for all of them.

Cheers
Tobias