From b4b7ff4b08e691656c9d77c758fc355833128ac0 Mon Sep 17 00:00:00 2001 From: AndrĂ© Fabian Silva Delgado Date: Wed, 20 Jan 2016 14:01:31 -0300 Subject: Linux-libre 4.4-gnu --- drivers/staging/rtl8712/drv_types.h | 11 +- drivers/staging/rtl8712/hal_init.c | 57 +++--- drivers/staging/rtl8712/ieee80211.c | 43 +++-- drivers/staging/rtl8712/ieee80211.h | 48 ++--- drivers/staging/rtl8712/mlme_linux.c | 5 +- drivers/staging/rtl8712/os_intfs.c | 11 +- drivers/staging/rtl8712/osdep_service.h | 4 - drivers/staging/rtl8712/recv_linux.c | 3 +- drivers/staging/rtl8712/rtl8712_cmd.c | 42 ++-- drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h | 3 +- drivers/staging/rtl8712/rtl8712_efuse.c | 138 ++++++------- drivers/staging/rtl8712/rtl8712_gp_bitdef.h | 3 +- drivers/staging/rtl8712/rtl8712_hal.h | 14 +- drivers/staging/rtl8712/rtl8712_io.c | 28 ++- drivers/staging/rtl8712/rtl8712_led.c | 187 +++++++++--------- drivers/staging/rtl8712/rtl8712_recv.c | 55 +++--- drivers/staging/rtl8712/rtl8712_xmit.c | 86 +++++---- drivers/staging/rtl8712/rtl871x_cmd.c | 25 +-- drivers/staging/rtl8712/rtl871x_eeprom.c | 22 +-- drivers/staging/rtl8712/rtl871x_io.c | 2 +- drivers/staging/rtl8712/rtl871x_io.h | 8 - drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 234 +++++++++++------------ drivers/staging/rtl8712/rtl871x_ioctl_rtl.c | 53 +++-- drivers/staging/rtl8712/rtl871x_ioctl_set.c | 33 ++-- drivers/staging/rtl8712/rtl871x_mlme.c | 150 ++++++++------- drivers/staging/rtl8712/rtl871x_mlme.h | 2 +- drivers/staging/rtl8712/rtl871x_mp.c | 39 ++-- drivers/staging/rtl8712/rtl871x_mp.h | 1 - drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 38 ++-- drivers/staging/rtl8712/rtl871x_pwrctrl.c | 6 +- drivers/staging/rtl8712/rtl871x_recv.c | 70 +++---- drivers/staging/rtl8712/rtl871x_security.c | 133 +++++++------ drivers/staging/rtl8712/rtl871x_sta_mgt.c | 10 +- drivers/staging/rtl8712/rtl871x_xmit.c | 95 ++++----- drivers/staging/rtl8712/usb_halinit.c | 13 +- drivers/staging/rtl8712/usb_intf.c | 20 +- drivers/staging/rtl8712/usb_ops.c | 20 +- drivers/staging/rtl8712/usb_ops_linux.c | 28 +-- drivers/staging/rtl8712/wifi.h | 9 - drivers/staging/rtl8712/xmit_linux.c | 4 +- 40 files changed, 901 insertions(+), 852 deletions(-) (limited to 'drivers/staging/rtl8712') diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index e62543d22..3d64feeb8 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -23,11 +23,12 @@ * Larry Finger * ******************************************************************************/ -/*--------------------------------------------------------------------- - - For type defines and data structure defines - ------------------------------------------------------------------------*/ +/* --------------------------------------------------------------------- + * + * For type defines and data structure defines + * + * --------------------------------------------------------------------- + */ #ifndef __DRV_TYPES_H__ #define __DRV_TYPES_H__ diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 59146cec8..7914bdab7 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -122,15 +122,15 @@ static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv) static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw) { pfwhdr->signature = le16_to_cpu(*(u16 *)pmappedfw); - pfwhdr->version = le16_to_cpu(*(u16 *)(pmappedfw+2)); + pfwhdr->version = le16_to_cpu(*(u16 *)(pmappedfw + 2)); /* define the size of boot loader */ - pfwhdr->dmem_size = le32_to_cpu(*(uint *)(pmappedfw+4)); + pfwhdr->dmem_size = le32_to_cpu(*(uint *)(pmappedfw + 4)); /* define the size of FW in IMEM */ - pfwhdr->img_IMEM_size = le32_to_cpu(*(uint *)(pmappedfw+8)); + pfwhdr->img_IMEM_size = le32_to_cpu(*(uint *)(pmappedfw + 8)); /* define the size of FW in SRAM */ - pfwhdr->img_SRAM_size = le32_to_cpu(*(uint *)(pmappedfw+12)); + pfwhdr->img_SRAM_size = le32_to_cpu(*(uint *)(pmappedfw + 12)); /* define the size of DMEM variable */ - pfwhdr->fw_priv_sz = le32_to_cpu(*(uint *)(pmappedfw+16)); + pfwhdr->fw_priv_sz = le32_to_cpu(*(uint *)(pmappedfw + 16)); } static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength) @@ -177,8 +177,8 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ? fwhdr.img_IMEM_size : fwhdr.img_SRAM_size; maxlen += txdscp_sz; - ptmpchar = kmalloc(maxlen + FWBUFF_ALIGN_SZ, GFP_ATOMIC); - if (ptmpchar == NULL) + ptmpchar = kmalloc(maxlen + FWBUFF_ALIGN_SZ, GFP_KERNEL); + if (!ptmpchar) return ret; ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ - @@ -191,9 +191,9 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) imem_sz = fwhdr.img_IMEM_size; do { memset(ptx_desc, 0, TXDESC_SIZE); - if (imem_sz > MAX_DUMP_FWSZ/*49152*/) + if (imem_sz > MAX_DUMP_FWSZ/*49152*/) { dump_imem_sz = MAX_DUMP_FWSZ; - else { + } else { dump_imem_sz = imem_sz; ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); } @@ -209,7 +209,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) i = 10; tmp16 = r8712_read16(padapter, TCR); while (((tmp16 & _IMEM_CODE_DONE) == 0) && (i > 0)) { - udelay(10); + usleep_range(10, 1000); tmp16 = r8712_read16(padapter, TCR); i--; } @@ -230,14 +230,14 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) 0x0000ffff); memcpy(ppayload, ptr, dump_emem_sz); r8712_write_mem(padapter, RTL8712_DMA_VOQ, - dump_emem_sz+TXDESC_SIZE, (u8 *)ptx_desc); + dump_emem_sz + TXDESC_SIZE, (u8 *)ptx_desc); ptr += dump_emem_sz; emem_sz -= dump_emem_sz; } while (emem_sz > 0); i = 5; tmp16 = r8712_read16(padapter, TCR); while (((tmp16 & _EMEM_CODE_DONE) == 0) && (i > 0)) { - udelay(10); + usleep_range(10, 1000); tmp16 = r8712_read16(padapter, TCR); i--; } @@ -246,15 +246,15 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) /* 3.Enable CPU */ tmp8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, tmp8|BIT(2)); + r8712_write8(padapter, SYS_CLKR, tmp8 | BIT(2)); tmp8_a = r8712_read8(padapter, SYS_CLKR); - if (tmp8_a != (tmp8|BIT(2))) + if (tmp8_a != (tmp8 | BIT(2))) goto exit_fail; tmp8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN+1, tmp8|BIT(2)); + r8712_write8(padapter, SYS_FUNC_EN + 1, tmp8 | BIT(2)); tmp8_a = r8712_read8(padapter, SYS_FUNC_EN + 1); - if (tmp8_a != (tmp8|BIT(2))) + if (tmp8_a != (tmp8 | BIT(2))) goto exit_fail; r8712_read32(padapter, TCR); @@ -278,7 +278,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) } /* 5.Download DMEM code size and Load EMEM Code Section */ memset(ptx_desc, 0, TXDESC_SIZE); - ptx_desc->txdw0 |= cpu_to_le32(fwhdr.fw_priv_sz&0x0000ffff); + ptx_desc->txdw0 |= cpu_to_le32(fwhdr.fw_priv_sz & 0x0000ffff); ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); memcpy(ppayload, &fwhdr.fwpriv, fwhdr.fw_priv_sz); r8712_write_mem(padapter, RTL8712_DMA_VOQ, @@ -309,8 +309,9 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) } if (i == 0) goto exit_fail; - } else + } else { goto exit_fail; + } ret = _SUCCESS; exit_fail: @@ -335,10 +336,10 @@ uint rtl8712_hal_init(struct _adapter *padapter) netdev_info(padapter->pnetdev, "2 RCR=0x%x\n", r8712_read32(padapter, RCR)); val32 = r8712_read32(padapter, RCR); - r8712_write32(padapter, RCR, (val32|BIT(25))); /* Append PHY status */ + r8712_write32(padapter, RCR, (val32 | BIT(25))); /* Append PHY status */ val32 = 0; val32 = r8712_read32(padapter, 0x10250040); - r8712_write32(padapter, 0x10250040, (val32&0x00FFFFFF)); + r8712_write32(padapter, 0x10250040, (val32 & 0x00FFFFFF)); /* for usb rx aggregation */ r8712_write8(padapter, 0x102500B5, r8712_read8(padapter, 0x102500B5) | BIT(0)); /* page = 128bytes */ @@ -362,33 +363,33 @@ uint rtl8712_hal_deinit(struct _adapter *padapter) /* Turn off BB */ msleep(20); /* Turn off MAC */ - r8712_write8(padapter, SYS_CLKR+1, 0x38); /* Switch Control Path */ - r8712_write8(padapter, SYS_FUNC_EN+1, 0x70); + r8712_write8(padapter, SYS_CLKR + 1, 0x38); /* Switch Control Path */ + r8712_write8(padapter, SYS_FUNC_EN + 1, 0x70); r8712_write8(padapter, PMC_FSM, 0x06); /* Enable Loader Data Keep */ r8712_write8(padapter, SYS_ISO_CTRL, 0xF9); /* Isolation signals from * CORE, PLL */ - r8712_write8(padapter, SYS_ISO_CTRL+1, 0xe8); /* Enable EFUSE 1.2V */ + r8712_write8(padapter, SYS_ISO_CTRL + 1, 0xe8); /* Enable EFUSE 1.2V */ r8712_write8(padapter, AFE_PLL_CTRL, 0x00); /* Disable AFE PLL. */ r8712_write8(padapter, LDOA15_CTRL, 0x54); /* Disable A15V */ - r8712_write8(padapter, SYS_FUNC_EN+1, 0x50); /* Disable E-Fuse 1.2V */ + r8712_write8(padapter, SYS_FUNC_EN + 1, 0x50); /* Disable E-Fuse 1.2V */ r8712_write8(padapter, LDOV12D_CTRL, 0x24); /* Disable LDO12(for CE) */ r8712_write8(padapter, AFE_MISC, 0x30); /* Disable AFE BG&MB */ /* Option for Disable 1.6V LDO. */ r8712_write8(padapter, SPS0_CTRL, 0x56); /* Disable 1.6V LDO */ - r8712_write8(padapter, SPS0_CTRL+1, 0x43); /* Set SW PFM */ + r8712_write8(padapter, SPS0_CTRL + 1, 0x43); /* Set SW PFM */ return _SUCCESS; } uint rtl871x_hal_init(struct _adapter *padapter) { padapter->hw_init_completed = false; - if (padapter->halpriv.hal_bus_init == NULL) + if (!padapter->halpriv.hal_bus_init) return _FAIL; if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS) return _FAIL; - if (rtl8712_hal_init(padapter) == _SUCCESS) + if (rtl8712_hal_init(padapter) == _SUCCESS) { padapter->hw_init_completed = true; - else { + } else { padapter->hw_init_completed = false; return _FAIL; } diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index c5527c1cc..974ca021c 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -107,9 +107,10 @@ u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen) return pbuf + len + 2; } -/*---------------------------------------------------------------------------- -index: the information element id index, limit is the limit for search ------------------------------------------------------------------------------*/ +/* --------------------------------------------------------------------------- + * index: the information element id index, limit is the limit for search + * --------------------------------------------------------------------------- + */ u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit) { sint tmp, i; @@ -303,8 +304,9 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, *group_cipher = r8712_get_wpa_cipher_suite(pos); pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; - } else if (left > 0) + } else if (left > 0) { return _FAIL; + } /*pairwise_cipher*/ if (left >= 2) { count = le16_to_cpu(*(u16 *)pos); @@ -317,8 +319,9 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; } - } else if (left == 1) + } else if (left == 1) { return _FAIL; + } return _SUCCESS; } @@ -333,7 +336,8 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, /* No RSN IE - fail silently */ return _FAIL; } - if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) + if ((*rsn_ie != _WPA2_IE_ID_) || + (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) return _FAIL; pos = rsn_ie; pos += 4; @@ -343,8 +347,9 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, *group_cipher = r8712_get_wpa2_cipher_suite(pos); pos += RSN_SELECTOR_LEN; left -= RSN_SELECTOR_LEN; - } else if (left > 0) + } else if (left > 0) { return _FAIL; + } /*pairwise_cipher*/ if (left >= 2) { count = le16_to_cpu(*(u16 *)pos); @@ -357,8 +362,9 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, pos += RSN_SELECTOR_LEN; left -= RSN_SELECTOR_LEN; } - } else if (left == 1) + } else if (left == 1) { return _FAIL; + } return _SUCCESS; } @@ -376,16 +382,17 @@ int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - *wpa_len = in_ie[cnt+1]+2; + *wpa_len = in_ie[cnt + 1] + 2; cnt += in_ie[cnt + 1] + 2; /*get next */ } else { if (authmode == _WPA2_IE_ID_) { memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - *rsn_len = in_ie[cnt+1] + 2; - cnt += in_ie[cnt+1] + 2; /*get next*/ - } else - cnt += in_ie[cnt+1] + 2; /*get next*/ + *rsn_len = in_ie[cnt + 1] + 2; + cnt += in_ie[cnt + 1] + 2; /*get next*/ + } else { + cnt += in_ie[cnt + 1] + 2; /*get next*/ + } } } return *rsn_len + *wpa_len; @@ -402,14 +409,14 @@ int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; if ((eid == _WPA_IE_ID_) && - (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { - memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); - *wps_ielen = in_ie[cnt+1]+2; - cnt += in_ie[cnt+1]+2; + (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { + memcpy(wps_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); + *wps_ielen = in_ie[cnt + 1] + 2; + cnt += in_ie[cnt + 1] + 2; match = true; break; } - cnt += in_ie[cnt+1]+2; /* goto next */ + cnt += in_ie[cnt + 1] + 2; /* goto next */ } return match; } diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h index 6e813a9c1..d374824c4 100644 --- a/drivers/staging/rtl8712/ieee80211.h +++ b/drivers/staging/rtl8712/ieee80211.h @@ -120,12 +120,13 @@ struct ieee_param { #define IEEE80211_DATA_LEN 2304 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section - 6.2.1.1.2. - - The figure in section 7.1.2 suggests a body size of up to 2312 - bytes is allowed, which is a bit confusing, I suspect this - represents the 2304 bytes of real data, plus a possible 8 bytes of - WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ + * 6.2.1.1.2. + * + * The figure in section 7.1.2 suggests a body size of up to 2312 + * bytes is allowed, which is a bit confusing, I suspect this + * represents the 2304 bytes of real data, plus a possible 8 bytes of + * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) + */ #define IEEE80211_HLEN 30 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) @@ -405,7 +406,8 @@ struct ieee80211_snap_hdr { /* NOTE: This data is for statistical purposes; not all hardware provides this * information for frames received. Not setting these will not cause - * any adverse affects. */ + * any adverse affects. + */ struct ieee80211_rx_stats { s8 rssi; u8 signal; @@ -420,7 +422,8 @@ struct ieee80211_rx_stats { /* IEEE 802.11 requires that STA supports concurrent reception of at least * three fragmented frames. This define can be increased to support more * concurrent frames, but it should be noted that each entry can consume about - * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ + * 2 kB of RAM and increasing cache size will slow down frame reassembly. + */ #define IEEE80211_FRAG_CACHE_LEN 4 struct ieee80211_frag_entry { @@ -510,19 +513,19 @@ struct ieee80211_security { } __packed; /* - - 802.11 data frame from AP - - ,-------------------------------------------------------------------. -Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | - |------|------|---------|---------|---------|------|---------|------| -Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `-------------------------------------------------------------------' - -Total: 28-2340 bytes - -*/ + * + * 802.11 data frame from AP + * + * ,-------------------------------------------------------------------. + * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | + * |------|------|---------|---------|---------|------|---------|------| + * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | + * | | tion | (BSSID) | | | ence | data | | + * `-------------------------------------------------------------------' + * + * Total: 28-2340 bytes + * + */ struct ieee80211_header_data { u16 frame_ctl; @@ -628,7 +631,8 @@ struct ieee80211_txb { /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the - * main rates information element... */ + * main rates information element... + */ #define MAX_RATES_LENGTH ((u8)12) #define MAX_RATES_EX_LENGTH ((u8)16) #define MAX_NETWORK_COUNT 128 diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c index 8c5a475f0..e4e4bdee7 100644 --- a/drivers/staging/rtl8712/mlme_linux.c +++ b/drivers/staging/rtl8712/mlme_linux.c @@ -122,7 +122,8 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter) r8712_use_tkipkey_handler, (unsigned long)adapter); /* Restore the PMK information to securitypriv structure - * for the following connection. */ + * for the following connection. + */ memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0], sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE); @@ -162,7 +163,7 @@ void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie) p += sprintf(p, "%02x", sec_ie[i]); p += sprintf(p, ")"); memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = p-buff; + wrqu.data.length = p - buff; wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? wrqu.data.length : IW_CUSTOM_MAX; wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 5d551a1ba..b89e2d3c4 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -97,7 +97,7 @@ static char *initmac; */ static int wifi_test; -module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); +module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO | S_IWUSR); module_param(wifi_test, int, 0644); module_param(initmac, charp, 0644); module_param(video_mode, int, 0644); @@ -177,7 +177,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p) struct _adapter *padapter = netdev_priv(pnetdev); struct sockaddr *addr = p; - if (padapter->bup == false) + if (!padapter->bup) ether_addr_copy(pnetdev->dev_addr, addr->sa_data); return 0; } @@ -333,7 +333,7 @@ u8 r8712_init_drv_sw(struct _adapter *padapter) u8 r8712_free_drv_sw(struct _adapter *padapter) { - struct net_device *pnetdev = (struct net_device *)padapter->pnetdev; + struct net_device *pnetdev = padapter->pnetdev; r8712_free_cmd_priv(&padapter->cmdpriv); r8712_free_evt_priv(&padapter->evtpriv); @@ -366,7 +366,8 @@ static void enable_video_mode(struct _adapter *padapter, int cbw40_value) if (cbw40_value) { /* if the driver supports the 40M bandwidth, - * we can enable the bit 9.*/ + * we can enable the bit 9. + */ intcmd |= 0x200; } r8712_fw_cmd(padapter, intcmd); @@ -383,7 +384,7 @@ static int netdev_open(struct net_device *pnetdev) struct _adapter *padapter = netdev_priv(pnetdev); mutex_lock(&padapter->mutex_start); - if (padapter->bup == false) { + if (!padapter->bup) { padapter->bDriverStopped = false; padapter->bSurpriseRemoved = false; padapter->bup = true; diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 0a7f58c59..076d5083c 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -60,10 +60,6 @@ struct __queue { #define LIST_CONTAINOR(ptr, type, member) \ ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member))) -#ifndef BIT - #define BIT(x) (1 << (x)) -#endif - static inline u32 _down_sema(struct semaphore *sema) { if (down_interruptible(sema)) diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 4201ce776..2f5460dbd 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -127,7 +127,8 @@ void r8712_recv_indicatepkt(struct _adapter *padapter, skb->protocol = eth_type_trans(skb, padapter->pnetdev); netif_rx(skb); precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before - * r8712_free_recvframe() */ + * r8712_free_recvframe() + */ r8712_free_recvframe(precv_frame, pfree_recv_queue); return; _recv_indicatepkt_drop: diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index 007f0a3ab..9b9160947 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -62,12 +62,14 @@ static void check_hw_pbc(struct _adapter *padapter) tmp1byte = r8712_read8(padapter, GPIO_CTRL); if (tmp1byte == 0xff) return; - if (tmp1byte&HAL_8192S_HW_GPIO_WPS_BIT) { + if (tmp1byte & HAL_8192S_HW_GPIO_WPS_BIT) { /* Here we only set bPbcPressed to true - * After trigger PBC, the variable will be set to false */ + * After trigger PBC, the variable will be set to false + */ DBG_8712("CheckPbcGPIO - PBC is pressed !!!!\n"); /* 0 is the default value and it means the application monitors - * the HW PBC doesn't provide its pid to driver. */ + * the HW PBC doesn't provide its pid to driver. + */ if (padapter->pid == 0) return; kill_pid(find_vpid(padapter->pid), SIGUSR1, 1); @@ -76,13 +78,14 @@ static void check_hw_pbc(struct _adapter *padapter) /* query rx phy status from fw. * Adhoc mode: beacon. - * Infrastructure mode: beacon , data. */ + * Infrastructure mode: beacon , data. + */ static void query_fw_rx_phy_status(struct _adapter *padapter) { u32 val32 = 0; int pollingcnts = 50; - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { r8712_write32(padapter, IOCMD_CTRL_REG, 0xf4000001); msleep(100); /* Wait FW complete IO Cmd */ @@ -257,7 +260,8 @@ static struct cmd_obj *cmd_hdl_filter(struct _adapter *padapter, /* Before set JoinBss_CMD to FW, driver must ensure FW is in * PS_MODE_ACTIVE. Directly write rpwm to radio on and assign * new pwr_mode to Driver, instead of use workitem to change - * state. */ + * state. + */ if (padapter->pwrctrlpriv.pwr_mode > PS_MODE_ACTIVE) { padapter->pwrctrlpriv.pwr_mode = PS_MODE_ACTIVE; _enter_pwrlock(&(padapter->pwrctrlpriv.lock)); @@ -320,8 +324,7 @@ int r8712_cmd_thread(void *context) while (1) { if ((_down_sema(&(pcmdpriv->cmd_queue_sema))) == _FAIL) break; - if ((padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true)) + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) break; if (r8712_register_cmd_alive(padapter) != _SUCCESS) continue; @@ -336,14 +339,13 @@ _next: memset(pdesc, 0, TXDESC_SIZE); pcmd = cmd_hdl_filter(padapter, pcmd); if (pcmd) { /* if pcmd != NULL, cmd will be handled by f/w */ - struct dvobj_priv *pdvobj = (struct dvobj_priv *) - &padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; u8 blnPending = 0; pcmdpriv->cmd_issued_cnt++; cmdsz = round_up(pcmd->cmdsz, 8); wr_sz = TXDESC_SIZE + 8 + cmdsz; - pdesc->txdw0 |= cpu_to_le32((wr_sz-TXDESC_SIZE) & + pdesc->txdw0 |= cpu_to_le32((wr_sz - TXDESC_SIZE) & 0x0000ffff); if (pdvobj->ishighspeed) { if ((wr_sz % 512) == 0) @@ -372,8 +374,8 @@ _next: pcmdbuf += 2; /* 8 bytes alignment */ memcpy((u8 *)pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); while (check_cmd_fifo(padapter, wr_sz) == _FAIL) { - if ((padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true)) + if (padapter->bDriverStopped || + padapter->bSurpriseRemoved) break; msleep(100); continue; @@ -403,10 +405,12 @@ _next: if (list_empty(&pcmdpriv->cmd_queue.queue)) { r8712_unregister_cmd_alive(padapter); continue; - } else + } else { goto _next; - } else + } + } else { goto _next; + } flush_signals_thread(); } /* free all cmd_obj resources */ @@ -439,20 +443,20 @@ void r8712_event_handle(struct _adapter *padapter, uint *peventbuf) } /* checking if event code is valid */ if (evt_code >= MAX_C2HEVT) { - pevt_priv->event_seq = ((evt_seq+1) & 0x7f); + pevt_priv->event_seq = ((evt_seq + 1) & 0x7f); goto _abort_event_; } else if ((evt_code == GEN_EVT_CODE(_Survey)) && (evt_sz > sizeof(struct wlan_bssid_ex))) { - pevt_priv->event_seq = ((evt_seq+1)&0x7f); + pevt_priv->event_seq = ((evt_seq + 1) & 0x7f); goto _abort_event_; } /* checking if event size match the event parm size */ if ((wlanevents[evt_code].parmsize) && (wlanevents[evt_code].parmsize != evt_sz)) { - pevt_priv->event_seq = ((evt_seq+1)&0x7f); + pevt_priv->event_seq = ((evt_seq + 1) & 0x7f); goto _abort_event_; } else if ((evt_sz == 0) && (evt_code != GEN_EVT_CODE(_WPS_PBC))) { - pevt_priv->event_seq = ((evt_seq+1)&0x7f); + pevt_priv->event_seq = ((evt_seq + 1) & 0x7f); goto _abort_event_; } pevt_priv->event_seq++; /* update evt_seq */ diff --git a/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h index 8dffe101b..b7dda9030 100644 --- a/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h @@ -21,7 +21,8 @@ #define __RTL8712_CMDCTRL_BITDEF_H__ /* - * 2. Command Control Registers (Offset: 0x0040 - 0x004F)*/ + * 2. Command Control Registers (Offset: 0x0040 - 0x004F) + */ /*--------------------------------------------------------------------------*/ /* 8192S (CMD) command register bits (Offset 0x40, 16 bits)*/ /*--------------------------------------------------------------------------*/ diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c index d95716999..eaa93fbb9 100644 --- a/drivers/staging/rtl8712/rtl8712_efuse.c +++ b/drivers/staging/rtl8712/rtl8712_efuse.c @@ -39,7 +39,7 @@ static void efuse_reg_ctrl(struct _adapter *padapter, u8 bPowerOn) { u8 tmpu8 = 0; - if (true == bPowerOn) { + if (bPowerOn) { /* -----------------e-fuse pwr & clk reg ctrl --------------- * Enable LDOE25 Macro Block */ @@ -80,12 +80,13 @@ static u8 efuse_one_byte_read(struct _adapter *padapter, u16 addr, u8 *data) u8 tmpidx = 0, bResult; /* -----------------e-fuse reg ctrl --------------------------------- */ - r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */ - r8712_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8)&0x03)) | - (r8712_read8(padapter, EFUSE_CTRL+2)&0xFC)); - r8712_write8(padapter, EFUSE_CTRL+3, 0x72); /* read cmd */ + r8712_write8(padapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ + r8712_write8(padapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | + (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC)); + r8712_write8(padapter, EFUSE_CTRL + 3, 0x72); /* read cmd */ /* wait for complete */ - while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && + (tmpidx < 100)) tmpidx++; if (tmpidx < 100) { *data = r8712_read8(padapter, EFUSE_CTRL); @@ -102,13 +103,14 @@ static u8 efuse_one_byte_write(struct _adapter *padapter, u16 addr, u8 data) u8 tmpidx = 0, bResult; /* -----------------e-fuse reg ctrl -------------------------------- */ - r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */ - r8712_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8)&0x03)) | - (r8712_read8(padapter, EFUSE_CTRL+2)&0xFC)); + r8712_write8(padapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ + r8712_write8(padapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | + (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC)); r8712_write8(padapter, EFUSE_CTRL, data); /* data */ - r8712_write8(padapter, EFUSE_CTRL+3, 0xF2); /* write cmd */ + r8712_write8(padapter, EFUSE_CTRL + 3, 0xF2); /* write cmd */ /* wait for complete */ - while ((0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + while ((0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && + (tmpidx < 100)) tmpidx++; if (tmpidx < 100) bResult = true; @@ -123,13 +125,13 @@ static u8 efuse_one_byte_rw(struct _adapter *padapter, u8 bRead, u16 addr, u8 tmpidx = 0, tmpv8 = 0, bResult; /* -----------------e-fuse reg ctrl --------------------------------- */ - r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */ + r8712_write8(padapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ tmpv8 = ((u8)((addr >> 8) & 0x03)) | (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC); - r8712_write8(padapter, EFUSE_CTRL+2, tmpv8); - if (true == bRead) { - r8712_write8(padapter, EFUSE_CTRL+3, 0x72); /* read cmd */ - while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && + r8712_write8(padapter, EFUSE_CTRL + 2, tmpv8); + if (bRead) { + r8712_write8(padapter, EFUSE_CTRL + 3, 0x72); /* read cmd */ + while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) { @@ -141,8 +143,8 @@ static u8 efuse_one_byte_rw(struct _adapter *padapter, u8 bRead, u16 addr, } } else { r8712_write8(padapter, EFUSE_CTRL, *data); /* data */ - r8712_write8(padapter, EFUSE_CTRL+3, 0xF2); /* write cmd */ - while ((0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && + r8712_write8(padapter, EFUSE_CTRL + 3, 0xF2); /* write cmd */ + while ((0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) @@ -158,13 +160,14 @@ static u8 efuse_is_empty(struct _adapter *padapter, u8 *empty) u8 value, ret = true; /* read one byte to check if E-Fuse is empty */ - if (efuse_one_byte_rw(padapter, true, 0, &value) == true) { + if (efuse_one_byte_rw(padapter, true, 0, &value)) { if (0xFF == value) *empty = true; else *empty = false; - } else + } else { ret = false; + } return ret; } @@ -207,7 +210,7 @@ static void pgpacket_copy_data(const u8 word_en, const u8 *sourdata, u8 word_idx, byte_idx; for (word_idx = 0; word_idx < PGPKG_MAX_WORDS; word_idx++) { - if (!(word_en&BIT(word_idx))) { + if (!(word_en & BIT(word_idx))) { byte_idx = word_idx * 2; targetdata[byte_idx] = sourdata[tmpindex++]; targetdata[byte_idx + 1] = sourdata[tmpindex++]; @@ -229,8 +232,9 @@ u16 r8712_efuse_get_current_size(struct _adapter *padapter) word_cnts = calculate_word_cnts(hworden); /* read next header */ efuse_addr = efuse_addr + (word_cnts * 2) + 1; - } else + } else { bContinual = false; + } } return efuse_addr; } @@ -248,10 +252,9 @@ u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data) return false; if (offset > 0x0f) return false; - memset(data, 0xFF, sizeof(u8)*PGPKT_DATA_SIZE); + memset(data, 0xFF, sizeof(u8) * PGPKT_DATA_SIZE); while (efuse_addr < efuse_available_max_size) { - if (efuse_one_byte_read(padapter, efuse_addr, &efuse_data) == - true) { + if (efuse_one_byte_read(padapter, efuse_addr, &efuse_data)) { if (efuse_data == 0xFF) break; hoffset = (efuse_data >> 4) & 0x0F; @@ -262,15 +265,16 @@ u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data) for (tmpidx = 0; tmpidx < word_cnts * 2; tmpidx++) { if (efuse_one_byte_read(padapter, - efuse_addr+1+tmpidx, &efuse_data) == - true) { + efuse_addr + 1 + tmpidx, + &efuse_data)) { tmpdata[tmpidx] = efuse_data; - } else + } else { ret = false; + } } pgpacket_copy_data(hworden, tmpdata, data); } - efuse_addr += 1 + (word_cnts*2); + efuse_addr += 1 + (word_cnts * 2); } else { ret = false; break; @@ -295,14 +299,14 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) /* retrieve original data */ addr = 0; while (addr < header_addr) { - if (efuse_one_byte_read(padapter, addr++, &value) == false) { + if (!efuse_one_byte_read(padapter, addr++, &value)) { ret = false; break; } offset = GET_EFUSE_OFFSET(value); word_en = GET_EFUSE_WORD_EN(value); if (pkt.offset != offset) { - addr += calculate_word_cnts(word_en)*2; + addr += calculate_word_cnts(word_en) * 2; continue; } for (i = 0; i < PGPKG_MAX_WORDS; i++) { @@ -310,15 +314,15 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) if (BIT(i) & pkt.word_en) { if (efuse_one_byte_read( padapter, addr, - &value) == true) - pkt.data[i*2] = value; + &value)) + pkt.data[i * 2] = value; else return false; if (efuse_one_byte_read( padapter, addr + 1, - &value) == true) - pkt.data[i*2 + 1] = + &value)) + pkt.data[i * 2 + 1] = value; else return false; @@ -333,27 +337,26 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) /* fill original data */ for (i = 0; i < PGPKG_MAX_WORDS; i++) { if (BIT(i) & pkt.word_en) { - efuse_one_byte_write(padapter, addr, pkt.data[i*2]); - efuse_one_byte_write(padapter, addr+1, - pkt.data[i*2 + 1]); + efuse_one_byte_write(padapter, addr, pkt.data[i * 2]); + efuse_one_byte_write(padapter, addr + 1, + pkt.data[i * 2 + 1]); /* additional check */ - if (efuse_one_byte_read(padapter, addr, &value) - == false) + if (!efuse_one_byte_read(padapter, addr, &value)) { ret = false; - else if (pkt.data[i*2] != value) { + } else if (pkt.data[i * 2] != value) { ret = false; if (0xFF == value) /* write again */ efuse_one_byte_write(padapter, addr, pkt.data[i * 2]); } - if (efuse_one_byte_read(padapter, addr+1, &value) == - false) + if (!efuse_one_byte_read(padapter, addr + 1, &value)) { ret = false; - else if (pkt.data[i*2 + 1] != value) { + } else if (pkt.data[i * 2 + 1] != value) { ret = false; if (0xFF == value) /* write again */ - efuse_one_byte_write(padapter, addr+1, - pkt.data[i*2 + 1]); + efuse_one_byte_write(padapter, addr + 1, + pkt.data[i * 2 + + 1]); } } addr += 2; @@ -388,8 +391,8 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, efuse_one_byte_write(padapter, efuse_addr, pg_header); /*hdr*/ sub_repeat = 0; /* check if what we read is what we write */ - while (efuse_one_byte_read(padapter, efuse_addr, - &efuse_data) == false) { + while (!efuse_one_byte_read(padapter, efuse_addr, + &efuse_data)) { if (++sub_repeat > _REPEAT_THRESHOLD_) { bResult = false; /* continue to blind write */ break; /* continue to blind write */ @@ -402,14 +405,15 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, /* go to next address */ efuse_addr++; - for (i = 0; i < target_word_cnts*2; i++) { + for (i = 0; i < target_word_cnts * 2; i++) { efuse_one_byte_write(padapter, efuse_addr + i, *(data + i)); - if (efuse_one_byte_read(padapter, - efuse_addr + i, &efuse_data) == false) + if (!efuse_one_byte_read(padapter, + efuse_addr + i, + &efuse_data)) bResult = false; - else if (*(data+i) != efuse_data) /* fail */ + else if (*(data + i) != efuse_data) /* fail */ bResult = false; } break; @@ -437,10 +441,10 @@ u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr, if (start_addr > EFUSE_MAX_SIZE) return false; - if ((bRead == false) && ((start_addr + cnts) > + if (!bRead && ((start_addr + cnts) > efuse_available_max_size)) return false; - if ((false == bRead) && (r8712_efuse_reg_init(padapter) == false)) + if (!bRead && !r8712_efuse_reg_init(padapter)) return false; /* -----------------e-fuse one byte read / write ---------------------*/ for (i = 0; i < cnts; i++) { @@ -450,10 +454,10 @@ u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr, } res = efuse_one_byte_rw(padapter, bRead, start_addr + i, data + i); - if ((false == bRead) && (false == res)) + if (!bRead && !res) break; } - if (false == bRead) + if (!bRead) r8712_efuse_reg_uninit(padapter); return res; } @@ -466,8 +470,7 @@ u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr, u16 cnts, u8 *data) if ((addr + cnts) > EFUSE_MAP_MAX_SIZE) return false; - if ((efuse_is_empty(padapter, &offset) == true) && (offset == - true)) { + if (efuse_is_empty(padapter, &offset) && offset) { for (i = 0; i < cnts; i++) data[i] = 0xFF; return ret; @@ -504,13 +507,14 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, empty = r8712_read8(padapter, EFUSE_CLK_CTRL); if (empty != 0x03) return false; - if (efuse_is_empty(padapter, &empty) == true) { - if (true == empty) + if (efuse_is_empty(padapter, &empty)) { + if (empty) memset(pktdata, 0xFF, PGPKT_DATA_SIZE); - } else + } else { return false; + } offset = (addr >> 3) & 0xF; - if (empty == false) + if (!empty) if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata)) return false; word_en = 0xF; @@ -541,8 +545,8 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, break; } - if ((data[idx] != pktdata[i]) || (data[idx+1] != - pktdata[i+1])) { + if ((data[idx] != pktdata[i]) || (data[idx + 1] != + pktdata[i + 1])) { word_en &= ~BIT(i >> 1); newdata[j++] = data[idx]; newdata[j++] = data[idx + 1]; @@ -554,13 +558,13 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, } if (word_en != 0xF) - if (r8712_efuse_pg_packet_write(padapter, offset, - word_en, newdata) == false) + if (!r8712_efuse_pg_packet_write(padapter, offset, + word_en, newdata)) return false; if (idx == cnts) break; offset++; - if (empty == false) + if (!empty) if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata)) return false; diff --git a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h index 138ea453d..44c906097 100644 --- a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h +++ b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h @@ -64,7 +64,8 @@ #define GPIOMUX_EN BIT(3) /* When this bit is set to "1", * GPIO PINs will switch to MAC - * GPIO Function*/ + * GPIO Function + */ #define GPIOSEL_GPIO 0 /* UART or JTAG or pure GPIO*/ #define GPIOSEL_PHYDBG 1 /* PHYDBG*/ #define GPIOSEL_BT 2 /* BT_coex*/ diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h index 4c51fa373..57d5d2db3 100644 --- a/drivers/staging/rtl8712/rtl8712_hal.h +++ b/drivers/staging/rtl8712/rtl8712_hal.h @@ -68,12 +68,14 @@ struct fw_priv { /*8-bytes alignment required*/ unsigned char signature_0; /*0x12: CE product, 0x92: IT product*/ unsigned char signature_1; /*0x87: CE product, 0x81: IT product*/ unsigned char hci_sel; /*0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP, - * 0x12: 72S-U, 03:SDIO*/ + * 0x12: 72S-U, 03:SDIO + */ unsigned char chip_version; /*the same value as register value*/ unsigned char customer_ID_0; /*customer ID low byte*/ unsigned char customer_ID_1; /*customer ID high byte*/ unsigned char rf_config; /*0x11: 1T1R, 0x12: 1T2R, 0x92: 1T2R turbo, - * 0x22: 2T2R*/ + * 0x22: 2T2R + */ unsigned char usb_ep_num; /* 4: 4EP, 6: 6EP, 11: 11EP*/ /*--- long word 1 ----*/ unsigned char regulatory_class_0; /*regulatory class bit map 0*/ @@ -97,7 +99,8 @@ struct fw_priv { /*8-bytes alignment required*/ unsigned char qos_en; /*1: QoS enable*/ unsigned char bw_40MHz_en; /*1: 40MHz BW enable*/ unsigned char AMSDU2AMPDU_en; /*1: 4181 convert AMSDU to AMPDU, - * 0: disable*/ + * 0: disable + */ unsigned char AMPDU_en; /*1: 11n AMPDU enable*/ unsigned char rate_control_offload; /*1: FW offloads,0: driver handles*/ unsigned char aggregation_offload; /*1: FW offloads,0: driver handles*/ @@ -125,8 +128,9 @@ struct fw_priv { /*8-bytes alignment required*/ struct fw_hdr {/*8-byte alignment required*/ unsigned short signature; - unsigned short version; /*0x8000 ~ 0x8FFF for FPGA version, - *0x0000 ~ 0x7FFF for ASIC version,*/ + unsigned short version; /* 0x8000 ~ 0x8FFF for FPGA version, + * 0x0000 ~ 0x7FFF for ASIC version, + */ unsigned int dmem_size; /*define the size of boot loader*/ unsigned int img_IMEM_size; /*define the size of FW in IMEM*/ unsigned int img_SRAM_size; /*define the size of FW in SRAM*/ diff --git a/drivers/staging/rtl8712/rtl8712_io.c b/drivers/staging/rtl8712/rtl8712_io.c index 921fcffb3..4148d48ec 100644 --- a/drivers/staging/rtl8712/rtl8712_io.c +++ b/drivers/staging/rtl8712/rtl8712_io.c @@ -36,7 +36,7 @@ u8 r8712_read8(struct _adapter *adapter, u32 addr) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); @@ -46,7 +46,7 @@ u8 r8712_read8(struct _adapter *adapter, u32 addr) u16 r8712_read16(struct _adapter *adapter, u32 addr) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); @@ -56,7 +56,7 @@ u16 r8712_read16(struct _adapter *adapter, u32 addr) u32 r8712_read32(struct _adapter *adapter, u32 addr) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); @@ -66,7 +66,7 @@ u32 r8712_read32(struct _adapter *adapter, u32 addr) void r8712_write8(struct _adapter *adapter, u32 addr, u8 val) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); @@ -76,7 +76,7 @@ void r8712_write8(struct _adapter *adapter, u32 addr, u8 val) void r8712_write16(struct _adapter *adapter, u32 addr, u16 val) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); @@ -86,8 +86,8 @@ void r8712_write16(struct _adapter *adapter, u32 addr, u16 val) void r8712_write32(struct _adapter *adapter, u32 addr, u32 val) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; - struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_queue->intf)); + struct io_queue *pio_queue = adapter->pio_queue; + struct intf_hdl *pintfhdl = &(pio_queue->intf); void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); @@ -97,13 +97,12 @@ void r8712_write32(struct _adapter *adapter, u32 addr, u32 val) void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - if ((adapter->bDriverStopped == true) || - (adapter->bSurpriseRemoved == true)) + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) return; _read_mem = pintfhdl->io_ops._read_mem; _read_mem(pintfhdl, addr, cnt, pmem); @@ -111,7 +110,7 @@ void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); @@ -122,13 +121,12 @@ void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - if ((adapter->bDriverStopped == true) || - (adapter->bSurpriseRemoved == true)) + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) return; _read_port = pintfhdl->io_ops._read_port; _read_port(pintfhdl, addr, cnt, pmem); @@ -136,7 +134,7 @@ void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; + struct io_queue *pio_queue = adapter->pio_queue; struct intf_hdl *pintfhdl = &(pio_queue->intf); u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c index ada8d5daf..9055827cc 100644 --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -122,8 +122,7 @@ static void SwLedOn(struct _adapter *padapter, struct LED_871x *pLed) { u8 LedCfg; - if ((padapter->bSurpriseRemoved == true) || - (padapter->bDriverStopped == true)) + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; LedCfg = r8712_read8(padapter, LEDCFG); switch (pLed->LedPin) { @@ -131,11 +130,11 @@ static void SwLedOn(struct _adapter *padapter, struct LED_871x *pLed) break; case LED_PIN_LED0: /* SW control led0 on.*/ - r8712_write8(padapter, LEDCFG, LedCfg&0xf0); + r8712_write8(padapter, LEDCFG, LedCfg & 0xf0); break; case LED_PIN_LED1: /* SW control led1 on.*/ - r8712_write8(padapter, LEDCFG, LedCfg&0x0f); + r8712_write8(padapter, LEDCFG, LedCfg & 0x0f); break; default: break; @@ -151,8 +150,7 @@ static void SwLedOff(struct _adapter *padapter, struct LED_871x *pLed) { u8 LedCfg; - if ((padapter->bSurpriseRemoved == true) || - (padapter->bDriverStopped == true)) + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; LedCfg = r8712_read8(padapter, LEDCFG); switch (pLed->LedPin) { @@ -160,11 +158,11 @@ static void SwLedOff(struct _adapter *padapter, struct LED_871x *pLed) break; case LED_PIN_LED0: LedCfg &= 0xf0; /* Set to software control.*/ - r8712_write8(padapter, LEDCFG, (LedCfg|BIT(3))); + r8712_write8(padapter, LEDCFG, (LedCfg | BIT(3))); break; case LED_PIN_LED1: LedCfg &= 0x0f; /* Set to software control.*/ - r8712_write8(padapter, LEDCFG, (LedCfg|BIT(7))); + r8712_write8(padapter, LEDCFG, (LedCfg | BIT(7))); break; default: break; @@ -222,11 +220,11 @@ static void SwLedBlink(struct LED_871x *pLed) bStopBlinking = true; break; case LED_BLINK_StartToBlink: - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && + if (check_fwstate(pmlmepriv, _FW_LINKED) && (pmlmepriv->fw_state & WIFI_STATION_STATE)) bStopBlinking = true; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && - ((pmlmepriv->fw_state & WIFI_ADHOC_STATE) || + if (check_fwstate(pmlmepriv, _FW_LINKED) && + ((pmlmepriv->fw_state & WIFI_ADHOC_STATE) || (pmlmepriv->fw_state & WIFI_ADHOC_MASTER_STATE))) bStopBlinking = true; else if (pLed->BlinkTimes == 0) @@ -241,11 +239,10 @@ static void SwLedBlink(struct LED_871x *pLed) break; } if (bStopBlinking) { - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && - (pLed->bLedOn == false)) + if (check_fwstate(pmlmepriv, _FW_LINKED) && + !pLed->bLedOn) SwLedOn(padapter, pLed); - else if ((check_fwstate(pmlmepriv, _FW_LINKED) == - true) && pLed->bLedOn == true) + else if (check_fwstate(pmlmepriv, _FW_LINKED) && pLed->bLedOn) SwLedOff(padapter, pLed); pLed->BlinkTimes = 0; pLed->bLedBlinkInProgress = false; @@ -296,18 +293,20 @@ static void SwLedBlink1(struct LED_871x *pLed) else SwLedOff(padapter, pLed); if (peeprompriv->CustomerID == RT_CID_DEFAULT) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { if (!pLed1->bSWLedCtrl) { SwLedOn(padapter, pLed1); pLed1->bSWLedCtrl = true; - } else if (!pLed1->bLedOn) + } else if (!pLed1->bLedOn) { SwLedOn(padapter, pLed1); + } } else { if (!pLed1->bSWLedCtrl) { SwLedOff(padapter, pLed1); pLed1->bSWLedCtrl = true; - } else if (pLed1->bLedOn) + } else if (pLed1->bLedOn) { SwLedOff(padapter, pLed1); + } } } switch (pLed->CurrLedState) { @@ -332,7 +331,7 @@ static void SwLedBlink1(struct LED_871x *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_NORMAL; if (pLed->bLedOn) @@ -366,7 +365,7 @@ static void SwLedBlink1(struct LED_871x *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_NORMAL; if (pLed->bLedOn) @@ -410,8 +409,9 @@ static void SwLedBlink1(struct LED_871x *pLed) mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA)); bStopBlinking = false; - } else + } else { bStopBlinking = true; + } if (bStopBlinking) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_NORMAL; @@ -446,7 +446,7 @@ static void SwLedBlink2(struct LED_871x *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; SwLedOn(padapter, pLed); @@ -470,7 +470,7 @@ static void SwLedBlink2(struct LED_871x *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; SwLedOn(padapter, pLed); @@ -512,7 +512,7 @@ static void SwLedBlink3(struct LED_871x *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; if (!pLed->bLedOn) @@ -538,7 +538,7 @@ static void SwLedBlink3(struct LED_871x *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; if (!pLed->bLedOn) @@ -573,8 +573,9 @@ static void SwLedBlink3(struct LED_871x *pLed) mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA)); bStopBlinking = false; - } else + } else { bStopBlinking = true; + } if (bStopBlinking) { pLed->CurrLedState = LED_ON; pLed->BlinkingLedState = LED_ON; @@ -827,8 +828,7 @@ static void BlinkTimerCallback(unsigned long data) /* This fixed the crash problem on Fedora 12 when trying to do the * insmod;ifconfig up;rmmod commands. */ - if ((pLed->padapter->bSurpriseRemoved == true) || - (pLed->padapter->bDriverStopped == true)) + if (pLed->padapter->bSurpriseRemoved || pLed->padapter->bDriverStopped) return; schedule_work(&pLed->BlinkWorkItem); } @@ -893,15 +893,15 @@ static void SwLedControlMode1(struct _adapter *padapter, switch (LedAction) { case LED_CTL_START_TO_LINK: case LED_CTL_NO_LINK: - if (pLed->bLedNoLinkBlinkInProgress == false) { + if (!pLed->bLedNoLinkBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedLinkBlinkInProgress == true) { + if (pLed->bLedLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -916,15 +916,15 @@ static void SwLedControlMode1(struct _adapter *padapter, } break; case LED_CTL_LINK: - if (pLed->bLedLinkBlinkInProgress == false) { + if (!pLed->bLedLinkBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -939,21 +939,21 @@ static void SwLedControlMode1(struct _adapter *padapter, } break; case LED_CTL_SITE_SURVEY: - if ((psitesurveyctrl->traffic_busy) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) + if (psitesurveyctrl->traffic_busy && + check_fwstate(pmlmepriv, _FW_LINKED)) ; /* dummy branch */ - else if (pLed->bLedScanBlinkInProgress == false) { + else if (!pLed->bLedScanBlinkInProgress) { if (IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedLinkBlinkInProgress == true) { + if (pLed->bLedLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -970,15 +970,15 @@ static void SwLedControlMode1(struct _adapter *padapter, break; case LED_CTL_TX: case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false) { + if (!pLed->bLedBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedLinkBlinkInProgress == true) { + if (pLed->bLedLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } @@ -996,20 +996,20 @@ static void SwLedControlMode1(struct _adapter *padapter, case LED_CTL_START_WPS: /*wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedLinkBlinkInProgress == true) { + if (pLed->bLedLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedScanBlinkInProgress == true) { + if (pLed->bLedScanBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } @@ -1024,19 +1024,19 @@ static void SwLedControlMode1(struct _adapter *padapter, } break; case LED_CTL_STOP_WPS: - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedLinkBlinkInProgress == true) { + if (pLed->bLedLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedScanBlinkInProgress == true) { + if (pLed->bLedScanBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } @@ -1111,11 +1111,11 @@ static void SwLedControlMode2(struct _adapter *padapter, case LED_CTL_SITE_SURVEY: if (pmlmepriv->sitesurveyctrl.traffic_busy) ; /* dummy branch */ - else if (pLed->bLedScanBlinkInProgress == false) { + else if (!pLed->bLedScanBlinkInProgress) { if (IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1133,8 +1133,8 @@ static void SwLedControlMode2(struct _adapter *padapter, case LED_CTL_TX: case LED_CTL_RX: - if ((pLed->bLedBlinkInProgress == false) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + if (!pLed->bLedBlinkInProgress && + check_fwstate(pmlmepriv, _FW_LINKED)) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; @@ -1168,12 +1168,12 @@ static void SwLedControlMode2(struct _adapter *padapter, case LED_CTL_START_WPS: /*wait until xinpin finish*/ case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedScanBlinkInProgress == true) { + if (pLed->bLedScanBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } @@ -1244,10 +1244,10 @@ static void SwLedControlMode3(struct _adapter *padapter, case LED_CTL_SITE_SURVEY: if (pmlmepriv->sitesurveyctrl.traffic_busy) ; /* dummy branch */ - else if (pLed->bLedScanBlinkInProgress == false) { + else if (!pLed->bLedScanBlinkInProgress) { if (IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1264,8 +1264,8 @@ static void SwLedControlMode3(struct _adapter *padapter, break; case LED_CTL_TX: case LED_CTL_RX: - if ((pLed->bLedBlinkInProgress == false) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + if (!pLed->bLedBlinkInProgress && + check_fwstate(pmlmepriv, _FW_LINKED)) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; @@ -1298,12 +1298,12 @@ static void SwLedControlMode3(struct _adapter *padapter, break; case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedScanBlinkInProgress == true) { + if (pLed->bLedScanBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } @@ -1321,8 +1321,9 @@ static void SwLedControlMode3(struct _adapter *padapter, if (pLed->bLedWPSBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; - } else + } else { pLed->bLedWPSBlinkInProgress = true; + } pLed->CurrLedState = LED_BLINK_WPS_STOP; if (pLed->bLedOn) { pLed->BlinkingLedState = LED_OFF; @@ -1395,15 +1396,15 @@ static void SwLedControlMode4(struct _adapter *padapter, mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(0)); } - if (pLed->bLedStartToLinkBlinkInProgress == false) { + if (!pLed->bLedStartToLinkBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } @@ -1434,11 +1435,11 @@ static void SwLedControlMode4(struct _adapter *padapter, jiffies + msecs_to_jiffies(0)); } } - if (pLed->bLedNoLinkBlinkInProgress == false) { + if (!pLed->bLedNoLinkBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1453,17 +1454,17 @@ static void SwLedControlMode4(struct _adapter *padapter, } break; case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->sitesurveyctrl.traffic_busy) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) + if (pmlmepriv->sitesurveyctrl.traffic_busy && + check_fwstate(pmlmepriv, _FW_LINKED)) ; - else if (pLed->bLedScanBlinkInProgress == false) { + else if (!pLed->bLedScanBlinkInProgress) { if (IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1480,11 +1481,11 @@ static void SwLedControlMode4(struct _adapter *padapter, break; case LED_CTL_TX: case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false) { + if (!pLed->bLedBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } @@ -1510,16 +1511,16 @@ static void SwLedControlMode4(struct _adapter *padapter, mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(0)); } - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedNoLinkBlinkInProgress == true) { + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress == true) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedScanBlinkInProgress == true) { + if (pLed->bLedScanBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } @@ -1666,11 +1667,11 @@ static void SwLedControlMode5(struct _adapter *padapter, jiffies + msecs_to_jiffies(0)); break; case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->sitesurveyctrl.traffic_busy) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) + if (pmlmepriv->sitesurveyctrl.traffic_busy && + check_fwstate(pmlmepriv, _FW_LINKED)) ; /* dummy branch */ - else if (pLed->bLedScanBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { + else if (!pLed->bLedScanBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1687,7 +1688,7 @@ static void SwLedControlMode5(struct _adapter *padapter, break; case LED_CTL_TX: case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false) { + if (!pLed->bLedBlinkInProgress) { if (pLed->CurrLedState == LED_SCAN_BLINK) return; pLed->bLedBlinkInProgress = true; @@ -1737,8 +1738,8 @@ static void SwLedControlMode6(struct _adapter *padapter, break; case LED_CTL_TX: case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + if (!pLed->bLedBlinkInProgress && + check_fwstate(pmlmepriv, _FW_LINKED)) { if (IS_LED_WPS_BLINKING(pLed)) return; pLed->bLedBlinkInProgress = true; @@ -1754,8 +1755,8 @@ static void SwLedControlMode6(struct _adapter *padapter, break; case LED_CTL_START_WPS: /*wait until xinpin finish*/ case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { del_timer(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1805,7 +1806,7 @@ void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &(padapter->ledpriv); - if (ledpriv->bRegUseLed == false) + if (!ledpriv->bRegUseLed) return; switch (ledpriv->LedStrategy) { case SW_LED_MODE0: diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 4fa2540a6..d187508dd 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -89,7 +89,7 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter) RECVBUFF_ALIGN_SZ); if (pskb) { tmpaddr = (addr_t)pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); } @@ -158,9 +158,9 @@ int r8712_free_recvframe(union recv_frame *precvframe, static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, struct recv_stat *prxstat) { - u16 drvinfo_sz = 0; + u16 drvinfo_sz; - drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16; + drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16; drvinfo_sz <<= 3; /*TODO: * Offset 0 */ @@ -180,8 +180,9 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, pattrib->ip_chkrpt = 1; /* correct */ else pattrib->ip_chkrpt = 0; /* incorrect */ - } else + } else { pattrib->tcpchk_valid = 0; /* invalid */ + } pattrib->mcs_rate = (u8)((le32_to_cpu(prxstat->rxdw3)) & 0x3f); pattrib->htc = (u8)((le32_to_cpu(prxstat->rxdw3) >> 14) & 0x1); /*Offset 16*/ @@ -217,7 +218,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter, curfragnum++; plist = &defrag_q->queue; plist = plist->next; - while (end_of_queue_search(phead, plist) == false) { + while (!end_of_queue_search(phead, plist)) { pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); pnfhdr = &pnextrframe->u.hdr; /*check the fragment sequence (2nd ~n fragment frame) */ @@ -414,8 +415,9 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe) if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1)) { sub_skb->ip_summed = CHECKSUM_UNNECESSARY; - } else + } else { sub_skb->ip_summed = CHECKSUM_NONE; + } netif_rx(sub_skb); } } @@ -489,7 +491,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, phead = &ppending_recvframe_queue->queue; plist = phead->next; - while (end_of_queue_search(phead, plist) == false) { + while (!end_of_queue_search(phead, plist)) { pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); pnextattrib = &pnextrframe->u.hdr.attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) @@ -519,7 +521,7 @@ int r8712_recv_indicatepkts_in_order(struct _adapter *padapter, phead = &ppending_recvframe_queue->queue; plist = phead->next; /* Handling some condition for forced indicate case.*/ - if (bforced == true) { + if (bforced) { if (list_empty(phead)) return true; @@ -541,8 +543,8 @@ int r8712_recv_indicatepkts_in_order(struct _adapter *padapter, (preorder_ctrl->indicate_seq + 1) % 4096; /*indicate this recv_frame*/ if (!pattrib->amsdu) { - if ((padapter->bDriverStopped == false) && - (padapter->bSurpriseRemoved == false)) { + if (!padapter->bDriverStopped && + !padapter->bSurpriseRemoved) { /* indicate this recv_frame */ r8712_recv_indicatepkt(padapter, prframe); @@ -576,12 +578,13 @@ static int recv_indicatepkt_reorder(struct _adapter *padapter, /* s1. */ r8712_wlanhdr_to_ethhdr(prframe); if (pattrib->qos != 1) { - if ((padapter->bDriverStopped == false) && - (padapter->bSurpriseRemoved == false)) { + if (!padapter->bDriverStopped && + !padapter->bSurpriseRemoved) { r8712_recv_indicatepkt(padapter, prframe); return _SUCCESS; - } else + } else { return _FAIL; + } } } spin_lock_irqsave(&ppending_recvframe_queue->lock, irql); @@ -643,20 +646,20 @@ static int r8712_process_recv_indicatepkts(struct _adapter *padapter, if (phtpriv->ht_option == 1) { /*B/G/N Mode*/ if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { /* including perform A-MPDU Rx Ordering Buffer Control*/ - if ((padapter->bDriverStopped == false) && - (padapter->bSurpriseRemoved == false)) + if (!padapter->bDriverStopped && + !padapter->bSurpriseRemoved) return _FAIL; } } else { /*B/G mode*/ retval = r8712_wlanhdr_to_ethhdr(prframe); if (retval != _SUCCESS) return retval; - if ((padapter->bDriverStopped == false) && - (padapter->bSurpriseRemoved == false)) { + if (!padapter->bDriverStopped && !padapter->bSurpriseRemoved) { /* indicate this recv_frame */ r8712_recv_indicatepkt(padapter, prframe); - } else + } else { return _FAIL; + } } return retval; } @@ -813,16 +816,16 @@ static void query_rx_phy_status(struct _adapter *padapter, /* * (3) Get Signal Quality (EVM) */ - if (pwdb_all > 40) + if (pwdb_all > 40) { sq = 100; - else { + } else { sq = pcck_buf->sq_rpt; if (pcck_buf->sq_rpt > 64) sq = 0; else if (pcck_buf->sq_rpt < 20) sq = 100; else - sq = ((64-sq) * 100) / 44; + sq = ((64 - sq) * 100) / 44; } prframe->u.hdr.attrib.signal_qual = sq; prframe->u.hdr.attrib.rx_mimo_signal_qual[0] = sq; @@ -962,12 +965,12 @@ int recv_func(struct _adapter *padapter, void *pcontext) prframe = (union recv_frame *)pcontext; orig_prframe = prframe; pattrib = &prframe->u.hdr.attrib; - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { if (pattrib->crc_err == 1) padapter->mppriv.rx_crcerrpktcount++; else padapter->mppriv.rx_pktcount++; - if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) { + if (!check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE)) { /* free this recv_frame */ r8712_free_recvframe(orig_prframe, pfree_recv_queue); goto _exit_recv_func; @@ -1019,8 +1022,8 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) pfree_recv_queue = &(precvpriv->free_recv_queue); pbuf = pskb->data; prxstat = (struct recv_stat *)pbuf; - pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16)&0xff; - pkt_len = le32_to_cpu(prxstat->rxdw0)&0x00003fff; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; + pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff; transfer_len = pskb->len; /* Test throughput with Netgear 3700 (No security) with Chariot 3T3R * pairs. The packet count will be a big number so that the containing @@ -1032,7 +1035,7 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) } do { prxstat = (struct recv_stat *)pbuf; - pkt_len = le32_to_cpu(prxstat->rxdw0)&0x00003fff; + pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff; /* more fragment bit */ mf = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1; /* ragmentation number */ diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index 86206d34a..b21a60e9f 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -96,13 +96,13 @@ static u32 get_ff_hwaddr(struct xmit_frame *pxmitframe) u32 addr = 0; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct _adapter *padapter = pxmitframe->padapter; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; - if (pxmitframe->frame_tag == TXAGG_FRAMETAG) + if (pxmitframe->frame_tag == TXAGG_FRAMETAG) { addr = RTL8712_DMA_H2CCMD; - else if (pxmitframe->frame_tag == MGNT_FRAMETAG) + } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) { addr = RTL8712_DMA_MGTQ; - else if (pdvobj->nr_endpoint == 6) { + } else if (pdvobj->nr_endpoint == 6) { switch (pattrib->priority) { case 0: case 3: @@ -168,7 +168,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, xmitframe_phead = &pframe_queue->queue; xmitframe_plist = xmitframe_phead->next; - if ((end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) { + if (!end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); list_del_init(&pxmitframe->list); @@ -208,7 +208,7 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv, phwxmit = phwxmit_i + inx[i]; sta_phead = &phwxmit->sta_queue->queue; sta_plist = sta_phead->next; - while ((end_of_queue_search(sta_phead, sta_plist)) == false) { + while (!end_of_queue_search(sta_phead, sta_plist)) { ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); pframe_queue = &ptxservq->sta_pending; @@ -237,11 +237,11 @@ void r8712_do_queue_select(struct _adapter *padapter, struct pkt_attrib *pattrib) { unsigned int qsel = 0; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; - if (pdvobj->nr_endpoint == 6) + if (pdvobj->nr_endpoint == 6) { qsel = (unsigned int) pattrib->priority; - else if (pdvobj->nr_endpoint == 4) { + } else if (pdvobj->nr_endpoint == 4) { qsel = (unsigned int) pattrib->priority; if (qsel == 0 || qsel == 3) qsel = 3; @@ -264,13 +264,14 @@ u8 r8712_construct_txaggr_cmd_desc(struct xmit_buf *pxmitbuf) /* Fill up TxCmd Descriptor according as USB FW Tx Aaggregation info.*/ /* dw0 */ - ptx_desc->txdw0 = cpu_to_le32(CMD_HDR_SZ&0xffff); + ptx_desc->txdw0 = cpu_to_le32(CMD_HDR_SZ & 0xffff); ptx_desc->txdw0 |= - cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* dw1 */ - ptx_desc->txdw1 |= cpu_to_le32((0x13<txdw1 |= cpu_to_le32((0x13 << QSEL_SHT) & 0x00001f00); return _SUCCESS; } @@ -322,12 +323,14 @@ u8 r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf, int i; for (i = 0; i < padding_sz; i++) - *(pxmitframe->buf_addr+TXDESC_SIZE+last_txcmdsz+i) = 0; + *(pxmitframe->buf_addr + TXDESC_SIZE + last_txcmdsz + + i) = 0; } /* Add the new mpdu's length */ - ptx_desc->txdw0 = cpu_to_le32((ptx_desc->txdw0&0xffff0000) | - ((ptx_desc->txdw0&0x0000ffff)+ - ((TXDESC_SIZE+last_txcmdsz+padding_sz)&0x0000ffff))); + ptx_desc->txdw0 = cpu_to_le32((ptx_desc->txdw0 & 0xffff0000) | + ((ptx_desc->txdw0 & 0x0000ffff) + + ((TXDESC_SIZE + last_txcmdsz + padding_sz) & + 0x0000ffff))); return _SUCCESS; } @@ -341,7 +344,7 @@ u8 r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf, pxmitbuf->priv_data = pxmitframe; pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0]; /* buffer addr assoc */ - pxmitframe->buf_addr = pxmitbuf->pbuf+TXDESC_SIZE+CMD_HDR_SZ; + pxmitframe->buf_addr = pxmitbuf->pbuf + TXDESC_SIZE + CMD_HDR_SZ; /*RTL8712_DMA_H2CCMD */ r8712_construct_txaggr_cmd_desc(pxmitbuf); r8712_construct_txaggr_cmd_hdr(pxmitbuf); @@ -374,37 +377,40 @@ u8 r8712_dump_aggr_xframe(struct xmit_buf *pxmitbuf, struct xmit_frame *pxmitframe) { struct _adapter *padapter = pxmitframe->padapter; - struct dvobj_priv *pdvobj = (struct dvobj_priv *) &padapter->dvobjpriv; - struct tx_desc *ptxdesc = (struct tx_desc *)pxmitbuf->pbuf; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; + struct tx_desc *ptxdesc = pxmitbuf->pbuf; struct cmd_hdr *pcmd_hdr = (struct cmd_hdr *) (pxmitbuf->pbuf + TXDESC_SIZE); u16 total_length = (u16) (ptxdesc->txdw0 & 0xffff); /* use 1st xmitframe as media */ xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf); - pcmd_hdr->cmd_dw0 = cpu_to_le32(((total_length-CMD_HDR_SZ)&0x0000ffff)| - (pcmd_hdr->cmd_dw0&0xffff0000)); + pcmd_hdr->cmd_dw0 = cpu_to_le32(((total_length - CMD_HDR_SZ) & + 0x0000ffff) | (pcmd_hdr->cmd_dw0 & + 0xffff0000)); /* urb length in cmd_dw1 */ pcmd_hdr->cmd_dw1 = cpu_to_le32((pxmitbuf->aggr_nr & 0xff)| - ((total_length+TXDESC_SIZE) << 16)); + ((total_length + TXDESC_SIZE) << 16)); pxmitframe->last[0] = 1; pxmitframe->bpending[0] = false; pxmitframe->mem_addr = pxmitbuf->pbuf; - if ((pdvobj->ishighspeed && ((total_length+TXDESC_SIZE)%0x200) == 0) || - ((!pdvobj->ishighspeed && - ((total_length+TXDESC_SIZE)%0x40) == 0))) { + if ((pdvobj->ishighspeed && ((total_length + TXDESC_SIZE) % 0x200) == + 0) || ((!pdvobj->ishighspeed && ((total_length + TXDESC_SIZE) % + 0x40) == 0))) { ptxdesc->txdw0 |= cpu_to_le32 - (((TXDESC_SIZE+OFFSET_SZ+8)<txdw0 |= cpu_to_le32 - (((TXDESC_SIZE+OFFSET_SZ)<padapter, RTL8712_DMA_H2CCMD, - total_length+TXDESC_SIZE, (u8 *)pxmitframe); + total_length + TXDESC_SIZE, (u8 *)pxmitframe); return _SUCCESS; } @@ -420,9 +426,9 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) struct security_priv *psecuritypriv = &padapter->securitypriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct tx_desc *ptxdesc = (struct tx_desc *)pmem; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; #ifdef CONFIG_R8712_TX_AGGR - struct cmd_priv *pcmdpriv = (struct cmd_priv *)&padapter->cmdpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; #endif u8 blnSetTxDescOffset; sint bmcst = IS_MCAST(pattrib->ra); @@ -432,7 +438,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) memcpy(&txdesc_mp, ptxdesc, sizeof(struct tx_desc)); memset(ptxdesc, 0, sizeof(struct tx_desc)); /* offset 0 */ - ptxdesc->txdw0 |= cpu_to_le32(sz&0x0000ffff); + ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff); if (pdvobj->ishighspeed) { if (((sz + TXDESC_SIZE) % 512) == 0) blnSetTxDescOffset = 1; @@ -446,42 +452,42 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) } if (blnSetTxDescOffset) { /* 32 bytes for TX Desc + 8 bytes pending */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ + 8) << + ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ + 8) << OFFSET_SHT) & 0x00ff0000); } else { /* default = 32 bytes for TX Desc */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ) << + ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff0000); } ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); if (pxmitframe->frame_tag == DATA_FRAMETAG) { /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id)&0x1f); + ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x1f); #ifdef CONFIG_R8712_TX_AGGR /* dirty workaround, need to check if it is aggr cmd. */ if ((u8 *)pmem != (u8 *)pxmitframe->pxmitbuf->pbuf) { ptxdesc->txdw0 |= cpu_to_le32 - ((0x3 << TYPE_SHT)&TYPE_MSK); + ((0x3 << TYPE_SHT) & TYPE_MSK); qsel = (uint)(pattrib->qsel & 0x0000001f); if (qsel == 2) qsel = 0; ptxdesc->txdw1 |= cpu_to_le32 ((qsel << QSEL_SHT) & 0x00001f00); ptxdesc->txdw2 = cpu_to_le32 - ((qsel << RTS_RC_SHT)&0x001f0000); + ((qsel << RTS_RC_SHT) & 0x001f0000); ptxdesc->txdw6 |= cpu_to_le32 - ((0x5 << RSVD6_SHT)&RSVD6_MSK); + ((0x5 << RSVD6_SHT) & RSVD6_MSK); } else { ptxdesc->txdw0 |= cpu_to_le32 - ((0x3 << TYPE_SHT)&TYPE_MSK); + ((0x3 << TYPE_SHT) & TYPE_MSK); ptxdesc->txdw1 |= cpu_to_le32 ((0x13 << QSEL_SHT) & 0x00001f00); qsel = (uint)(pattrib->qsel & 0x0000001f); if (qsel == 2) qsel = 0; ptxdesc->txdw2 = cpu_to_le32 - ((qsel << RTS_RC_SHT)&0x0001f000); + ((qsel << RTS_RC_SHT) & 0x0001f000); ptxdesc->txdw7 |= cpu_to_le32 (pcmdpriv->cmd_seq << 24); pcmdpriv->cmd_seq++; @@ -593,7 +599,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); } else { /* offset 4 */ - qsel = (uint)(pattrib->priority&0x0000001f); + qsel = (uint)(pattrib->priority & 0x0000001f); ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); /*offset 8*/ /*offset 12*/ diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index ef7182961..562a10203 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -70,7 +70,7 @@ static sint _init_cmd_priv(struct cmd_priv *pcmdpriv) return _FAIL; pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((addr_t)(pcmdpriv->cmd_allocated_buf) & - (CMDBUFF_ALIGN_SZ-1)); + (CMDBUFF_ALIGN_SZ - 1)); pcmdpriv->rsp_allocated_buf = kmalloc(MAX_RSPSZ + 4, GFP_ATOMIC); if (pcmdpriv->rsp_allocated_buf == NULL) return _FAIL; @@ -137,9 +137,9 @@ static struct cmd_obj *_dequeue_cmd(struct __queue *queue) struct cmd_obj *obj; spin_lock_irqsave(&(queue->lock), irqL); - if (list_empty(&(queue->queue))) + if (list_empty(&(queue->queue))) { obj = NULL; - else { + } else { obj = LIST_CONTAINOR(queue->queue.next, struct cmd_obj, list); list_del_init(&obj->list); @@ -172,7 +172,7 @@ u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { int res; - if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true) + if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) return _FAIL; res = _enqueue_cmd(&pcmdpriv->cmd_queue, obj); up(&pcmdpriv->cmd_queue_sema); @@ -186,7 +186,7 @@ u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) if (obj == NULL) return _SUCCESS; - if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true) + if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) return _FAIL; queue = &pcmdpriv->cmd_queue; spin_lock_irqsave(&queue->lock, irqL); @@ -485,7 +485,7 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) return _FAIL; /* for hidden ap to set fw_state here */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) != + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) != true) { switch (ndis_network_mode) { case Ndis802_11IBSS: @@ -508,18 +508,18 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) memcpy(psecnetwork, &pnetwork->network, sizeof(*psecnetwork)); psecuritypriv->authenticator_ie[0] = (unsigned char) psecnetwork->IELength; - if ((psecnetwork->IELength-12) < (256 - 1)) + if ((psecnetwork->IELength - 12) < (256 - 1)) memcpy(&psecuritypriv->authenticator_ie[1], - &psecnetwork->IEs[12], psecnetwork->IELength-12); + &psecnetwork->IEs[12], psecnetwork->IELength - 12); else memcpy(&psecuritypriv->authenticator_ie[1], - &psecnetwork->IEs[12], (256-1)); + &psecnetwork->IEs[12], (256 - 1)); psecnetwork->IELength = 0; /* If the driver wants to use the bssid to create the connection. * If not, we copy the connecting AP's MAC address to it so that * the driver just has the bssid information for PMKIDList searching. */ - if (pmlmepriv->assoc_by_bssid == false) + if (!pmlmepriv->assoc_by_bssid) ether_addr_copy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0]); psecnetwork->IELength = r8712_restruct_sec_ie(padapter, @@ -538,8 +538,9 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) if (psecnetwork->IELength != tmp_len) { psecnetwork->IELength = tmp_len; pqospriv->qos_option = 1; /* WMM IE in beacon */ - } else + } else { pqospriv->qos_option = 0; /* no WMM IE in beacon */ + } } if (pregistrypriv->ht_enable) { /* For WEP mode, we will use the bg mode to do the connection @@ -679,7 +680,7 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) else GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); - if (unicast_key == true) + if (unicast_key) memcpy(&psetstakey_para->key, &sta->x_UncstKey, 16); else memcpy(&psetstakey_para->key, diff --git a/drivers/staging/rtl8712/rtl871x_eeprom.c b/drivers/staging/rtl8712/rtl871x_eeprom.c index 50339e67d..4e713610a 100644 --- a/drivers/staging/rtl8712/rtl871x_eeprom.c +++ b/drivers/staging/rtl8712/rtl871x_eeprom.c @@ -49,7 +49,7 @@ static void shift_out_bits(struct _adapter *padapter, u16 data, u16 count) { u16 x, mask; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; mask = 0x01 << (count - 1); x = r8712_read8(padapter, EE_9346CR); @@ -58,7 +58,7 @@ static void shift_out_bits(struct _adapter *padapter, u16 data, u16 count) x &= ~_EEDI; if (data & mask) x |= _EEDI; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; r8712_write8(padapter, EE_9346CR, (u8)x); udelay(CLOCK_RATE); @@ -66,7 +66,7 @@ static void shift_out_bits(struct _adapter *padapter, u16 data, u16 count) down_clk(padapter, &x); mask >>= 1; } while (mask); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x &= ~_EEDI; r8712_write8(padapter, EE_9346CR, (u8)x); @@ -77,7 +77,7 @@ static u16 shift_in_bits(struct _adapter *padapter) { u16 x, d = 0, i; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x = r8712_read8(padapter, EE_9346CR); x &= ~(_EEDO | _EEDI); @@ -85,7 +85,7 @@ static u16 shift_in_bits(struct _adapter *padapter) for (i = 0; i < 16; i++) { d <<= 1; up_clk(padapter, &x); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x = r8712_read8(padapter, EE_9346CR); x &= ~(_EEDI); @@ -129,17 +129,17 @@ static void eeprom_clean(struct _adapter *padapter) { u16 x; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) return; x = r8712_read8(padapter, EE_9346CR); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) return; x &= ~(_EECS | _EEDI); r8712_write8(padapter, EE_9346CR, (u8)x); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) return; up_clk(padapter, &x); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) return; down_clk(padapter, &x); } @@ -206,11 +206,11 @@ u16 r8712_eeprom_read16(struct _adapter *padapter, u16 reg) /*ReadEEprom*/ tmp8_clk_new = tmp8_clk_ori | 0x20; if (tmp8_clk_new != tmp8_clk_ori) r8712_write8(padapter, 0x10250003, tmp8_clk_new); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; /* select EEPROM, reset bits, set _EECS */ x = r8712_read8(padapter, EE_9346CR); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x &= ~(_EEDI | _EEDO | _EESK | _EEM0); x |= _EEM1 | _EECS; diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c index e4e5b13cb..fbbc63570 100644 --- a/drivers/staging/rtl8712/rtl871x_io.c +++ b/drivers/staging/rtl8712/rtl871x_io.c @@ -150,7 +150,7 @@ alloc_io_queue_fail: void r8712_free_io_queue(struct _adapter *adapter) { - struct io_queue *pio_queue = (struct io_queue *)(adapter->pio_queue); + struct io_queue *pio_queue = adapter->pio_queue; if (pio_queue) { kfree(pio_queue->pallocated_free_ioreqs_buf); diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h index 070cc03ce..26dd24cdd 100644 --- a/drivers/staging/rtl8712/rtl871x_io.h +++ b/drivers/staging/rtl8712/rtl871x_io.h @@ -232,14 +232,6 @@ struct io_queue { struct intf_hdl intf; }; -static inline u32 _RND4(u32 sz) -{ - u32 val; - - val = ((sz >> 2) + ((sz & 3) ? 1 : 0)) << 2; - return val; -} - u8 r8712_read8(struct _adapter *adapter, u32 addr); u16 r8712_read16(struct _adapter *adapter, u32 addr); u32 r8712_read32(struct _adapter *adapter, u32 addr); diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 143be0fdc..edfc6805e 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -72,32 +72,6 @@ static const char * const iw_operation_mode[] = { "Monitor" }; -/** - * hwaddr_aton - Convert ASCII string to MAC address - * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") - * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) - * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) - */ -static int hwaddr_aton_i(const char *txt, u8 *addr) -{ - int i; - - for (i = 0; i < 6; i++) { - int a, b; - - a = hex_to_bin(*txt++); - if (a < 0) - return -1; - b = hex_to_bin(*txt++); - if (b < 0) - return -1; - *addr++ = (a << 4) | b; - if (i < 5 && *txt++ != ':') - return -1; - } - return 0; -} - void r8712_indicate_wx_assoc_event(struct _adapter *padapter) { union iwreq_data wrqu; @@ -140,16 +114,17 @@ static inline void handle_pairwise_key(struct sta_info *psta, static inline void handle_group_key(struct ieee_param *param, struct _adapter *padapter) { - if (0 < param->u.crypt.idx && + if (param->u.crypt.idx > 0 && param->u.crypt.idx < 3) { /* group key idx is 1 or 2 */ memcpy(padapter->securitypriv.XGrpKey[param->u.crypt. - idx-1].skey, param->u.crypt.key, (param->u.crypt.key_len - > 16 ? 16 : param->u.crypt.key_len)); + idx - 1].skey, param->u.crypt.key, + (param->u.crypt.key_len > 16 ? 16 : + param->u.crypt.key_len)); memcpy(padapter->securitypriv.XGrptxmickey[param-> - u.crypt.idx-1].skey, &(param->u.crypt.key[16]), 8); + u.crypt.idx - 1].skey, &(param->u.crypt.key[16]), 8); memcpy(padapter->securitypriv. XGrprxmickey[param-> - u.crypt.idx-1].skey, &(param->u.crypt.key[24]), 8); + u.crypt.idx - 1].skey, &(param->u.crypt.key[24]), 8); padapter->securitypriv.binstallGrpkey = true; r8712_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx); @@ -204,17 +179,17 @@ static inline char *translate_scan(struct _adapter *padapter, /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; if (r8712_is_cckratesonly_included(pnetwork->network.rates)) { - if (ht_cap == true) + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); } else if (r8712_is_cckrates_included(pnetwork->network.rates)) { - if (ht_cap == true) + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (ht_cap == true) + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); @@ -225,7 +200,7 @@ static inline char *translate_scan(struct _adapter *padapter, memcpy((u8 *)&cap, r8712_get_capability_from_ie(pnetwork->network.IEs), 2); cap = le16_to_cpu(cap); - if (cap & (WLAN_CAPABILITY_IBSS|WLAN_CAPABILITY_BSS)) { + if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { if (cap & WLAN_CAPABILITY_BSS) iwe.u.mode = (u32)IW_MODE_MASTER; else @@ -336,7 +311,7 @@ static inline char *translate_scan(struct _adapter *padapter, if (r8712_get_wps_ie(pnetwork->network.IEs, pnetwork->network.IELength, - wps_ie, &wps_ielen) == true) { + wps_ie, &wps_ielen)) { if (wps_ielen > 2) { iwe.cmd = IWEVGENIE; iwe.u.data.length = (u16)wps_ielen; @@ -382,8 +357,9 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value) Ndis802_11AuthModeOpen; padapter->securitypriv.AuthAlgrthm = 0; } - } else + } else { ret = -EINVAL; + } return ret; } @@ -407,8 +383,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, /* for large key indices, set the default (0) */ param->u.crypt.idx = 0; } - } else + } else { return -EINVAL; + } if (strcmp(param->u.crypt.alg, "WEP") == 0) { netdev_info(dev, "r8712u: %s: crypt.alg = WEP\n", __func__); padapter->securitypriv.ndisencryptstatus = @@ -437,8 +414,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, padapter->securitypriv.XGrpPrivacy = _WEP104_; } - } else + } else { return -EINVAL; + } pwep->KeyIndex = wep_key_idx; pwep->KeyIndex |= 0x80000000; memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); @@ -469,7 +447,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, struct sta_priv *pstapriv = &padapter->stapriv; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | - WIFI_MP_STATE) == true) { /* sta mode */ + WIFI_MP_STATE)) { /* sta mode */ psta = r8712_get_stainfo(pstapriv, get_bssid(pmlmepriv)); if (psta) { @@ -598,10 +576,10 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, eid = buf[cnt]; if ((eid == _VENDOR_SPECIFIC_IE_) && - (!memcmp(&buf[cnt+2], wps_oui, 4))) { + (!memcmp(&buf[cnt + 2], wps_oui, 4))) { netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE\n"); padapter->securitypriv.wps_ie_len = - ((buf[cnt+1] + 2) < + ((buf[cnt + 1] + 2) < (MAX_WPA_IE_LEN << 2)) ? (buf[cnt + 1] + 2) : (MAX_WPA_IE_LEN << 2); @@ -611,10 +589,11 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, padapter->securitypriv.wps_phase = true; netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE, wps_phase==true\n"); - cnt += buf[cnt+1]+2; + cnt += buf[cnt + 1] + 2; break; - } else + } else { cnt += buf[cnt + 1] + 2; + } } } } @@ -635,7 +614,7 @@ static int r8711_wx_get_name(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; u8 *prates; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, @@ -643,30 +622,31 @@ static int r8711_wx_get_name(struct net_device *dev, if (p && ht_ielen > 0) ht_cap = true; prates = pcur_bss->rates; - if (r8712_is_cckratesonly_included(prates) == true) { - if (ht_cap == true) + if (r8712_is_cckratesonly_included(prates)) { + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((r8712_is_cckrates_included(prates)) == true) { - if (ht_cap == true) + } else if (r8712_is_cckrates_included(prates)) { + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (ht_cap == true) + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); } - } else + } else { snprintf(wrqu->name, IFNAMSIZ, "unassociated"); + } return 0; } @@ -700,14 +680,14 @@ static int r8711_wx_set_freq(struct net_device *dev, fwrq->m = c + 1; } /* Setting by channel number */ - if ((fwrq->m > 14) || (fwrq->e > 0)) + if ((fwrq->m > 14) || (fwrq->e > 0)) { rc = -EOPNOTSUPP; - else { + } else { int channel = fwrq->m; - if ((channel < 1) || (channel > 14)) + if ((channel < 1) || (channel > 14)) { rc = -EINVAL; - else { + } else { /* Yes ! We can set it !!! */ padapter->registrypriv.channel = channel; } @@ -723,9 +703,9 @@ static int r8711_wx_get_freq(struct net_device *dev, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { wrqu->freq.m = ieee80211_wlan_frequencies[ - pcur_bss->Configuration.DSConfig-1] * 100000; + pcur_bss->Configuration.DSConfig - 1] * 100000; wrqu->freq.e = 1; wrqu->freq.i = pcur_bss->Configuration.DSConfig; } else { @@ -772,12 +752,12 @@ static int r8711_wx_get_mode(struct net_device *dev, struct iw_request_info *a, struct _adapter *padapter = netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) wrqu->mode = IW_MODE_INFRA; else if (check_fwstate(pmlmepriv, - WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) == true) + WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE)) wrqu->mode = IW_MODE_ADHOC; - else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) wrqu->mode = IW_MODE_MASTER; else wrqu->mode = IW_MODE_AUTO; @@ -797,13 +777,13 @@ static int r871x_wx_set_pmkid(struct net_device *dev, int intReturn = false; /* - There are the BSSID information in the bssid.sa_data array. - If cmd is IW_PMKSA_FLUSH, it means the wpa_supplicant wants to clear - all the PMKID information. If cmd is IW_PMKSA_ADD, it means the - wpa_supplicant wants to add a PMKID/BSSID to driver. - If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to - remove a PMKID/BSSID from driver. -*/ + * There are the BSSID information in the bssid.sa_data array. + * If cmd is IW_PMKSA_FLUSH, it means the wpa_supplicant wants to clear + * all the PMKID information. If cmd is IW_PMKSA_ADD, it means the + * wpa_supplicant wants to add a PMKID/BSSID to driver. + * If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to + * remove a PMKID/BSSID from driver. + */ if (pPMK == NULL) return -EINVAL; memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); @@ -818,7 +798,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev, if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { /* BSSID is matched, the same AP => rewrite - * with new PMKID. */ + * with new PMKID. + */ netdev_info(dev, "r8712u: %s: BSSID exists in the PMKList.\n", __func__); memcpy(psecuritypriv->PMKIDList[j].PMKID, @@ -850,7 +831,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev, if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { /* BSSID is matched, the same AP => Remove - * this PMKID information and reset it. */ + * this PMKID information and reset it. + */ eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid); psecuritypriv->PMKIDList[j].bUsed = false; break; @@ -909,7 +891,7 @@ static int r8711_wx_get_range(struct net_device *dev, range->max_qual.updated = 7; /* Updated all three */ range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ /* TODO: Find real 'good' to 'bad' threshold value for RSSI */ - range->avg_qual.level = 20 + -98; + range->avg_qual.level = 0x100 - 78; range->avg_qual.noise = 0; range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; @@ -957,24 +939,24 @@ static int r871x_wx_set_priv(struct net_device *dev, if (IS_ERR(ext)) return PTR_ERR(ext); - if (0 == strcasecmp(ext, "RSSI")) { + if (!strcasecmp(ext, "RSSI")) { /*Return received signal strength indicator in -db for */ /* current AP */ /* Rssi xx */ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_network *pcur_network = &pmlmepriv->cur_network; /*static u8 xxxx; */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { sprintf(ext, "%s rssi %d", pcur_network->network.Ssid.Ssid, /*(xxxx=xxxx+10) */ - ((padapter->recvpriv.fw_rssi)>>1)-95 + ((padapter->recvpriv.fw_rssi) >> 1) - 95 /*pcur_network->network.Rssi */ ); } else { sprintf(ext, "OK"); } - } else if (0 == strcasecmp(ext, "LINKSPEED")) { + } else if (!strcasecmp(ext, "LINKSPEED")) { /*Return link speed in MBPS */ /*LinkSpeed xx */ union iwreq_data wrqd; @@ -982,30 +964,30 @@ static int r871x_wx_set_priv(struct net_device *dev, int mbps; ret_inner = r8711_wx_get_rate(dev, info, &wrqd, extra); - if (0 != ret_inner) + if (ret_inner != 0) mbps = 0; else mbps = wrqd.bitrate.value / 1000000; sprintf(ext, "LINKSPEED %d", mbps); - } else if (0 == strcasecmp(ext, "MACADDR")) { + } else if (!strcasecmp(ext, "MACADDR")) { /*Return mac address of the station */ /* Macaddr = xx:xx:xx:xx:xx:xx */ sprintf(ext, "MACADDR = %pM", dev->dev_addr); - } else if (0 == strcasecmp(ext, "SCAN-ACTIVE")) { + } else if (!strcasecmp(ext, "SCAN-ACTIVE")) { /*Set scan type to active */ /*OK if successful */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; pmlmepriv->passive_mode = 1; sprintf(ext, "OK"); - } else if (0 == strcasecmp(ext, "SCAN-PASSIVE")) { + } else if (!strcasecmp(ext, "SCAN-PASSIVE")) { /*Set scan type to passive */ /*OK if successful */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; pmlmepriv->passive_mode = 0; sprintf(ext, "OK"); - } else if (0 == strncmp(ext, "DCE-E", 5)) { + } else if (!strncmp(ext, "DCE-E", 5)) { /*Set scan type to passive */ /*OK if successful */ r8712_disconnectCtrlEx_cmd(padapter @@ -1015,7 +997,7 @@ static int r871x_wx_set_priv(struct net_device *dev, , 5000 /*u32 firstStageTO */ ); sprintf(ext, "OK"); - } else if (0 == strncmp(ext, "DCE-D", 5)) { + } else if (!strncmp(ext, "DCE-D", 5)) { /*Set scan type to passive */ /*OK if successfu */ r8712_disconnectCtrlEx_cmd(padapter @@ -1031,7 +1013,7 @@ static int r871x_wx_set_priv(struct net_device *dev, goto FREE_EXT; } if (copy_to_user(dwrq->pointer, ext, - min(dwrq->length, (__u16)(strlen(ext)+1)))) + min(dwrq->length, (__u16)(strlen(ext) + 1)))) ret = -EFAULT; FREE_EXT: @@ -1068,9 +1050,9 @@ static int r8711_wx_set_wap(struct net_device *dev, struct wlan_network *pnetwork = NULL; enum NDIS_802_11_AUTHENTICATION_MODE authmode; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) return -EBUSY; - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) return ret; if (temp->sa_family != ARPHRD_ETHER) return -EINVAL; @@ -1079,7 +1061,7 @@ static int r8711_wx_set_wap(struct net_device *dev, phead = &queue->queue; pmlmepriv->pscanned = phead->next; while (1) { - if (end_of_queue_search(phead, pmlmepriv->pscanned) == true) + if (end_of_queue_search(phead, pmlmepriv->pscanned)) break; pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); @@ -1093,9 +1075,9 @@ static int r8711_wx_set_wap(struct net_device *dev, } spin_unlock_irqrestore(&queue->lock, irqL); if (!ret) { - if (!r8712_set_802_11_authentication_mode(padapter, authmode)) + if (!r8712_set_802_11_authentication_mode(padapter, authmode)) { ret = -ENOMEM; - else { + } else { if (!r8712_set_802_11_bssid(padapter, temp->sa_data)) ret = -1; } @@ -1161,17 +1143,17 @@ static int r8711_wx_set_scan(struct net_device *dev, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 status = true; - if (padapter->bDriverStopped == true) { + if (padapter->bDriverStopped) { netdev_info(dev, "In %s: bDriverStopped=%d\n", __func__, padapter->bDriverStopped); return -1; } - if (padapter->bup == false) + if (!padapter->bup) return -ENETDOWN; - if (padapter->hw_init_completed == false) + if (!padapter->hw_init_completed) return -1; - if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || - (pmlmepriv->sitesurveyctrl.traffic_busy == true)) + if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) || + (pmlmepriv->sitesurveyctrl.traffic_busy)) return 0; if (wrqu->data.length == sizeof(struct iw_scan_req)) { struct iw_scan_req *req = (struct iw_scan_req *)extra; @@ -1188,16 +1170,18 @@ static int r8711_wx_set_scan(struct net_device *dev, spin_lock_irqsave(&pmlmepriv->lock, irqL); if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) || - (pmlmepriv->sitesurveyctrl.traffic_busy == true)) { + (pmlmepriv->sitesurveyctrl.traffic_busy)) { if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) status = false; - } else + } else { status = r8712_sitesurvey_cmd(padapter, &ssid); + } spin_unlock_irqrestore(&pmlmepriv->lock, irqL); } - } else + } else { status = r8712_set_802_11_bssid_list_scan(padapter); - if (status == false) + } + if (!status) return -1; return 0; } @@ -1218,7 +1202,8 @@ static int r8711_wx_get_scan(struct net_device *dev, if (padapter->bDriverStopped) return -EINVAL; - while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | + _FW_UNDER_LINKING)) { msleep(30); cnt++; if (cnt > 100) @@ -1228,7 +1213,7 @@ static int r8711_wx_get_scan(struct net_device *dev, phead = &queue->queue; plist = phead->next; while (1) { - if (end_of_queue_search(phead, plist) == true) + if (end_of_queue_search(phead, plist)) break; if ((stop - ev) < SCAN_ITEM_SIZE) { ret = -E2BIG; @@ -1328,7 +1313,7 @@ static int r8711_wx_get_essid(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; u32 len, ret = 0; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { len = pcur_bss->Ssid.SsidLength; wrqu->essid.length = len; memcpy(extra, pcur_bss->Ssid.Ssid, len); @@ -1403,8 +1388,9 @@ set_rate: datarates[i] = mpdatarate[i]; if (fixed == 0) break; - } else + } else { datarates[i] = 0xff; + } } if (r8712_setdatarate_cmd(padapter, datarates) != _SUCCESS) ret = -ENOMEM; @@ -1428,7 +1414,7 @@ static int r8711_wx_get_rate(struct net_device *dev, u16 mcs_rate = 0; i = 0; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength - 12); @@ -1448,13 +1434,13 @@ static int r8711_wx_get_rate(struct net_device *dev, if (rate > max_rate) max_rate = rate; wrqu->bitrate.fixed = 0; /* no auto select */ - wrqu->bitrate.value = rate*500000; + wrqu->bitrate.value = rate * 500000; i++; } - if (ht_cap == true) { + if (ht_cap) { if (mcs_rate & 0x8000 /* MCS15 */ && - RTL8712_RF_2T2R == rf_type) + rf_type == RTL8712_RF_2T2R) max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); else /* default MCS7 */ @@ -1463,8 +1449,9 @@ static int r8711_wx_get_rate(struct net_device *dev, max_rate *= 2; /* Mbps/2 */ } wrqu->bitrate.value = max_rate * 500000; - } else + } else { return -ENOLINK; + } return 0; } @@ -1485,9 +1472,9 @@ static int r8711_wx_set_frag(struct net_device *dev, { struct _adapter *padapter = netdev_priv(dev); - if (wrqu->frag.disabled) + if (wrqu->frag.disabled) { padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; - else { + } else { if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; @@ -1587,7 +1574,8 @@ static int r8711_wx_set_enc(struct net_device *dev, } else { wep.KeyLength = 0; if (keyindex_provided == 1) { /* set key_id only, no given - * KeyMaterial(erq->length==0).*/ + * KeyMaterial(erq->length==0). + */ padapter->securitypriv.PrivacyKeyIndex = key; switch (padapter->securitypriv.DefKeylen[key]) { case 5: @@ -1622,7 +1610,7 @@ static int r8711_wx_get_enc(struct net_device *dev, struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + if (!check_fwstate(pmlmepriv, _FW_LINKED)) { if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { erq->length = 0; erq->flags |= IW_ENCODE_DISABLED; @@ -1811,8 +1799,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev, if (param == NULL) return -ENOMEM; param->cmd = IEEE_CMD_SET_ENCRYPTION; - memset(param->sta_addr, 0xff, ETH_ALEN); - + eth_broadcast_addr(param->sta_addr); strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) param->u.crypt.set_tx = 0; @@ -1868,7 +1855,7 @@ static int r8711_wx_write32(struct net_device *dev, u32 data32; get_user(addr, (u32 __user *)wrqu->data.pointer); - data32 = ((u32)wrqu->data.length<<16) | (u32)wrqu->data.flags; + data32 = ((u32)wrqu->data.length << 16) | (u32)wrqu->data.flags; r8712_write32(padapter, addr, data32); return 0; } @@ -1922,9 +1909,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev, ret = -EINVAL; goto _r871x_mp_ioctl_hdl_exit; } - if (phandler->oid == 0 && phandler->handler) + if (phandler->oid == 0 && phandler->handler) { status = phandler->handler(&oid_par); - else if (phandler->handler) { + } else if (phandler->handler) { oid_par.adapter_context = padapter; oid_par.oid = phandler->oid; oid_par.information_buf = poidparam->data; @@ -1981,7 +1968,8 @@ static int r871x_get_ap_info(struct net_device *dev, if (padapter->bDriverStopped || (pdata == NULL)) return -EINVAL; - while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | + _FW_UNDER_LINKING)) { msleep(30); cnt++; if (cnt > 100) @@ -1991,16 +1979,17 @@ static int r871x_get_ap_info(struct net_device *dev, if (pdata->length >= 32) { if (copy_from_user(data, pdata->pointer, 32)) return -EINVAL; - } else + } else { return -EINVAL; + } spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL); phead = &queue->queue; plist = phead->next; while (1) { - if (end_of_queue_search(phead, plist) == true) + if (end_of_queue_search(phead, plist)) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (hwaddr_aton_i(data, bssid)) { + if (!mac_pton(data, bssid)) { netdev_info(dev, "r8712u: Invalid BSSID '%s'.\n", (u8 *)data); spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock), @@ -2008,16 +1997,16 @@ static int r871x_get_ap_info(struct net_device *dev, return -EINVAL; } netdev_info(dev, "r8712u: BSSID:%pM\n", bssid); - if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { + if (ether_addr_equal(bssid, pnetwork->network.MacAddress)) { /* BSSID match, then check if supporting wpa/wpa2 */ pbuf = r8712_get_wpa_ie(&pnetwork->network.IEs[12], - &wpa_ielen, pnetwork->network.IELength-12); + &wpa_ielen, pnetwork->network.IELength - 12); if (pbuf && (wpa_ielen > 0)) { pdata->flags = 1; break; } pbuf = r8712_get_wpa2_ie(&pnetwork->network.IEs[12], - &wpa_ielen, pnetwork->network.IELength-12); + &wpa_ielen, pnetwork->network.IELength - 12); if (pbuf && (wpa_ielen > 0)) { pdata->flags = 2; break; @@ -2102,7 +2091,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) switch (name) { case IEEE_PARAM_WPA_ENABLED: padapter->securitypriv.AuthAlgrthm = 2; /* 802.1x */ - switch ((value)&0xff) { + switch ((value) & 0xff) { case 1: /* WPA */ padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ @@ -2241,7 +2230,8 @@ static iw_handler r8711_handlers[] = { r8711_wx_set_wap, /* SIOCSIWAP */ r8711_wx_get_wap, /* SIOCGIWAP */ r871x_wx_set_mlme, /* request MLME operation; - * uses struct iw_mlme */ + * uses struct iw_mlme + */ dummy, /* SIOCGIWAPLIST -- deprecated */ r8711_wx_set_scan, /* SIOCSIWSCAN */ r8711_wx_get_scan, /* SIOCGIWSCAN */ diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c index ac0baff7f..7c346a405 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c @@ -58,8 +58,9 @@ uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv) *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_smallpacket_crcerr; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -74,8 +75,9 @@ uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv) *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_middlepacket_crcerr; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -90,8 +92,9 @@ uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv) *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_largepacket_crcerr; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -122,8 +125,9 @@ uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv) padapter->recvpriv.rx_pkts + padapter->recvpriv.rx_drop; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -152,8 +156,9 @@ uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv) *(uint *)poid_par_priv->information_buf = padapter->recvpriv.rx_icv_err; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -182,8 +187,9 @@ uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv) preamblemode = 2; *(u32 *)poid_par_priv->information_buf = preamblemode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -239,8 +245,9 @@ uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv padapter->registrypriv.preamble = PREAMBLE_SHORT; *(u32 *)poid_par_priv->information_buf = preamblemode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -269,8 +276,9 @@ uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv *(u32 *)poid_par_priv->information_buf = padapter->xmitpriv.tx_bytes; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -287,8 +295,9 @@ uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv padapter->recvpriv.rx_bytes; *poid_par_priv->bytes_rw = poid_par_priv-> information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -324,8 +333,8 @@ uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv) if (poid_par_priv->type_of_oid != QUERY_OID) return RNDIS_STATUS_NOT_ACCEPTED; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) + if (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) pnic_Config = &pmlmepriv->cur_network.network.Configuration; else pnic_Config = &padapter->registrypriv.dev_network. @@ -364,8 +373,9 @@ uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv ulInfo |= 0x0400; /* WIRELESS_MODE_A */ *(u32 *) poid_par_priv->information_buf = ulInfo; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { return RNDIS_STATUS_INVALID_LENGTH; + } return RNDIS_STATUS_SUCCESS; } @@ -451,8 +461,9 @@ uint oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv* (unsigned long)(*((unsigned long *) poid_par_priv->information_buf + 2)))) status = RNDIS_STATUS_NOT_ACCEPTED; - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } return status; } @@ -464,10 +475,11 @@ uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv) if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */ return RNDIS_STATUS_NOT_ACCEPTED; - if (poid_par_priv->information_buf_len == (sizeof(unsigned long)*3)) { - if (Adapter->mppriv.act_in_progress == true) + if (poid_par_priv->information_buf_len == (sizeof(unsigned long) * + 3)) { + if (Adapter->mppriv.act_in_progress) { status = RNDIS_STATUS_NOT_ACCEPTED; - else { + } else { /* init workparam */ Adapter->mppriv.act_in_progress = true; Adapter->mppriv.workparam.bcompleted = false; @@ -489,8 +501,9 @@ uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv) io_value)) status = RNDIS_STATUS_NOT_ACCEPTED; } - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } return status; } @@ -515,11 +528,11 @@ uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv) * nStatus==2 AdHocMode * nStatus==3 NotAssociated */ - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) ulInfo = CHECKINGSTATUS; - else if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + else if (check_fwstate(pmlmepriv, _FW_LINKED)) ulInfo = ASSOCIATED; - else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) + else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) ulInfo = ADHOCMODE; else ulInfo = NOTASSOCIATED; diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index 22262b355..f772675ae 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -136,12 +136,12 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid) } spin_lock_irqsave(&pmlmepriv->lock, irqL); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | - _FW_UNDER_LINKING) == true) { + _FW_UNDER_LINKING)) { status = check_fwstate(pmlmepriv, _FW_UNDER_LINKING); goto _Abort_Set_BSSID; } if (check_fwstate(pmlmepriv, - _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) @@ -149,7 +149,7 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid) * WIFI_ADHOC_MASTER_STATE */ } else { r8712_disassoc_cmd(padapter); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) r8712_ind_disconnect(padapter); r8712_free_assoc_resources(padapter); if ((check_fwstate(pmlmepriv, @@ -180,11 +180,11 @@ void r8712_set_802_11_ssid(struct _adapter *padapter, if (!padapter->hw_init_completed) return; spin_lock_irqsave(&pmlmepriv->lock, irqL); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) { check_fwstate(pmlmepriv, _FW_UNDER_LINKING); goto _Abort_Set_SSID; } - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { @@ -197,7 +197,7 @@ void r8712_set_802_11_ssid(struct _adapter *padapter, */ r8712_disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, - _FW_LINKED) == true) + _FW_LINKED)) r8712_ind_disconnect(padapter); r8712_free_assoc_resources(padapter); if (check_fwstate(pmlmepriv, @@ -207,24 +207,25 @@ void r8712_set_802_11_ssid(struct _adapter *padapter, set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } - } else + } else { goto _Abort_Set_SSID; /* driver is in * WIFI_ADHOC_MASTER_STATE */ + } } } else { r8712_disassoc_cmd(padapter); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) r8712_ind_disconnect(padapter); r8712_free_assoc_resources(padapter); if (check_fwstate(pmlmepriv, - WIFI_ADHOC_MASTER_STATE) == true) { + WIFI_ADHOC_MASTER_STATE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } - if (padapter->securitypriv.btkip_countermeasure == true) + if (padapter->securitypriv.btkip_countermeasure) goto _Abort_Set_SSID; if (!validate_ssid(ssid)) goto _Abort_Set_SSID; @@ -248,13 +249,13 @@ void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, if (*pold_state != networktype) { spin_lock_irqsave(&pmlmepriv->lock, irqL); - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || + if (check_fwstate(pmlmepriv, _FW_LINKED) || (*pold_state == Ndis802_11IBSS)) r8712_disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, - _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) + _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) r8712_free_assoc_resources(padapter); - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || + if (check_fwstate(pmlmepriv, _FW_LINKED) || (*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { /* will clr Linked_state before this function, @@ -291,7 +292,7 @@ u8 r8712_set_802_11_disassociate(struct _adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; spin_lock_irqsave(&pmlmepriv->lock, irqL); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { r8712_disassoc_cmd(padapter); r8712_ind_disconnect(padapter); r8712_free_assoc_resources(padapter); @@ -312,8 +313,8 @@ u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter) if (!padapter->hw_init_completed) return false; spin_lock_irqsave(&pmlmepriv->lock, irqL); - if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || - (pmlmepriv->sitesurveyctrl.traffic_busy == true)) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING) || + pmlmepriv->sitesurveyctrl.traffic_busy) { /* Scan or linking is in progress, do nothing. */ ret = (u8)check_fwstate(pmlmepriv, _FW_UNDER_SURVEY); } else { diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index fc5dbea08..a4a002b55 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -62,8 +62,8 @@ static sint _init_mlme_priv(struct _adapter *padapter) _init_queue(&(pmlmepriv->scanned_queue)); set_scanned_network_val(pmlmepriv, 0); memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - pbuf = kmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)), - GFP_ATOMIC); + pbuf = kmalloc_array(MAX_BSS_CNT, sizeof(struct wlan_network), + GFP_ATOMIC); if (pbuf == NULL) return _FAIL; pmlmepriv->free_bss_buf = pbuf; @@ -110,7 +110,7 @@ static void _free_network(struct mlme_priv *pmlmepriv, if (pnetwork == NULL) return; - if (pnetwork->fixed == true) + if (pnetwork->fixed) return; curr_time = jiffies; delta_time = (curr_time - (u32)pnetwork->last_scanned) / HZ; @@ -130,7 +130,7 @@ static void _free_network_nolock(struct mlme_priv *pmlmepriv, if (pnetwork == NULL) return; - if (pnetwork->fixed == true) + if (pnetwork->fixed) return; list_del_init(&pnetwork->list); list_add_tail(&pnetwork->list, &free_queue->queue); @@ -176,7 +176,7 @@ static void _free_network_queue(struct _adapter *padapter) spin_lock_irqsave(&scanned_queue->lock, irqL); phead = &scanned_queue->queue; plist = phead->next; - while (end_of_queue_search(phead, plist) == false) { + while (!end_of_queue_search(phead, plist)) { pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); plist = plist->next; _free_network(pmlmepriv, pnetwork); @@ -189,10 +189,11 @@ sint r8712_if_up(struct _adapter *padapter) sint res; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { + !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { res = false; - } else + } else { res = true; + } return res; } @@ -204,8 +205,8 @@ void r8712_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff); - pibss[4] = (u8)((curtime>>8) & 0xff); - pibss[5] = (u8)((curtime>>16) & 0xff); + pibss[4] = (u8)((curtime >> 8) & 0xff); + pibss[5] = (u8)((curtime >> 16) & 0xff); } uint r8712_get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) @@ -354,8 +355,9 @@ static void update_network(struct wlan_bssid_ex *dst, padapter->recvpriv.signal = (u8)tmpVal; src->Rssi = padapter->recvpriv.signal; - } else + } else { src->Rssi = (src->Rssi + dst->Rssi) / 2; + } memcpy((u8 *)dst, (u8 *)src, r8712_get_wlan_bssid_ex_sz(src)); } @@ -392,7 +394,7 @@ static void update_scanned_network(struct _adapter *adapter, plist = phead->next; while (1) { - if (end_of_queue_search(phead, plist) == true) + if (end_of_queue_search(phead, plist)) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); @@ -409,7 +411,7 @@ static void update_scanned_network(struct _adapter *adapter, /* If we didn't find a match, then get a new network slot to initialize * with this beacon's information */ - if (end_of_queue_search(phead, plist) == true) { + if (end_of_queue_search(phead, plist)) { if (list_empty(&pmlmepriv->free_bss_pool.queue)) { /* If there are no more slots, expire the oldest */ pnetwork = oldest; @@ -468,10 +470,10 @@ static int is_desired_network(struct _adapter *adapter, int bselected = true; struct security_priv *psecuritypriv = &adapter->securitypriv; - if (psecuritypriv->wps_phase == true) { + if (psecuritypriv->wps_phase) { if (r8712_get_wps_ie(pnetwork->network.IEs, pnetwork->network.IELength, wps_ie, - &wps_ielen) == true) + &wps_ielen)) return true; else return false; @@ -479,7 +481,7 @@ static int is_desired_network(struct _adapter *adapter, if ((psecuritypriv->PrivacyAlgrthm != _NO_PRIVACY_) && (pnetwork->network.Privacy == 0)) bselected = false; - if (check_fwstate(&adapter->mlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(&adapter->mlmepriv, WIFI_ADHOC_STATE)) { if (pnetwork->network.InfrastructureMode != adapter->mlmepriv.cur_network.network. InfrastructureMode) @@ -533,7 +535,7 @@ void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf) return; spin_lock_irqsave(&pmlmepriv->lock2, flags); /* update IBSS_network 's timestamp */ - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; @@ -551,10 +553,10 @@ void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf) } } /* lock pmlmepriv->lock when you accessing network_q */ - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) { - if (pnetwork->Ssid.Ssid[0] != 0) + if (!check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { + if (pnetwork->Ssid.Ssid[0] != 0) { rtl8711_add_network(adapter, pnetwork); - else { + } else { pnetwork->Ssid.SsidLength = 8; memcpy(pnetwork->Ssid.Ssid, "", 8); rtl8711_add_network(adapter, pnetwork); @@ -571,15 +573,15 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) spin_lock_irqsave(&pmlmepriv->lock, irqL); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { del_timer(&pmlmepriv->scan_to_timer); _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } - if (pmlmepriv->to_join == true) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + if (pmlmepriv->to_join) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (!check_fwstate(pmlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); if (r8712_select_and_join_from_scan(pmlmepriv) @@ -633,7 +635,7 @@ void r8712_free_assoc_resources(struct _adapter *adapter) pwlan = r8712_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE)) { struct sta_info *psta; psta = r8712_get_stainfo(&adapter->stapriv, @@ -645,7 +647,7 @@ void r8712_free_assoc_resources(struct _adapter *adapter) } if (check_fwstate(pmlmepriv, - WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) + WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) r8712_free_all_stainfo(adapter); if (pwlan) pwlan->fixed = false; @@ -679,7 +681,7 @@ void r8712_ind_disconnect(struct _adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { _clr_fwstate_(pmlmepriv, _FW_LINKED); padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK); r8712_os_indicate_disconnect(padapter); @@ -717,10 +719,11 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) pnetwork = kmalloc(sizeof(struct wlan_network), GFP_ATOMIC); if (!pnetwork) return; - memcpy((u8 *)pnetwork+16, (u8 *)pbuf + 8, - sizeof(struct wlan_network) - 16); - } else + memcpy((u8 *)pnetwork + 16, (u8 *)pbuf + 8, + sizeof(struct wlan_network) - 16); + } else { pnetwork = (struct wlan_network *)pbuf; + } #ifdef __BIG_ENDIAN /* endian_convert */ @@ -764,15 +767,15 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) goto ignore_joinbss_callback; if (pnetwork->join_res > 0) { - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { /*s1. find ptarget_wlan*/ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - if (the_same_macaddr == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (the_same_macaddr) { ptarget_wlan = r8712_find_network(&pmlmepriv-> scanned_queue, cur_network->network.MacAddress); - else { + } else { pcur_wlan = r8712_find_network(&pmlmepriv-> scanned_queue, @@ -813,7 +816,7 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) /*s2. find ptarget_sta & update ptarget_sta*/ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (the_same_macaddr == true) { + if (the_same_macaddr) { ptarget_sta = r8712_get_stainfo(pstapriv, pnetwork->network.MacAddress); @@ -821,10 +824,11 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) ptarget_sta = r8712_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); - } else + } else { ptarget_sta = r8712_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); + } if (ptarget_sta) /*update ptarget_sta*/ { ptarget_sta->aid = pnetwork->join_res; ptarget_sta->qos_option = 1; @@ -897,14 +901,14 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) update_ht_cap(adapter, cur_network->network.IEs, cur_network->network.IELength); /*indicate connect*/ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) - == true) + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) r8712_indicate_connect(adapter); del_timer(&pmlmepriv->assoc_timer); - } else + } else { goto ignore_joinbss_callback; + } } else { - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(1)); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); @@ -924,7 +928,7 @@ void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf) struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; /* to do: */ - if (r8712_access_ctrl(&adapter->acl_list, pstassoc->macaddr) == false) + if (!r8712_access_ctrl(&adapter->acl_list, pstassoc->macaddr)) return; psta = r8712_get_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta != NULL) { @@ -946,8 +950,8 @@ void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf) psta->XPrivacy = adapter->securitypriv.PrivacyAlgrthm; psta->ieee8021x_blocked = false; spin_lock_irqsave(&pmlmepriv->lock, irqL); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (adapter->stapriv.asoc_sta_count == 2) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ r8712_indicate_connect(adapter); @@ -969,7 +973,7 @@ void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf) struct wlan_network *tgt_network = &pmlmepriv->cur_network; spin_lock_irqsave(&pmlmepriv->lock, irqL2); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { r8712_ind_disconnect(adapter); r8712_free_assoc_resources(adapter); } @@ -1046,7 +1050,7 @@ void r8712_got_addbareq_event_callback(struct _adapter *adapter, u8 *pbuf) void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf) { - if (adapter->securitypriv.wps_hw_pbc_pressed == false) + if (!adapter->securitypriv.wps_hw_pbc_pressed) adapter->securitypriv.wps_hw_pbc_pressed = true; } @@ -1081,7 +1085,7 @@ void _r8712_join_timeout_handler(struct _adapter *adapter) spin_lock_irqsave(&pmlmepriv->lock, irqL); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); pmlmepriv->to_join = false; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { r8712_os_indicate_disconnect(adapter); _clr_fwstate_(pmlmepriv, _FW_LINKED); } @@ -1131,8 +1135,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) phead = &queue->queue; pmlmepriv->pscanned = phead->next; while (1) { - if (end_of_queue_search(phead, pmlmepriv->pscanned) == true) { - if ((pmlmepriv->assoc_by_rssi == true) && + if (end_of_queue_search(phead, pmlmepriv->pscanned)) { + if ((pmlmepriv->assoc_by_rssi) && (pnetwork_max_rssi != NULL)) { pnetwork = pnetwork_max_rssi; goto ask_for_joinbss; @@ -1144,7 +1148,7 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) if (pnetwork == NULL) return _FAIL; pmlmepriv->pscanned = pmlmepriv->pscanned->next; - if (pmlmepriv->assoc_by_bssid == true) { + if (pmlmepriv->assoc_by_bssid) { dst_ssid = pnetwork->network.MacAddress; src_ssid = pmlmepriv->assoc_bssid; if (!memcmp(dst_ssid, src_ssid, ETH_ALEN)) { @@ -1164,23 +1168,25 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) } goto ask_for_joinbss; } - } else if (pmlmepriv->assoc_ssid.SsidLength == 0) + } else if (pmlmepriv->assoc_ssid.SsidLength == 0) { goto ask_for_joinbss; + } dst_ssid = pnetwork->network.Ssid.Ssid; src_ssid = pmlmepriv->assoc_ssid.Ssid; if ((pnetwork->network.Ssid.SsidLength == pmlmepriv->assoc_ssid.SsidLength) && (!memcmp(dst_ssid, src_ssid, pmlmepriv->assoc_ssid.SsidLength))) { - if (pmlmepriv->assoc_by_rssi == true) { + if (pmlmepriv->assoc_by_rssi) { /* if the ssid is the same, select the bss * which has the max rssi*/ if (pnetwork_max_rssi) { if (pnetwork->network.Rssi > pnetwork_max_rssi->network.Rssi) pnetwork_max_rssi = pnetwork; - } else + } else { pnetwork_max_rssi = pnetwork; + } } else if (is_desired_network(adapter, pnetwork)) { if (check_fwstate(pmlmepriv, _FW_LINKED)) { r8712_disassoc_cmd(adapter); @@ -1190,7 +1196,7 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) } } } - return _FAIL; + ask_for_joinbss: return r8712_joinbss_cmd(adapter, pnetwork); } @@ -1408,7 +1414,7 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, while (cnt < in_len) { if (in_ie[cnt] == authmode) { if ((authmode == _WPA_IE_ID_) && - (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { memcpy(&sec_ie[0], &in_ie[cnt], in_ie[cnt + 1] + 2); match = true; @@ -1426,10 +1432,10 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, memcpy(&bkup_ie[0], &in_ie[cnt], in_ie[cnt + 1] + 2); } - cnt += in_ie[cnt+1] + 2; /*get next*/ + cnt += in_ie[cnt + 1] + 2; /*get next*/ } /*restruct WPA IE or WPA2 IE in sec_ie[] */ - if (match == true) { + if (match) { if (sec_ie[0] == _WPA_IE_ID_) { /* parsing SSN IE to select required encryption * algorithm, and set the bc/mc encryption algorithm */ @@ -1486,7 +1492,7 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, /*select the uncst_oui and remove * the other uncst_oui*/ cnt = sec_ie[12]; - remove_cnt = (cnt-1) * 4; + remove_cnt = (cnt - 1) * 4; sec_ie[12] = 0x01; memcpy(&sec_ie[14], &uncst_oui[0], 4); /*remove the other unicast suit*/ @@ -1547,7 +1553,7 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, /*select the uncst_oui and remove the * other uncst_oui*/ cnt = sec_ie[8]; - remove_cnt = (cnt-1)*4; + remove_cnt = (cnt - 1) * 4; sec_ie[8] = 0x01; memcpy(&sec_ie[10], &uncst_oui[0], 4); /*remove the other unicast suit*/ @@ -1555,7 +1561,7 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, &sec_ie[14 + remove_cnt], (sec_ie[1] - 14 + 2 - remove_cnt)); - sec_ie[1] = sec_ie[1]-remove_cnt; + sec_ie[1] = sec_ie[1] - remove_cnt; } break; } @@ -1566,8 +1572,8 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, memcpy(out_ie, in_ie, 12); ielength = 12; /*copy RSN or SSN*/ - if (match == true) { - memcpy(&out_ie[ielength], &sec_ie[0], sec_ie[1]+2); + if (match) { + memcpy(&out_ie[ielength], &sec_ie[0], sec_ie[1] + 2); ielength += sec_ie[1] + 2; if (authmode == _WPA2_IE_ID_) { /*the Pre-Authentication bit should be zero*/ @@ -1580,9 +1586,9 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, /*copy fixed ie only*/ memcpy(out_ie, in_ie, 12); ielength = 12; - if (psecuritypriv->wps_phase == true) { - memcpy(out_ie+ielength, psecuritypriv->wps_ie, - psecuritypriv->wps_ie_len); + if (psecuritypriv->wps_phase) { + memcpy(out_ie + ielength, psecuritypriv->wps_ie, + psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; } } @@ -1696,11 +1702,11 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, struct ht_priv *phtpriv = &pmlmepriv->htpriv; phtpriv->ht_option = 0; - p = r8712_get_ie(in_ie+12, _HT_CAPABILITY_IE_, &ielen, in_len-12); + p = r8712_get_ie(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12); if (p && (ielen > 0)) { if (pqospriv->qos_option == 0) { out_len = *pout_len; - r8712_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + r8712_set_ie(out_ie + out_len, _VENDOR_SPECIFIC_IE_, _WMM_IE_Length_, WMM_IE, pout_len); pqospriv->qos_option = 1; } @@ -1714,7 +1720,7 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, IEEE80211_HT_CAP_DSSSCCK40; ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); - r8712_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, + r8712_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_, sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = 1; @@ -1738,7 +1744,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) if (!phtpriv->ht_option) return; /* maybe needs check if ap supports rx ampdu. */ - if ((phtpriv->ampdu_enable == false) && + if (!phtpriv->ampdu_enable && (pregistrypriv->ampdu_enable == 1)) phtpriv->ampdu_enable = true; /*check Max Rx A-MPDU Size*/ @@ -1748,11 +1754,11 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) &len, ie_len - sizeof(struct NDIS_802_11_FIXED_IEs)); if (p && len > 0) { - pht_capie = (struct ieee80211_ht_cap *)(p+2); + pht_capie = (struct ieee80211_ht_cap *)(p + 2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); /* max_ampdu_sz (kbytes); */ - max_ampdu_sz = 1 << (max_ampdu_sz+3); + max_ampdu_sz = 1 << (max_ampdu_sz + 3); phtpriv->rx_ampdu_maxlen = max_ampdu_sz; } /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info @@ -1780,7 +1786,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) len = 0; p = r8712_get_ie(pie + sizeof(struct NDIS_802_11_FIXED_IEs), _HT_ADD_INFO_IE_, &len, - ie_len-sizeof(struct NDIS_802_11_FIXED_IEs)); + ie_len - sizeof(struct NDIS_802_11_FIXED_IEs)); } void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority) @@ -1788,8 +1794,8 @@ void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if ((phtpriv->ht_option == 1) && (phtpriv->ampdu_enable == true)) { - if (phtpriv->baddbareq_issued[priority] == false) { + if ((phtpriv->ht_option == 1) && (phtpriv->ampdu_enable)) { + if (!phtpriv->baddbareq_issued[priority]) { r8712_addbareq_cmd(padapter, (u8)priority); phtpriv->baddbareq_issued[priority] = true; } diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h index 08d6c986c..61e0eb745 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.h +++ b/drivers/staging/rtl8712/rtl871x_mlme.h @@ -153,7 +153,7 @@ static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state) unsigned long irqL; spin_lock_irqsave(&pmlmepriv->lock, irqL); - if (check_fwstate(pmlmepriv, state) == true) + if (check_fwstate(pmlmepriv, state)) pmlmepriv->fw_state ^= state; spin_unlock_irqrestore(&pmlmepriv->lock, irqL); } diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index 26201ea3c..44da4fe89 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -211,19 +211,18 @@ static u32 bitshift(u32 bitmask) u32 i; for (i = 0; i <= 31; i++) - if (((bitmask>>i) & 0x1) == 1) + if (((bitmask >> i) & 0x1) == 1) break; return i; } static u32 get_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask) { - u32 org_value, bit_shift, new_value; + u32 org_value, bit_shift; org_value = r8712_bb_reg_read(pAdapter, offset); bit_shift = bitshift(bitmask); - new_value = (org_value & bitmask) >> bit_shift; - return new_value; + return (org_value & bitmask) >> bit_shift; } static u8 set_bb_reg(struct _adapter *pAdapter, @@ -237,20 +236,20 @@ static u8 set_bb_reg(struct _adapter *pAdapter, org_value = r8712_bb_reg_read(pAdapter, offset); bit_shift = bitshift(bitmask); new_value = ((org_value & (~bitmask)) | (value << bit_shift)); - } else + } else { new_value = value; + } return r8712_bb_reg_write(pAdapter, offset, new_value); } static u32 get_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset, u32 bitmask) { - u32 org_value, bit_shift, new_value; + u32 org_value, bit_shift; org_value = r8712_rf_reg_read(pAdapter, path, offset); bit_shift = bitshift(bitmask); - new_value = (org_value & bitmask) >> bit_shift; - return new_value; + return (org_value & bitmask) >> bit_shift; } static u8 set_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset, u32 bitmask, @@ -262,8 +261,9 @@ static u8 set_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset, u32 bitmask, org_value = r8712_rf_reg_read(pAdapter, path, offset); bit_shift = bitshift(bitmask); new_value = ((org_value & (~bitmask)) | (value << bit_shift)); - } else + } else { new_value = value; + } return r8712_rf_reg_write(pAdapter, path, offset, new_value); } @@ -305,7 +305,8 @@ static void SetOFDMTxPower(struct _adapter *pAdapter, u8 TxPower) { u32 TxAGC = 0; - TxAGC |= ((TxPower<<24)|(TxPower<<16)|(TxPower<<8)|TxPower); + TxAGC |= ((TxPower << 24) | (TxPower << 16) | (TxPower << 8) | + TxPower); set_bb_reg(pAdapter, rTxAGC_Rate18_06, bTxAGCRate18_06, TxAGC); set_bb_reg(pAdapter, rTxAGC_Rate54_24, bTxAGCRate54_24, TxAGC); set_bb_reg(pAdapter, rTxAGC_Mcs03_Mcs00, bTxAGCRateMCS3_MCS0, TxAGC); @@ -326,12 +327,12 @@ void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset) { u32 TxAGCOffset_B, TxAGCOffset_C, TxAGCOffset_D, tmpAGC; - TxAGCOffset_B = (ulTxAGCOffset&0x000000ff); - TxAGCOffset_C = (ulTxAGCOffset & 0x0000ff00)>>8; - TxAGCOffset_D = (ulTxAGCOffset & 0x00ff0000)>>16; - tmpAGC = (TxAGCOffset_D<<8 | TxAGCOffset_C<<4 | TxAGCOffset_B); + TxAGCOffset_B = (ulTxAGCOffset & 0x000000ff); + TxAGCOffset_C = (ulTxAGCOffset & 0x0000ff00) >> 8; + TxAGCOffset_D = (ulTxAGCOffset & 0x00ff0000) >> 16; + tmpAGC = (TxAGCOffset_D << 8 | TxAGCOffset_C << 4 | TxAGCOffset_B); set_bb_reg(pAdapter, rFPGA0_TxGainStage, - (bXBTxAGC|bXCTxAGC|bXDTxAGC), tmpAGC); + (bXBTxAGC | bXCTxAGC | bXDTxAGC), tmpAGC); } void r8712_SetDataRate(struct _adapter *pAdapter) @@ -377,7 +378,7 @@ void r8712_SwitchBandwidth(struct _adapter *pAdapter) * Set Control channel to upper or lower. These settings are * required only for 40MHz */ set_bb_reg(pAdapter, rCCK0_System, bCCKSideBand, - (HAL_PRIME_CHNL_OFFSET_DONT_CARE>>1)); + (HAL_PRIME_CHNL_OFFSET_DONT_CARE >> 1)); set_bb_reg(pAdapter, rOFDM1_LSTF, 0xC00, HAL_PRIME_CHNL_OFFSET_DONT_CARE); set_bb_reg(pAdapter, rFPGA0_AnalogParameter2, bMaskDWord, 0x18); @@ -490,12 +491,6 @@ void r8712_SwitchAntenna(struct _adapter *pAdapter) set_bb_reg(pAdapter, rCCK0_AFESetting, bMaskByte3, cck_ant_sel_val); } -void r8712_SetCrystalCap(struct _adapter *pAdapter) -{ - set_bb_reg(pAdapter, rFPGA0_AnalogParameter1, bXtalCap, - pAdapter->mppriv.curr_crystalcap); -} - static void TriggerRFThermalMeter(struct _adapter *pAdapter) { /* 0x24: RF Reg[6:5] */ diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h index 75893f225..3f3b2e73b 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.h +++ b/drivers/staging/rtl8712/rtl871x_mp.h @@ -272,7 +272,6 @@ void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset); void r8712_SetDataRate(struct _adapter *pAdapter); void r8712_SwitchBandwidth(struct _adapter *pAdapter); void r8712_SwitchAntenna(struct _adapter *pAdapter); -void r8712_SetCrystalCap(struct _adapter *pAdapter); void r8712_GetThermalMeter(struct _adapter *pAdapter, u32 *value); void r8712_SetContinuousTx(struct _adapter *pAdapter, u8 bStart); void r8712_SetSingleCarrierTx(struct _adapter *pAdapter, u8 bStart); diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 77f01bf1c..b98a59675 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -56,8 +56,9 @@ uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) Adapter->registrypriv.wireless_mode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } } else { status = RNDIS_STATUS_NOT_ACCEPTED; } @@ -178,10 +179,11 @@ static int mp_start_test(struct _adapter *padapter) if (length % 4) { /*round up to multiple of 4 bytes.*/ bssid.Length = ((length >> 2) + 1) << 2; - } else + } else { bssid.Length = length; + } spin_lock_irqsave(&pmlmepriv->lock, irqL); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) goto end_of_mp_start_test; /*init mp_start_test status*/ pmppriv->prev_fw_state = get_fwstate(pmlmepriv); @@ -223,7 +225,7 @@ static int mp_stop_test(struct _adapter *padapter) unsigned long irqL; spin_lock_irqsave(&pmlmepriv->lock, irqL); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_MP_STATE)) goto end_of_mp_stop_test; /* 3 1. disconnect psudo AdHoc */ r8712_os_indicate_disconnect(padapter); @@ -247,9 +249,9 @@ int mp_start_joinbss(struct _adapter *padapter, struct ndis_802_11_ssid *pssid) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned char res = _SUCCESS; - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_MP_STATE)) return _FAIL; - if (check_fwstate(pmlmepriv, _FW_LINKED) == false) + if (!check_fwstate(pmlmepriv, _FW_LINKED)) return _FAIL; _clr_fwstate_(pmlmepriv, _FW_LINKED); res = r8712_setassocsta_cmd(padapter, pmppriv->network_macaddr); @@ -293,7 +295,7 @@ uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) r8712_write8(Adapter, MSR, 1); /* Link in ad hoc network, 0x1025004C */ r8712_write8(Adapter, RCR, 0); /* RCR : disable all pkt, 0x10250048 */ /* RCR disable Check BSSID, 0x1025004a */ - r8712_write8(Adapter, RCR+2, 0x57); + r8712_write8(Adapter, RCR + 2, 0x57); /* disable RX filter map , mgt frames will put in RX FIFO 0 */ r8712_write16(Adapter, RXFLTMAP0, 0x0); val8 = r8712_read8(Adapter, EE_9346CR); @@ -388,8 +390,9 @@ uint oid_rt_pro_query_tx_packet_sent_hdl( *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.tx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } return status; } @@ -408,8 +411,9 @@ uint oid_rt_pro_query_rx_packet_received_hdl( *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } return status; } @@ -428,8 +432,9 @@ uint oid_rt_pro_query_rx_packet_crc32_error_hdl( *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } return status; } @@ -457,8 +462,9 @@ uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv if (poid_par_priv->information_buf_len == sizeof(u32)) { Adapter->mppriv.rx_pktcount = 0; Adapter->mppriv.rx_crcerrpktcount = 0; - } else + } else { status = RNDIS_STATUS_INVALID_LENGTH; + } return status; } @@ -684,7 +690,7 @@ uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) if (poid_par_priv->type_of_oid != QUERY_OID) return RNDIS_STATUS_NOT_ACCEPTED; - if (Adapter->mppriv.act_in_progress == true) + if (Adapter->mppriv.act_in_progress) return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u8)) @@ -728,7 +734,7 @@ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) > EFUSE_MAX_SIZE) return RNDIS_STATUS_NOT_ACCEPTED; - if (r8712_efuse_access(Adapter, true, addr, cnts, data) == false) + if (!r8712_efuse_access(Adapter, true, addr, cnts, data)) status = RNDIS_STATUS_FAILURE; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; return status; @@ -756,7 +762,7 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) > r8712_efuse_get_max_size(Adapter)) return RNDIS_STATUS_NOT_ACCEPTED; - if (r8712_efuse_access(Adapter, false, addr, cnts, data) == false) + if (!r8712_efuse_access(Adapter, false, addr, cnts, data)) status = RNDIS_STATUS_FAILURE; return status; } @@ -824,7 +830,7 @@ uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) status = RNDIS_STATUS_FAILURE; } else { /* SET_OID */ - if (r8712_efuse_reg_init(Adapter) == true) { + if (r8712_efuse_reg_init(Adapter)) { if (r8712_efuse_map_write(Adapter, 0, EFUSE_MAP_MAX_SIZE, data)) *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE; @@ -879,7 +885,7 @@ uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv rcr_val32 |= (RCR_AB | RCR_AM | RCR_APM | RCR_AAP | RCR_ACRC32); break; case RX_PKT_PHY_MATCH: - rcr_val32 |= (RCR_APM|RCR_ACRC32); + rcr_val32 |= (RCR_APM | RCR_ACRC32); break; default: rcr_val32 &= ~(RCR_AAP | diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c index 9bc04f474..bf10d6db5 100644 --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c @@ -44,8 +44,7 @@ void r8712_set_rpwm(struct _adapter *padapter, u8 val8) if (pwrpriv->rpwm_retry == 0) return; } - if ((padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true)) + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) return; rpwm = val8 | pwrpriv->tog; switch (val8) { @@ -129,8 +128,7 @@ static void _rpwm_check_handler (struct _adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - if (padapter->bDriverStopped == true || - padapter->bSurpriseRemoved == true) + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) return; if (pwrpriv->cpwm != pwrpriv->rpwm) schedule_work(&pwrpriv->rpwm_workitem); diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index 046a46c4c..4ff530155 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -83,7 +83,7 @@ sint _r8712_init_recv_priv(struct recv_priv *precvpriv, precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - ((addr_t)(precvpriv->pallocated_frame_buf) & - (RXFRAME_ALIGN_SZ-1)); + (RXFRAME_ALIGN_SZ - 1)); precvframe = (union recv_frame *)precvpriv->precv_frame_buf; for (i = 0; i < NR_RECVFRAME; i++) { INIT_LIST_HEAD(&(precvframe->u.list)); @@ -112,9 +112,9 @@ union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue) struct recv_priv *precvpriv; spin_lock_irqsave(&pfree_recv_queue->lock, irqL); - if (list_empty(&pfree_recv_queue->queue)) + if (list_empty(&pfree_recv_queue->queue)) { precvframe = NULL; - else { + } else { phead = &pfree_recv_queue->queue; plist = phead->next; precvframe = LIST_CONTAINOR(plist, union recv_frame, u); @@ -147,7 +147,7 @@ void r8712_free_recvframe_queue(struct __queue *pframequeue, spin_lock(&pframequeue->lock); phead = &pframequeue->queue; plist = phead->next; - while (end_of_queue_search(phead, plist) == false) { + while (!end_of_queue_search(phead, plist)) { precvframe = LIST_CONTAINOR(plist, union recv_frame, u); plist = plist->next; r8712_free_recvframe(precvframe, pfree_recv_queue); @@ -178,10 +178,11 @@ sint r8712_recvframe_chkmic(struct _adapter *adapter, idx = iv[3]; mickey = &psecuritypriv->XGrprxmickey[(((idx >> 6) & 0x3)) - 1].skey[0]; - if (psecuritypriv->binstallGrpkey == false) + if (!psecuritypriv->binstallGrpkey) return _FAIL; - } else + } else { mickey = &stainfo->tkiprxmickey.skey[0]; + } /*icv_len included the mic code*/ datalen = precvframe->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len - prxattrib->icv_len - 8; @@ -197,16 +198,15 @@ sint r8712_recvframe_chkmic(struct _adapter *adapter, if (miccode[i] != *(pframemic + i)) bmic_err = true; } - if (bmic_err == true) { - if (prxattrib->bdecrypted == true) + if (bmic_err) { + if (prxattrib->bdecrypted) r8712_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); res = _FAIL; } else { /* mic checked ok */ - if ((psecuritypriv->bcheck_grpkey == - false) && (IS_MCAST(prxattrib->ra) == - true)) + if (!psecuritypriv->bcheck_grpkey && + IS_MCAST(prxattrib->ra)) psecuritypriv->bcheck_grpkey = true; } recvframe_pull_tail(precvframe, 8); @@ -224,7 +224,7 @@ union recv_frame *r8712_decryptor(struct _adapter *padapter, union recv_frame *return_packet = precv_frame; if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) || - (psecuritypriv->sw_decrypt == true))) { + psecuritypriv->sw_decrypt)) { psecuritypriv->hw_decrypted = false; switch (prxattrib->encrypt) { case _WEP40_: @@ -240,8 +240,9 @@ union recv_frame *r8712_decryptor(struct _adapter *padapter, default: break; } - } else if (prxattrib->bdecrypted == 1) + } else if (prxattrib->bdecrypted == 1) { psecuritypriv->hw_decrypted = true; + } return return_packet; } /*###set the security information in the recv_frame */ @@ -271,9 +272,9 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter, if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked * only accept EAPOL frame */ - if (ether_type == 0x888e) + if (ether_type == 0x888e) { prtnframe = precv_frame; - else { + } else { /*free this frame*/ r8712_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue); @@ -290,8 +291,9 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter, prtnframe = precv_frame; } } - } else + } else { prtnframe = precv_frame; + } return prtnframe; } @@ -299,7 +301,7 @@ static sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache) { sint tid = precv_frame->u.hdr.attrib.priority; - u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | + u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num & 0xffff) << 4) | (precv_frame->u.hdr.attrib.frag_num & 0xf); if (tid > 15) @@ -324,8 +326,8 @@ static sint sta2sta_data_frame(struct _adapter *adapter, u8 *sta_addr = NULL; sint bmcast = IS_MCAST(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) return _FAIL; @@ -336,13 +338,13 @@ static sint sta2sta_data_frame(struct _adapter *adapter, (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) return _FAIL; sta_addr = pattrib->src; - } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* For Station mode, sa and bssid should always be BSSID, * and DA is my mac-address */ if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) return _FAIL; sta_addr = pattrib->bssid; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { if (bmcast) { /* For AP mode, if DA == MCAST, then BSSID should * be also MCAST */ @@ -355,21 +357,22 @@ static sint sta2sta_data_frame(struct _adapter *adapter, return _FAIL; sta_addr = pattrib->src; } - } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); memcpy(pattrib->ta, pattrib->src, ETH_ALEN); sta_addr = mybssid; - } else + } else { ret = _FAIL; + } if (bmcast) *psta = r8712_get_bcmc_stainfo(adapter); else *psta = r8712_get_stainfo(pstapriv, sta_addr); /* get ap_info */ if (*psta == NULL) { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) adapter->mppriv.rx_pktloss++; return _FAIL; } @@ -388,8 +391,8 @@ static sint ap2sta_data_frame(struct _adapter *adapter, u8 *myhwaddr = myid(&adapter->eeprompriv); sint bmcast = IS_MCAST(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - && (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && + check_fwstate(pmlmepriv, _FW_LINKED)) { /* if NULL-frame, drop packet */ if ((GetFrameSubType(ptr)) == WIFI_DATA_NULL) return _FAIL; @@ -419,8 +422,8 @@ static sint ap2sta_data_frame(struct _adapter *adapter, *psta = r8712_get_stainfo(pstapriv, pattrib->bssid); if (*psta == NULL) return _FAIL; - } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && + check_fwstate(pmlmepriv, _FW_LINKED)) { memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); @@ -430,8 +433,9 @@ static sint ap2sta_data_frame(struct _adapter *adapter, *psta = r8712_get_stainfo(pstapriv, pattrib->bssid); if (*psta == NULL) return _FAIL; - } else + } else { return _FAIL; + } return _SUCCESS; } @@ -444,7 +448,7 @@ static sint sta2ap_data_frame(struct _adapter *adapter, struct mlme_priv *pmlmepriv = &adapter->mlmepriv; unsigned char *mybssid = get_bssid(pmlmepriv); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* For AP mode, if DA is non-MCAST, then it must be BSSID, * and bssid == BSSID * For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */ @@ -630,10 +634,10 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); len = precvframe->u.hdr.len - rmv_len; - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { ptr += rmv_len; *ptr = 0x87; - *(ptr+1) = 0x12; + *(ptr + 1) = 0x12; /* append rx status for mp test packets */ ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + 2) - 24); @@ -644,7 +648,7 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0))); memcpy(ptr, pattrib->dst, ETH_ALEN); - memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN); + memcpy(ptr + ETH_ALEN, pattrib->src, ETH_ALEN); if (!bsnaphdr) { len = htons(len); memcpy(ptr + 12, &len, 2); diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 862792826..09242425d 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -175,22 +175,22 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe) if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return; - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr+TXDESC_OFFSET; + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET; /*start to encrypt each fragment*/ if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) { keylength = psecuritypriv->DefKeylen[psecuritypriv-> PrivacyKeyIndex]; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; + iv = pframe + pattrib->hdrlen; memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[3], &psecuritypriv->DefKey[ psecuritypriv->PrivacyKeyIndex].skey[0], keylength); - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + payload = pframe + pattrib->iv_len + pattrib->hdrlen; if ((curfragnum + 1) == pattrib->nr_frags) { - length = pattrib->last_txcmdsz-pattrib-> - hdrlen-pattrib->iv_len - + length = pattrib->last_txcmdsz - pattrib-> + hdrlen - pattrib->iv_len - pattrib->icv_len; *((u32 *)crc) = cpu_to_le32(getcrc32( payload, length)); @@ -200,14 +200,15 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe) arcfour_encrypt(&mycontext, payload + length, crc, 4); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen - - pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - + pattrib->hdrlen - pattrib->iv_len - + pattrib->icv_len; *((u32 *)crc) = cpu_to_le32(getcrc32( payload, length)); arcfour_init(&mycontext, wepkey, 3 + keylength); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, + arcfour_encrypt(&mycontext, payload + length, crc, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((addr_t)(pframe)); @@ -241,8 +242,8 @@ void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe) psecuritypriv->PrivacyKeyIndex].skey[0], keylength); length = ((union recv_frame *)precvframe)-> - u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; - payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len; + payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; /* decrypt payload include icv */ arcfour_init(&mycontext, wepkey, 3 + keylength); arcfour_encrypt(&mycontext, payload, payload, length); @@ -495,11 +496,11 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) /* Now compute an unbalanced Feistel cipher with 80-bit block */ /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add is mod 2**16 */ - p1k[0] += _S_(p1k[4] ^ TK16((i&1) + 0)); - p1k[1] += _S_(p1k[0] ^ TK16((i&1) + 2)); - p1k[2] += _S_(p1k[1] ^ TK16((i&1) + 4)); - p1k[3] += _S_(p1k[2] ^ TK16((i&1) + 6)); - p1k[4] += _S_(p1k[3] ^ TK16((i&1) + 0)); + p1k[0] += _S_(p1k[4] ^ TK16((i & 1) + 0)); + p1k[1] += _S_(p1k[0] ^ TK16((i & 1) + 2)); + p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4)); + p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6)); + p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0)); p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ } } @@ -587,7 +588,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe) if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr+TXDESC_OFFSET; + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET; /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _TKIP_) { if (pattrib->psta) @@ -600,7 +601,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe) for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { iv = pframe + pattrib->hdrlen; - payload = pframe+pattrib->iv_len + + payload = pframe + pattrib->iv_len + pattrib->hdrlen; GET_TKIP_PN(iv, txpn); pnl = (u16)(txpn.val); @@ -612,7 +613,8 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe) if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ length = pattrib->last_txcmdsz - - pattrib->hdrlen-pattrib->iv_len - + pattrib->hdrlen - + pattrib->iv_len - pattrib->icv_len; *((u32 *)crc) = cpu_to_le32( getcrc32(payload, length)); @@ -622,22 +624,25 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe) arcfour_encrypt(&mycontext, payload + length, crc, 4); } else { - length = pxmitpriv->frag_len-pattrib-> - hdrlen-pattrib-> - iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - + pattrib->hdrlen - + pattrib->iv_len - + pattrib->icv_len; *((u32 *)crc) = cpu_to_le32(getcrc32( payload, length)); arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, - payload+length, crc, 4); + payload + length, crc, + 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((addr_t)(pframe)); } } - } else + } else { res = _FAIL; + } } return res; } @@ -666,8 +671,9 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe) stainfo = r8712_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { - iv = pframe+prxattrib->hdrlen; - payload = pframe+prxattrib->iv_len + prxattrib->hdrlen; + iv = pframe + prxattrib->hdrlen; + payload = pframe + prxattrib->iv_len + + prxattrib->hdrlen; length = ((union recv_frame *)precvframe)-> u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len; @@ -675,10 +681,11 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe) idx = iv[3]; prwskey = &psecuritypriv->XGrpKey[ ((idx >> 6) & 0x3) - 1].skey[0]; - if (psecuritypriv->binstallGrpkey == false) + if (!psecuritypriv->binstallGrpkey) return _FAIL; - } else + } else { prwskey = &stainfo->x_UncstKey.skey[0]; + } GET_TKIP_PN(iv, txpn); pnl = (u16)(txpn.val); pnh = (u32)(txpn.val >> 16); @@ -696,8 +703,9 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe) crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) return _FAIL; - } else + } else { return _FAIL; + } } return _SUCCESS; } @@ -851,7 +859,7 @@ static void mix_column(u8 *in, u8 *out) andf7[3] = in[3] & 0x7f; for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ andf7[i] = andf7[i] << 1; - if ((andf7[i-1] & 0x80) == 0x80) + if ((andf7[i - 1] & 0x80) == 0x80) andf7[i] = (andf7[i] | 0x01); } andf7[0] = andf7[0] << 1; @@ -1069,14 +1077,15 @@ static sint aes_cipher(u8 *key, uint hdrlen, if (hdrlen != WLAN_HDR_A3_QOS_LEN) hdrlen += 2; qc_exists = 1; - } else + } else { qc_exists = 0; + } pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); construct_mic_header1(mic_header1, hdrlen, pframe); construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists); @@ -1108,7 +1117,7 @@ static sint aes_cipher(u8 *key, uint hdrlen, mic[j] = aes_out[j]; /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; + pframe[payload_index + j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { construct_ctr_preload(ctr_preload, a4_exists, qc_exists, @@ -1121,11 +1130,11 @@ static sint aes_cipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If short final block, then pad it,*/ /* encrypt and copy unpadded part back */ construct_ctr_preload(ctr_preload, a4_exists, qc_exists, - pframe, pn_vector, num_blocks+1); + pframe, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; + padded_buffer[j] = pframe[payload_index + j]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1137,7 +1146,7 @@ static sint aes_cipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < 8; j++) - padded_buffer[j] = pframe[j+hdrlen+8+plen]; + padded_buffer[j] = pframe[j + hdrlen + 8 + plen]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < 8; j++) @@ -1188,8 +1197,9 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe) pframe = (u8 *)RND4((addr_t)(pframe)); } } - } else + } else { res = _FAIL; + } } return res; } @@ -1224,13 +1234,13 @@ static sint aes_decipher(u8 *key, uint hdrlen, /* start to decrypt the payload */ /*(plen including llc, payload and mic) */ num_blocks = (plen - 8) / 16; - payload_remainder = (plen-8) % 16; + payload_remainder = (plen - 8) % 16; pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) a4_exists = 0; else @@ -1264,7 +1274,7 @@ static sint aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If short final block, pad it,*/ /* encrypt it and copy the unpadded part back */ construct_ctr_preload(ctr_preload, a4_exists, qc_exists, - pframe, pn_vector, num_blocks+1); + pframe, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) @@ -1277,12 +1287,12 @@ static sint aes_decipher(u8 *key, uint hdrlen, /* start to calculate the mic */ memcpy((void *)message, pframe, (hdrlen + plen + 8)); pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; - construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen-8, + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; + construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen - 8, pn_vector); construct_mic_header1(mic_header1, hdrlen, message); construct_mic_header2(mic_header2, message, a4_exists, qc_exists); @@ -1314,7 +1324,7 @@ static sint aes_decipher(u8 *key, uint hdrlen, mic[j] = aes_out[j]; /* Insert MIC into payload */ for (j = 0; j < 8; j++) - message[payload_index+j] = mic[j]; + message[payload_index + j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { construct_ctr_preload(ctr_preload, a4_exists, qc_exists, @@ -1327,7 +1337,7 @@ static sint aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If short final block, pad it,*/ /* encrypt and copy unpadded part back */ construct_ctr_preload(ctr_preload, a4_exists, qc_exists, - message, pn_vector, num_blocks+1); + message, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) @@ -1370,21 +1380,24 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe) &prxattrib->ta[0]); if (stainfo != NULL) { if (IS_MCAST(prxattrib->ra)) { - iv = pframe+prxattrib->hdrlen; + iv = pframe + prxattrib->hdrlen; idx = iv[3]; prwskey = &psecuritypriv->XGrpKey[ ((idx >> 6) & 0x3) - 1].skey[0]; - if (psecuritypriv->binstallGrpkey == false) + if (!psecuritypriv->binstallGrpkey) return _FAIL; - } else + } else { prwskey = &stainfo->x_UncstKey.skey[0]; + } length = ((union recv_frame *)precvframe)-> - u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + u.hdr.len - prxattrib->hdrlen - + prxattrib->iv_len; aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); - } else + } else { return _FAIL; + } } return _SUCCESS; } diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index 6ae8cdc1b..162e61c6e 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -83,7 +83,7 @@ static void mfree_all_stainfo(struct sta_priv *pstapriv) spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL); phead = &pstapriv->free_sta_queue.queue; plist = phead->next; - while ((end_of_queue_search(phead, plist)) == false) + while (!end_of_queue_search(phead, plist)) plist = plist->next; spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL); @@ -117,9 +117,9 @@ struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) pfree_sta_queue = &pstapriv->free_sta_queue; spin_lock_irqsave(&(pfree_sta_queue->lock), flags); - if (list_empty(&pfree_sta_queue->queue)) + if (list_empty(&pfree_sta_queue->queue)) { psta = NULL; - else { + } else { psta = LIST_CONTAINOR(pfree_sta_queue->queue.next, struct sta_info, list); list_del_init(&(psta->list)); @@ -222,7 +222,7 @@ void r8712_free_all_stainfo(struct _adapter *padapter) for (index = 0; index < NUM_STA; index++) { phead = &(pstapriv->sta_hash[index]); plist = phead->next; - while ((end_of_queue_search(phead, plist)) == false) { + while (!end_of_queue_search(phead, plist)) { psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); plist = plist->next; @@ -247,7 +247,7 @@ struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL); phead = &(pstapriv->sta_hash[index]); plist = phead->next; - while ((end_of_queue_search(phead, plist)) == false) { + while (!end_of_queue_search(phead, plist)) { psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); if ((!memcmp(psta->hwaddr, hwaddr, ETH_ALEN))) { /* if found the matched address */ diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 2e4fa8895..68d65d230 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -217,8 +217,8 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); pattrib->pctrl = 0; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); memcpy(pattrib->ta, pattrib->src, ETH_ALEN); } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { @@ -227,7 +227,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); - } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { /*firstly, filter packet not belongs to mp*/ if (pattrib->ether_type != 0x8712) return _FAIL; @@ -267,7 +267,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, psta = r8712_get_bcmc_stainfo(padapter); pattrib->mac_id = 4; } else { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { psta = r8712_get_stainfo(pstapriv, get_bssid(pmlmepriv)); pattrib->mac_id = 5; @@ -293,20 +293,21 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, /* get ether_hdr_len */ pattrib->pkt_hdrlen = ETH_HLEN; - if (pqospriv->qos_option) + if (pqospriv->qos_option) { r8712_set_qos(&pktfile, pattrib); - else { + } else { pattrib->hdrlen = WLAN_HDR_A3_LEN; pattrib->subtype = WIFI_DATA_TYPE; pattrib->priority = 0; } - if (psta->ieee8021x_blocked == true) { + if (psta->ieee8021x_blocked) { pattrib->encrypt = 0; if ((pattrib->ether_type != 0x888e) && - (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) + !check_fwstate(pmlmepriv, WIFI_MP_STATE)) return _FAIL; - } else + } else { GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast); + } switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: @@ -330,14 +331,14 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, } if (pattrib->encrypt && - ((padapter->securitypriv.sw_encrypt == true) || - (psecuritypriv->hw_decrypted == false))) + (padapter->securitypriv.sw_encrypt || + !psecuritypriv->hw_decrypted)) pattrib->bswenc = true; else pattrib->bswenc = false; /* if in MP_STATE, update pkt_attrib from mp_txcmd, and overwrite * some settings above.*/ - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) pattrib->priority = (txdesc.txdw1 >> QSEL_SHT) & 0x1f; return _SUCCESS; } @@ -389,7 +390,7 @@ static sint xmitframe_addmic(struct _adapter *padapter, if (pframe[1] & 1) { /* ToDS==1 */ r8712_secmicappend(&micdata, &pframe[16], 6); /*DA*/ - if (pframe[1]&2) /* From Ds==1 */ + if (pframe[1] & 2) /* From Ds==1 */ r8712_secmicappend(&micdata, &pframe[24], 6); else @@ -398,7 +399,7 @@ static sint xmitframe_addmic(struct _adapter *padapter, } else { /* ToDS==0 */ r8712_secmicappend(&micdata, &pframe[4], 6); /* DA */ - if (pframe[1]&2) /* From Ds==1 */ + if (pframe[1] & 2) /* From Ds==1 */ r8712_secmicappend(&micdata, &pframe[16], 6); else @@ -413,8 +414,8 @@ static sint xmitframe_addmic(struct _adapter *padapter, for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { payload = (u8 *)RND4((addr_t)(payload)); - payload = payload+pattrib-> - hdrlen+pattrib->iv_len; + payload = payload + pattrib-> + hdrlen + pattrib->iv_len; if ((curfragnum + 1) == pattrib->nr_frags) { length = pattrib->last_txcmdsz - pattrib->hdrlen - @@ -423,10 +424,10 @@ static sint xmitframe_addmic(struct _adapter *padapter, ? pattrib->icv_len : 0); r8712_secmicappend(&micdata, payload, length); - payload = payload+length; + payload = payload + length; } else{ length = pxmitpriv->frag_len - - pattrib->hdrlen-pattrib->iv_len - + pattrib->hdrlen - pattrib->iv_len - ((psecuritypriv->sw_encrypt) ? pattrib->icv_len : 0); r8712_secmicappend(&micdata, payload, @@ -440,7 +441,7 @@ static sint xmitframe_addmic(struct _adapter *padapter, * last_txcmdsz */ memcpy(payload, &(mic[0]), 8); pattrib->last_txcmdsz += 8; - payload = payload-pattrib->last_txcmdsz + 8; + payload = payload - pattrib->last_txcmdsz + 8; } } return _SUCCESS; @@ -483,34 +484,35 @@ static sint make_wlanhdr(struct _adapter *padapter, u8 *hdr, memset(hdr, 0, WLANHDR_OFFSET); SetFrameSubType(fctrl, pattrib->subtype); if (pattrib->subtype & WIFI_DATA_TYPE) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* to_ds = 1, fr_ds = 0; */ SetToDs(fctrl); memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* to_ds = 0, fr_ds = 1; */ SetFrDs(fctrl); memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); - } else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) - || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) - == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, + WIFI_ADHOC_MASTER_STATE)) { memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - } else + } else { return _FAIL; + } if (pattrib->encrypt) SetPrivacy(fctrl); @@ -526,9 +528,9 @@ static sint make_wlanhdr(struct _adapter *padapter, u8 *hdr, struct sta_info *psta; sint bmcst = IS_MCAST(pattrib->ra); - if (pattrib->psta) + if (pattrib->psta) { psta = pattrib->psta; - else { + } else { if (bmcst) psta = r8712_get_bcmc_stainfo(padapter); else @@ -609,7 +611,7 @@ sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt, return _FAIL; _r8712_open_pktfile(pkt, &pktfile); _r8712_pktfile_read(&pktfile, NULL, (uint) pattrib->pkt_hdrlen); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { /* truncate TXDESC_SIZE bytes txcmd if at mp mode for 871x */ if (pattrib->ether_type == 0x8712) { /* take care - update_txdesc overwrite this */ @@ -680,7 +682,7 @@ sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt, pframe += pattrib->icv_len; } frg_inx++; - if (bmcst || (r8712_endofpktfile(&pktfile) == true)) { + if (bmcst || r8712_endofpktfile(&pktfile)) { pattrib->nr_frags = frg_inx; pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + @@ -719,17 +721,18 @@ void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len) case AUTO_VCS: default: perp = r8712_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); - if (perp == NULL) + if (perp == NULL) { pxmitpriv->vcs = NONE_VCS; - else { + } else { protection = (*(perp + 2)) & BIT(1); if (protection) { if (pregistrypriv->vcs_type == RTS_CTS) pxmitpriv->vcs = RTS_CTS; else pxmitpriv->vcs = CTS_TO_SELF; - } else + } else { pxmitpriv->vcs = NONE_VCS; + } } break; } @@ -743,9 +746,9 @@ struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv) struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL); - if (list_empty(&pfree_xmitbuf_queue->queue)) + if (list_empty(&pfree_xmitbuf_queue->queue)) { pxmitbuf = NULL; - else { + } else { phead = &pfree_xmitbuf_queue->queue; plist = phead->next; pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); @@ -797,9 +800,9 @@ struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv) struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; spin_lock_irqsave(&pfree_xmit_queue->lock, irqL); - if (list_empty(&pfree_xmit_queue->queue)) + if (list_empty(&pfree_xmit_queue->queue)) { pxframe = NULL; - else { + } else { phead = &pfree_xmit_queue->queue; plist = phead->next; pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); @@ -855,7 +858,7 @@ void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv, spin_lock_irqsave(&(pframequeue->lock), irqL); phead = &pframequeue->queue; plist = phead->next; - while (end_of_queue_search(phead, plist) == false) { + while (!end_of_queue_search(phead, plist)) { pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); plist = plist->next; r8712_free_xmitframe(pxmitpriv, pxmitframe); @@ -876,19 +879,19 @@ static inline struct tx_servq *get_sta_pending(struct _adapter *padapter, case 2: ptxservq = &(psta->sta_xmitpriv.bk_q); *ppstapending = &padapter->xmitpriv.bk_pending; - (phwxmits+3)->accnt++; + (phwxmits + 3)->accnt++; break; case 4: case 5: ptxservq = &(psta->sta_xmitpriv.vi_q); *ppstapending = &padapter->xmitpriv.vi_pending; - (phwxmits+1)->accnt++; + (phwxmits + 1)->accnt++; break; case 6: case 7: ptxservq = &(psta->sta_xmitpriv.vo_q); *ppstapending = &padapter->xmitpriv.vo_pending; - (phwxmits+0)->accnt++; + (phwxmits + 0)->accnt++; break; case 0: case 3: @@ -917,13 +920,13 @@ sint r8712_xmit_classifier(struct _adapter *padapter, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; sint bmcst = IS_MCAST(pattrib->ra); - if (pattrib->psta) + if (pattrib->psta) { psta = pattrib->psta; - else { - if (bmcst) + } else { + if (bmcst) { psta = r8712_get_bcmc_stainfo(padapter); - else { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + } else { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) psta = r8712_get_stainfo(pstapriv, get_bssid(pmlmepriv)); else diff --git a/drivers/staging/rtl8712/usb_halinit.c b/drivers/staging/rtl8712/usb_halinit.c index b4ae11a78..ad21df16c 100644 --- a/drivers/staging/rtl8712/usb_halinit.c +++ b/drivers/staging/rtl8712/usb_halinit.c @@ -167,12 +167,12 @@ u8 r8712_usb_hal_bus_init(struct _adapter *padapter) r8712_write8(padapter, CR + 1, 0x37); /* Fix the RX FIFO issue(usb error), */ val8 = r8712_read8(padapter, 0x1025FE5c); - r8712_write8(padapter, 0x1025FE5c, (val8|BIT(7))); + r8712_write8(padapter, 0x1025FE5c, (val8 | BIT(7))); val8 = r8712_read8(padapter, 0x102500ab); - r8712_write8(padapter, 0x102500ab, (val8|BIT(6)|BIT(7))); + r8712_write8(padapter, 0x102500ab, (val8 | BIT(6) | BIT(7))); /* For power save, used this in the bit file after 970621 */ val8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, val8&(~CPU_CLKSEL)); + r8712_write8(padapter, SYS_CLKR, val8 & (~CPU_CLKSEL)); } else if (pregistrypriv->chip_version == RTL8712_2ndCUT || pregistrypriv->chip_version == RTL8712_3rdCUT) { /* Initialization for power on sequence, @@ -280,13 +280,14 @@ u8 r8712_usb_hal_bus_init(struct _adapter *padapter) if (PollingCnt <= 0) { val8 = r8712_read8(padapter, CR); - r8712_write8(padapter, CR, val8&(~_TXDMA_EN)); + r8712_write8(padapter, CR, val8 & (~_TXDMA_EN)); udelay(2); /* PlatformStallExecution(2); */ /* Reset TxDMA */ - r8712_write8(padapter, CR, val8|_TXDMA_EN); + r8712_write8(padapter, CR, val8 | _TXDMA_EN); } - } else + } else { ret = _FAIL; + } return ret; } diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 943a0e204..c71333fbe 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -302,7 +302,7 @@ void rtl871x_intf_stop(struct _adapter *padapter) void r871x_dev_unload(struct _adapter *padapter) { - if (padapter->bup == true) { + if (padapter->bup) { /*s1.*/ padapter->bDriverStopped = true; @@ -331,8 +331,7 @@ static void disable_ht_for_spec_devid(const struct usb_device_id *pdid, u16 vid, pid; u32 flags; int i; - int num = sizeof(specific_device_id_tbl) / - sizeof(struct specific_device_id); + int num = ARRAY_SIZE(specific_device_id_tbl); for (i = 0; i < num; i++) { vid = specific_device_id_tbl[i].idVendor; @@ -340,7 +339,7 @@ static void disable_ht_for_spec_devid(const struct usb_device_id *pdid, flags = specific_device_id_tbl[i].flags; if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && - (flags&SPEC_DEV_ID_DISABLE_HT)) { + (flags & SPEC_DEV_ID_DISABLE_HT)) { padapter->registrypriv.ht_enable = 0; padapter->registrypriv.cbw40_enable = 0; padapter->registrypriv.ampdu_enable = 0; @@ -396,9 +395,9 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, /* step 3. * initialize the dvobj_priv */ - if (!padapter->dvobj_init) - goto error; - else { + if (!padapter->dvobj_init) { + goto error; + } else { status = padapter->dvobj_init(padapter); if (status != _SUCCESS) goto error; @@ -427,7 +426,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, /* The following operations prevent Efuse leakage by * turning on 2.5V. */ - tmpU1b = r8712_read8(padapter, EFUSE_TEST+3); + tmpU1b = r8712_read8(padapter, EFUSE_TEST + 3); r8712_write8(padapter, EFUSE_TEST + 3, tmpU1b | 0x80); msleep(20); r8712_write8(padapter, EFUSE_TEST + 3, @@ -554,8 +553,9 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, padapter->ledpriv.bRegUseLed = false; break; } - } else + } else { AutoloadFail = false; + } if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || @@ -612,7 +612,7 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) release_firmware(padapter->fw); /* never exit with a firmware callback pending */ wait_for_completion(&padapter->rtl8712_fw_ready); - if (drvpriv.drv_registered == true) + if (drvpriv.drv_registered) padapter->bSurpriseRemoved = true; unregister_netdev(pnetdev); /* will call netdev_close() */ flush_scheduled_work(); diff --git a/drivers/staging/rtl8712/usb_ops.c b/drivers/staging/rtl8712/usb_ops.c index c03508d93..856f257bb 100644 --- a/drivers/staging/rtl8712/usb_ops.c +++ b/drivers/staging/rtl8712/usb_ops.c @@ -47,11 +47,11 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) request = 0x05; requesttype = 0x01; /* read_in */ index = 0; - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 1; r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, requesttype); - return (u8)(le32_to_cpu(data)&0x0ff); + return (u8)(le32_to_cpu(data) & 0x0ff); } static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) @@ -67,11 +67,11 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) request = 0x05; requesttype = 0x01; /* read_in */ index = 0; - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 2; r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, requesttype); - return (u16)(le32_to_cpu(data)&0xffff); + return (u16)(le32_to_cpu(data) & 0xffff); } static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) @@ -87,7 +87,7 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) request = 0x05; requesttype = 0x01; /* read_in */ index = 0; - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 4; r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, requesttype); @@ -107,10 +107,10 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) request = 0x05; requesttype = 0x00; /* write_out */ index = 0; - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; - data = cpu_to_le32(data&0x000000ff); + data = cpu_to_le32(data & 0x000000ff); r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, requesttype); } @@ -128,10 +128,10 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) request = 0x05; requesttype = 0x00; /* write_out */ index = 0; - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 2; data = val; - data = cpu_to_le32(data&0x0000ffff); + data = cpu_to_le32(data & 0x0000ffff); r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, requesttype); } @@ -149,7 +149,7 @@ static void usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) request = 0x05; requesttype = 0x00; /* write_out */ index = 0; - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 4; data = cpu_to_le32(val); r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index c3a4e3f26..489a9e6d5 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -144,8 +144,9 @@ static unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) pipe = usb_sndbulkpipe(pusbd, 0x0d); break; } - } else + } else { pipe = 0; + } return pipe; } @@ -170,7 +171,7 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) unsigned int pipe; struct _adapter *padapter = (struct _adapter *)pintfhdl->adapter; struct intf_priv *pintfpriv = pintfhdl->pintfpriv; - struct io_queue *pio_queue = (struct io_queue *)padapter->pio_queue; + struct io_queue *pio_queue = padapter->pio_queue; struct dvobj_priv *pdvobj = (struct dvobj_priv *)pintfpriv->intf_dev; struct usb_device *pusbd = pdvobj->pusbdev; struct urb *piorw_urb = pintfpriv->piorw_urb; @@ -259,16 +260,16 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) struct recv_buf *precvbuf = (struct recv_buf *)rmem; struct intf_priv *pintfpriv = pintfhdl->pintfpriv; struct dvobj_priv *pdvobj = (struct dvobj_priv *)pintfpriv->intf_dev; - struct _adapter *adapter = (struct _adapter *)pdvobj->padapter; + struct _adapter *adapter = pdvobj->padapter; struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) return _FAIL; - if (!precvbuf->reuse == false || !precvbuf->pskb) { + if (precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); - if (NULL != precvbuf->pskb) + if (precvbuf->pskb != NULL) precvbuf->reuse = true; } if (precvbuf != NULL) { @@ -280,7 +281,7 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) if (!precvbuf->pskb) return _FAIL; tmpaddr = (addr_t)precvbuf->pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); precvbuf->phead = precvbuf->pskb->head; @@ -306,8 +307,9 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) err = usb_submit_urb(purb, GFP_ATOMIC); if ((err) && (err != (-EPERM))) ret = _FAIL; - } else + } else { ret = _FAIL; + } return ret; } @@ -330,13 +332,13 @@ void r8712_xmit_bh(void *priv) struct _adapter *padapter = (struct _adapter *)priv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - if ((padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true)) { + if (padapter->bDriverStopped || + padapter->bSurpriseRemoved) { netdev_err(padapter->pnetdev, "xmit_bh => bDriverStopped or bSurpriseRemoved\n"); return; } ret = r8712_xmitframe_complete(padapter, pxmitpriv, NULL); - if (ret == false) + if (!ret) return; tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } @@ -400,7 +402,7 @@ u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) u32 ret, bwritezero; struct urb *purb = NULL; struct _adapter *padapter = (struct _adapter *)pintfhdl->adapter; - struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv; + struct dvobj_priv *pdvobj = &padapter->dvobjpriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = (struct xmit_frame *)wmem; struct usb_device *pusbd = pdvobj->pusbdev; @@ -410,7 +412,7 @@ u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) (padapter->pwrctrlpriv.pnp_bstop_trx)) return _FAIL; for (i = 0; i < 8; i++) { - if (pxmitframe->bpending[i] == false) { + if (!pxmitframe->bpending[i]) { spin_lock_irqsave(&pxmitpriv->lock, irqL); pxmitpriv->txirp_cnt++; pxmitframe->bpending[i] = true; @@ -449,7 +451,7 @@ u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) } /* translate DMA FIFO addr to pipehandle */ pipe = ffaddr2pipehdl(pdvobj, addr); - if (pxmitpriv->free_xmitbuf_cnt%NR_XMITBUFF == 0) + if (pxmitpriv->free_xmitbuf_cnt % NR_XMITBUFF == 0) purb->transfer_flags &= (~URB_NO_INTERRUPT); else purb->transfer_flags |= URB_NO_INTERRUPT; diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 17f513122..7a352c453 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -28,15 +28,7 @@ #include -#ifdef BIT -#undef BIT -#endif -#define BIT(x) (1 << (x)) - -#define WLAN_ETHHDR_LEN 14 -#define WLAN_ETHADDR_LEN 6 #define WLAN_IEEE_OUI_LEN 3 -#define WLAN_ADDR_LEN 6 #define WLAN_CRC_LEN 4 #define WLAN_BSSID_LEN 6 #define WLAN_BSS_TS_LEN 8 @@ -52,7 +44,6 @@ #define WLAN_MIN_ETHFRM_LEN 60 #define WLAN_MAX_ETHFRM_LEN 1514 -#define WLAN_ETHHDR_LEN 14 #define P80211CAPTURE_VERSION 0x80211001 diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index d15fb1ad4..d3981836c 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -166,7 +166,7 @@ int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev) struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); int ret = 0; - if (r8712_if_up(padapter) == false) { + if (!r8712_if_up(padapter)) { ret = 0; goto _xmit_entry_drop; } @@ -181,7 +181,7 @@ int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev) } padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX); pxmitframe->pkt = pkt; - if (r8712_pre_xmit(padapter, pxmitframe) == true) { + if (r8712_pre_xmit(padapter, pxmitframe)) { /*dump xmitframe directly or drop xframe*/ dev_kfree_skb_any(pkt); pxmitframe->pkt = NULL; -- cgit v1.2.3-54-g00ecf