mirror of https://gitee.com/openkylin/linux.git
staging: csr: remove CsrMemAlloc()
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>
This commit is contained in:
parent
4fe9db3710
commit
70128792b7
|
@ -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
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue