Minor fixes and cleanup

This commit is contained in:
kimocoder 2023-05-02 02:11:29 +02:00
parent 62821699bb
commit 357faf7221
4 changed files with 15 additions and 214 deletions

View File

@ -15,11 +15,6 @@ EXTRA_CFLAGS += -Wno-unknown-pragmas
EXTRA_CFLAGS += -Wno-address
EXTRA_CFLAGS += -Wno-vla -g
#GCC_VER_49 := $(shell echo `$(CC) -dumpversion | cut -f1-2 -d.` \>= 4.9 | bc )
#ifeq ($(GCC_VER_49),1)
#EXTRA_CFLAGS += -Wno-date-time # Fix compile error && warning on gcc 4.9 and later
#endif
EXTRA_CFLAGS += -I$(src)/include -I$(srctree)/$(src)/include
EXTRA_CFLAGS += -I$(src)/hal/phydm -I$(srctree)/$(src)/hal/phydm
EXTRA_LDFLAGS += --strip-all -O3

View File

@ -32,33 +32,18 @@ enum {
extern void rtl871x_cedbg(const char *fmt, ...);
#endif
#ifdef PLATFORM_WINDOWS
#define RTW_PRINT do {} while (0)
#define RTW_ERR do {} while (0)
#define RTW_WARN do {} while (0)
#define RTW_INFO do {} while (0)
#define RTW_DBG do {} while (0)
#define RTW_PRINT_SEL do {} while (0)
#define _RTW_PRINT do {} while (0)
#define _RTW_ERR do {} while (0)
#define _RTW_WARN do {} while (0)
#define _RTW_INFO do {} while (0)
#define _RTW_DBG do {} while (0)
#define _RTW_PRINT_SEL do {} while (0)
#else
#define RTW_PRINT(x, ...) do {} while (0)
#define RTW_ERR(x, ...) do {} while (0)
#define RTW_WARN(x,...) do {} while (0)
#define RTW_INFO(x,...) do {} while (0)
#define RTW_DBG(x,...) do {} while (0)
#define RTW_PRINT_SEL(x,...) do {} while (0)
#define _RTW_PRINT(x, ...) do {} while (0)
#define _RTW_ERR(x, ...) do {} while (0)
#define _RTW_WARN(x,...) do {} while (0)
#define _RTW_INFO(x,...) do {} while (0)
#define _RTW_DBG(x,...) do {} while (0)
#define _RTW_PRINT_SEL(x,...) do {} while (0)
#endif
#define RTW_PRINT(x, ...) do {} while (0)
#define RTW_ERR(x, ...) do {} while (0)
#define RTW_WARN(x,...) do {} while (0)
#define RTW_INFO(x,...) do {} while (0)
#define RTW_DBG(x,...) do {} while (0)
#define RTW_PRINT_SEL(x,...) do {} while (0)
#define _RTW_PRINT(x, ...) do {} while (0)
#define _RTW_ERR(x, ...) do {} while (0)
#define _RTW_WARN(x,...) do {} while (0)
#define _RTW_INFO(x,...) do {} while (0)
#define _RTW_DBG(x,...) do {} while (0)
#define _RTW_PRINT_SEL(x,...) do {} while (0)
#define RTW_INFO_DUMP(_TitleString, _HexData, _HexDataLen) do {} while (0)
#define RTW_DBG_DUMP(_TitleString, _HexData, _HexDataLen) do {} while (0)
@ -68,8 +53,6 @@ extern void rtl871x_cedbg(const char *fmt, ...);
#define RTW_DBGDUMP 0 /* 'stream' for _dbgdump */
#undef _dbgdump
#undef _seqdump
@ -77,10 +60,6 @@ extern void rtl871x_cedbg(const char *fmt, ...);
#define _dbgdump DbgPrint
#define KERN_CONT
#define _seqdump(sel, fmt, arg...) _dbgdump(fmt, ##arg)
#elif defined(PLATFORM_WINDOWS) && defined(PLATFORM_OS_CE)
#define _dbgdump rtl871x_cedbg
#define KERN_CONT
#define _seqdump(sel, fmt, arg...) _dbgdump(fmt, ##arg)
#elif defined PLATFORM_LINUX
#define _dbgdump printk
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))

View File

@ -1155,12 +1155,10 @@ check_bss:
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0))
roam_info.links[0].channel = notify_channel;
roam_info.links[0].bssid = cur_network->network.MacAddress;
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
roam_info.channel = notify_channel;
roam_info.bssid = cur_network->network.MacAddress;
#endif
#endif
roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2;
roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2;
roam_info.resp_ie = pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6;

View File

@ -85,10 +85,6 @@ inline void *_rtw_vmalloc(u32 sz)
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) {
@ -112,11 +108,6 @@ inline void *_rtw_zvmalloc(u32 sz)
#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;
}
@ -129,9 +120,6 @@ inline void _rtw_vmfree(void *pbuf, u32 sz)
#ifdef PLATFORM_FREEBSD
free(pbuf, M_DEVBUF);
#endif
#ifdef PLATFORM_WINDOWS
NdisFreeMemory(pbuf, sz, 0);
#endif
#ifdef DBG_MEMORY_LEAK
#ifdef PLATFORM_LINUX
@ -157,11 +145,6 @@ void *_rtw_malloc(u32 sz)
#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
@ -190,10 +173,6 @@ void *_rtw_zmalloc(u32 sz)
memset(pbuf, 0, sz);
#endif
#ifdef PLATFORM_WINDOWS
NdisFillMemory(pbuf, sz, 0);
#endif
}
return pbuf;
@ -215,11 +194,6 @@ void _rtw_mfree(void *pbuf, u32 sz)
#ifdef PLATFORM_FREEBSD
free(pbuf, M_DEVBUF);
#endif
#ifdef PLATFORM_WINDOWS
NdisFreeMemory(pbuf, sz, 0);
#endif
#ifdef DBG_MEMORY_LEAK
#ifdef PLATFORM_LINUX
@ -933,12 +907,6 @@ void _rtw_memcpy(void *dst, const void *src, u32 sz)
#endif
#ifdef PLATFORM_WINDOWS
NdisMoveMemory(dst, src, sz);
#endif
}
inline void _rtw_memmove(void *dst, const void *src, u32 sz)
@ -962,19 +930,6 @@ int _rtw_memcmp(const void *dst, const void *src, u32 sz)
return _FALSE;
#endif
#ifdef PLATFORM_WINDOWS
/* under Windows, the return value of NdisEqualMemory for two same mem. chunk is 1 */
if (NdisEqualMemory(dst, src, sz))
return _TRUE;
else
return _FALSE;
#endif
}
void _rtw_memset(void *pbuf, int c, u32 sz)
@ -986,16 +941,6 @@ void _rtw_memset(void *pbuf, int c, u32 sz)
#endif
#ifdef PLATFORM_WINDOWS
#if 0
NdisZeroMemory(pbuf, sz);
if (c != 0)
memset(pbuf, c, sz);
#else
NdisFillMemory(pbuf, sz, c);
#endif
#endif
}
#ifdef PLATFORM_FREEBSD
@ -1022,11 +967,6 @@ void _rtw_init_listhead(_list *list)
list->next = list;
list->prev = list;
#endif
#ifdef PLATFORM_WINDOWS
NdisInitializeListHead(list);
#endif
}
@ -1056,17 +996,6 @@ u32 rtw_is_list_empty(_list *phead)
#endif
#ifdef PLATFORM_WINDOWS
if (IsListEmpty(phead))
return _TRUE;
else
return _FALSE;
#endif
}
void rtw_list_insert_head(_list *plist, _list *phead)
@ -1080,9 +1009,6 @@ void rtw_list_insert_head(_list *plist, _list *phead)
__list_add(plist, phead, phead->next);
#endif
#ifdef PLATFORM_WINDOWS
InsertHeadList(phead, plist);
#endif
}
void rtw_list_insert_tail(_list *plist, _list *phead)
@ -1097,11 +1023,6 @@ void rtw_list_insert_tail(_list *plist, _list *phead)
__list_add(plist, phead->prev, phead);
#endif
#ifdef PLATFORM_WINDOWS
InsertTailList(phead, plist);
#endif
}
@ -1193,9 +1114,6 @@ void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc, void *ctx)
#ifdef PLATFORM_FREEBSD
_init_timer(ptimer, adapter->pifp, pfunc, ctx);
#endif
#ifdef PLATFORM_WINDOWS
_init_timer(ptimer, adapter->hndis_adapter, pfunc, ctx);
#endif
}
/*
@ -1454,15 +1372,8 @@ void _rtw_spinunlock_ex(_lock *plock)
#ifdef PLATFORM_FREEBSD
mtx_unlock(plock);
#endif
#ifdef PLATFORM_WINDOWS
NdisDprReleaseSpinLock(plock);
#endif
}
void _rtw_init_queue(_queue *pqueue)
{
_rtw_init_listhead(&(pqueue->queue));
@ -1500,11 +1411,6 @@ systime _rtw_get_current_time(void)
getmicrotime(&tvp);
return tvp.tv_sec;
#endif
#ifdef PLATFORM_WINDOWS
LARGE_INTEGER SystemTime;
NdisGetCurrentSystemTime(&SystemTime);
return SystemTime.LowPart;/* count of 100-nanosecond intervals */
#endif
}
inline u32 _rtw_systime_to_ms(systime stime)
@ -1515,9 +1421,6 @@ inline u32 _rtw_systime_to_ms(systime stime)
#ifdef PLATFORM_FREEBSD
return stime * 1000;
#endif
#ifdef PLATFORM_WINDOWS
return stime / 10000 ;
#endif
}
inline systime _rtw_ms_to_systime(u32 ms)
@ -1528,9 +1431,6 @@ inline systime _rtw_ms_to_systime(u32 ms)
#ifdef PLATFORM_FREEBSD
return ms / 1000;
#endif
#ifdef PLATFORM_WINDOWS
return ms * 10000 ;
#endif
}
inline systime _rtw_us_to_systime(u32 us)
@ -1589,15 +1489,8 @@ void rtw_sleep_schedulable(int ms)
return ;
#endif
#ifdef PLATFORM_WINDOWS
NdisMSleep(ms * 1000); /* (us)*1000=(ms) */
#endif
}
void rtw_msleep_os(int ms)
{
@ -1616,13 +1509,6 @@ void rtw_msleep_os(int ms)
DELAY(ms * 1000);
return ;
#endif
#ifdef PLATFORM_WINDOWS
NdisMSleep(ms * 1000); /* (us)*1000=(ms) */
#endif
}
void rtw_usleep_os(int us)
{
@ -1645,16 +1531,8 @@ void rtw_usleep_os(int us)
return ;
#endif
#ifdef PLATFORM_WINDOWS
NdisMSleep(us); /* (us) */
#endif
}
#ifdef DBG_DELAY_OS
void _rtw_mdelay_os(int ms, const char *func, const int line)
{
@ -1672,10 +1550,6 @@ void _rtw_mdelay_os(int ms, const char *func, const int line)
mdelay((unsigned long)ms);
#elif defined(PLATFORM_WINDOWS)
NdisStallExecution(ms * 1000); /* (us)*1000=(ms) */
#endif
@ -1699,10 +1573,6 @@ void _rtw_udelay_os(int us, const char *func, const int line)
udelay((unsigned long)us);
#elif defined(PLATFORM_WINDOWS)
NdisStallExecution(us); /* (us) */
#endif
}
@ -1719,13 +1589,6 @@ void rtw_mdelay_os(int ms)
DELAY(ms * 1000);
return ;
#endif
#ifdef PLATFORM_WINDOWS
NdisStallExecution(ms * 1000); /* (us)*1000=(ms) */
#endif
}
void rtw_udelay_os(int us)
{
@ -1740,11 +1603,6 @@ void rtw_udelay_os(int us)
DELAY(us);
return ;
#endif
#ifdef PLATFORM_WINDOWS
NdisStallExecution(us); /* (us) */
#endif
}
#endif
@ -1757,9 +1615,6 @@ void rtw_yield_os(void)
#ifdef PLATFORM_FREEBSD
yield();
#endif
#ifdef PLATFORM_WINDOWS
SwitchToThread();
#endif
}
bool rtw_macaddr_is_larger(const u8 *a, const u8 *b)
@ -1924,8 +1779,6 @@ inline void ATOMIC_SET(ATOMIC_T *v, int i)
{
#ifdef PLATFORM_LINUX
atomic_set(v, i);
#elif defined(PLATFORM_WINDOWS)
*v = i; /* other choice???? */
#elif defined(PLATFORM_FREEBSD)
atomic_set_int(v, i);
#endif
@ -1935,8 +1788,6 @@ inline int ATOMIC_READ(ATOMIC_T *v)
{
#ifdef PLATFORM_LINUX
return atomic_read(v);
#elif defined(PLATFORM_WINDOWS)
return *v; /* other choice???? */
#elif defined(PLATFORM_FREEBSD)
return atomic_load_acq_32(v);
#endif
@ -1946,8 +1797,6 @@ inline void ATOMIC_ADD(ATOMIC_T *v, int i)
{
#ifdef PLATFORM_LINUX
atomic_add(i, v);
#elif defined(PLATFORM_WINDOWS)
InterlockedAdd(v, i);
#elif defined(PLATFORM_FREEBSD)
atomic_add_int(v, i);
#endif
@ -1956,8 +1805,6 @@ inline void ATOMIC_SUB(ATOMIC_T *v, int i)
{
#ifdef PLATFORM_LINUX
atomic_sub(i, v);
#elif defined(PLATFORM_WINDOWS)
InterlockedAdd(v, -i);
#elif defined(PLATFORM_FREEBSD)
atomic_subtract_int(v, i);
#endif
@ -1967,8 +1814,6 @@ inline void ATOMIC_INC(ATOMIC_T *v)
{
#ifdef PLATFORM_LINUX
atomic_inc(v);
#elif defined(PLATFORM_WINDOWS)
InterlockedIncrement(v);
#elif defined(PLATFORM_FREEBSD)
atomic_add_int(v, 1);
#endif
@ -1978,8 +1823,6 @@ inline void ATOMIC_DEC(ATOMIC_T *v)
{
#ifdef PLATFORM_LINUX
atomic_dec(v);
#elif defined(PLATFORM_WINDOWS)
InterlockedDecrement(v);
#elif defined(PLATFORM_FREEBSD)
atomic_subtract_int(v, 1);
#endif
@ -1989,8 +1832,6 @@ inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i)
{
#ifdef PLATFORM_LINUX
return atomic_add_return(i, v);
#elif defined(PLATFORM_WINDOWS)
return InterlockedAdd(v, i);
#elif defined(PLATFORM_FREEBSD)
atomic_add_int(v, i);
return atomic_load_acq_32(v);
@ -2001,8 +1842,6 @@ inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i)
{
#ifdef PLATFORM_LINUX
return atomic_sub_return(i, v);
#elif defined(PLATFORM_WINDOWS)
return InterlockedAdd(v, -i);
#elif defined(PLATFORM_FREEBSD)
atomic_subtract_int(v, i);
return atomic_load_acq_32(v);
@ -2013,8 +1852,6 @@ inline int ATOMIC_INC_RETURN(ATOMIC_T *v)
{
#ifdef PLATFORM_LINUX
return atomic_inc_return(v);
#elif defined(PLATFORM_WINDOWS)
return InterlockedIncrement(v);
#elif defined(PLATFORM_FREEBSD)
atomic_add_int(v, 1);
return atomic_load_acq_32(v);
@ -2025,8 +1862,6 @@ inline int ATOMIC_DEC_RETURN(ATOMIC_T *v)
{
#ifdef PLATFORM_LINUX
return atomic_dec_return(v);
#elif defined(PLATFORM_WINDOWS)
return InterlockedDecrement(v);
#elif defined(PLATFORM_FREEBSD)
atomic_subtract_int(v, 1);
return atomic_load_acq_32(v);
@ -2565,8 +2400,6 @@ u64 rtw_modular64(u64 x, u64 y)
{
#ifdef PLATFORM_LINUX
return do_div(x, y);
#elif defined(PLATFORM_WINDOWS)
return x % y;
#elif defined(PLATFORM_FREEBSD)
return x % y;
#endif
@ -2577,8 +2410,6 @@ u64 rtw_division64(u64 x, u64 y)
#ifdef PLATFORM_LINUX
do_div(x, y);
return x;
#elif defined(PLATFORM_WINDOWS)
return x / y;
#elif defined(PLATFORM_FREEBSD)
return x / y;
#endif
@ -2598,8 +2429,6 @@ inline u32 rtw_random32(void)
#else
return random32();
#endif
#elif defined(PLATFORM_WINDOWS)
#error "to be implemented\n"
#elif defined(PLATFORM_FREEBSD)
#error "to be implemented\n"
#endif