Skip to content

Commit

Permalink
net: Fix rtl8192cu build errors on other platforms
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Elwell <[email protected]>

suppress spurious messages

Add #if for 3.14 kernel change (#87)

Fixes compiling after changes in torvalds/linux@f663dd9 and torvalds/linux@99932d4

Fixes #86

Set dev_type to wlan

Fixes #23

Tentatively added support for more 8188CUS based devices.

Add support for more 8188CUS and 8192CUS devices

Add ProductId for the Netgear N150 - WNA1000M

Fixes CONFIG_CONCURRENT_MODE CONFIG_MULTI_VIR_IFACES

Fixes compatibility with 3.13

Enables warning in the compiler and fixes some issues, reference => https://github.com/diederikdehaas/rtl8812AU

Starts device in station mode instead of monitor, fixes NetworkManager issues

Enable cfg80211 support

Fix cfg80211 for kernel >= 4.7

Fixes rtl8192cu for kernel >= 4.8

rtl8192: Fixup build

fixup: rtl8192cu fixes from milhouse

rtl8192: switch to netdev->priv_destructor()

When trying to build from the rpi-4.11.y branch, I'm getting the
following error :

drivers/net/wireless/realtek/rtl8192cu/os_dep/linux/ioctl_cfg80211.c:3464:10: error: 'struct net_device' has no member named 'destructor'

It seems to occur since this upstream commit :

torvalds/linux@cf124db

[...]

netdev->priv_destructor() performs all actions to free up the private
resources that used to be freed by netdev->destructor(), except for
free_netdev().

netdev->needs_free_netdev is a boolean that indicates whether
free_netdev() should be done at the end of unregister_netdevice().

Signed-off-by: Bilal Amarni <[email protected]>
  • Loading branch information
Phil Elwell authored and popcornmix committed Jan 25, 2018
1 parent f8793ff commit 534fbac
Show file tree
Hide file tree
Showing 25 changed files with 244 additions and 114 deletions.
20 changes: 17 additions & 3 deletions drivers/net/wireless/realtek/rtl8192cu/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
EXTRA_CFLAGS += -O1
#EXTRA_CFLAGS += -O3
#EXTRA_CFLAGS += -Wall
#EXTRA_CFLAGS += -Wextra
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -Wextra
#EXTRA_CFLAGS += -Werror
#EXTRA_CFLAGS += -pedantic
#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes

# The "$(call cc-option,-Wxxx)" macro only includes that option when it's
# supported by the compiler used. It may only work on Debian systems.

# Wdate-time was added in gcc-4.9
EXTRA_CFLAGS += $(call cc-option,-Werror=date-time)
# Wincompatible-pointer-types was added in gcc-5.0
EXTRA_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)

EXTRA_CFLAGS += -Wno-unused-variable
EXTRA_CFLAGS += -Wno-unused-value
EXTRA_CFLAGS += -Wno-unused-label
EXTRA_CFLAGS += -Wno-unused-parameter
EXTRA_CFLAGS += -Wno-unused-function
EXTRA_CFLAGS += -Wno-unused

EXTRA_CFLAGS += -Wno-uninitialized
# Relax some warnings from '-Wextra' so we won't get flooded with warnings
EXTRA_CFLAGS += -Wno-sign-compare
EXTRA_CFLAGS += -Wno-missing-field-initializers

#EXTRA_CFLAGS += -Wno-uninitialized

EXTRA_CFLAGS += -I$(src)/include

EXTRA_LDFLAGS += --strip-debug

CONFIG_AUTOCFG_CP = n

CONFIG_RTL8192C = y
Expand Down
7 changes: 5 additions & 2 deletions drivers/net/wireless/realtek/rtl8192cu/core/rtw_ap.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void rtw_add_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index, u8 *d
PNDIS_802_11_VARIABLE_IEs pIE;
u8 bmatch = _FALSE;
u8 *pie = pnetwork->IEs;
u8 *p, *dst_ie, *premainder_ie=NULL, *pbackup_remainder_ie=NULL;
u8 *p=NULL, *dst_ie=NULL, *premainder_ie=NULL, *pbackup_remainder_ie=NULL;
u32 i, offset, ielen, ie_offset, remainder_ielen = 0;

for (i = sizeof(NDIS_802_11_FIXED_IEs); i < pnetwork->IELength;)
Expand Down Expand Up @@ -250,6 +250,9 @@ void rtw_add_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index, u8 *d
dst_ie = (p+ielen);
}

if(dst_ie == NULL)
return;

if(remainder_ielen>0)
{
pbackup_remainder_ie = rtw_malloc(remainder_ielen);
Expand Down Expand Up @@ -357,7 +360,7 @@ void expire_timeout_chk(_adapter *padapter)
{
_irqL irqL;
_list *phead, *plist;
u8 updated;
u8 updated = _FALSE;
struct sta_info *psta=NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 chk_alive_num = 0;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/realtek/rtl8192cu/core/rtw_ieee80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,8 @@ int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8* category, u8 *act
{
const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr);
u16 fc;
u8 c, a;
u8 c;
u8 a = ACT_PUBLIC_MAX;

fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl);

Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wireless/realtek/rtl8192cu/core/rtw_ioctl_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern void indicate_wx_scan_complete_event(_adapter *padapter);
(addr[4] == 0xff) && (addr[5] == 0xff) ) ? _TRUE : _FALSE \
)

u8 rtw_validate_bssid(u8 *bssid)
u8 rtw_validate_bssid(const u8 *bssid)
{
u8 ret = _TRUE;

Expand Down Expand Up @@ -535,7 +535,8 @@ _func_exit_;

}

u8 rtw_set_802_11_connect(_adapter* padapter, u8 *bssid, NDIS_802_11_SSID *ssid)
u8 rtw_set_802_11_connect(_adapter *padapter, const u8 *bssid
, NDIS_802_11_SSID *ssid)
{
_irqL irqL;
u8 status = _SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/realtek/rtl8192cu/core/rtw_mlme_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,7 @@ unsigned int OnDeAuth(_adapter *padapter, union recv_frame *precv_frame)
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if(psta)
{
u8 updated;
u8 updated = _FALSE;

_enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
if(rtw_is_list_empty(&psta->asoc_list)==_FALSE)
Expand Down Expand Up @@ -2548,7 +2548,7 @@ unsigned int OnDisassoc(_adapter *padapter, union recv_frame *precv_frame)
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if(psta)
{
u8 updated;
u8 updated = _FALSE;

_enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
if(rtw_is_list_empty(&psta->asoc_list)==_FALSE)
Expand Down Expand Up @@ -5663,7 +5663,7 @@ unsigned int on_action_public_p2p(union recv_frame *precv_frame)

// Commented by Kurt 20120113
// Get peer_dev_addr here if peer doesn't issue prov_disc frame.
if( _rtw_memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN) );
if( _rtw_memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN) )
_rtw_memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN);

result = process_p2p_group_negotation_req( pwdinfo, frame_body, len );
Expand Down Expand Up @@ -11932,7 +11932,7 @@ u8 setkey_hdl(_adapter *padapter, u8 *pbuf)
u8 set_stakey_hdl(_adapter *padapter, u8 *pbuf)
{
u16 ctrl=0;
u8 cam_id;//cam_entry
u8 cam_id=0;//cam_entry
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/realtek/rtl8192cu/core/rtw_p2p.c
Original file line number Diff line number Diff line change
Expand Up @@ -4896,9 +4896,9 @@ void init_wifidirect_info( _adapter* padapter, enum P2P_ROLE role)
#endif
#ifdef CONFIG_CONCURRENT_MODE
_adapter *pbuddy_adapter = padapter->pbuddy_adapter;
struct wifidirect_info *pbuddy_wdinfo;
struct mlme_priv *pbuddy_mlmepriv;
struct mlme_ext_priv *pbuddy_mlmeext;
struct wifidirect_info *pbuddy_wdinfo = NULL;
struct mlme_priv *pbuddy_mlmepriv = NULL;
struct mlme_ext_priv *pbuddy_mlmeext = NULL;
#endif

pwdinfo = &padapter->wdinfo;
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/wireless/realtek/rtl8192cu/core/rtw_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3894,7 +3894,7 @@ int process_recv_indicatepkts(_adapter *padapter, union recv_frame *prframe)

}

int recv_func_prehandle(_adapter *padapter, union recv_frame *rframe)
static int recv_func_prehandle(_adapter *padapter, union recv_frame *rframe)
{
int ret = _SUCCESS;
struct rx_pkt_attrib *pattrib = &rframe->u.hdr.attrib;
Expand Down Expand Up @@ -3935,7 +3935,7 @@ int recv_func_prehandle(_adapter *padapter, union recv_frame *rframe)
return ret;
}

int recv_func_posthandle(_adapter *padapter, union recv_frame *prframe)
static int recv_func_posthandle(_adapter *padapter, union recv_frame *prframe)
{
int ret = _SUCCESS;
union recv_frame *orig_prframe = prframe;
Expand Down Expand Up @@ -4107,8 +4107,7 @@ int recv_func_posthandle(_adapter *padapter, union recv_frame *prframe)
}


int recv_func(_adapter *padapter, union recv_frame *rframe);
int recv_func(_adapter *padapter, union recv_frame *rframe)
static int recv_func(_adapter *padapter, union recv_frame *rframe)
{
int ret;
struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/realtek/rtl8192cu/core/rtw_sta_mgt.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ _func_exit_;
}

/* any station allocated can be searched by hash list */
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr)
{

_irqL irqL;
Expand All @@ -696,7 +696,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)

u32 index;

u8 *addr;
const u8 *addr;

u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ void flush_all_cam_entry(_adapter *padapter)
{
struct sta_priv *pstapriv = &padapter->stapriv;
struct sta_info *psta;
u8 cam_id;//cam_entry
u8 cam_id=0;//cam_entry

psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress);
if(psta) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/realtek/rtl8192cu/core/rtw_xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,7 @@ struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv)
s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe)
{
_irqL irqL;
_queue *queue;
_queue *queue = NULL;
_adapter *padapter = pxmitpriv->adapter;
_pkt *pndis_pkt = NULL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static void getTxPowerWriteValByRegulatory(
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
struct dm_priv *pdmpriv = &pHalData->dmpriv;
u8 i, chnlGroup, pwr_diff_limit[4];
u8 i, chnlGroup = 0, pwr_diff_limit[4];
u32 writeVal, customer_limit, rf;

//
Expand Down Expand Up @@ -615,7 +615,7 @@ phy_RF6052_Config_ParaFile(
IN PADAPTER Adapter
)
{
u32 u4RegValue;
u32 u4RegValue=0;
u8 eRFPath;
BB_REGISTER_DEFINITION_T *pPhyReg;

Expand Down
9 changes: 5 additions & 4 deletions drivers/net/wireless/realtek/rtl8192cu/include/autoconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@

#define PLATFORM_LINUX 1

//#define CONFIG_IOCTL_CFG80211 1
#define CONFIG_IOCTL_CFG80211 1
#ifdef CONFIG_IOCTL_CFG80211
//#define RTW_USE_CFG80211_STA_EVENT /* Indecate new sta asoc through cfg80211_new_sta */
#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
/* Indicate new sta asoc through cfg80211_new_sta */
#define RTW_USE_CFG80211_STA_EVENT
/*#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER*/
//#define CONFIG_DEBUG_CFG80211 1
//#define CONFIG_DRV_ISSUE_PROV_REQ // IOT FOR S2
#define CONFIG_SET_SCAN_DENY_TIMER
Expand Down Expand Up @@ -324,7 +325,7 @@

//#define DBG_MEMORY_LEAK 1

#define DBG_CONFIG_ERROR_DETECT
/*#define DBG_CONFIG_ERROR_DETECT*/
//#define DBG_CONFIG_ERROR_RESET

//TX use 1 urb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,15 @@ bool rtw_cfg80211_pwr_mgmt(_adapter *adapter);
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->pnetdev, freq, buf, len, gfp)
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->pnetdev, freq, sig_dbm, buf, len, gfp)
#else
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0))
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, gfp)
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0))
/* 3.12 added a flags argument which is just set to zero*/
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) \
cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, 0, gfp)
#else
#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) \
cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, 0)
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) && !defined(COMPAT_KERNEL_RELEASE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,8 @@ __inline static void _set_workitem(_workitem *pwork)
#include <linux/interrupt.h> // for struct tasklet_struct
#include <linux/ip.h>
#include <linux/kthread.h>
#include <linux/signal.h>
#include <linux/sched/signal.h>

#ifdef CONFIG_IOCTL_CFG80211
// #include <linux/ieee80211.h>
Expand Down Expand Up @@ -1395,8 +1397,8 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a
extern void* rtw_malloc2d(int h, int w, int size);
extern void rtw_mfree2d(void *pbuf, int h, int w, int size);

extern void _rtw_memcpy(void* dec, void* sour, u32 sz);
extern int _rtw_memcmp(void *dst, void *src, u32 sz);
extern void _rtw_memcpy(void *dec, const void *sour, u32 sz);
extern int _rtw_memcmp(const void *dst, const void *src, u32 sz);
extern void _rtw_memset(void *pbuf, int c, u32 sz);

extern void _rtw_init_listhead(_list *list);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/realtek/rtl8192cu/include/rtw_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ extern u32 GlobalDebugLevel;
#if defined (_dbgdump)
#undef DBG_871X
// #define DBG_871X _dbgdump
#define DBG_871X(...) LOG_LEVEL(_drv_emerg_ , __VA_ARGS__)
#define DBG_871X(...) LOG_LEVEL(_drv_debug_ , __VA_ARGS__)

#undef MSG_8192C
// #define MSG_8192C _dbgdump
#define MSG_8192C(...) LOG_LEVEL(_drv_emerg_ , __VA_ARGS__)
#define MSG_8192C(...) LOG_LEVEL(_drv_info_ , __VA_ARGS__)

#undef DBG_8192C
// #define DBG_8192C _dbgdump
#define DBG_8192C(...) LOG_LEVEL(_drv_emerg_ , __VA_ARGS__)
#define DBG_8192C(...) LOG_LEVEL(_drv_debug_ , __VA_ARGS__)


#undef WRN_8192C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ u8 rtw_set_802_11_bssid_list_scan(_adapter* padapter, NDIS_802_11_SSID *pssid, i
u8 rtw_set_802_11_infrastructure_mode(_adapter * padapter, NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
u8 rtw_set_802_11_remove_wep(_adapter * padapter, u32 keyindex);
u8 rtw_set_802_11_ssid(_adapter * padapter, NDIS_802_11_SSID * ssid);
u8 rtw_set_802_11_connect(_adapter* padapter, u8 *bssid, NDIS_802_11_SSID *ssid);
u8 rtw_set_802_11_connect(_adapter *padapter, const u8 *bssid
, NDIS_802_11_SSID *ssid);
u8 rtw_set_802_11_remove_key(_adapter * padapter, NDIS_802_11_REMOVE_KEY * key);

u8 rtw_validate_bssid(u8 *bssid);
u8 rtw_validate_bssid(const u8 *bssid);
u8 rtw_validate_ssid(NDIS_802_11_SSID *ssid);

u16 rtw_get_cur_max_rate(_adapter *adapter);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/realtek/rtl8192cu/include/sta_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ struct sta_priv {
};


__inline static u32 wifi_mac_hash(u8 *mac)
__inline static u32 wifi_mac_hash(const u8 *mac)
{
u32 x;

Expand Down Expand Up @@ -423,7 +423,7 @@ struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset)
extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
extern void rtw_free_all_stainfo(_adapter *padapter);
extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
extern u32 rtw_init_bcmc_stainfo(_adapter* padapter);
extern struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter);
extern u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/realtek/rtl8192cu/include/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ enum WIFI_REG_DOMAIN {
(addr[4] == 0xff) && (addr[5] == 0xff) ) ? _TRUE : _FALSE \
)

__inline static int IS_MCAST(unsigned char *da)
__inline static int IS_MCAST(const unsigned char *da)
{
if ((*da) & 0x01)
return _TRUE;
Expand Down
Loading

0 comments on commit 534fbac

Please sign in to comment.