staging: csr: remove CsrMemAlloc()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Jul 2012 22:37:12 +0000 (15:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Jul 2012 22:37:12 +0000 (15:37 -0700)
It's just calling kmalloc(, GFP_KERNEL), so call that instead.
A few places should be calling kzalloc(), so do that, and remove the
call to memset at the same time.

Cc: Mikko Virkkilä <mikko.virkkila@bluegiga.com>
Cc: Lauri Hintsala <Lauri.Hintsala@bluegiga.com>
Cc: Riku Mettälä <riku.mettala@bluegiga.com>
Cc: Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/csr/csr_framework_ext.c
drivers/staging/csr/csr_framework_ext.h
drivers/staging/csr/csr_wifi_hip_card_sdio.c
drivers/staging/csr/csr_wifi_hip_download.c
drivers/staging/csr/csr_wifi_hip_dump.c
drivers/staging/csr/csr_wifi_hip_xbv.c
drivers/staging/csr/io.c

index 22345e80467fe37531836e0e258fb3dc97457b82..a34d2632ae223bb8a6d684ca9e02d52f14871f95 100644 (file)
@@ -176,24 +176,6 @@ void *CsrMemCalloc(size_t numberOfElements, size_t elementSize)
     return buf;
 }
 
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrMemAlloc
- *
- *  DESCRIPTION
- *      Allocate dynamic memory of a given size.
- *
- *  RETURNS
- *      Pointer to allocated memory, or NULL in case of failure.
- *      Allocated memory is not initialised.
- *
- *----------------------------------------------------------------------------*/
-void *CsrMemAlloc(size_t size)
-{
-    return kmalloc(size, GFP_KERNEL);
-}
-EXPORT_SYMBOL_GPL(CsrMemAlloc);
-
 /*----------------------------------------------------------------------------*
  *  NAME
  *      CsrMemAllocDma
index a3fc152990752a481ff4296eaecfa27227f10a4e..141f2884688f8dcf16513ff1c3164b392a5fe1a0 100644 (file)
@@ -242,26 +242,6 @@ CsrResult CsrThreadEqual(CsrThreadHandle *threadHandle1, CsrThreadHandle *thread
 void CsrThreadSleep(u16 sleepTimeInMs);
 
 #ifndef CSR_PMEM_DEBUG_ENABLE
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrMemAlloc
- *
- *  DESCRIPTION
- *      Allocate dynamic memory of a given size.
- *
- *  RETURNS
- *      Pointer to allocated memory, or NULL in case of failure.
- *      Allocated memory is not initialised.
- *
- *----------------------------------------------------------------------------*/
-#ifdef CSR_MEM_DEBUG
-void *CsrMemAllocDebug(size_t size,
-    const char *file, u32 line);
-#define CsrMemAlloc(sz) CsrMemAllocDebug((sz), __FILE__, __LINE__)
-#else
-void *CsrMemAlloc(size_t size);
-#endif
-
 /*----------------------------------------------------------------------------*
  *  NAME
  *      CsrMemCalloc
@@ -308,8 +288,6 @@ void *CsrMemAllocDma(size_t size);
 
 #include "csr_pmem.h"
 
-#define CsrMemAlloc(size) CsrPmemDebugAlloc(size, CSR_PMEM_DEBUG_TYPE_MEM_ALLOC, __FILE__, __LINE__)
-
 #define CsrMemCalloc(numberOfElements, elementSize) CsrPmemDebugAlloc((numberOfElements * elementSize), CSR_PMEM_DEBUG_TYPE_MEM_CALLOC, __FILE__, __LINE__)
 
 #define CsrMemAllocDma(size) CsrPmemDebugAlloc(size, CSR_PMEM_DEBUG_TYPE_MEM_ALLOC_DMA, __FILE__, __LINE__)
index 4f2d2e3e45bb56c429fee65ef7cdadded2a2be6a..608a0690d5e051060be57c13103a6fb2c9c09b96 100644 (file)
@@ -73,13 +73,11 @@ card_t* unifi_alloc_card(CsrSdioFunction *sdio, void *ospriv)
     func_enter();
 
 
-    card = (card_t *)CsrMemAlloc(sizeof(card_t));
+    card = kzalloc(sizeof(card_t), GFP_KERNEL);
     if (card == NULL)
     {
         return NULL;
     }
-    memset(card, 0, sizeof(card_t));
-
 
     card->sdio_if = sdio;
     card->ospriv  = ospriv;
@@ -1665,8 +1663,7 @@ static CsrResult card_allocate_memory_resources(card_t *card)
     n = cfg_data->num_fromhost_data_slots;
 
     unifi_trace(card->ospriv, UDBG3, "Alloc from-host resources, %d slots.\n", n);
-    card->from_host_data =
-        (slot_desc_t *)CsrMemAlloc(n * sizeof(slot_desc_t));
+    card->from_host_data = kmalloc(n * sizeof(slot_desc_t), GFP_KERNEL);
     if (card->from_host_data == NULL)
     {
         unifi_error(card->ospriv, "Failed to allocate memory for F-H bulk data array\n");
@@ -1681,8 +1678,7 @@ static CsrResult card_allocate_memory_resources(card_t *card)
     }
 
     /* Allocate memory for the array used for slot host tag mapping */
-    card->fh_slot_host_tag_record =
-        (u32 *)CsrMemAlloc(n * sizeof(u32));
+    card->fh_slot_host_tag_record = kmalloc(n * sizeof(u32), GFP_KERNEL);
 
     if (card->fh_slot_host_tag_record == NULL)
     {
@@ -1702,8 +1698,7 @@ static CsrResult card_allocate_memory_resources(card_t *card)
     n = cfg_data->num_tohost_data_slots;
 
     unifi_trace(card->ospriv, UDBG3, "Alloc to-host resources, %d slots.\n", n);
-    card->to_host_data =
-        (bulk_data_desc_t *)CsrMemAlloc(n * sizeof(bulk_data_desc_t));
+    card->to_host_data = kmalloc(n * sizeof(bulk_data_desc_t), GFP_KERNEL);
     if (card->to_host_data == NULL)
     {
         unifi_error(card->ospriv, "Failed to allocate memory for T-H bulk data array\n");
index 1a1dfb628450bd5ff136fdea92f04a792ac5be08..f0f0ffd89d622512a98475fe4fda2f948a3c38a5 100644 (file)
@@ -327,7 +327,7 @@ CsrResult unifi_dl_firmware(card_t *card, void *dlpriv)
 
     func_enter();
 
-    fwinfo = CsrMemAlloc(sizeof(xbv1_t));
+    fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
     if (fwinfo == NULL)
     {
         unifi_error(card->ospriv, "Failed to allocate memory for firmware\n");
@@ -409,7 +409,7 @@ CsrResult unifi_dl_patch(card_t *card, void *dlpriv, u32 boot_ctrl)
 
     unifi_info(card->ospriv, "unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl);
 
-    fwinfo = CsrMemAlloc(sizeof(xbv1_t));
+    fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
     if (fwinfo == NULL)
     {
         unifi_error(card->ospriv, "Failed to allocate memory for patches\n");
index 350d9d20448855d467b4f826369740100cf43083..d67b460e7a85db730cab0ef51880a972cda81ac2 100644 (file)
@@ -667,24 +667,19 @@ coredump_buffer* new_coredump_node(void *ospriv, coredump_buffer *prevnode)
     u32 zone_size;
 
     /* Allocate node header */
-    newnode = (coredump_buffer *)CsrMemAlloc(sizeof(coredump_buffer));
+    newnode = kzalloc(sizeof(coredump_buffer), GFP_KERNEL);
     if (newnode == NULL)
     {
         return NULL;
     }
-    memset(newnode, 0, sizeof(coredump_buffer));
 
     /* Allocate chip memory zone capture buffers */
     for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++)
     {
         zone_size = sizeof(u16) * zonedef_table[i].length;
-        newzone = (u16 *)CsrMemAlloc(zone_size);
+        newzone = kzalloc(zone_size, GFP_KERNEL);
         newnode->zone[i] = newzone;
-        if (newzone != NULL)
-        {
-            memset(newzone, 0, zone_size);
-        }
-        else
+        if (newzone == NULL)
         {
             unifi_error(ospriv, "Out of memory on coredump zone %d (%d words)\n",
                         i, zonedef_table[i].length);
index 3016e63e212cfb58654e4c23b2a746578ada9fc0..071f80a49f1983c757107fbdaf75eab100d0adde 100644 (file)
@@ -994,7 +994,7 @@ void* xbv_to_patch(card_t *card, fwreadfn_t readfn,
     }
 
     /* Pre-allocate read buffer for chunk conversion */
-    rdbuf = CsrMemAlloc(PTDL_MAX_SIZE);
+    rdbuf = kmalloc(PTDL_MAX_SIZE, GFP_KERNEL);
     if (!rdbuf)
     {
         unifi_error(card, "Couldn't alloc conversion buffer\n");
@@ -1019,7 +1019,7 @@ void* xbv_to_patch(card_t *card, fwreadfn_t readfn,
      */
     patch_buf_size = calc_patch_size(fwinfo);
 
-    patch_buf = (void *)CsrMemAlloc(patch_buf_size);
+    patch_buf = kmalloc(patch_buf_size, GFP_KERNEL);
     if (!patch_buf)
     {
         kfree(rdbuf);
index 38b5f7ee6486b43b0f28e30ce8391176a518235d..e6503d9620a4310152cc8045389a58e5f18b9fca 100644 (file)
@@ -99,7 +99,7 @@ static CsrResult signal_buffer_init(unifi_priv_t * priv, int size)
     for(i=0; i<size; i++)
     {
          priv->rxSignalBuffer.rx_buff[i].sig_len=0;
-         priv->rxSignalBuffer.rx_buff[i].bufptr = CsrMemAlloc(UNIFI_PACKED_SIGBUF_SIZE);
+         priv->rxSignalBuffer.rx_buff[i].bufptr = kmalloc(UNIFI_PACKED_SIGBUF_SIZE, GFP_KERNEL);
          if (priv->rxSignalBuffer.rx_buff[i].bufptr == NULL)
          {
              int j;