remove function _rtw_vmalloc

Remove the function _rtw_vmalloc from os_dep/osdep_service.c, converting
its only user (also in os_dep/osdep_service.c) to use plain vmalloc.
This function is just an inline wrapper around vmalloc which returns a u8
pointer, which isn't needed. Also remove the declaration from
include/osdep_service.h.

It is considered generally bad practice to declare functions as inline in
the majority of cases, as not only can this qualifier be ignored by the
compiler but the compiler generally makes good decisions about inlining
anyway.

Link: https://lore.kernel.org/r/20210818234853.208448-4-phil@philpotter.co.uk
This commit is contained in:
Phillip Potter 2021-08-19 00:48:49 +01:00 committed by Carlos Garcés
parent 6e2f371df5
commit 1f0cf855dc
2 changed files with 3 additions and 30 deletions

View File

@ -212,7 +212,6 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm
#define rtw_mstat_update(flag, status, sz) do {} while (0) #define rtw_mstat_update(flag, status, sz) do {} while (0)
#define rtw_mstat_dump(sel) do {} while (0) #define rtw_mstat_dump(sel) do {} while (0)
#define match_mstat_sniff_rules(flags, size) _FALSE #define match_mstat_sniff_rules(flags, size) _FALSE
void *_rtw_vmalloc(u32 sz);
void *_rtw_zvmalloc(u32 sz); void *_rtw_zvmalloc(u32 sz);
void *_rtw_zmalloc(u32 sz); void *_rtw_zmalloc(u32 sz);
void *_rtw_malloc(u32 sz); void *_rtw_malloc(u32 sz);
@ -238,7 +237,7 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a
#ifdef CONFIG_USE_VMALLOC #ifdef CONFIG_USE_VMALLOC
#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz))
#define rtw_vmalloc_f(sz, mstat_f) _rtw_vmalloc((sz)) #define rtw_vmalloc_f(sz, mstat_f) vmalloc((sz))
#define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz))
#define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz))
#else /* CONFIG_USE_VMALLOC */ #else /* CONFIG_USE_VMALLOC */

View File

@ -65,37 +65,11 @@ u32 rtw_atoi(u8 *s)
} }
inline void *_rtw_vmalloc(u32 sz)
{
void *pbuf;
#ifdef PLATFORM_LINUX
pbuf = vmalloc(sz);
#endif
#ifdef PLATFORM_FREEBSD
pbuf = malloc(sz, M_DEVBUF, M_NOWAIT);
#endif
#ifdef PLATFORM_WINDOWS
NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG);
#endif
#ifdef DBG_MEMORY_LEAK
#ifdef PLATFORM_LINUX
if (pbuf != NULL) {
atomic_inc(&_malloc_cnt);
atomic_add(sz, &_malloc_size);
}
#endif
#endif /* DBG_MEMORY_LEAK */
return pbuf;
}
inline void *_rtw_zvmalloc(u32 sz) inline void *_rtw_zvmalloc(u32 sz)
{ {
void *pbuf; void *pbuf;
#ifdef PLATFORM_LINUX #ifdef PLATFORM_LINUX
pbuf = _rtw_vmalloc(sz); pbuf = vmalloc(sz);
if (pbuf != NULL) if (pbuf != NULL)
memset(pbuf, 0, sz); memset(pbuf, 0, sz);
#endif #endif
@ -547,7 +521,7 @@ inline void *dbg_rtw_vmalloc(u32 sz, const enum mstat_f flags, const char *func,
if (match_mstat_sniff_rules(flags, sz)) if (match_mstat_sniff_rules(flags, sz))
RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz));
p = _rtw_vmalloc((sz)); p = vmalloc(sz);
rtw_mstat_update( rtw_mstat_update(
flags flags