Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 786eeeb3 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

staging: csr: remove CsrPmemAlloc



It's just a wrapper around kmalloc(, GFP_KERNEL) + a call to panic() if
we are out of memory, which is a very foolish thing to do (the panic
that is.)

So replace it with calls to kmalloc() and ignore the out-of-memory
casese for now, odds are it will not be hit, and if it does, hey, we
will end up panicing just the same as with the old code.

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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 55a27055
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ csr_wifi-y := bh.o \
csr_helper-y :=	csr_time.o			\
		csr_util.o			\
		csr_framework_ext.o		\
		csr_pmem.o			\
		csr_wifi_serialize_primitive_types.o	\
		csr_serialize_primitive_types.o	\
		csr_utf16.o			\
+2 −2
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce)
    }
    else
    {
        pc = CsrPmemAlloc(sizeof(*pc));
        pc = kmalloc(sizeof(*pc), GFP_KERNEL);
        pc->primType = primType;
        pc->conv = ce;
        pc->lookupFunc = NULL;
@@ -279,7 +279,7 @@ CsrMsgConvEntry *CsrMsgConvInit(void)
{
    if (!converter)
    {
        converter = (CsrMsgConvEntry *) CsrPmemAlloc(sizeof(CsrMsgConvEntry));
        converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);

        converter->profile_converters = NULL;
        converter->free_message = free_message;

drivers/staging/csr/csr_pmem.c

deleted100644 → 0
+0 −40
Original line number Diff line number Diff line
/*****************************************************************************

            (c) Cambridge Silicon Radio Limited 2010
            All rights reserved and confidential information of CSR

            Refer to LICENSE.txt included with this source for details
            on the license terms.

*****************************************************************************/

#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>


#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
#include <linux/autoconf.h>
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
#include <linux/config.h>
#endif

#include <linux/slab.h>

#include "csr_panic.h"
#include "csr_pmem.h"

void *CsrPmemAlloc(size_t size)
{
    void *ret;

    ret = kmalloc(size, GFP_KERNEL);
    if (!ret)
    {
        CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_HEAP_EXHAUSTION,
            "out of memory");
    }

    return ret;
}
EXPORT_SYMBOL_GPL(CsrPmemAlloc);
+0 −31
Original line number Diff line number Diff line
@@ -17,36 +17,6 @@
extern "C" {
#endif

#ifndef CSR_PMEM_DEBUG_ENABLE
/*****************************************************************************

    NAME
        CsrPmemAlloc

    DESCRIPTION
        This function will allocate a contiguous block of memory of at least
        the specified size in bytes and return a pointer to the allocated
        memory. This function is not allowed to return NULL. A size of 0 is a
        valid request, and a unique and valid (not NULL) pointer must be
        returned in this case.

    PARAMETERS
        size - Size of memory requested. Note that a size of 0 is valid.

    RETURNS
        Pointer to allocated memory.

*****************************************************************************/
#ifdef CSR_PMEM_DEBUG
void *CsrPmemAllocDebug(size_t size,
    const char *file, u32 line);
#define CsrPmemAlloc(sz) CsrPmemAllocDebug((sz), __FILE__, __LINE__)
#else
void *CsrPmemAlloc(size_t size);
#endif

#endif

/*****************************************************************************

    NAME
@@ -114,7 +84,6 @@ typedef void (CsrPmemDebugOnFree)(void *ptr, void *userptr, CsrPmemDebugAllocTyp
void CsrPmemDebugInstallHooks(u8 headSize, u8 endSize, CsrPmemDebugOnAlloc *onAllocCallback, CsrPmemDebugOnFree *onFreeCallback);

void *CsrPmemDebugAlloc(size_t size, CsrPmemDebugAllocType type, const char* file, u32 line);
#define CsrPmemAlloc(size) CsrPmemDebugAlloc(size, CSR_PMEM_DEBUG_TYPE_PMEM_ALLOC, __FILE__, __LINE__)

void CsrPmemDebugFree(void *ptr, CsrPmemDebugAllocType type, const char* file, u32 line);

+2 −2
Original line number Diff line number Diff line
@@ -120,9 +120,9 @@ void CsrSchedBgintSet(CsrSchedBgint bgint);
 *      be null.
 *
 *  NOTE
 *      If "mv" is not null then it will typically be a chunk of CsrPmemAlloc()ed
 *      If "mv" is not null then it will typically be a chunk of kmalloc()ed
 *      memory, though there is no need for it to be so. Tasks should normally
 *      obey the convention that when a message built with CsrPmemAlloc()ed memory
 *      obey the convention that when a message built with kmalloc()ed memory
 *      is given to CsrSchedMessagePut() then ownership of the memory is ceded to the
 *      scheduler - and eventually to the recipient task. I.e., the receiver of
 *      the message will be expected to kfree() the message storage.
Loading