From 3255bcf09375f7c72993b4ee871bb0517ad2f698 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:52 +0100 Subject: [PATCH] remove function _rtw_zvmalloc Remove the function _rtw_zvmalloc from os_dep/osdep_service.c, as this function is now unused and is just an inline wrapper around vmalloc which zeroes out the memory. All previous callers have been converted to use vzalloc. 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-7-phil@philpotter.co.uk --- include/osdep_service.h | 25 ------------------ os_dep/osdep_service.c | 56 ----------------------------------------- 2 files changed, 81 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index 585870a..6fc4ae0 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -106,10 +106,6 @@ extern int RTW_STATUS_CODE(int error_code); -#ifndef RTK_DMP_PLATFORM - #define CONFIG_USE_VMALLOC -#endif - /* flags used for rtw_mstat_update() */ enum mstat_f { /* type: 0x00ff */ @@ -143,8 +139,6 @@ typedef enum mstat_status { void rtw_mstat_update(const enum mstat_f flags, const MSTAT_STATUS status, u32 sz); void rtw_mstat_dump(void *sel); bool match_mstat_sniff_rules(const enum mstat_f flags, const size_t size); -void *dbg_rtw_vmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); -void *dbg_rtw_zvmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); void dbg_rtw_vmfree(void *pbuf, const enum mstat_f flags, u32 sz, const char *func, const int line); void *dbg_rtw_malloc(u32 sz, const enum mstat_f flags, const char *func, const int line); void *dbg_rtw_zmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); @@ -167,15 +161,6 @@ void *dbg_rtw_usb_buffer_alloc(struct usb_device *dev, size_t size, dma_addr_t * void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma, const enum mstat_f flags, const char *func, const int line); #endif /* CONFIG_USB_HCI */ -#ifdef CONFIG_USE_VMALLOC -#define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_vmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zvmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_vmfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#else /* CONFIG_USE_VMALLOC */ -#define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_malloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_mfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#endif /* CONFIG_USE_VMALLOC */ #define rtw_malloc(sz) dbg_rtw_malloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zmalloc(sz) dbg_rtw_zmalloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_mfree(pbuf, sz) dbg_rtw_mfree((pbuf), (sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) @@ -210,7 +195,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_dump(sel) do {} while (0) #define match_mstat_sniff_rules(flags, size) _FALSE -void *_rtw_zvmalloc(u32 sz); void *_rtw_zmalloc(u32 sz); void *_rtw_malloc(u32 sz); void _rtw_mfree(void *pbuf, u32 sz); @@ -233,15 +217,6 @@ void *_rtw_usb_buffer_alloc(struct usb_device *dev, size_t size, dma_addr_t *dma void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma); #endif /* CONFIG_USB_HCI */ -#ifdef CONFIG_USE_VMALLOC -#define rtw_vmalloc_f(sz, mstat_f) vmalloc((sz)) -#define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) -#define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) -#else /* CONFIG_USE_VMALLOC */ -#define rtw_vmalloc_f(sz, mstat_f) _rtw_malloc((sz)) -#define rtw_zvmalloc_f(sz, mstat_f) _rtw_zmalloc((sz)) -#define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_mfree((pbuf), (sz)) -#endif /* CONFIG_USE_VMALLOC */ #define rtw_malloc(sz) _rtw_malloc((sz)) #define rtw_zmalloc(sz) _rtw_zmalloc((sz)) #define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index d5e9c87..d3714a8 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -65,26 +65,6 @@ u32 rtw_atoi(u8 *s) } -inline void *_rtw_zvmalloc(u32 sz) -{ - void *pbuf; -#ifdef PLATFORM_LINUX - pbuf = vmalloc(sz); - if (pbuf != NULL) - memset(pbuf, 0, sz); -#endif -#ifdef PLATFORM_FREEBSD - pbuf = malloc(sz, M_DEVBUF, M_ZERO | M_NOWAIT); -#endif -#ifdef PLATFORM_WINDOWS - NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG); - if (pbuf != NULL) - NdisFillMemory(pbuf, sz, 0); -#endif - - return pbuf; -} - void *_rtw_malloc(u32 sz) { void *pbuf = NULL; @@ -514,42 +494,6 @@ bool match_mstat_sniff_rules(const enum mstat_f flags, const size_t size) return _FALSE; } -inline void *dbg_rtw_vmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line) -{ - void *p; - - if (match_mstat_sniff_rules(flags, sz)) - RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - - p = vmalloc(sz); - - rtw_mstat_update( - flags - , p ? MSTAT_ALLOC_SUCCESS : MSTAT_ALLOC_FAIL - , sz - ); - - return p; -} - -inline void *dbg_rtw_zvmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line) -{ - void *p; - - if (match_mstat_sniff_rules(flags, sz)) - RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - - p = _rtw_zvmalloc((sz)); - - rtw_mstat_update( - flags - , p ? MSTAT_ALLOC_SUCCESS : MSTAT_ALLOC_FAIL - , sz - ); - - return p; -} - inline void dbg_rtw_vmfree(void *pbuf, u32 sz, const enum mstat_f flags, const char *func, const int line) {