[PATCH 0/8] staging: rtl8192e: Fix more checkpatch.pl warnings

2015-04-07 Thread Mateusz Kulikowski
This series of patches fixes another set of checkpatch.pl warnings.

Most of the patches are trivial, with the exception of #8, #7 and #5;
Driver logic should not be affected. 
Some of the patches cause LONG_LINE warnings, but fix has to wait until
I do more driver refactorings (It's hard to keep line length when variable 
names have 30 characters).

Series should apply to staging-next/testing (c610f7f7). 

Smoke tested on rtl8192e card vs staging-next:
- Module load/unload
- Interface up/down

Mateusz Kulikowski (8):
  staging: rtl8192e: Fix SPACE_BEFORE_TAB warnings
  staging: rtl8192e: Copy comments from r819XE_phyreg.h to r8192E_phyreg.h
  staging: rtl8192e: remove r819xE_phyreg.h
  staging: rtl8192e: Fix SPACING errors
  staging: rtl8192e: Remove bb tx gains from r8192_priv
  staging: rtl8192e: Fix LINE_SPACING warning
  staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtllib_parse_info_param()
  staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtl_dm.c

 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c|5 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c|2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 1496 +++--
 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h |  908 -
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c  |6 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h  |   20 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c|  821 +++
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.h|9 +
 drivers/staging/rtl8192e/rtllib_debug.h   |3 +-
 drivers/staging/rtl8192e/rtllib_rx.c  |   23 +-
 10 files changed, 1014 insertions(+), 2279 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h

-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/8] staging: rtl8192e: Fix SPACE_BEFORE_TAB warnings

2015-04-07 Thread Mateusz Kulikowski
Reformat r8192E_phyreg.h to make checkpatch happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 1442 ++---
 1 file changed, 721 insertions(+), 721 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
index 7899dd5..d080876 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
@@ -3,7 +3,7 @@
  *
  * This program is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
@@ -20,48 +20,48 @@
 #define _R819XU_PHYREG_H
 
 
-#define   RF_DATA  0x1d4
-
-#define rPMAC_Reset0x100
-#define rPMAC_TxStart  0x104
-#define rPMAC_TxLegacySIG  0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum  0x118
-#define rPMAC_TxIdle   0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType   0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble  0x140
-#define rPMAC_CCKPLCPHeader0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK0x170
-#define rPMAC_OFDMRxCRC32Er0x174
-#define rPMAC_OFDMRxParityEr   0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-#defineMCS_TXAGC   0x340
-#defineCCK_TXAGC   0x348
+#define RF_DATA0x1d4
+
+#define rPMAC_Reset0x100
+#define rPMAC_TxStart  0x104
+#define rPMAC_TxLegacySIG  0x108
+#define rPMAC_TxHTSIG1 0x10c
+#define rPMAC_TxHTSIG2 0x110
+#define rPMAC_PHYDebug 0x114
+#define rPMAC_TxPacketNum  0x118
+#define rPMAC_TxIdle   0x11c
+#define rPMAC_TxMACHeader0 0x120
+#define rPMAC_TxMACHeader1 0x124
+#define rPMAC_TxMACHeader2 0x128
+#define rPMAC_TxMACHeader3 0x12c
+#define rPMAC_TxMACHeader4 0x130
+#define rPMAC_TxMACHeader5 0x134
+#define rPMAC_TxDataType   0x138
+#define rPMAC_TxRandomSeed 0x13c
+#define rPMAC_CCKPLCPPreamble  0x140
+#define rPMAC_CCKPLCPHeader0x144
+#define rPMAC_CCKCRC16 0x148
+#define rPMAC_OFDMRxCRC32OK0x170
+#define rPMAC_OFDMRxCRC32Er0x174
+#define rPMAC_OFDMRxParityEr   0x178
+#define rPMAC_OFDMRxCRC8Er 0x17c
+#define rPMAC_CCKCRxRC16Er 0x180
+#define rPMAC_CCKCRxRC32Er 0x184
+#define rPMAC_CCKCRxRC32OK 0x188
+#define rPMAC_TxStatus 0x18c
+
+#define MCS_TXAGC  0x340
+#define CCK_TXAGC  0x348
 
 /*-0x400~0x4ff--*/
-#defineMacBlkCtrl  0x403
-
-#define rFPGA0_RFMOD   0x800
-#define rFPGA0_TxInfo  0x804
-#define rFPGA0_PSDFunction 0x808
-#define rFPGA0_TxGainStage 0x80c
-#define rFPGA0_RFTiming1   0x810
-#define rFPGA0_RFTiming2   0x814
+#define MacBlkCtrl 0x403
+
+#define rFPGA0_RFMOD   0x800
+#define rFPGA0_TxInfo  0x804
+#define rFPGA0_PSDFunction 0x808
+#define rFPGA0_TxGainStage 0x80c
+#define rFPGA0_RFTiming1   0x810
+#define rFPGA0_RFTiming2   0x814
 #define rFPGA0_XA_HSSIParameter1   0x820
 #define rFPGA0_XA_HSSIParameter2   0x824
 #define rFPGA0_XB_HSSIParameter1   0x828
@@ -94,49 +94,49 @@
 #define rFPGA0_XB_LSSIReadBack 0x8a4
 #define rFPGA0_XC_LSSIReadBack 0x8a8
 #define rFPGA0_XD_LSSIReadBack 0x8ac
-#define rFPGA0_PSDReport   0x8b4
+#define rFPGA0_PSDReport   0x8b4
 #define rFPGA0_XAB_RFInterfaceRB   0x8e0
 #define rFPGA0_XCD_RFInterfaceRB   0x8e4
 
-#define rFPGA1_RFMOD   0x900

[PATCH 2/8] staging: rtl8192e: Copy comments from r819XE_phyreg.h to r8192E_phyreg.h

2015-04-07 Thread Mateusz Kulikowski
Both files have the same contents (with the exception of comments).
One of them will not survive future commits.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 92 ---
 1 file changed, 65 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
index d080876..8a1d91e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
@@ -53,10 +53,10 @@
 #define MCS_TXAGC  0x340
 #define CCK_TXAGC  0x348
 
-/*-0x400~0x4ff--*/
+/* Mac block on/off control register */
 #define MacBlkCtrl 0x403
 
-#define rFPGA0_RFMOD   0x800
+#define rFPGA0_RFMOD   0x800 /* RF mode & CCK TxSC */
 #define rFPGA0_TxInfo  0x804
 #define rFPGA0_PSDFunction 0x808
 #define rFPGA0_TxGainStage 0x80c
@@ -98,6 +98,7 @@
 #define rFPGA0_XAB_RFInterfaceRB   0x8e0
 #define rFPGA0_XCD_RFInterfaceRB   0x8e4
 
+/* Page 9 - RF mode & OFDM TxSC */
 #define rFPGA1_RFMOD   0x900
 #define rFPGA1_TxBlock 0x904
 #define rFPGA1_DebugSelect 0x908
@@ -106,14 +107,16 @@
 #define rCCK0_System   0xa00
 #define rCCK0_AFESetting   0xa04
 #define rCCK0_CCA  0xa08
+/* AGC default value, saturation level */
 #define rCCK0_RxAGC1   0xa0c
-#define rCCK0_RxAGC2   0xa10
+#define rCCK0_RxAGC2   0xa10 /* AGC & DAGC */
 #define rCCK0_RxHP 0xa14
+/* Timing recovery & channel estimation threshold */
 #define rCCK0_DSPParameter10xa18
-#define rCCK0_DSPParameter20xa1c
+#define rCCK0_DSPParameter20xa1c /* SQ threshold */
 #define rCCK0_TxFilter10xa20
 #define rCCK0_TxFilter20xa24
-#define rCCK0_DebugPort0xa28
+#define rCCK0_DebugPort0xa28 /* Debug port and TX 
filter 3 */
 #define rCCK0_FalseAlarmReport 0xa2c
 #define rCCK0_TRSSIReport  0xa50
 #define rCCK0_RxReport 0xa54
@@ -124,22 +127,24 @@
 #define rOFDM0_TRxPathEnable   0xc04
 #define rOFDM0_TRMuxPar0xc08
 #define rOFDM0_TRSWIsolation   0xc0c
+/* RxIQ DC offset, Rx digital filter, DC notch filter */
 #define rOFDM0_XARxAFE 0xc10
-#define rOFDM0_XARxIQImbalance 0xc14
+#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */
 #define rOFDM0_XBRxAFE 0xc18
 #define rOFDM0_XBRxIQImbalance 0xc1c
 #define rOFDM0_XCRxAFE 0xc20
 #define rOFDM0_XCRxIQImbalance 0xc24
 #define rOFDM0_XDRxAFE 0xc28
 #define rOFDM0_XDRxIQImbalance 0xc2c
-#define rOFDM0_RxDetector1 0xc30
-#define rOFDM0_RxDetector2 0xc34
-#define rOFDM0_RxDetector3 0xc38
+#define rOFDM0_RxDetector1 0xc30 /* PD, BW & SBD */
+#define rOFDM0_RxDetector2 0xc34 /* SBD */
+#define rOFDM0_RxDetector3 0xc38 /* Frame Sync */
+/* PD, SBD, Frame Sync & Short-GI */
 #define rOFDM0_RxDetector4 0xc3c
-#define rOFDM0_RxDSP   0xc40
-#define rOFDM0_CFOandDAGC  0xc44
+#define rOFDM0_RxDSP   0xc40 /* Rx Sync Path */
+#define rOFDM0_CFOandDAGC  0xc44 /* CFO & DAGC */
 #define rOFDM0_CCADropThreshold0xc48
-#define rOFDM0_ECCAThreshold   0xc4c
+#define rOFDM0_ECCAThreshold   0xc4c /* Energy CCA */
 #define rOFDM0_XAAGCCore1  0xc50
 #define rOFDM0_XAAGCCore2  0xc54
 #define rOFDM0_XBAGCCore1  0xc58
@@ -184,9 +189,9 @@
 #define rOFDM1_PseudoNoiseStateAB  0xd50
 #define rOFDM1_PseudoNoiseStateCD  0xd54
 #define rOFDM1_RxPseudoNoiseWgt0xd58
-#define rOFDM_PHYCounter1  0xda0
-#define rOFDM_PHYCounter2  0xda4
-#define rOFDM_PHYCounter3  0xda8
+#define rOFDM_PHYCounter1  0xda0 /* cca, parity fail */
+#define rOFDM_PHYCounter2  0xda4 /* rate illegal, crc8 fail */
+#define rOFDM_PHYCounter3  0xda8 /* MCS not supported */
 #define rOFDM_ShortCFOAB   0xdac
 #define rOFDM_ShortCFOCD   0xdb0
 #define rOFDM_LongCFOAB0xdb4
@@ -221,14 +226,17 @@
 #define rZebra1_RxLPF  0xb
 #define rZebra1_RxHPFCorner0xc
 
+/* Zebra 4 */
 #define rGlobalCtrl0
 #define rRTL8256_TxLPF 19
 #define rRTL8256_RxLPF 11
 
+/* RTL8258 */
 #define rRTL8258_TxLPF 0x11
 #define rRTL8258_RxLPF 0x

[PATCH 6/8] staging: rtl8192e: Fix LINE_SPACING warning

2015-04-07 Thread Mateusz Kulikowski
Trivial fix - add newline in dm_InitializeTXPowerTracking_TSSI()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index c99d584..9de5846 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -941,6 +941,7 @@ static void dm_InitializeTXPowerTracking_TSSI(struct 
net_device *dev)
 {
 
struct r8192_priv *priv = rtllib_priv(dev);
+
priv->btxpower_tracking = true;
priv->txpower_count   = 0;
priv->btxpower_trackingInit = false;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/8] staging: rtl8192e: Remove bb tx gains from r8192_priv

2015-04-07 Thread Mateusz Kulikowski
r8192_priv structure had 2 big arrays with tx gain register values:
- cck_txbbgain_table
- cck_txbbgain_ch14_table
- txbbgain_table

This arrays were read-only - filled in driver init code and look
like firmware/chip-specific.

This patch removes them from r8192_priv and puts them in (global) variables.

tx_bb_gain is also flattened - register values are stored in array;
Amplification value can be calculated using dm_tx_bb_gain_idx_to_amplify().

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |   5 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   |  14 -
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 674 +
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.h |   9 +
 4 files changed, 151 insertions(+), 551 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 2869602..aad5cc9 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -918,8 +918,7 @@ start:
tmpRegC = rtl8192_QueryBBReg(dev,
  rOFDM0_XCTxIQImbalance, bMaskDWord);
for (i = 0; i < TxBBGainTableLength; i++) {
-   if (tmpRegA ==
-   priv->txbbgain_table[i].txbbgain_value) {
+   if (tmpRegA == dm_tx_bb_gain[i]) {
priv->rfa_txpowertrackingindex = (u8)i;
priv->rfa_txpowertrackingindex_real =
 (u8)i;
@@ -933,7 +932,7 @@ start:
  rCCK0_TxFilter1, bMaskByte2);
 
for (i = 0; i < CCKTxBBGainTableLength; i++) {
-   if (TempCCk == 
priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) {
+   if (TempCCk == dm_cck_tx_bb_gain[i][0]) {
priv->CCKPresentAttentuation_20Mdefault 
= (u8)i;
break;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index a6279e7..0640e76 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -451,15 +451,6 @@ enum two_port_status {
TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE
 };
 
-struct txbbgain_struct {
-   longtxbb_iq_amplifygain;
-   u32 txbbgain_value;
-};
-
-struct ccktxbbgain {
-   u8  ccktxbb_valuearray[8];
-};
-
 struct init_gain {
u8  xaagccore1;
u8  xbagccore1;
@@ -567,11 +558,6 @@ struct r8192_priv {
struct bb_reg_definition PHYRegDef[4];
struct rate_adaptive rate_adaptive;
 
-   struct ccktxbbgain cck_txbbgain_table[CCKTxBBGainTableLength];
-   struct ccktxbbgain cck_txbbgain_ch14_table[CCKTxBBGainTableLength];
-
-   struct txbbgain_struct txbbgain_table[TxBBGainTableLength];
-
enum acm_method AcmMethod;
 
struct rt_firmware  *pFirmware;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index df4bbcf..c99d584 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -60,6 +60,99 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
 
 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
+
+const u32 dm_tx_bb_gain[TxBBGainTableLength] = {
+   0x7f8001fe, /* 12 dB */
+   0x788001e2, /* 11 dB */
+   0x71c001c7,
+   0x6b8001ae,
+   0x65400195,
+   0x5fc0017f,
+   0x5a400169,
+   0x55400155,
+   0x50800142,
+   0x4c000130,
+   0x47c0011f,
+   0x43c0010f,
+   0x4100,
+   0x3c8000f2,
+   0x39e4,
+   0x35c000d7,
+   0x32c000cb,
+   0x30c0,
+   0x2d4000b5,
+   0x2ac000ab,
+   0x288000a2,
+   0x2698,
+   0x2490,
+   0x2288,
+   0x2080,
+   0x1a6c,
+   0x1c800072,
+   0x1860,
+   0x19800066,
+   0x15800056,
+   0x26c0005b,
+   0x14400051,
+   0x24400051,
+   0x134c,
+   0x1248,
+   0x1144,
+   0x1040, /* -24 dB */
+};
+
+const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8] = {
+   {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
+   {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
+   {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
+   {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
+   {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
+   {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
+   {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
+   {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
+   {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06,

[PATCH 3/8] staging: rtl8192e: remove r819xE_phyreg.h

2015-04-07 Thread Mateusz Kulikowski
This file is not used and its contents are duplicated in r8192E_phyreg.h.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h | 908 --
 1 file changed, 908 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h

diff --git a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h 
b/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
deleted file mode 100644
index 03eee3d..000
--- a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
+++ /dev/null
@@ -1,908 +0,0 @@
-#ifndef _R819XU_PHYREG_H
-#define _R819XU_PHYREG_H
-
-
-#define   RF_DATA  0x1d4   
// FW will write RF data in the register.
-
-//Register   //duplicate register due to connection: RF_Mode, TRxRN, NumOf 
L-STF
-//page 1
-#define rPMAC_Reset0x100
-#define rPMAC_TxStart  0x104
-#define rPMAC_TxLegacySIG  0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum  0x118
-#define rPMAC_TxIdle   0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType   0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble  0x140
-#define rPMAC_CCKPLCPHeader0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK0x170
-#define rPMAC_OFDMRxCRC32Er0x174
-#define rPMAC_OFDMRxParityEr   0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-//90P
-#defineMCS_TXAGC   0x340   // MCS AGC
-#defineCCK_TXAGC   0x348   // CCK AGC
-
-#defineMacBlkCtrl  0x403   
// Mac block on/off control register
-
-//page8
-#define rFPGA0_RFMOD   0x800  //RF mode & CCK TxSC
-#define rFPGA0_TxInfo  0x804
-#define rFPGA0_PSDFunction 0x808
-#define rFPGA0_TxGainStage 0x80c
-#define rFPGA0_RFTiming1   0x810
-#define rFPGA0_RFTiming2   0x814
-//#define rFPGA0_XC_RFTiming   0x818
-//#define rFPGA0_XD_RFTiming   0x81c
-#define rFPGA0_XA_HSSIParameter1   0x820
-#define rFPGA0_XA_HSSIParameter2   0x824
-#define rFPGA0_XB_HSSIParameter1   0x828
-#define rFPGA0_XB_HSSIParameter2   0x82c
-#define rFPGA0_XC_HSSIParameter1   0x830
-#define rFPGA0_XC_HSSIParameter2   0x834
-#define rFPGA0_XD_HSSIParameter1   0x838
-#define rFPGA0_XD_HSSIParameter2   0x83c
-#define rFPGA0_XA_LSSIParameter0x840
-#define rFPGA0_XB_LSSIParameter0x844
-#define rFPGA0_XC_LSSIParameter0x848
-#define rFPGA0_XD_LSSIParameter0x84c
-#define rFPGA0_RFWakeUpParameter   0x850
-#define rFPGA0_RFSleepUpParameter  0x854
-#define rFPGA0_XAB_SwitchControl   0x858
-#define rFPGA0_XCD_SwitchControl   0x85c
-#define rFPGA0_XA_RFInterfaceOE0x860
-#define rFPGA0_XB_RFInterfaceOE0x864
-#define rFPGA0_XC_RFInterfaceOE0x868
-#define rFPGA0_XD_RFInterfaceOE0x86c
-#define rFPGA0_XAB_RFInterfaceSW   0x870
-#define rFPGA0_XCD_RFInterfaceSW   0x874
-#define rFPGA0_XAB_RFParameter 0x878
-#define rFPGA0_XCD_RFParameter 0x87c
-#define rFPGA0_AnalogParameter10x880
-#define rFPGA0_AnalogParameter20x884
-#define rFPGA0_AnalogParameter30x888
-#define rFPGA0_AnalogParameter40x88c
-#define rFPGA0_XA_LSSIReadBack 0x8a0
-#define rFPGA0_XB_LSSIReadBack 0x8a4
-#define rFPGA0_XC_LSSIReadBack 0x8a8
-#define rFPGA0_XD_LSSIReadBack 0x8ac
-#define rFPGA0_PSDReport   0x8b4
-#define rFPGA0_XAB_RFInterfaceRB   0x8e0
-#define rFPGA0_XCD_RFInterfaceRB   0x8e4
-
-/* Page 9 - RF mode & OFDM TxSC */
-#define rFPGA1_RFMOD   0x900
-#define rFPGA1_TxBlock 0x904
-#define rFPGA1_DebugSelect 0x908
-#define rFPGA1_TxInfo  0x90c
-
-/* Page a */
-#define rCCK0_System   0xa00
-#define rCCK0_AFESetting   0xa04
-#define rCCK0_CCA  0xa08
-/* AGC defau

[PATCH 7/8] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtllib_parse_info_param()

2015-04-07 Thread Mateusz Kulikowski
- Replace ?: with min_t
- Remove condition that is always true

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 95cd17e..bb789cc 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1924,13 +1924,12 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
   info_element->data[2] == 0x4c &&
   info_element->data[3] == 0x033) {
 
-   tmp_htcap_len = min_t(u8, 
info_element->len, MAX_IE_LEN);
-   if (tmp_htcap_len != 0) {
-   
network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-   
network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
-   
sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len;
-   
memcpy(network->bssht.bdHTCapBuf, info_element->data, 
network->bssht.bdHTCapLen);
-   }
+   tmp_htcap_len = min_t(u8, 
info_element->len, MAX_IE_LEN);
+   if (tmp_htcap_len != 0) {
+   network->bssht.bdHTSpecVer = 
HT_SPEC_VER_EWC;
+   network->bssht.bdHTCapLen = 
min_t(u16, tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
+   
memcpy(network->bssht.bdHTCapBuf, info_element->data, 
network->bssht.bdHTCapLen);
+   }
}
if (tmp_htcap_len != 0) {
network->bssht.bdSupportHT = true;
@@ -1951,12 +1950,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
tmp_htinfo_len = min_t(u8, 
info_element->len, MAX_IE_LEN);
if (tmp_htinfo_len != 0) {
network->bssht.bdHTSpecVer = 
HT_SPEC_VER_EWC;
-   if (tmp_htinfo_len) {
-   
network->bssht.bdHTInfoLen = tmp_htinfo_len > 
sizeof(network->bssht.bdHTInfoBuf) ?
-   
sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len;
-   
memcpy(network->bssht.bdHTInfoBuf, info_element->data, 
network->bssht.bdHTInfoLen);
-   }
-
+   network->bssht.bdHTInfoLen = 
min_t(u16, tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
+   
memcpy(network->bssht.bdHTInfoBuf, info_element->data, 
network->bssht.bdHTInfoLen);
}
 
}
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/8] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtl_dm.c

2015-04-07 Thread Mateusz Kulikowski
Separate parts of dm_TXPowerTrackingCallback_TSSI() into two new functions:
- dm_tx_update_tssi_weak_signal()
- dm_tx_update_tssi_strong_signal()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 176 +++--
 1 file changed, 93 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index 9de5846..66baed80 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -542,6 +542,97 @@ static u8  CCKSwingTable_Ch14[CCK_Table_length][8] = {
 #defineTssi_Report_Value2  0x13e
 #defineFW_Busy_Flag0x13f
 
+static void dm_tx_update_tssi_weak_signal(struct net_device *dev, u8 RF_Type)
+{
+   struct r8192_priv *p = rtllib_priv(dev);
+
+   if (RF_Type == RF_2T4R) {
+   if ((p->rfa_txpowertrackingindex > 0) &&
+   (p->rfc_txpowertrackingindex > 0)) {
+   p->rfa_txpowertrackingindex--;
+   if (p->rfa_txpowertrackingindex_real > 4) {
+   p->rfa_txpowertrackingindex_real--;
+   rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+   }
+
+   p->rfc_txpowertrackingindex--;
+   if (p->rfc_txpowertrackingindex_real > 4) {
+   p->rfc_txpowertrackingindex_real--;
+   rtl8192_setBBreg(dev,
+rOFDM0_XCTxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+   }
+   } else {
+   rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+bMaskDWord,
+dm_tx_bb_gain[4]);
+   rtl8192_setBBreg(dev,
+rOFDM0_XCTxIQImbalance,
+bMaskDWord, dm_tx_bb_gain[4]);
+   }
+   } else {
+   if (p->rfa_txpowertrackingindex > 0) {
+   p->rfa_txpowertrackingindex--;
+   if (p->rfa_txpowertrackingindex_real > 4) {
+   p->rfa_txpowertrackingindex_real--;
+   rtl8192_setBBreg(dev,
+rOFDM0_XATxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+   }
+   } else {
+   rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+bMaskDWord, dm_tx_bb_gain[4]);
+   }
+   }
+}
+
+static void dm_tx_update_tssi_strong_signal(struct net_device *dev, u8 RF_Type)
+{
+   struct r8192_priv *p = rtllib_priv(dev);
+
+   if (RF_Type == RF_2T4R) {
+   if ((p->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&
+   (p->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) {
+   p->rfa_txpowertrackingindex++;
+   p->rfa_txpowertrackingindex_real++;
+   rtl8192_setBBreg(dev,
+rOFDM0_XATxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+   p->rfc_txpowertrackingindex++;
+   p->rfc_txpowertrackingindex_real++;
+   rtl8192_setBBreg(dev,
+rOFDM0_XCTxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+   } else {
+   rtl8192_setBBreg(dev,
+rOFDM0_XATxIQImbalance,
+bMaskDWord,
+dm_tx_bb_gain[TxBBGainTableLength - 1]);
+   rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance,
+bMaskDWord,
+dm_tx_bb_gain[TxBBGainTableLength - 
1]);
+   }
+   } else {
+   if (p->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
+   p->rfa_txpowertrackingindex++;
+ 

[PATCH 4/8] staging: rtl8192e: Fix SPACING errors

2015-04-07 Thread Mateusz Kulikowski
Fix several SPACING errors to make checkpatch happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 6 +++---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   | 6 +++---
 drivers/staging/rtl8192e/rtllib_debug.h| 3 +--
 drivers/staging/rtl8192e/rtllib_rx.c   | 2 +-
 5 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 4664a4f..eea2e39 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -1002,7 +1002,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev)
RT_TRACE(COMP_TRACE, "=>--%s(), set chan:%d, priv:%p\n", __func__,
 priv->chan, priv);
 
-   rtl8192_phy_FinishSwChnlNow(dev , priv->chan);
+   rtl8192_phy_FinishSwChnlNow(dev, priv->chan);
 
RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n");
 }
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 352d381..3ce7676 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1533,7 +1533,7 @@ RESET_START:
SEM_UP_IEEE_WX(&ieee->wx_sem);
} else {
netdev_info(dev, "ieee->state is NOT LINKED\n");
-   rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
+   rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
}
 
dm_backup_dynamic_mechanism_state(dev);
@@ -2102,7 +2102,7 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device 
*dev)
entry->OWN = 1;
}
 
-   if(entry)
+   if (entry)
entry->EOR = 1;
}
return 0;
@@ -2519,7 +2519,7 @@ void rtl8192_commit(struct net_device *dev)
 
if (priv->up == 0)
return;
-   rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
+   rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
rtl8192_irq_disable(dev);
priv->ops->stop_adapter(dev, true);
_rtl8192_up(dev, false);
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index d365af6..a6279e7 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -84,7 +84,7 @@
 
 #define RTL_PCI_DEVICE(vend, dev, cfg) \
.vendor = (vend), .device = (dev), \
-   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
.driver_data = (kernel_ulong_t)&(cfg)
 
 #define RTL_MAX_SCAN_SIZE 128
@@ -303,9 +303,9 @@ enum pci_bridge_vendor {
PCI_BRIDGE_VENDOR_INTEL = 0x0,
PCI_BRIDGE_VENDOR_ATI,
PCI_BRIDGE_VENDOR_AMD,
-   PCI_BRIDGE_VENDOR_SIS ,
+   PCI_BRIDGE_VENDOR_SIS,
PCI_BRIDGE_VENDOR_UNKNOWN,
-   PCI_BRIDGE_VENDOR_MAX ,
+   PCI_BRIDGE_VENDOR_MAX,
 };
 
 struct buffer {
diff --git a/drivers/staging/rtl8192e/rtllib_debug.h 
b/drivers/staging/rtl8192e/rtllib_debug.h
index 119729d..6df8df1 100644
--- a/drivers/staging/rtl8192e/rtllib_debug.h
+++ b/drivers/staging/rtl8192e/rtllib_debug.h
@@ -73,8 +73,7 @@ enum RTL_DEBUG {
 #define RT_TRACE(component, x, args...)\
 do {   \
if (rt_global_debug_component & component) \
-   printk(KERN_DEBUG DRV_NAME ":" x "\n" , \
-  ##args);\
+   printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\
 } while (0)
 
 #define assert(expr) \
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index fe3e7e12..95cd17e 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -469,7 +469,7 @@ static bool AddReorderEntry(struct rx_ts_record *pTS,
 void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb 
**prxbIndicateArray, u8 index)
 {
struct net_device_stats *stats = &ieee->stats;
-   u8 i = 0 , j = 0;
+   u8 i = 0, j = 0;
u16 ethertype;
 
for (j = 0; j < index; j++) {
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/21] staging: rtl8192e: Fix more checkpatch.pl warnings

2015-04-13 Thread Mateusz Kulikowski
New cleanup patchset for rtl8192e. It fixes (mostly) checkpatch.pl warnings.
When applied, checkpatch.pl warning count drops to 34 (from ).
It should apply cleanly to staging-next/testing (c610f7f7) branches.

Series was smoke tested on rtl8192e card vs staging-next:
- Module load/unload
- Interface up/down

Most of changes are related to checkpatch.pl with the exception of
- bugfix - staging: rtl8192e: Fix DeviceID in rtl8192_pci_findadapter()
  This is clearly (in my opinion) typo - I checked two rtl8192e cards from 
  different vendors and both had DeviceID == 0x8192.
- Removal of unimplemented/unused iwpriv handlers - they just give false sense 
  of hope to iwpriv user

Additional changes in v2:
- Fix (most) LONG_LINE warnings
- Replace memcpy() with custom macro - later __aligned(2) will be added to 
  structures (where possible) - I prefer not to do this change before I have 
  working hardware. Unfortunantely these cards are grumpy and refuse to enable 
  radio in PC mPCIe slot (even after soldering W_DISABLE override and using two 
  different antenna sets)
- Fix (most) remaining PREFER_PR_LEVEL warnings

Notes from v1:
This series of patches fixes another set of checkpatch.pl warnings.

Most of the patches are trivial, with the exception of #8, #7 and #5;
Driver logic should not be affected. 
Some of the patches cause LONG_LINE warnings, but fix has to wait until
I do more driver refactorings (It's hard to keep line length when variable 
names have 30 characters).

Mateusz Kulikowski (21):
  staging: rtl8192e: Fix SPACE_BEFORE_TAB warnings
  staging: rtl8192e: Copy comments from r819XE_phyreg.h to r8192E_phyreg.h
  staging: rtl8192e: remove r819xE_phyreg.h
  staging: rtl8192e: Fix SPACING errors
  staging: rtl8192e: Remove bb tx gains from r8192_priv
  staging: rtl8192e: Fix LINE_SPACING warning
  staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtllib_parse_info_param()
  staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtl_dm.c
  staging: rtl8192e: Fix DeviceID in rtl8192_pci_findadapter()
  staging: rtl8192e: replace memcpy() -> ether_addr_copy_unaligned()
  staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param()
  staging: rtl8192e: replace memcmp() with ether_addr_equal_unaligned()
  staging: rtl8192e: Fix PREFER_PR_LEVEL warnings
  staging: rtl8192e: Fix LONG_LINE warnings
  staging: rtl8192e: Fix LONG_LINE warnings - modify variables
  staging: rtl8192e: Fix LONG_LING in rtllib_parse_info_param()
  staging: rtl8192e: Fix LONG_LINE warnings (conditions)
  staging: rtl8192e: fix LONG_LINE warnings - replace ?: expressions
  staging: rtl8192e: Fix LONG_LINE in rtllib_parse_mife_generic()
  staging: rtl8192e: Fix LONG_LINE in simplify rtl8192_process_phyinfo()
  staging: rtl8192e: Remove unimplemented iwpriv handlers

 drivers/staging/rtl8192e/dot11d.h  |4 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  144 +-
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|   42 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c |   51 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h  | 1496 ++-
 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h  |  908 
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c|   53 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |   10 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   |   21 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 1546 
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.h |9 +
 drivers/staging/rtl8192e/rtl8192e/rtl_pci.c|2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |   89 +-
 drivers/staging/rtl8192e/rtl819x_BAProc.c  |   12 +-
 drivers/staging/rtl8192e/rtl819x_HTProc.c  |3 +-
 drivers/staging/rtl8192e/rtl819x_TSProc.c  |   21 +-
 drivers/staging/rtl8192e/rtllib.h  |8 +-
 drivers/staging/rtl8192e/rtllib_crypt.c|   17 +-
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   |   77 +-
 drivers/staging/rtl8192e/rtllib_debug.h|3 +-
 drivers/staging/rtl8192e/rtllib_rx.c   |  797 +-
 drivers/staging/rtl8192e/rtllib_softmac.c  |  360 ++---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c   |5 +-
 drivers/staging/rtl8192e/rtllib_tx.c   |   87 +-
 drivers/staging/rtl8192e/rtllib_wx.c   |4 +-
 25 files changed, 2289 insertions(+), 3480 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h

-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 02/21] staging: rtl8192e: Copy comments from r819XE_phyreg.h to r8192E_phyreg.h

2015-04-13 Thread Mateusz Kulikowski
Both files have the same contents (with the exception of comments).
One of them will not survive future commits.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 92 ---
 1 file changed, 65 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
index d080876..8a1d91e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
@@ -53,10 +53,10 @@
 #define MCS_TXAGC  0x340
 #define CCK_TXAGC  0x348
 
-/*-0x400~0x4ff--*/
+/* Mac block on/off control register */
 #define MacBlkCtrl 0x403
 
-#define rFPGA0_RFMOD   0x800
+#define rFPGA0_RFMOD   0x800 /* RF mode & CCK TxSC */
 #define rFPGA0_TxInfo  0x804
 #define rFPGA0_PSDFunction 0x808
 #define rFPGA0_TxGainStage 0x80c
@@ -98,6 +98,7 @@
 #define rFPGA0_XAB_RFInterfaceRB   0x8e0
 #define rFPGA0_XCD_RFInterfaceRB   0x8e4
 
+/* Page 9 - RF mode & OFDM TxSC */
 #define rFPGA1_RFMOD   0x900
 #define rFPGA1_TxBlock 0x904
 #define rFPGA1_DebugSelect 0x908
@@ -106,14 +107,16 @@
 #define rCCK0_System   0xa00
 #define rCCK0_AFESetting   0xa04
 #define rCCK0_CCA  0xa08
+/* AGC default value, saturation level */
 #define rCCK0_RxAGC1   0xa0c
-#define rCCK0_RxAGC2   0xa10
+#define rCCK0_RxAGC2   0xa10 /* AGC & DAGC */
 #define rCCK0_RxHP 0xa14
+/* Timing recovery & channel estimation threshold */
 #define rCCK0_DSPParameter10xa18
-#define rCCK0_DSPParameter20xa1c
+#define rCCK0_DSPParameter20xa1c /* SQ threshold */
 #define rCCK0_TxFilter10xa20
 #define rCCK0_TxFilter20xa24
-#define rCCK0_DebugPort0xa28
+#define rCCK0_DebugPort0xa28 /* Debug port and TX 
filter 3 */
 #define rCCK0_FalseAlarmReport 0xa2c
 #define rCCK0_TRSSIReport  0xa50
 #define rCCK0_RxReport 0xa54
@@ -124,22 +127,24 @@
 #define rOFDM0_TRxPathEnable   0xc04
 #define rOFDM0_TRMuxPar0xc08
 #define rOFDM0_TRSWIsolation   0xc0c
+/* RxIQ DC offset, Rx digital filter, DC notch filter */
 #define rOFDM0_XARxAFE 0xc10
-#define rOFDM0_XARxIQImbalance 0xc14
+#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */
 #define rOFDM0_XBRxAFE 0xc18
 #define rOFDM0_XBRxIQImbalance 0xc1c
 #define rOFDM0_XCRxAFE 0xc20
 #define rOFDM0_XCRxIQImbalance 0xc24
 #define rOFDM0_XDRxAFE 0xc28
 #define rOFDM0_XDRxIQImbalance 0xc2c
-#define rOFDM0_RxDetector1 0xc30
-#define rOFDM0_RxDetector2 0xc34
-#define rOFDM0_RxDetector3 0xc38
+#define rOFDM0_RxDetector1 0xc30 /* PD, BW & SBD */
+#define rOFDM0_RxDetector2 0xc34 /* SBD */
+#define rOFDM0_RxDetector3 0xc38 /* Frame Sync */
+/* PD, SBD, Frame Sync & Short-GI */
 #define rOFDM0_RxDetector4 0xc3c
-#define rOFDM0_RxDSP   0xc40
-#define rOFDM0_CFOandDAGC  0xc44
+#define rOFDM0_RxDSP   0xc40 /* Rx Sync Path */
+#define rOFDM0_CFOandDAGC  0xc44 /* CFO & DAGC */
 #define rOFDM0_CCADropThreshold0xc48
-#define rOFDM0_ECCAThreshold   0xc4c
+#define rOFDM0_ECCAThreshold   0xc4c /* Energy CCA */
 #define rOFDM0_XAAGCCore1  0xc50
 #define rOFDM0_XAAGCCore2  0xc54
 #define rOFDM0_XBAGCCore1  0xc58
@@ -184,9 +189,9 @@
 #define rOFDM1_PseudoNoiseStateAB  0xd50
 #define rOFDM1_PseudoNoiseStateCD  0xd54
 #define rOFDM1_RxPseudoNoiseWgt0xd58
-#define rOFDM_PHYCounter1  0xda0
-#define rOFDM_PHYCounter2  0xda4
-#define rOFDM_PHYCounter3  0xda8
+#define rOFDM_PHYCounter1  0xda0 /* cca, parity fail */
+#define rOFDM_PHYCounter2  0xda4 /* rate illegal, crc8 fail */
+#define rOFDM_PHYCounter3  0xda8 /* MCS not supported */
 #define rOFDM_ShortCFOAB   0xdac
 #define rOFDM_ShortCFOCD   0xdb0
 #define rOFDM_LongCFOAB0xdb4
@@ -221,14 +226,17 @@
 #define rZebra1_RxLPF  0xb
 #define rZebra1_RxHPFCorner0xc
 
+/* Zebra 4 */
 #define rGlobalCtrl0
 #define rRTL8256_TxLPF 19
 #define rRTL8256_RxLPF 11
 
+/* RTL8258 */
 #define rRTL8258_TxLPF 0x11
 #define rRTL8258_RxLPF 0x

[PATCH v2 06/21] staging: rtl8192e: Fix LINE_SPACING warning

2015-04-13 Thread Mateusz Kulikowski
Trivial fix - add newline in dm_InitializeTXPowerTracking_TSSI()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index c99d584..9de5846 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -941,6 +941,7 @@ static void dm_InitializeTXPowerTracking_TSSI(struct 
net_device *dev)
 {
 
struct r8192_priv *priv = rtllib_priv(dev);
+
priv->btxpower_tracking = true;
priv->txpower_count   = 0;
priv->btxpower_trackingInit = false;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 01/21] staging: rtl8192e: Fix SPACE_BEFORE_TAB warnings

2015-04-13 Thread Mateusz Kulikowski
Reformat r8192E_phyreg.h to make checkpatch happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 1442 ++---
 1 file changed, 721 insertions(+), 721 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
index 7899dd5..d080876 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
@@ -3,7 +3,7 @@
  *
  * This program is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
@@ -20,48 +20,48 @@
 #define _R819XU_PHYREG_H
 
 
-#define   RF_DATA  0x1d4
-
-#define rPMAC_Reset0x100
-#define rPMAC_TxStart  0x104
-#define rPMAC_TxLegacySIG  0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum  0x118
-#define rPMAC_TxIdle   0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType   0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble  0x140
-#define rPMAC_CCKPLCPHeader0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK0x170
-#define rPMAC_OFDMRxCRC32Er0x174
-#define rPMAC_OFDMRxParityEr   0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-#defineMCS_TXAGC   0x340
-#defineCCK_TXAGC   0x348
+#define RF_DATA0x1d4
+
+#define rPMAC_Reset0x100
+#define rPMAC_TxStart  0x104
+#define rPMAC_TxLegacySIG  0x108
+#define rPMAC_TxHTSIG1 0x10c
+#define rPMAC_TxHTSIG2 0x110
+#define rPMAC_PHYDebug 0x114
+#define rPMAC_TxPacketNum  0x118
+#define rPMAC_TxIdle   0x11c
+#define rPMAC_TxMACHeader0 0x120
+#define rPMAC_TxMACHeader1 0x124
+#define rPMAC_TxMACHeader2 0x128
+#define rPMAC_TxMACHeader3 0x12c
+#define rPMAC_TxMACHeader4 0x130
+#define rPMAC_TxMACHeader5 0x134
+#define rPMAC_TxDataType   0x138
+#define rPMAC_TxRandomSeed 0x13c
+#define rPMAC_CCKPLCPPreamble  0x140
+#define rPMAC_CCKPLCPHeader0x144
+#define rPMAC_CCKCRC16 0x148
+#define rPMAC_OFDMRxCRC32OK0x170
+#define rPMAC_OFDMRxCRC32Er0x174
+#define rPMAC_OFDMRxParityEr   0x178
+#define rPMAC_OFDMRxCRC8Er 0x17c
+#define rPMAC_CCKCRxRC16Er 0x180
+#define rPMAC_CCKCRxRC32Er 0x184
+#define rPMAC_CCKCRxRC32OK 0x188
+#define rPMAC_TxStatus 0x18c
+
+#define MCS_TXAGC  0x340
+#define CCK_TXAGC  0x348
 
 /*-0x400~0x4ff--*/
-#defineMacBlkCtrl  0x403
-
-#define rFPGA0_RFMOD   0x800
-#define rFPGA0_TxInfo  0x804
-#define rFPGA0_PSDFunction 0x808
-#define rFPGA0_TxGainStage 0x80c
-#define rFPGA0_RFTiming1   0x810
-#define rFPGA0_RFTiming2   0x814
+#define MacBlkCtrl 0x403
+
+#define rFPGA0_RFMOD   0x800
+#define rFPGA0_TxInfo  0x804
+#define rFPGA0_PSDFunction 0x808
+#define rFPGA0_TxGainStage 0x80c
+#define rFPGA0_RFTiming1   0x810
+#define rFPGA0_RFTiming2   0x814
 #define rFPGA0_XA_HSSIParameter1   0x820
 #define rFPGA0_XA_HSSIParameter2   0x824
 #define rFPGA0_XB_HSSIParameter1   0x828
@@ -94,49 +94,49 @@
 #define rFPGA0_XB_LSSIReadBack 0x8a4
 #define rFPGA0_XC_LSSIReadBack 0x8a8
 #define rFPGA0_XD_LSSIReadBack 0x8ac
-#define rFPGA0_PSDReport   0x8b4
+#define rFPGA0_PSDReport   0x8b4
 #define rFPGA0_XAB_RFInterfaceRB   0x8e0
 #define rFPGA0_XCD_RFInterfaceRB   0x8e4
 
-#define rFPGA1_RFMOD   0x900

[PATCH v2 04/21] staging: rtl8192e: Fix SPACING errors

2015-04-13 Thread Mateusz Kulikowski
Fix several SPACING errors to make checkpatch happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 6 +++---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   | 6 +++---
 drivers/staging/rtl8192e/rtllib_debug.h| 3 +--
 drivers/staging/rtl8192e/rtllib_rx.c   | 2 +-
 5 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 4664a4f..eea2e39 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -1002,7 +1002,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev)
RT_TRACE(COMP_TRACE, "=>--%s(), set chan:%d, priv:%p\n", __func__,
 priv->chan, priv);
 
-   rtl8192_phy_FinishSwChnlNow(dev , priv->chan);
+   rtl8192_phy_FinishSwChnlNow(dev, priv->chan);
 
RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n");
 }
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 352d381..3ce7676 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1533,7 +1533,7 @@ RESET_START:
SEM_UP_IEEE_WX(&ieee->wx_sem);
} else {
netdev_info(dev, "ieee->state is NOT LINKED\n");
-   rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
+   rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
}
 
dm_backup_dynamic_mechanism_state(dev);
@@ -2102,7 +2102,7 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device 
*dev)
entry->OWN = 1;
}
 
-   if(entry)
+   if (entry)
entry->EOR = 1;
}
return 0;
@@ -2519,7 +2519,7 @@ void rtl8192_commit(struct net_device *dev)
 
if (priv->up == 0)
return;
-   rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
+   rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
rtl8192_irq_disable(dev);
priv->ops->stop_adapter(dev, true);
_rtl8192_up(dev, false);
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index d365af6..a6279e7 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -84,7 +84,7 @@
 
 #define RTL_PCI_DEVICE(vend, dev, cfg) \
.vendor = (vend), .device = (dev), \
-   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
.driver_data = (kernel_ulong_t)&(cfg)
 
 #define RTL_MAX_SCAN_SIZE 128
@@ -303,9 +303,9 @@ enum pci_bridge_vendor {
PCI_BRIDGE_VENDOR_INTEL = 0x0,
PCI_BRIDGE_VENDOR_ATI,
PCI_BRIDGE_VENDOR_AMD,
-   PCI_BRIDGE_VENDOR_SIS ,
+   PCI_BRIDGE_VENDOR_SIS,
PCI_BRIDGE_VENDOR_UNKNOWN,
-   PCI_BRIDGE_VENDOR_MAX ,
+   PCI_BRIDGE_VENDOR_MAX,
 };
 
 struct buffer {
diff --git a/drivers/staging/rtl8192e/rtllib_debug.h 
b/drivers/staging/rtl8192e/rtllib_debug.h
index 119729d..6df8df1 100644
--- a/drivers/staging/rtl8192e/rtllib_debug.h
+++ b/drivers/staging/rtl8192e/rtllib_debug.h
@@ -73,8 +73,7 @@ enum RTL_DEBUG {
 #define RT_TRACE(component, x, args...)\
 do {   \
if (rt_global_debug_component & component) \
-   printk(KERN_DEBUG DRV_NAME ":" x "\n" , \
-  ##args);\
+   printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\
 } while (0)
 
 #define assert(expr) \
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index fe3e7e12..95cd17e 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -469,7 +469,7 @@ static bool AddReorderEntry(struct rx_ts_record *pTS,
 void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb 
**prxbIndicateArray, u8 index)
 {
struct net_device_stats *stats = &ieee->stats;
-   u8 i = 0 , j = 0;
+   u8 i = 0, j = 0;
u16 ethertype;
 
for (j = 0; j < index; j++) {
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/21] staging: rtl8192e: remove r819xE_phyreg.h

2015-04-13 Thread Mateusz Kulikowski
This file is not used and its contents are duplicated in r8192E_phyreg.h.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h | 908 --
 1 file changed, 908 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h

diff --git a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h 
b/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
deleted file mode 100644
index 03eee3d..000
--- a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
+++ /dev/null
@@ -1,908 +0,0 @@
-#ifndef _R819XU_PHYREG_H
-#define _R819XU_PHYREG_H
-
-
-#define   RF_DATA  0x1d4   
// FW will write RF data in the register.
-
-//Register   //duplicate register due to connection: RF_Mode, TRxRN, NumOf 
L-STF
-//page 1
-#define rPMAC_Reset0x100
-#define rPMAC_TxStart  0x104
-#define rPMAC_TxLegacySIG  0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum  0x118
-#define rPMAC_TxIdle   0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType   0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble  0x140
-#define rPMAC_CCKPLCPHeader0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK0x170
-#define rPMAC_OFDMRxCRC32Er0x174
-#define rPMAC_OFDMRxParityEr   0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-//90P
-#defineMCS_TXAGC   0x340   // MCS AGC
-#defineCCK_TXAGC   0x348   // CCK AGC
-
-#defineMacBlkCtrl  0x403   
// Mac block on/off control register
-
-//page8
-#define rFPGA0_RFMOD   0x800  //RF mode & CCK TxSC
-#define rFPGA0_TxInfo  0x804
-#define rFPGA0_PSDFunction 0x808
-#define rFPGA0_TxGainStage 0x80c
-#define rFPGA0_RFTiming1   0x810
-#define rFPGA0_RFTiming2   0x814
-//#define rFPGA0_XC_RFTiming   0x818
-//#define rFPGA0_XD_RFTiming   0x81c
-#define rFPGA0_XA_HSSIParameter1   0x820
-#define rFPGA0_XA_HSSIParameter2   0x824
-#define rFPGA0_XB_HSSIParameter1   0x828
-#define rFPGA0_XB_HSSIParameter2   0x82c
-#define rFPGA0_XC_HSSIParameter1   0x830
-#define rFPGA0_XC_HSSIParameter2   0x834
-#define rFPGA0_XD_HSSIParameter1   0x838
-#define rFPGA0_XD_HSSIParameter2   0x83c
-#define rFPGA0_XA_LSSIParameter0x840
-#define rFPGA0_XB_LSSIParameter0x844
-#define rFPGA0_XC_LSSIParameter0x848
-#define rFPGA0_XD_LSSIParameter0x84c
-#define rFPGA0_RFWakeUpParameter   0x850
-#define rFPGA0_RFSleepUpParameter  0x854
-#define rFPGA0_XAB_SwitchControl   0x858
-#define rFPGA0_XCD_SwitchControl   0x85c
-#define rFPGA0_XA_RFInterfaceOE0x860
-#define rFPGA0_XB_RFInterfaceOE0x864
-#define rFPGA0_XC_RFInterfaceOE0x868
-#define rFPGA0_XD_RFInterfaceOE0x86c
-#define rFPGA0_XAB_RFInterfaceSW   0x870
-#define rFPGA0_XCD_RFInterfaceSW   0x874
-#define rFPGA0_XAB_RFParameter 0x878
-#define rFPGA0_XCD_RFParameter 0x87c
-#define rFPGA0_AnalogParameter10x880
-#define rFPGA0_AnalogParameter20x884
-#define rFPGA0_AnalogParameter30x888
-#define rFPGA0_AnalogParameter40x88c
-#define rFPGA0_XA_LSSIReadBack 0x8a0
-#define rFPGA0_XB_LSSIReadBack 0x8a4
-#define rFPGA0_XC_LSSIReadBack 0x8a8
-#define rFPGA0_XD_LSSIReadBack 0x8ac
-#define rFPGA0_PSDReport   0x8b4
-#define rFPGA0_XAB_RFInterfaceRB   0x8e0
-#define rFPGA0_XCD_RFInterfaceRB   0x8e4
-
-/* Page 9 - RF mode & OFDM TxSC */
-#define rFPGA1_RFMOD   0x900
-#define rFPGA1_TxBlock 0x904
-#define rFPGA1_DebugSelect 0x908
-#define rFPGA1_TxInfo  0x90c
-
-/* Page a */
-#define rCCK0_System   0xa00
-#define rCCK0_AFESetting   0xa04
-#define rCCK0_CCA  0xa08
-/* AGC defau

[PATCH v2 07/21] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtllib_parse_info_param()

2015-04-13 Thread Mateusz Kulikowski
- Replace ?: with min_t
- Remove condition that is always true

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 95cd17e..bb789cc 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1924,13 +1924,12 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
   info_element->data[2] == 0x4c &&
   info_element->data[3] == 0x033) {
 
-   tmp_htcap_len = min_t(u8, 
info_element->len, MAX_IE_LEN);
-   if (tmp_htcap_len != 0) {
-   
network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-   
network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
-   
sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len;
-   
memcpy(network->bssht.bdHTCapBuf, info_element->data, 
network->bssht.bdHTCapLen);
-   }
+   tmp_htcap_len = min_t(u8, 
info_element->len, MAX_IE_LEN);
+   if (tmp_htcap_len != 0) {
+   network->bssht.bdHTSpecVer = 
HT_SPEC_VER_EWC;
+   network->bssht.bdHTCapLen = 
min_t(u16, tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
+   
memcpy(network->bssht.bdHTCapBuf, info_element->data, 
network->bssht.bdHTCapLen);
+   }
}
if (tmp_htcap_len != 0) {
network->bssht.bdSupportHT = true;
@@ -1951,12 +1950,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
tmp_htinfo_len = min_t(u8, 
info_element->len, MAX_IE_LEN);
if (tmp_htinfo_len != 0) {
network->bssht.bdHTSpecVer = 
HT_SPEC_VER_EWC;
-   if (tmp_htinfo_len) {
-   
network->bssht.bdHTInfoLen = tmp_htinfo_len > 
sizeof(network->bssht.bdHTInfoBuf) ?
-   
sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len;
-   
memcpy(network->bssht.bdHTInfoBuf, info_element->data, 
network->bssht.bdHTInfoLen);
-   }
-
+   network->bssht.bdHTInfoLen = 
min_t(u16, tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
+   
memcpy(network->bssht.bdHTInfoBuf, info_element->data, 
network->bssht.bdHTInfoLen);
}
 
}
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/21] staging: rtl8192e: Fix DEEP_INDENTATION warnings in rtl_dm.c

2015-04-13 Thread Mateusz Kulikowski
Separate parts of dm_TXPowerTrackingCallback_TSSI() into two new functions:
- dm_tx_update_tssi_weak_signal()
- dm_tx_update_tssi_strong_signal()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 180 +++--
 1 file changed, 95 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index 9de5846..ba69157 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -542,6 +542,97 @@ static u8  CCKSwingTable_Ch14[CCK_Table_length][8] = {
 #defineTssi_Report_Value2  0x13e
 #defineFW_Busy_Flag0x13f
 
+static void dm_tx_update_tssi_weak_signal(struct net_device *dev, u8 RF_Type)
+{
+   struct r8192_priv *p = rtllib_priv(dev);
+
+   if (RF_Type == RF_2T4R) {
+   if ((p->rfa_txpowertrackingindex > 0) &&
+   (p->rfc_txpowertrackingindex > 0)) {
+   p->rfa_txpowertrackingindex--;
+   if (p->rfa_txpowertrackingindex_real > 4) {
+   p->rfa_txpowertrackingindex_real--;
+   rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+   }
+
+   p->rfc_txpowertrackingindex--;
+   if (p->rfc_txpowertrackingindex_real > 4) {
+   p->rfc_txpowertrackingindex_real--;
+   rtl8192_setBBreg(dev,
+rOFDM0_XCTxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+   }
+   } else {
+   rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+bMaskDWord,
+dm_tx_bb_gain[4]);
+   rtl8192_setBBreg(dev,
+rOFDM0_XCTxIQImbalance,
+bMaskDWord, dm_tx_bb_gain[4]);
+   }
+   } else {
+   if (p->rfa_txpowertrackingindex > 0) {
+   p->rfa_txpowertrackingindex--;
+   if (p->rfa_txpowertrackingindex_real > 4) {
+   p->rfa_txpowertrackingindex_real--;
+   rtl8192_setBBreg(dev,
+rOFDM0_XATxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+   }
+   } else {
+   rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+bMaskDWord, dm_tx_bb_gain[4]);
+   }
+   }
+}
+
+static void dm_tx_update_tssi_strong_signal(struct net_device *dev, u8 RF_Type)
+{
+   struct r8192_priv *p = rtllib_priv(dev);
+
+   if (RF_Type == RF_2T4R) {
+   if ((p->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&
+   (p->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) {
+   p->rfa_txpowertrackingindex++;
+   p->rfa_txpowertrackingindex_real++;
+   rtl8192_setBBreg(dev,
+rOFDM0_XATxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+   p->rfc_txpowertrackingindex++;
+   p->rfc_txpowertrackingindex_real++;
+   rtl8192_setBBreg(dev,
+rOFDM0_XCTxIQImbalance,
+bMaskDWord,
+
dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+   } else {
+   rtl8192_setBBreg(dev,
+rOFDM0_XATxIQImbalance,
+bMaskDWord,
+dm_tx_bb_gain[TxBBGainTableLength - 1]);
+   rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance,
+bMaskDWord,
+dm_tx_bb_gain[TxBBGainTableLength - 
1]);
+   }
+   } else {
+   if (p->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
+   p->rfa_txpowertrackingindex++;
+ 

[PATCH v2 05/21] staging: rtl8192e: Remove bb tx gains from r8192_priv

2015-04-13 Thread Mateusz Kulikowski
r8192_priv structure had 2 big arrays with tx gain register values:
- cck_txbbgain_table
- cck_txbbgain_ch14_table
- txbbgain_table

This arrays were read-only - filled in driver init code and look
like firmware/chip-specific.

This patch removes them from r8192_priv and puts them in (global) variables.

tx_bb_gain is also flattened - register values are stored in array;
Amplification value can be calculated using dm_tx_bb_gain_idx_to_amplify().

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |   5 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   |  14 -
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 674 +
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.h |   9 +
 4 files changed, 151 insertions(+), 551 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 2869602..aad5cc9 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -918,8 +918,7 @@ start:
tmpRegC = rtl8192_QueryBBReg(dev,
  rOFDM0_XCTxIQImbalance, bMaskDWord);
for (i = 0; i < TxBBGainTableLength; i++) {
-   if (tmpRegA ==
-   priv->txbbgain_table[i].txbbgain_value) {
+   if (tmpRegA == dm_tx_bb_gain[i]) {
priv->rfa_txpowertrackingindex = (u8)i;
priv->rfa_txpowertrackingindex_real =
 (u8)i;
@@ -933,7 +932,7 @@ start:
  rCCK0_TxFilter1, bMaskByte2);
 
for (i = 0; i < CCKTxBBGainTableLength; i++) {
-   if (TempCCk == 
priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) {
+   if (TempCCk == dm_cck_tx_bb_gain[i][0]) {
priv->CCKPresentAttentuation_20Mdefault 
= (u8)i;
break;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index a6279e7..0640e76 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -451,15 +451,6 @@ enum two_port_status {
TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE
 };
 
-struct txbbgain_struct {
-   longtxbb_iq_amplifygain;
-   u32 txbbgain_value;
-};
-
-struct ccktxbbgain {
-   u8  ccktxbb_valuearray[8];
-};
-
 struct init_gain {
u8  xaagccore1;
u8  xbagccore1;
@@ -567,11 +558,6 @@ struct r8192_priv {
struct bb_reg_definition PHYRegDef[4];
struct rate_adaptive rate_adaptive;
 
-   struct ccktxbbgain cck_txbbgain_table[CCKTxBBGainTableLength];
-   struct ccktxbbgain cck_txbbgain_ch14_table[CCKTxBBGainTableLength];
-
-   struct txbbgain_struct txbbgain_table[TxBBGainTableLength];
-
enum acm_method AcmMethod;
 
struct rt_firmware  *pFirmware;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index df4bbcf..c99d584 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -60,6 +60,99 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
 
 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
+
+const u32 dm_tx_bb_gain[TxBBGainTableLength] = {
+   0x7f8001fe, /* 12 dB */
+   0x788001e2, /* 11 dB */
+   0x71c001c7,
+   0x6b8001ae,
+   0x65400195,
+   0x5fc0017f,
+   0x5a400169,
+   0x55400155,
+   0x50800142,
+   0x4c000130,
+   0x47c0011f,
+   0x43c0010f,
+   0x4100,
+   0x3c8000f2,
+   0x39e4,
+   0x35c000d7,
+   0x32c000cb,
+   0x30c0,
+   0x2d4000b5,
+   0x2ac000ab,
+   0x288000a2,
+   0x2698,
+   0x2490,
+   0x2288,
+   0x2080,
+   0x1a6c,
+   0x1c800072,
+   0x1860,
+   0x19800066,
+   0x15800056,
+   0x26c0005b,
+   0x14400051,
+   0x24400051,
+   0x134c,
+   0x1248,
+   0x1144,
+   0x1040, /* -24 dB */
+};
+
+const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8] = {
+   {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
+   {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
+   {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
+   {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
+   {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
+   {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
+   {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
+   {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
+   {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06,

[PATCH v2 14/21] staging: rtl8192e: Fix LONG_LINE warnings

2015-04-13 Thread Mateusz Kulikowski
Fix most of simple LONG_LINE warnings. None of the changes should affect
behaviour of code, so several modifications are included in this patch:
- Code is reindented where needed
- Local variable names are compacted (priv -> p)
- Unnecessary casts are removed
- Nested ifs are replaced with logical and
- a = b = c = d expressions are split
- Replace if/then series with clamp_t()
- Removed unneeded scopes

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/dot11d.h  |   4 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  22 +-
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|  29 ++-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c |   4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |   3 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 191 +++---
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |   3 +-
 drivers/staging/rtl8192e/rtl819x_HTProc.c  |   3 +-
 drivers/staging/rtl8192e/rtl819x_TSProc.c  |  21 +-
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   |  12 +-
 drivers/staging/rtl8192e/rtllib_rx.c   | 222 +
 drivers/staging/rtl8192e/rtllib_softmac.c  |  39 ++--
 drivers/staging/rtl8192e/rtllib_tx.c   |  41 ++--
 drivers/staging/rtl8192e/rtllib_wx.c   |   4 +-
 14 files changed, 356 insertions(+), 242 deletions(-)

diff --git a/drivers/staging/rtl8192e/dot11d.h 
b/drivers/staging/rtl8192e/dot11d.h
index aad3394..69e0f8f 100644
--- a/drivers/staging/rtl8192e/dot11d.h
+++ b/drivers/staging/rtl8192e/dot11d.h
@@ -74,8 +74,8 @@ static inline void cpMacAddr(unsigned char *des, unsigned 
char *src)
(GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
 
 #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa)\
-
ether_addr_equal_unaligned(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, \
-   __pTa)
+ether_addr_equal_unaligned( \
+   GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
 #define UPDATE_CIE_SRC(__pIeeeDev, __pTa)  \
cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index aad5cc9..6802294 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -30,7 +30,8 @@
 #include "rtl_dm.h"
 #include "rtl_wx.h"
 
-static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, 
EDCAPARA_VO};
+static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI,
+EDCAPARA_VO};
 
 void rtl8192e_start_beacon(struct net_device *dev)
 {
@@ -187,22 +188,21 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 
variable, u8 *val)
u8  u1bAIFS;
u32 u4bAcParam;
u8 mode = priv->rtllib->mode;
-   struct rtllib_qos_parameters *qos_parameters =
+   struct rtllib_qos_parameters *qop =
 &priv->rtllib->current_network.qos_data.parameters;
 
-   u1bAIFS = qos_parameters->aifs[pAcParam] *
+   u1bAIFS = qop->aifs[pAcParam] *
  ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime;
 
dm_init_edca_turbo(dev);
 
-   u4bAcParam = (((le16_to_cpu(
-   qos_parameters->tx_op_limit[pAcParam])) 
<<
-AC_PARAM_TXOP_LIMIT_OFFSET) |
-((le16_to_cpu(qos_parameters->cw_max[pAcParam])) <<
-AC_PARAM_ECW_MAX_OFFSET) |
-((le16_to_cpu(qos_parameters->cw_min[pAcParam])) <<
-AC_PARAM_ECW_MIN_OFFSET) |
-(((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
+   u4bAcParam = (le16_to_cpu(qop->tx_op_limit[pAcParam]) <<
+ AC_PARAM_TXOP_LIMIT_OFFSET) |
+   ((le16_to_cpu(qop->cw_max[pAcParam])) <<
+AC_PARAM_ECW_MAX_OFFSET) |
+   ((le16_to_cpu(qop->cw_min[pAcParam])) <<
+AC_PARAM_ECW_MIN_OFFSET) |
+   (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET);
 
RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n",
 __func__, eACI, u4bAcParam);
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index c465f87..02c5b0a 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -230,7 +230,7 @@ bool init_firmware(struct net_device *dev)
 
u32 file_length = 0;
   

[PATCH v2 10/21] staging: rtl8192e: replace memcpy() -> ether_addr_copy_unaligned()

2015-04-13 Thread Mateusz Kulikowski
rtl8192e driver uses memcpy() to copy hw addresses in several places.
checkpatch.pl suggests to use ether_addr_copy(), but most of
addresses in driver may be unaligned.
This patch replaces all memcpy occurences with single macro therby
silencing checkpatch.pl (single complaints in macro remains).

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c| 12 ++---
 drivers/staging/rtl8192e/rtllib.h|  3 ++
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 18 +++
 drivers/staging/rtl8192e/rtllib_rx.c | 74 +---
 drivers/staging/rtl8192e/rtllib_softmac.c| 67 +
 drivers/staging/rtl8192e/rtllib_softmac_wx.c |  5 +-
 drivers/staging/rtl8192e/rtllib_tx.c | 24 -
 7 files changed, 113 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 26258ea..5b2141f 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -103,10 +103,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
BAReq = (struct rtllib_hdr_3addr *)skb_put(skb,
 sizeof(struct rtllib_hdr_3addr));
 
-   memcpy(BAReq->addr1, Dst, ETH_ALEN);
-   memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
+   ether_addr_copy_unaligned(BAReq->addr1, Dst);
+   ether_addr_copy_unaligned(BAReq->addr2, ieee->dev->dev_addr);
 
-   memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
+   ether_addr_copy_unaligned(BAReq->addr3, ieee->current_network.bssid);
BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
tag = (u8 *)skb_put(skb, 9);
@@ -167,9 +167,9 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
Delba = (struct rtllib_hdr_3addr *) skb_put(skb,
 sizeof(struct rtllib_hdr_3addr));
 
-   memcpy(Delba->addr1, dst, ETH_ALEN);
-   memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
-   memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
+   ether_addr_copy_unaligned(Delba->addr1, dst);
+   ether_addr_copy_unaligned(Delba->addr2, ieee->dev->dev_addr);
+   ether_addr_copy_unaligned(Delba->addr3, ieee->current_network.bssid);
Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
tag = (u8 *)skb_put(skb, 6);
diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 3c8b708..472e880 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -2972,4 +2972,7 @@ extern void rtllib_TURBO_Info(struct rtllib_device *ieee, 
u8 **tag_p);
 #define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
 #endif
 
+/* TODO: replace with aligned calls where possible */
+#define ether_addr_copy_unaligned(dst, src) memcpy(dst, src, ETH_ALEN)
+
 #endif /* RTLLIB_H */
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c 
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 656b4b3..c3eed40 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -532,20 +532,20 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
switch (le16_to_cpu(hdr11->frame_ctl) &
(RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_TODS:
-   memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+   ether_addr_copy_unaligned(hdr, hdr11->addr3); /* DA */
+   ether_addr_copy_unaligned(hdr + ETH_ALEN, hdr11->addr2); /* SA 
*/
break;
case RTLLIB_FCTL_FROMDS:
-   memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+   ether_addr_copy_unaligned(hdr, hdr11->addr1); /* DA */
+   ether_addr_copy_unaligned(hdr + ETH_ALEN, hdr11->addr3); /* SA 
*/
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
-   memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+   ether_addr_copy_unaligned(hdr, hdr11->addr3); /* DA */
+   ether_addr_copy_unaligned(hdr + ETH_ALEN, hdr11->addr4); /* SA 
*/
break;
case 0:
-   memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+   ether_addr_copy_unaligned(hdr, hdr11->addr1); /* DA */
+   ether_addr_copy_unaligned(hdr + ETH_ALEN, hdr11->addr2); /* SA 
*/
break;
}
 
@@ -598,7 +598,7 @@ static void rtllib_michael_mic_failure(struct net_device 
*dev,
else
   

[PATCH v2 11/21] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param()

2015-04-13 Thread Mateusz Kulikowski
Move MFIE_TYPE_GENERIC handler to rtllib_parse_mife_generic() function.
Code was not altered significantly, therefore in some places it generates
LONG_LINE checkpatch.pl warnings.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 365 +--
 1 file changed, 178 insertions(+), 187 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 67f45af..0030f33 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1747,6 +1747,181 @@ static inline void rtllib_extract_country_ie(
 
 }
 
+static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
+ struct rtllib_info_element *info_element,
+ struct rtllib_network *network,
+ u16 *tmp_htcap_len,
+ u16 *tmp_htinfo_len)
+{
+   u16 ht_realtek_agg_len = 0;
+   u8  ht_realtek_agg_buf[MAX_IE_LEN];
+
+   if (!rtllib_parse_qos_info_param_IE(info_element, network))
+   return;
+
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 && info_element->data[1] == 0x50 &&
+   info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) {
+   network->wpa_ie_len = min(info_element->len + 2,
+ MAX_WPA_IE_LEN);
+   memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+   return;
+   }
+
+   if (info_element->len == 7 && info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0xe0 && info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x01 && info_element->data[4] == 0x02)
+   network->Turbo_Enable = 1;
+
+   if (*tmp_htcap_len == 0) {
+   if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0x90 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x033) {
+   *tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
+   if (*tmp_htcap_len != 0) {
+   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+   network->bssht.bdHTCapLen = min_t(u16, 
*tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
+   memcpy(network->bssht.bdHTCapBuf,
+  info_element->data,
+  network->bssht.bdHTCapLen);
+   }
+   }
+   if (*tmp_htcap_len != 0) {
+   network->bssht.bdSupportHT = true;
+   network->bssht.bdHT1R = struct ht_capab_ele 
*)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+   } else {
+   network->bssht.bdSupportHT = false;
+   network->bssht.bdHT1R = false;
+   }
+   }
+
+
+   if (*tmp_htinfo_len == 0) {
+   if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0x90 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x034) {
+   *tmp_htinfo_len = min_t(u8, info_element->len,
+   MAX_IE_LEN);
+   if (*tmp_htinfo_len != 0) {
+   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+   network->bssht.bdHTInfoLen = min_t(u16, 
*tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
+   memcpy(network->bssht.bdHTInfoBuf,
+  info_element->data,
+  network->bssht.bdHTInfoLen);
+   }
+
+   }
+   }
+
+   if (ieee->aggregation) {
+   if (network->bssht.bdSupportHT) {
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0xe0 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x02) {
+   ht_realtek_agg_len = min_t(u8,
+  info_element->len,
+  MAX_IE_LEN);
+   memcpy(ht_realtek_agg

[PATCH v2 19/21] staging: rtl8192e: Fix LONG_LINE in rtllib_parse_mife_generic()

2015-04-13 Thread Mateusz Kulikowski
Simplify function to make checkpatch.pl happy. Changes:
- Helper variables used
- Local variable names compacted
- Conditions were rephrased to return quickly (and decrease indent).

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 170 +--
 1 file changed, 85 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 0bf0163..2e4fd33 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1806,141 +1806,141 @@ static inline void rtllib_extract_country_ie(
 }
 
 static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
- struct rtllib_info_element *info_element,
+ struct rtllib_info_element *info,
  struct rtllib_network *network,
  u16 *tmp_htcap_len,
  u16 *tmp_htinfo_len)
 {
u16 ht_realtek_agg_len = 0;
u8  ht_realtek_agg_buf[MAX_IE_LEN];
+   struct bss_ht *bssht = &network->bssht;
 
-   if (!rtllib_parse_qos_info_param_IE(info_element, network))
+   if (!rtllib_parse_qos_info_param_IE(info, network))
return;
 
-   if (info_element->len >= 4 &&
-   info_element->data[0] == 0x00 && info_element->data[1] == 0x50 &&
-   info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) {
-   network->wpa_ie_len = min(info_element->len + 2,
- MAX_WPA_IE_LEN);
-   memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+   if (info->len >= 4 &&
+   info->data[0] == 0x00 && info->data[1] == 0x50 &&
+   info->data[2] == 0xf2 && info->data[3] == 0x01) {
+   network->wpa_ie_len = min(info->len + 2, MAX_WPA_IE_LEN);
+   memcpy(network->wpa_ie, info, network->wpa_ie_len);
return;
}
 
-   if (info_element->len == 7 && info_element->data[0] == 0x00 &&
-   info_element->data[1] == 0xe0 && info_element->data[2] == 0x4c &&
-   info_element->data[3] == 0x01 && info_element->data[4] == 0x02)
+   if (info->len == 7 &&
+   info->data[0] == 0x00 && info->data[1] == 0xe0 &&
+   info->data[2] == 0x4c && info->data[3] == 0x01 &&
+   info->data[4] == 0x02)
network->Turbo_Enable = 1;
 
if (*tmp_htcap_len == 0) {
-   if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
-   info_element->data[1] == 0x90 &&
-   info_element->data[2] == 0x4c &&
-   info_element->data[3] == 0x033) {
-   *tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
+   if (info->len >= 4 &&
+   info->data[0] == 0x00 && info->data[1] == 0x90 &&
+   info->data[2] == 0x4c && info->data[3] == 0x33) {
+   *tmp_htcap_len = min_t(u8, info->len, MAX_IE_LEN);
if (*tmp_htcap_len != 0) {
-   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-   network->bssht.bdHTCapLen = min_t(u16, 
*tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
-   memcpy(network->bssht.bdHTCapBuf,
-  info_element->data,
-  network->bssht.bdHTCapLen);
+   bssht->bdHTSpecVer = HT_SPEC_VER_EWC;
+   bssht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+sizeof(bssht->bdHTCapBuf));
+   memcpy(bssht->bdHTCapBuf, info->data,
+  bssht->bdHTCapLen);
}
}
if (*tmp_htcap_len != 0) {
-   network->bssht.bdSupportHT = true;
-   network->bssht.bdHT1R = struct ht_capab_ele 
*)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+   bssht->bdSupportHT = true;
+   bssht->bdHT1R = struct ht_capab_ele *)
+  (bssht->bdHTCapBuf))->MCS[1]) == 0);
} else {
-   network->bssht.bdSupportHT = false;
-   network->bssht.bdHT1R = false;
+   bssht->

[PATCH v2 16/21] staging: rtl8192e: Fix LONG_LING in rtllib_parse_info_param()

2015-04-13 Thread Mateusz Kulikowski
Take out MIFE_TYPE_HT_CAP processing into separate function -
rtllib_parse_mfie_ht_cap()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 50 +---
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 2ae4a3f..5371667 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1980,6 +1980,33 @@ static void rtllib_parse_mife_generic(struct 
rtllib_device *ieee,
}
 }
 
+static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element,
+struct rtllib_network *network,
+u16 *tmp_htcap_len)
+{
+   struct bss_ht *ht = &network->bssht;
+
+   *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
+   if (*tmp_htcap_len != 0) {
+   ht->bdHTSpecVer = HT_SPEC_VER_EWC;
+   ht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+  sizeof(ht->bdHTCapBuf));
+   memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen);
+
+   ht->bdSupportHT = true;
+   ht->bdHT1R = struct ht_capab_ele *)
+   ht->bdHTCapBuf))->MCS[1]) == 0;
+
+   ht->bdBandWidth = (enum ht_channel_width)
+(((struct ht_capab_ele *)
+(ht->bdHTCapBuf))->ChlWidth);
+   } else {
+   ht->bdSupportHT = false;
+   ht->bdHT1R = false;
+   ht->bdBandWidth = HT_CHANNEL_WIDTH_20;
+   }
+}
+
 int rtllib_parse_info_param(struct rtllib_device *ieee,
struct rtllib_info_element *info_element,
u16 length,
@@ -2160,27 +2187,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
case MFIE_TYPE_HT_CAP:
RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
 info_element->len);
-   tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
-   if (tmp_htcap_len != 0) {
-   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-   network->bssht.bdHTCapLen = tmp_htcap_len > 
sizeof(network->bssht.bdHTCapBuf) ?
-   sizeof(network->bssht.bdHTCapBuf) : 
tmp_htcap_len;
-   memcpy(network->bssht.bdHTCapBuf,
-  info_element->data,
-  network->bssht.bdHTCapLen);
-
-   network->bssht.bdSupportHT = true;
-   network->bssht.bdHT1R = struct ht_capab_ele 
*)
-   
network->bssht.bdHTCapBuf))->MCS[1]) == 0;
-
-   network->bssht.bdBandWidth = (enum 
ht_channel_width)
-(((struct 
ht_capab_ele *)
-
(network->bssht.bdHTCapBuf))->ChlWidth);
-   } else {
-   network->bssht.bdSupportHT = false;
-   network->bssht.bdHT1R = false;
-   network->bssht.bdBandWidth = 
HT_CHANNEL_WIDTH_20;
-   }
+   rtllib_parse_mfie_ht_cap(info_element, network,
+&tmp_htcap_len);
break;
 
 
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 21/21] staging: rtl8192e: Remove unimplemented iwpriv handlers

2015-04-13 Thread Mateusz Kulikowski
Remove the following private variables:
- force_mic_error - changes force_mic_error that is not used
- radio - changes sw_radio_on that is not used
- adhoc_peer_list - unimplemented
- firm_ver - unimplemented

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c |  1 -
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h |  1 -
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c   | 86 ++--
 drivers/staging/rtl8192e/rtllib.h|  1 -
 4 files changed, 4 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index da28f63..2d11ad6b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1117,7 +1117,6 @@ static void rtl8192_init_priv_variable(struct net_device 
*dev)
priv->bDriverIsGoingToUnload = false;
priv->being_init_adapter = false;
priv->initialized_at_probe = false;
-   priv->sw_radio_on = true;
priv->bdisable_nic = false;
priv->bfirst_init = false;
priv->txringcount = 64;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index 0640e76..6127e92 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -626,7 +626,6 @@ struct r8192_priv {
u8  RegCWinMin;
u8  keepAliveLevel;
 
-   boolsw_radio_on;
boolbHwRadioOff;
boolpwrdown;
boolblinked_ingpio;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index e4d1825..46a7c13 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -175,48 +175,6 @@ static int r8192_wx_force_reset(struct net_device *dev,
 
 }
 
-static int r8192_wx_force_mic_error(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
-{
-   struct r8192_priv *priv = rtllib_priv(dev);
-   struct rtllib_device *ieee = priv->rtllib;
-
-   down(&priv->wx_sem);
-
-   RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__);
-   ieee->force_mic_error = true;
-   up(&priv->wx_sem);
-   return 0;
-
-}
-
-#define MAX_ADHOC_PEER_NUM 64
-struct adhoc_peer_entry {
-   unsigned char MacAddr[ETH_ALEN];
-   unsigned char WirelessMode;
-   unsigned char bCurTxBW40MHz;
-};
-struct adhoc_peers_info {
-   struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM];
-   unsigned char num;
-};
-
-static int r8192_wx_get_adhoc_peers(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
-{
-   return 0;
-}
-
-
-static int r8191se_wx_get_firm_version(struct net_device *dev,
-   struct iw_request_info *info,
-   struct iw_param *wrqu, char *extra)
-{
-   return 0;
-}
-
 static int r8192_wx_adapter_power_status(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -247,28 +205,6 @@ static int r8192_wx_adapter_power_status(struct net_device 
*dev,
return 0;
 }
 
-static int r8192se_wx_set_radio(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
-{
-   struct r8192_priv *priv = rtllib_priv(dev);
-
-   down(&priv->wx_sem);
-
-   netdev_info(dev, "%s(): set radio ! extra is %d\n", __func__, *extra);
-   if ((*extra != 0) && (*extra != 1)) {
-   RT_TRACE(COMP_ERR,
-"%s(): set radio an err value,must 0(radio off) or 
1(radio on)\n",
-__func__);
-   up(&priv->wx_sem);
-   return -1;
-   }
-   priv->sw_radio_on = *extra;
-   up(&priv->wx_sem);
-   return 0;
-
-}
-
 static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -1240,21 +1176,10 @@ static const struct iw_priv_args r8192_private_args[] = 
{
SIOCIWFIRSTPRIV + 0x3,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
}, {
-   SIOCIWFIRSTPRIV + 0x4,
-   IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error"
-   }, {
-   SIOCIWFIRSTPRIV + 0x5,
-   IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
-   "firm_ver"
-   }, {
SIOCIWFIRSTPRIV + 0x6,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
"

[PATCH v2 18/21] staging: rtl8192e: fix LONG_LINE warnings - replace ?: expressions

2015-04-13 Thread Mateusz Kulikowski
Replace temporary conditional (?:) with ordinary condition or max_t.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 30 +-
 drivers/staging/rtl8192e/rtllib_rx.c   |  2 +-
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index 2f4a96c..2362e84 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -403,17 +403,29 @@ static void dm_check_rate_adaptive(struct net_device *dev)
((bshort_gi_enabled) ? BIT31 : 0);
 
if (pra->ratr_state == DM_RATR_STA_HIGH) {
-   HighRSSIThreshForRA = 
pra->high2low_rssi_thresh_for_ra;
-   LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
-   (pra->low_rssi_thresh_for_ra40M) : 
(pra->low_rssi_thresh_for_ra20M);
+   HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra;
+   if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+   LowRSSIThreshForRA =
+   pra->low_rssi_thresh_for_ra40M;
+   else
+   LowRSSIThreshForRA =
+   pra->low_rssi_thresh_for_ra20M;
} else if (pra->ratr_state == DM_RATR_STA_LOW) {
-   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
-   LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
-   (pra->low2high_rssi_thresh_for_ra40M) : 
(pra->low2high_rssi_thresh_for_ra20M);
+   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+   if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+   LowRSSIThreshForRA =
+   pra->low2high_rssi_thresh_for_ra40M;
+   else
+   LowRSSIThreshForRA =
+   pra->low2high_rssi_thresh_for_ra20M;
} else {
-   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
-   LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
-   (pra->low_rssi_thresh_for_ra40M) : 
(pra->low_rssi_thresh_for_ra20M);
+   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+   if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
+   LowRSSIThreshForRA =
+   pra->low_rssi_thresh_for_ra40M;
+   else
+   LowRSSIThreshForRA =
+   pra->low_rssi_thresh_for_ra20M;
}
 
if (priv->undecorated_smoothed_pwdb >=
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index a66d8dc..0bf0163 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1687,7 +1687,7 @@ static int rtllib_qos_convert_ac_to_parameters(struct 
rtllib_qos_parameter_info
qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
 
/* WMM spec P.11: The minimum value for AIFSN shall be 2 */
-   qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : 
qos_param->aifs[aci];
+   qos_param->aifs[aci] = max_t(u8, qos_param->aifs[aci], 2);
 
qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max &
 0x0F);
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 09/21] staging: rtl8192e: Fix DeviceID in rtl8192_pci_findadapter()

2015-04-13 Thread Mateusz Kulikowski
rtl8192_pci_findadapter() was looking for invalid DeviceID (0x8172),
instead of proper for rtl8192e/se devices (0x8192)

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
index 51f53be..e8065c0 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
@@ -62,7 +62,7 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct 
net_device *dev)
 
priv->card_8192 = priv->ops->nic_type;
 
-   if (DeviceID == 0x8172) {
+   if (DeviceID == 0x8192) {
switch (RevisionID) {
case HAL_HW_PCI_REVISION_ID_8192PCIE:
dev_info(&pdev->dev,
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 15/21] staging: rtl8192e: Fix LONG_LINE warnings - modify variables

2015-04-13 Thread Mateusz Kulikowski
Further reduction of checkpatch.pl LONG_LINE warnings:
- Local variables are compacted where it's needed
- Helper (local) variables are used (to avoid expressions like a.b.c.d.e)

Both changes should be optimized out by compilers.dd

Signed-off-by: Mateusz Kulikowski 
---
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|  13 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c |  45 +--
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c|  53 ++-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 397 +++--
 drivers/staging/rtl8192e/rtllib_rx.c   |   2 +-
 drivers/staging/rtl8192e/rtllib_softmac.c  | 123 +++
 drivers/staging/rtl8192e/rtllib_tx.c   |  28 +-
 7 files changed, 344 insertions(+), 317 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index 02c5b0a..05f534e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -36,6 +36,7 @@ static bool fw_download_code(struct net_device *dev, u8 
*code_virtual_address,
 u32 buffer_len)
 {
struct r8192_priv *priv = rtllib_priv(dev);
+   struct rtllib_device *rt = priv->rtllib;
u16 frag_threshold;
u16 frag_length, frag_offset = 0;
int i;
@@ -80,15 +81,15 @@ static bool fw_download_code(struct net_device *dev, u8 
*code_virtual_address,
tcb_desc->txbuf_size = (u16)i;
skb_put(skb, i);
 
-   if (!priv->rtllib->check_nic_enough_desc(dev, 
tcb_desc->queue_index) ||
-   
(!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index])) ||
-   (priv->rtllib->queue_stop)) {
+   if (!rt->check_nic_enough_desc(dev, tcb_desc->queue_index) ||
+   !skb_queue_empty(&rt->skb_waitQ[tcb_desc->queue_index]) ||
+   rt->queue_stop) {
RT_TRACE(COMP_FIRMWARE,
 "===> tx full!\n");
-   skb_queue_tail(&priv->rtllib->skb_waitQ
-   [tcb_desc->queue_index], skb);
+   skb_queue_tail(&rt->skb_waitQ[tcb_desc->queue_index],
+   skb);
} else {
-   priv->rtllib->softmac_hard_start_xmit(skb, dev);
+   rt->softmac_hard_start_xmit(skb, dev);
}
 
code_virtual_address += frag_length;
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 0765c97..87361cd 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -640,42 +640,43 @@ void rtl8192_phy_getTxPower(struct net_device *dev)
 
 void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel)
 {
-   struct r8192_priv *priv = rtllib_priv(dev);
+   struct r8192_priv *p = rtllib_priv(dev);
u8  powerlevel = 0, powerlevelOFDM24G = 0;
char ant_pwr_diff;
u32 u4RegValue;
 
-   if (priv->epromtype == EEPROM_93C46) {
-   powerlevel = priv->TxPowerLevelCCK[channel-1];
-   powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1];
-   } else if (priv->epromtype == EEPROM_93C56) {
-   if (priv->rf_type == RF_1T2R) {
-   powerlevel = priv->TxPowerLevelCCK_C[channel-1];
-   powerlevelOFDM24G = 
priv->TxPowerLevelOFDM24G_C[channel-1];
-   } else if (priv->rf_type == RF_2T4R) {
-   powerlevel = priv->TxPowerLevelCCK_A[channel-1];
-   powerlevelOFDM24G = 
priv->TxPowerLevelOFDM24G_A[channel-1];
+   if (p->epromtype == EEPROM_93C46) {
+   powerlevel = p->TxPowerLevelCCK[channel-1];
+   powerlevelOFDM24G = p->TxPowerLevelOFDM24G[channel-1];
+   } else if (p->epromtype == EEPROM_93C56) {
+   if (p->rf_type == RF_1T2R) {
+   powerlevel = p->TxPowerLevelCCK_C[channel-1];
+   powerlevelOFDM24G = p->TxPowerLevelOFDM24G_C[channel-1];
+   } else if (p->rf_type == RF_2T4R) {
+   powerlevel = p->TxPowerLevelCCK_A[channel-1];
+   powerlevelOFDM24G = p->TxPowerLevelOFDM24G_A[channel-1];
 
-   ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1]
-  - priv->TxPowerLevelOFDM24G_A[channel-1];
+   ant_pwr_diff = p->TxPowerLevelOFDM24G_C[channel-1] -
+  p->TxPowerLevelOFDM

[PATCH v2 13/21] staging: rtl8192e: Fix PREFER_PR_LEVEL warnings

2015-04-13 Thread Mateusz Kulikowski
Fix most of remaining PREFER_PR_LEVEL warnings in rtllib.
Replace printk() with pr_* where possible.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|  4 +-
 drivers/staging/rtl8192e/rtllib_crypt.c  | 17 
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 59 +++-
 drivers/staging/rtl8192e/rtllib_rx.c |  4 +-
 4 files changed, 34 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 472e880..fd7b7a5 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -685,13 +685,13 @@ extern u32 rtllib_debug_level;
 #define RTLLIB_DEBUG(level, fmt, args...) \
 do {   \
if (rtllib_debug_level & (level))   \
-   printk(KERN_DEBUG "rtllib: " fmt, ## args); \
+   pr_debug("rtllib: " fmt, ## args);  \
 } while (0)
 
 #define RTLLIB_DEBUG_DATA(level, data, datalen)\
do {\
if ((rtllib_debug_level & (level)) == (level)) {\
-   printk(KERN_DEBUG "rtllib: %s()\n", __func__);  \
+   pr_debug("rtllib: %s()\n", __func__);   \
print_hex_dump_bytes(KERN_DEBUG, DUMP_PREFIX_NONE, \
 data, datalen); \
}   \
diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c 
b/drivers/staging/rtl8192e/rtllib_crypt.c
index 1e6ae9b..80711ee 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt.c
@@ -62,9 +62,8 @@ void rtllib_crypt_deinit_handler(unsigned long data)
spin_lock_irqsave(info->lock, flags);
rtllib_crypt_deinit_entries(info, 0);
if (!list_empty(&info->crypt_deinit_list)) {
-   printk(KERN_DEBUG
-  "%s: entries remaining in delayed crypt deletion list\n",
-  info->name);
+   pr_debug("%s: entries remaining in delayed crypt deletion 
list\n",
+info->name);
info->crypt_deinit_timer.expires = jiffies + HZ;
add_timer(&info->crypt_deinit_timer);
}
@@ -118,8 +117,7 @@ int rtllib_register_crypto_ops(struct lib80211_crypto_ops 
*ops)
list_add(&alg->list, &hcrypt->algs);
spin_unlock_irqrestore(&hcrypt->lock, flags);
 
-   printk(KERN_DEBUG "rtllib_crypt: registered algorithm '%s'\n",
-  ops->name);
+   pr_debug("rtllib_crypt: registered algorithm '%s'\n", ops->name);
 
return 0;
 }
@@ -147,8 +145,8 @@ int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops 
*ops)
spin_unlock_irqrestore(&hcrypt->lock, flags);
 
if (del_alg) {
-   printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm '%s'\n",
-  ops->name);
+   pr_debug("rtllib_crypt: unregistered algorithm '%s'\n",
+ops->name);
kfree(del_alg);
}
 
@@ -239,9 +237,8 @@ void __exit rtllib_crypto_deinit(void)
struct rtllib_crypto_alg *alg =
(struct rtllib_crypto_alg *) ptr;
list_del(ptr);
-   printk(KERN_DEBUG
-  "rtllib_crypt: unregistered algorithm '%s' (deinit)\n",
-  alg->ops->name);
+   pr_debug("rtllib_crypt: unregistered algorithm '%s' (deinit)\n",
+alg->ops->name);
kfree(alg);
}
 
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c 
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index c3eed40..8fe2ec2 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -66,8 +66,7 @@ static void *rtllib_tkip_init(int key_idx)
priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_arc4)) {
-   printk(KERN_DEBUG
-  "rtllib_crypt_tkip: could not allocate crypto API 
arc4\n");
+   pr_debug("rtllib_crypt_tkip: could not allocate crypto API 
arc4\n");
priv->tx_tfm_arc4 = NULL;
goto fail;
}
@@ -75,8 +74,7 @@ static void *rtllib_tkip_init(int key_idx)
priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_michael)) {
-   

[PATCH v2 20/21] staging: rtl8192e: Fix LONG_LINE in simplify rtl8192_process_phyinfo()

2015-04-13 Thread Mateusz Kulikowski
Simplify function to make checkpatch.pl happy. Changes:
- Helper variables used
- Conditions were rephrased to return quickly (and decrease indent).

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 111 -
 1 file changed, 53 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 2f21bdc..96938d7 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -1701,6 +1701,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv 
*priv, u8 *buffer,
struct rtllib_hdr_3addr *hdr;
u16 sc;
unsigned int frag, seq;
+   struct rt_stats *stats = &priv->stats;
 
hdr = (struct rtllib_hdr_3addr *)buffer;
sc = le16_to_cpu(hdr->seq_ctl);
@@ -1712,20 +1713,20 @@ static void rtl8192_process_phyinfo(struct r8192_priv 
*priv, u8 *buffer,
 
if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX;
-   last_rssi = priv->stats.slide_signal_strength[slide_rssi_index];
-   priv->stats.slide_rssi_total -= last_rssi;
+   last_rssi = stats->slide_signal_strength[slide_rssi_index];
+   stats->slide_rssi_total -= last_rssi;
}
-   priv->stats.slide_rssi_total += prev_st->SignalStrength;
+   stats->slide_rssi_total += prev_st->SignalStrength;
 
-   priv->stats.slide_signal_strength[slide_rssi_index++] =
-prev_st->SignalStrength;
+   stats->slide_signal_strength[slide_rssi_index++] =
+   prev_st->SignalStrength;
if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
slide_rssi_index = 0;
 
-   tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics;
-   priv->stats.signal_strength = rtl819x_translate_todbm(priv,
+   tmp_val = stats->slide_rssi_total/slide_rssi_statistics;
+   stats->signal_strength = rtl819x_translate_todbm(priv,
  (u8)tmp_val);
-   curr_st->rssi = priv->stats.signal_strength;
+   curr_st->rssi = stats->signal_strength;
if (!prev_st->bPacketMatchBSSID) {
if (!prev_st->bToSelfBA)
return;
@@ -1736,7 +1737,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv 
*priv, u8 *buffer,
 
rtl819x_process_cck_rxpathsel(priv, prev_st);
 
-   priv->stats.num_process_phyinfo++;
+   stats->num_process_phyinfo++;
if (!prev_st->bIsCCK && prev_st->bPacketToSelf) {
for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) {
if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev,
@@ -1745,30 +1746,30 @@ static void rtl8192_process_phyinfo(struct r8192_priv 
*priv, u8 *buffer,
RT_TRACE(COMP_DBG,
 "Jacken -> 
pPreviousstats->RxMIMOSignalStrength[rfpath]  = %d\n",
 prev_st->RxMIMOSignalStrength[rfpath]);
-   if (priv->stats.rx_rssi_percentage[rfpath] == 0) {
-   priv->stats.rx_rssi_percentage[rfpath] =
+   if (stats->rx_rssi_percentage[rfpath] == 0) {
+   stats->rx_rssi_percentage[rfpath] =
 prev_st->RxMIMOSignalStrength[rfpath];
}
if (prev_st->RxMIMOSignalStrength[rfpath]  >
-   priv->stats.rx_rssi_percentage[rfpath]) {
-   priv->stats.rx_rssi_percentage[rfpath] =
-   ((priv->stats.rx_rssi_percentage[rfpath]
+   stats->rx_rssi_percentage[rfpath]) {
+   stats->rx_rssi_percentage[rfpath] =
+   ((stats->rx_rssi_percentage[rfpath]
* (RX_SMOOTH - 1)) +
(prev_st->RxMIMOSignalStrength
[rfpath])) / (RX_SMOOTH);
-   priv->stats.rx_rssi_percentage[rfpath] =
-priv->stats.rx_rssi_percentage[rfpath]
+   stats->rx_rssi_percentage[rfpath] =
+stats->rx_rssi_percentage[rfpath]
 + 1;
} else {
-   priv->stats.rx_rssi_percentage[rfpath] =
-  ((priv->stats.rx_rssi_percentage[rfpath] 

[PATCH v2 17/21] staging: rtl8192e: Fix LONG_LINE warnings (conditions)

2015-04-13 Thread Mateusz Kulikowski
Rework some conditions to bail out of functions faster therby
decreasing overall indent. This patch should not cause any negative
side effect (except for different execution time).

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |   8 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 197 +
 drivers/staging/rtl8192e/rtllib_rx.c   |  99 +++--
 drivers/staging/rtl8192e/rtllib_softmac.c  | 128 
 4 files changed, 216 insertions(+), 216 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 6802294..2f21bdc 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -932,10 +932,10 @@ start:
  rCCK0_TxFilter1, bMaskByte2);
 
for (i = 0; i < CCKTxBBGainTableLength; i++) {
-   if (TempCCk == dm_cck_tx_bb_gain[i][0]) {
-   priv->CCKPresentAttentuation_20Mdefault 
= (u8)i;
-   break;
-   }
+   if (TempCCk != dm_cck_tx_bb_gain[i][0])
+   continue;
+   priv->CCKPresentAttentuation_20Mdefault = (u8)i;
+   break;
}
priv->CCKPresentAttentuation_40Mdefault = 0;
priv->CCKPresentAttentuation_difference = 0;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index d71459f..2f4a96c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -2034,9 +2034,6 @@ static void dm_init_rxpath_selection(struct net_device 
*dev)
}
 }
 
-#define PWDB_IN_RANGE  ((cur_cck_pwdb < tmp_cck_max_pwdb) &&   \
-   (cur_cck_pwdb > tmp_cck_sec_pwdb))
-
 static void dm_rxpath_sel_byrssi(struct net_device *dev)
 {
struct r8192_priv *priv = rtllib_priv(dev);
@@ -2069,53 +2066,60 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev)
 
for (i = 0; i < RF90_PATH_MAX; i++) {
if (!DM_RxPathSelTable.DbgMode)
-   DM_RxPathSelTable.rf_rssi[i] = 
priv->stats.rx_rssi_percentage[i];
-
-   if (priv->brfpath_rxenable[i]) {
-   rf_num++;
-   cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i];
-
-   if (rf_num == 1) {
-   max_rssi_index = min_rssi_index = 
sec_rssi_index = i;
-   tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = 
cur_rf_rssi;
-   } else if (rf_num == 2) {
-   if (cur_rf_rssi >= tmp_max_rssi) {
-   tmp_max_rssi = cur_rf_rssi;
-   max_rssi_index = i;
-   } else {
-   tmp_sec_rssi = tmp_min_rssi = 
cur_rf_rssi;
-   sec_rssi_index = min_rssi_index = i;
-   }
+   DM_RxPathSelTable.rf_rssi[i] =
+   priv->stats.rx_rssi_percentage[i];
+   if (!priv->brfpath_rxenable[i])
+   continue;
+
+   rf_num++;
+   cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i];
+
+   if (rf_num == 1) {
+   sec_rssi_index = i;
+   max_rssi_index = i;
+   min_rssi_index = i;
+   tmp_sec_rssi = cur_rf_rssi;
+   tmp_max_rssi = cur_rf_rssi;
+   tmp_min_rssi = cur_rf_rssi;
+   } else if (rf_num == 2) {
+   if (cur_rf_rssi >= tmp_max_rssi) {
+   tmp_max_rssi = cur_rf_rssi;
+   max_rssi_index = i;
} else {
-   if (cur_rf_rssi > tmp_max_rssi) {
-   tmp_sec_rssi = tmp_max_rssi;
-   sec_rssi_index = max_rssi_index;
-   tmp_max_rssi = cur_rf_rssi;
-   max_rssi_index = i;
-   } else if (cur_rf_rssi == tmp_max_rssi) {
-   tmp_sec_rssi = cur_rf_rssi;
-   sec_rssi_index = i;
-   } else if ((cur_rf_rssi < tmp_max_rssi) &&
-  (cur_rf_rssi > tmp_sec_rssi)) {
+   tmp_sec_rssi = cur_

[PATCH v2 12/21] staging: rtl8192e: replace memcmp() with ether_addr_equal_unaligned()

2015-04-13 Thread Mateusz Kulikowski
Use dedicated macro to compare ethernet addresses in probe_rq_parse().

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index 29c23ff..a7d2411 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1853,7 +1853,8 @@ static short probe_rq_parse(struct rtllib_device *ieee, 
struct sk_buff *skb,
return -1; /* corrupted */
 
bssid_match =
- (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) &&
+ (!ether_addr_equal_unaligned(header->addr3,
+  ieee->current_network.bssid)) &&
  (!is_broadcast_ether_addr(header->addr3));
if (bssid_match)
return -1;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/21] staging: rtl8192e: Fix more checkpatch.pl warnings

2015-04-13 Thread Mateusz Kulikowski
On 14.04.2015 00:12, Dan Carpenter wrote:
> I don't know why you are doing a v2.  I went back to the original thread
> and I see that no one complained about it.
> 
> Since no one replied to v1 thread, then probably Greg is going to apply
> that one first because it is first in his inbox.  Greg's inbox has
> millions and millions of emails so he won't even get to this v2 series
> until a few days after he applied the v1 series.
> 
> Instead of sending a v2, just assume that Greg is going to apply the
> first set and send the additional cleanups as a separate set.
> 
> regards,
> dan carpenter
> 
> 

Sorry for confusion.

I made checkpatch regressions in v1 (that I missed at a time)

I will mark (reply-all) v1 as "do-not-apply" - Will that be enough?

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/8] staging: rtl8192e: Fix more checkpatch.pl warnings

2015-04-13 Thread Mateusz Kulikowski
On 08.04.2015 01:08, Mateusz Kulikowski wrote:
> This series of patches fixes another set of checkpatch.pl warnings.
> 
Please ignore this patchset and use v2 once it is reviewed.

Best Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/21] staging: rtl8192e: Fix more checkpatch.pl warnings

2015-04-13 Thread Mateusz Kulikowski
On 14.04.2015 00:33, Dan Carpenter wrote:
> On Tue, Apr 14, 2015 at 12:15:57AM +0200, Mateusz Kulikowski wrote:
>> I made checkpatch regressions in v1 (that I missed at a time)
> 
> As near as I can tell the only difference is that you left some curly
> braces in on patch 8 of first set and removed them on the second set.
> It's not worth resending the whole series for trivial stuff like that
> which can be fixed later.  But fine.

Will keep that mind in future - thanks for the tip.

>> I will mark (reply-all) v1 as "do-not-apply" - Will that be enough?
> 
> Yes.

Done

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 10/21] staging: rtl8192e: replace memcpy() -> ether_addr_copy_unaligned()

2015-04-15 Thread Mateusz Kulikowski
On 14.04.2015 10:00, Dan Carpenter wrote:
> BAReq->addr1 is part of struct rtllib_hdr_2addr.  It's 4 bytes into
> the struct so it's fine.
You're right - should I explicitly add __aligned() in such places or just 
leave comment in that case (for future commiters)?

> I sort of like the ether_addr_copy_unaligned() macro because it would
> let us silence some checkpatch false positives because otherwise people
> will eventually introduce bugs like a dripping roof leak will eventually
> destroy a building.  But it should be in the main kernel header with a
> name like that.  And also this is misleading that we are using it for
> data which is aligned.

Is it ok if I do following steps for v3:
- Align eth addresses that can be aligned (at least one structure - rtllib_rxb 
can't be aligned)
- Apply eth_addr_copy where possible
- Discuss and try to submit ether_addr_copy_unaligned on netdev list
- If they reject the change - rename macro to something less confusing 
(rtllib_something)

Regards and thanks for reviews,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 13/21] staging: rtl8192e: Fix PREFER_PR_LEVEL warnings

2015-04-15 Thread Mateusz Kulikowski
On 14.04.2015 10:07, Dan Carpenter wrote:
> On Mon, Apr 13, 2015 at 11:47:36PM +0200, Mateusz Kulikowski wrote:
>> Fix most of remaining PREFER_PR_LEVEL warnings in rtllib.
>> Replace printk() with pr_* where possible.
(...)
>>  #define RTLLIB_DEBUG_DATA(level, data, datalen) \
>>  do {\
>>  if ((rtllib_debug_level & (level)) == (level)) {\
>> -printk(KERN_DEBUG "rtllib: %s()\n", __func__);  \
>> +pr_debug("rtllib: %s()\n", __func__);   \
>>  print_hex_dump_bytes(KERN_DEBUG, DUMP_PREFIX_NONE, \
>>   data, datalen); \
>>  }   \
> 
> We've made it slightly more tricky to turn on these debug statements.
> 
> I don't think that's a big problem.  I don't think anyone cares about
> them.  They are just noise is my guess.

I agree that lot of the debug messages in that driver are garbage;
Proposal for v3:
- throw away all garbage messages (like "==>__func__\n"),
- use proper print functions (and loglevels) for remaining RTLLIB_ debug 
messages (possibly reword them)
- throw away RTLLIB_DEBUG and RTLLIB_DEBUG_DATA macros (i.e. whole RTL 
'logging' mechanism)

Most of the messages will stay on DEBUG loglevel, so will not bother "normal" 
users.

Does it sound good?

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 15/21] staging: rtl8192e: Fix LONG_LINE warnings - modify variables

2015-04-15 Thread Mateusz Kulikowski
On 14.04.2015 10:40, Dan Carpenter wrote:
> On Mon, Apr 13, 2015 at 11:47:38PM +0200, Mateusz Kulikowski wrote:
>> +if (*rfa_pti_r > 4) {
>> +(*rfa_pti_r)--;
> 
> 
> Honestly, I thought that patch 14 was too hard to review and did too
> many things, but this one is kind of ridiculous.
> 
> - p->rfa_txpowertrackingindex--;
> + (*rfa_pti)--;
> 
> The new version is fewer characters but it's way more complicated to
> think about.  Just rename rfa_txpowertrackingindex to something
> reasonable.  It's a stupid name, because it_hasninegazillionwordsinit
> and it's too long.
> 
> "rfa_pti_r" is a terrible name as well.   it_also_hngwit_for_realz.
True, but it's also used as local variable in one-screen function;
Nevertheless - I got the point.

> I'm not going to review the rest of this patch.

Thanks for the patience, I will try to split such commits more in future.

As for v3 I assume patches 15, 19, 20 should be reworked; I will:
- Try to find better names for structure members where possible (this mostly 
applies to r8192_priv members), 
- Do exactly one type of cleanup 'operation' in each commit (this means fixing 
  one LONG_LINE warning may take more than one commit)
- Avoid playing with pointers like above
- Standardize local variable names in all functions (i.e. if I use igain as 
init_gain pointer, I'll do it like that everywhere)

Is it enough or did I missed something?

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 10/21] staging: rtl8192e: replace memcpy() -> ether_addr_copy_unaligned()

2015-05-03 Thread Mateusz Kulikowski
Hi,

On 03.05.2015 21:10, Greg KH wrote:
> On Mon, Apr 13, 2015 at 11:47:33PM +0200, Mateusz Kulikowski wrote:
>> rtl8192e driver uses memcpy() to copy hw addresses in several places.
>> checkpatch.pl suggests to use ether_addr_copy(), but most of
>> addresses in driver may be unaligned.
>> This patch replaces all memcpy occurences with single macro therby
>> silencing checkpatch.pl (single complaints in macro remains).
>>
>> Signed-off-by: Mateusz Kulikowski 
>> ---
>>  drivers/staging/rtl8192e/rtl819x_BAProc.c| 12 ++---
>>  drivers/staging/rtl8192e/rtllib.h|  3 ++
>>  drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 18 +++
>>  drivers/staging/rtl8192e/rtllib_rx.c | 74 
>> +---
>>  drivers/staging/rtl8192e/rtllib_softmac.c| 67 +
>>  drivers/staging/rtl8192e/rtllib_softmac_wx.c |  5 +-
>>  drivers/staging/rtl8192e/rtllib_tx.c | 24 -
>>  7 files changed, 113 insertions(+), 90 deletions(-)
> 
> I've stopped applying here, no need to resend the first 9 of these
> patches for your next round.

Thanks,

I was afraid you applied whole changeset by accident.

I'm working on v3 (a bit slowly due to holidays/work) - 
hopefully will post it this/next week.

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: rtl8192e: fix wrong assignment

2015-05-04 Thread Mateusz Kulikowski
Hi,

On 04.05.2015 11:29, Gujulan Elango, Hari Prasath (H.) wrote:
> This patch addresses a spatch warning on assigning a negative
> value to a unsigned integer.Similar patch has been submitted by
> Larry Finger earlier to silence the same spatch warning in another
> file.
> 
> Signed-off-by: Hari Prasath Gujulan Elango 
> ---
>   v2: Address Dan Carpenter review comments for version 1 of this
>   patch.
> ---
>  drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
> b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
> index 352d381..a7a1ade 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
> @@ -2310,7 +2310,7 @@ static void rtl8192_rx_normal(struct net_device *dev)
>  
>   struct rtllib_rx_stats stats = {
>   .signal = 0,
> - .noise = -98,
> + .noise = (u8) -98,
>   .rate = 0,
>   .freq = RTLLIB_24GHZ_BAND,
>   };
> 

Small suggestion from my side - a bit late, but I was unable to check code 
earlier - so please don't
do v3 unless others say so.

As far as I know (radio) noise is rarely above 0 dBm - if it is, you're doing 
something wrong.
This means we can just change rtllib_rx_stats::noise to s8.

Then, we need to add cast in other place - when we access struct iw_quality 
(wireless.h).

Maybe we should even talk with wireless guys and change noise there as well.

Rationale:
127 dbM = ~5 GW (Giga Watt) - I doubt we can have transmitter with such power 
in nearest future;)
-128 dbM = <1fW (femto Watt, 1e-15) - thermal noise for wifi is > -100dBm


Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 00/33] staging: rtl8192e: Fix more checkpatch.pl warnings

2015-05-09 Thread Mateusz Kulikowski
This series applies some of review comments by Dan (thanks!) as well as does
further cleanups.

Further series will probably focus more on changing driver architecture into
something that may get accepted into -wireless.

This series should apply cleanly to staging-testing(7192a5dd5)
branches.
One changeset - #14 will not apply cleanly if the following patch will be 
applied:
[PATCH v2] staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu
It should apply via 3-way merge (only one line of context is different)

Target tested on netbook with rtl8192e card vs Linus master (1a9f064f):
- Module load/unload
- Interface up/down
- Network scanning
- Connect to WPA2 network + ping route
I've found one bug in the driver (it happens also on master) - rtllib doesn't 
handle rmmod of active (WPA) r8192e_pci - module refcount drops below 0.

Built-tested for each patch in series on staging-testing

New changes (patch numbers are valid for v3):
- #6 Removal of rtllib_crypt.[ch] - unused files are bad
- #10 Simplification of rtllib_proces_probe_response - fixing LONG_LINES in
process
- #24 Fix new checkpatch warnings (OOM_MESSAGE)
- #25 Remove another unused file (rtl_crypto.h)
- #26-#28 Replace ?: expression with min/max macros
- #29 Remove unused debug messages
- #30 Simplify/Optimize rtl8192_phy_checkBBAndRF()
- #31 Replace RT_TRACE(COMP_ERR,...) with netdev_* errors - this are error
messages that were (and should be) displayed, with this patch it will be
clearly visible where they belong (+log levels were changed to more
appropriate).
- #32 Trivial reindentations
- #33 Simplify awkward WoL reporting in rtl8192E_suspend()

What happened to v2 changesets (patch numbers are valid for v2 unless noted):
- Patches 1-9 were already applied by Greg - Thanks!
- Patch 10 was split and reworked into v3 patches: 1, 2, 3
- Patches 11, 12 were cherry-picked into v3 patches 4, 5
- Patch 13 became a series of patches removing whole RTLLIB_* debug "system"
(v3 patches 7-9, 11-19, 20). Where possible netdev_* was used, but in some
cases it would look awkward so I left with pr_*
- Patch 14 was cherry-picked into v3 patch 21 (Again - thanks for patience Dan)
- Patches 15, 17, 18, 19, 20 were thrown out - they fix some LONG_LINE
warnings, but it's not worth it as readability of code goes down -
I will remove remaining warnings while refactoring the driver
- Patch 16 was cherry-picked into v3 patch 22
- Patch 21 was cherry-picked into v3 patch 23

Notes from v2:

New cleanup patchset for rtl8192e. It fixes (mostly) checkpatch.pl warnings.
When applied, checkpatch.pl warning count drops to 34 (from ).
It should apply cleanly to staging-next/testing (c610f7f7) branches.

Series was smoke tested on rtl8192e card vs staging-next:
- Module load/unload
- Interface up/down

Most of changes are related to checkpatch.pl with the exception of
- bugfix - staging: rtl8192e: Fix DeviceID in rtl8192_pci_findadapter()
  This is clearly (in my opinion) typo - I checked two rtl8192e cards from
  different vendors and both had DeviceID == 0x8192.
- Removal of unimplemented/unused iwpriv handlers - they just give false sense
  of hope to iwpriv user

Additional changes in v2:
- Fix (most) LONG_LINE warnings
- Replace memcpy() with custom macro - later __aligned(2) will be added to
  structures (where possible) - I prefer not to do this change before I have
  working hardware. Unfortunantely these cards are grumpy and refuse to enable
  radio in PC mPCIe slot (even after soldering W_DISABLE override and using two
  different antenna sets)
- Fix (most) remaining PREFER_PR_LEVEL warnings

Notes from v1:
This series of patches fixes another set of checkpatch.pl warnings.

Most of the patches are trivial, with the exception of #8, #7 and #5;
Driver logic should not be affected.
Some of the patches cause LONG_LINE warnings, but fix has to wait until
I do more driver refactorings (It's hard to keep line length when variable
names have 30 characters).

Mateusz Kulikowski (33):
  staging: rtl8192e: Declare ethernet addresses as __aligned(2)
  staging: rtl8192e: Fix PREFER_ETHER_ADDR_COPY warnings
  staging: rtl8192e: Mark unaligned memcpy()
  staging: rtl8192e: Fix DEEP_INDENTATION warning in
rtllib_parse_info_param()
  staging: rtl8192e: Replace memcmp() with ether_addr_equal_unaligned()
  staging: rtl8192e: Remove rtllib_crypt.[ch]
  staging: rtl8192e: Replace RTLLIB_DEBUG(DL_ERR) with netdev_*()
  staging: rtl8192e: Remove RTLLIB_ERROR() and RTLLIB_WARNING()
  staging: rtl8192e: Remove RTLLIB_DEBUG_WX()
  staging: rtl8192e: Simplify rtllib_proces_probe_response()
  staging: rtl8192e: Remove RTLLIB_DEBUG_SCAN()
  staging: rtl8192e: Remove RTLLIB_DEBUG_(FRAG|EAP|DROP|STATE|TX|RX)()
  staging: rtl8192e: Remove RTLLIB_DEBUG_QOS()
  staging: rtl8192e: Remove RTLLIB_DEBUG_MGMT()
  staging: rtl8192e: Remove RTLLIB_DEBUG_INFO()
  staging: rtl8192e: Remove RTLLIB_DEBUG()
  staging: rtl8192e: Remove

[PATCH v3 02/33] staging: rtl8192e: Fix PREFER_ETHER_ADDR_COPY warnings

2015-05-09 Thread Mateusz Kulikowski
Replace memcpy() with ether_addr_copy() where possible to make
checkpatch.pl happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  2 +-
 drivers/staging/rtl8192e/rtl819x_BAProc.c  | 13 +++---
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   | 19 
 drivers/staging/rtl8192e/rtllib_rx.c   | 46 +-
 drivers/staging/rtl8192e/rtllib_softmac.c  | 64 +-
 drivers/staging/rtl8192e/rtllib_softmac_wx.c   |  4 +-
 drivers/staging/rtl8192e/rtllib_tx.c   | 24 +-
 7 files changed, 89 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index a3fbbb9..eb803dc 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -384,7 +384,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
*(u16 *)(&dev->dev_addr[i]) = usValue;
}
} else {
-   memcpy(dev->dev_addr, bMac_Tmp_Addr, 6);
+   ether_addr_copy(dev->dev_addr, bMac_Tmp_Addr);
}
 
RT_TRACE(COMP_INIT, "Permanent Address = %pM\n",
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 26258ea..5b72bce 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -18,6 +18,7 @@
 **/
 #include 
 #include 
+#include 
 #include "rtllib.h"
 #include "rtl819x_BA.h"
 
@@ -103,10 +104,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
BAReq = (struct rtllib_hdr_3addr *)skb_put(skb,
 sizeof(struct rtllib_hdr_3addr));
 
-   memcpy(BAReq->addr1, Dst, ETH_ALEN);
-   memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
+   ether_addr_copy(BAReq->addr1, Dst);
+   ether_addr_copy(BAReq->addr2, ieee->dev->dev_addr);
 
-   memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
+   ether_addr_copy(BAReq->addr3, ieee->current_network.bssid);
BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
tag = (u8 *)skb_put(skb, 9);
@@ -167,9 +168,9 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
Delba = (struct rtllib_hdr_3addr *) skb_put(skb,
 sizeof(struct rtllib_hdr_3addr));
 
-   memcpy(Delba->addr1, dst, ETH_ALEN);
-   memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
-   memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
+   ether_addr_copy(Delba->addr1, dst);
+   ether_addr_copy(Delba->addr2, ieee->dev->dev_addr);
+   ether_addr_copy(Delba->addr3, ieee->current_network.bssid);
Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
tag = (u8 *)skb_put(skb, 6);
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c 
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index eda68b9..9ec2b48 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rtllib.h"
 
@@ -533,20 +534,20 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
switch (le16_to_cpu(hdr11->frame_ctl) &
(RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_TODS:
-   memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr3); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */
break;
case RTLLIB_FCTL_FROMDS:
-   memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr1); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr3); /* SA */
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
-   memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr3); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr4); /* SA */
break;
case 0:
-   memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr1); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */
break;
}
 
@@ -599,7 +600,7 @@ sta

[PATCH v3 03/33] staging: rtl8192e: Mark unaligned memcpy()

2015-05-09 Thread Mateusz Kulikowski
Comment unaligned memcpy() that trigger PREFER_ETHER_ADDR_COPY
checkpatch.pl warning.
It will prevent accidential "Fix" to ether_addr_copy().

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index ebb328d..65e4d13 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -488,15 +488,19 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, 
struct rtllib_rxb **prx
 * and replace EtherType
 */
skb_pull(sub_skb, SNAP_SIZE);
-   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
-   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
+   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src,
+  ETH_ALEN); /* Must be unaligned */
+   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst,
+  ETH_ALEN); /* Must be unaligned */
} else {
u16 len;
/* Leave Ethernet header part of hdr and full payload */
len = sub_skb->len;
memcpy(skb_push(sub_skb, 2), &len, 2);
-   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
-   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
+   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src,
+  ETH_ALEN); /* Must be unaligned */
+   memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst,
+  ETH_ALEN); /* Must be unaligned */
}
 
/* Indicate the packets to upper layer */
@@ -781,15 +785,15 @@ static u8 parse_subframe(struct rtllib_device *ieee, 
struct sk_buff *skb,
 
rxb->subframes[0] = sub_skb;
 
-   memcpy(rxb->src, src, ETH_ALEN);
-   memcpy(rxb->dst, dst, ETH_ALEN);
+   memcpy(rxb->src, src, ETH_ALEN); /* Must stay unaligned */
+   memcpy(rxb->dst, dst, ETH_ALEN); /* Must stay unaligned */
rxb->subframes[0]->dev = ieee->dev;
return 1;
}
 
rxb->nr_subframes = 0;
-   memcpy(rxb->src, src, ETH_ALEN);
-   memcpy(rxb->dst, dst, ETH_ALEN);
+   memcpy(rxb->src, src, ETH_ALEN); /* Must stay unaligned */
+   memcpy(rxb->dst, dst, ETH_ALEN); /* Must stay unaligned */
while (skb->len > ETHERNET_HEADER_SIZE) {
/* Offset 12 denote 2 mac address */
nSubframe_Length = *((u16 *)(skb->data + 12));
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 05/33] staging: rtl8192e: Replace memcmp() with ether_addr_equal_unaligned()

2015-05-09 Thread Mateusz Kulikowski
Use dedicated macro to compare ethernet addresses in probe_rq_parse().

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index dccb642..bc934ed 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1852,7 +1852,8 @@ static short probe_rq_parse(struct rtllib_device *ieee, 
struct sk_buff *skb,
return -1; /* corrupted */
 
bssid_match =
- (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) &&
+ (!ether_addr_equal_unaligned(header->addr3,
+  ieee->current_network.bssid)) &&
  (!is_broadcast_ether_addr(header->addr3));
if (bssid_match)
return -1;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 06/33] staging: rtl8192e: Remove rtllib_crypt.[ch]

2015-05-09 Thread Mateusz Kulikowski
It is neither compiled nor used in rtl8192e.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_crypt.c | 254 
 drivers/staging/rtl8192e/rtllib_crypt.h |  34 -
 2 files changed, 288 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtllib_crypt.c
 delete mode 100644 drivers/staging/rtl8192e/rtllib_crypt.h

diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c 
b/drivers/staging/rtl8192e/rtllib_crypt.c
deleted file mode 100644
index 1e6ae9b..000
--- a/drivers/staging/rtl8192e/rtllib_crypt.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Host AP crypto routines
- *
- * Copyright (c) 2002-2003, Jouni Malinen 
- * Portions Copyright (C) 2004, Intel Corporation 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "rtllib.h"
-
-struct rtllib_crypto_alg {
-   struct list_head list;
-   struct lib80211_crypto_ops *ops;
-};
-
-
-struct rtllib_crypto {
-   struct list_head algs;
-   spinlock_t lock;
-};
-
-static struct rtllib_crypto *hcrypt;
-
-void rtllib_crypt_deinit_entries(struct lib80211_crypt_info *info,
-  int force)
-{
-   struct list_head *ptr, *n;
-   struct lib80211_crypt_data *entry;
-
-   for (ptr = info->crypt_deinit_list.next, n = ptr->next;
-ptr != &info->crypt_deinit_list; ptr = n, n = ptr->next) {
-   entry = list_entry(ptr, struct lib80211_crypt_data, list);
-
-   if (atomic_read(&entry->refcnt) != 0 && !force)
-   continue;
-
-   list_del(ptr);
-
-   if (entry->ops)
-   entry->ops->deinit(entry->priv);
-   kfree(entry);
-   }
-}
-EXPORT_SYMBOL(rtllib_crypt_deinit_entries);
-
-void rtllib_crypt_deinit_handler(unsigned long data)
-{
-   struct lib80211_crypt_info *info = (struct lib80211_crypt_info *)data;
-   unsigned long flags;
-
-   spin_lock_irqsave(info->lock, flags);
-   rtllib_crypt_deinit_entries(info, 0);
-   if (!list_empty(&info->crypt_deinit_list)) {
-   printk(KERN_DEBUG
-  "%s: entries remaining in delayed crypt deletion list\n",
-  info->name);
-   info->crypt_deinit_timer.expires = jiffies + HZ;
-   add_timer(&info->crypt_deinit_timer);
-   }
-   spin_unlock_irqrestore(info->lock, flags);
-
-}
-EXPORT_SYMBOL(rtllib_crypt_deinit_handler);
-
-void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info,
-struct lib80211_crypt_data **crypt)
-{
-   struct lib80211_crypt_data *tmp;
-   unsigned long flags;
-
-   if (*crypt == NULL)
-   return;
-
-   tmp = *crypt;
-   *crypt = NULL;
-
-   /* must not run ops->deinit() while there may be pending encrypt or
-* decrypt operations. Use a list of delayed deinits to avoid needing
-* locking.
-*/
-
-   spin_lock_irqsave(info->lock, flags);
-   list_add(&tmp->list, &info->crypt_deinit_list);
-   if (!timer_pending(&info->crypt_deinit_timer)) {
-   info->crypt_deinit_timer.expires = jiffies + HZ;
-   add_timer(&info->crypt_deinit_timer);
-   }
-   spin_unlock_irqrestore(info->lock, flags);
-}
-EXPORT_SYMBOL(rtllib_crypt_delayed_deinit);
-
-int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops)
-{
-   unsigned long flags;
-   struct rtllib_crypto_alg *alg;
-
-   if (hcrypt == NULL)
-   return -1;
-
-   alg = kzalloc(sizeof(*alg), GFP_KERNEL);
-   if (alg == NULL)
-   return -ENOMEM;
-
-   alg->ops = ops;
-
-   spin_lock_irqsave(&hcrypt->lock, flags);
-   list_add(&alg->list, &hcrypt->algs);
-   spin_unlock_irqrestore(&hcrypt->lock, flags);
-
-   printk(KERN_DEBUG "rtllib_crypt: registered algorithm '%s'\n",
-  ops->name);
-
-   return 0;
-}
-EXPORT_SYMBOL(rtllib_register_crypto_ops);
-
-int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
-{
-   unsigned long flags;
-   struct list_head *ptr;
-   struct rtllib_crypto_alg *del_alg = NULL;
-
-   if (hcrypt == NULL)
-   return -1;
-
-   spin_lock_irqsave(&hcrypt->lock, flags);
-   for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
-   struct rtllib_crypto_alg *alg =
-   (struct rtllib_crypto_alg *) ptr;
-   if (alg->ops == ops) {
-

[PATCH v3 15/33] staging: rtl8192e: Remove RTLLIB_DEBUG_INFO()

2015-05-09 Thread Mateusz Kulikowski
Use pr_debug() instead.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h| 1 -
 drivers/staging/rtl8192e/rtllib_module.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index faf94b4..f059153 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -701,7 +701,6 @@ do {
\
 #define RTLLIB_DL_TRACE   (1<<29)
 #define RTLLIB_DL_DATA(1<<30)
 #define RTLLIB_DL_ERR (1<<31)
-#define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
diff --git a/drivers/staging/rtl8192e/rtllib_module.c 
b/drivers/staging/rtl8192e/rtllib_module.c
index b8c7df5..b61035b 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -103,7 +103,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
struct net_device *dev;
int i, err;
 
-   RTLLIB_DEBUG_INFO("Initializing...\n");
+   pr_debug("rtllib: Initializing...\n");
 
dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
if (!dev) {
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 09/33] staging: rtl8192e: Remove RTLLIB_DEBUG_WX()

2015-05-09 Thread Mateusz Kulikowski
Use netdev_dbg() instead of RTLLIB_DEBUG_WX().
Rewrite some messages to be more readable.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|  1 -
 drivers/staging/rtl8192e/rtllib_wx.c | 33 -
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 5f47d75..4edbc87 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,7 +703,6 @@ do {
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
 #define RTLLIB_DEBUG_SCAN(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
 #define RTLLIB_DEBUG_STATE(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index 6234aae..c2c5f0d 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -266,7 +266,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
int i = 0;
int err = 0;
 
-   RTLLIB_DEBUG_WX("Getting scan\n");
+   netdev_dbg(ieee->dev, "Getting scan\n");
down(&ieee->wx_sem);
spin_lock_irqsave(&ieee->lock, flags);
 
@@ -293,7 +293,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
wrqu->data.length = ev -  extra;
wrqu->data.flags = 0;
 
-   RTLLIB_DEBUG_WX("exit: %d networks returned.\n", i);
+   netdev_dbg(ieee->dev, "%s(): %d networks returned.\n", __func__, i);
 
return err;
 }
@@ -311,7 +311,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
int i, key, key_provided, len;
struct lib80211_crypt_data **crypt;
 
-   RTLLIB_DEBUG_WX("SET_ENCODE\n");
+   netdev_dbg(ieee->dev, "%s()\n", __func__);
 
key = erq->flags & IW_ENCODE_INDEX;
if (key) {
@@ -324,16 +324,16 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
key = ieee->crypt_info.tx_keyidx;
}
 
-   RTLLIB_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
+   netdev_dbg(ieee->dev, "Key: %d [%s]\n", key, key_provided ?
   "provided" : "default");
crypt = &ieee->crypt_info.crypt[key];
if (erq->flags & IW_ENCODE_DISABLED) {
if (key_provided && *crypt) {
-   RTLLIB_DEBUG_WX("Disabling encryption on key %d.\n",
-  key);
+   netdev_dbg(ieee->dev,
+  "Disabling encryption on key %d.\n", key);
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
} else
-   RTLLIB_DEBUG_WX("Disabling encryption.\n");
+   netdev_dbg(ieee->dev, "Disabling encryption.\n");
 
/* Check all the keys to see if any are still configured,
 * and if no key index was provided, de-init them all
@@ -405,9 +405,9 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
if (len > erq->length)
memset(sec.keys[key] + erq->length, 0,
   len - erq->length);
-   RTLLIB_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
-  key, escape_essid(sec.keys[key], len),
-  erq->length, len);
+   netdev_dbg(ieee->dev, "Setting key %d to '%s' (%d:%d bytes)\n",
+  key, escape_essid(sec.keys[key], len), erq->length,
+  len);
sec.key_sizes[key] = len;
(*crypt)->ops->set_key(sec.keys[key], len, NULL,
   (*crypt)->priv);
@@ -436,8 +436,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
 
/* No key data - just set the default TX key index */
if (key_provided) {
-   RTLLIB_DEBUG_WX("Setting key %d to default Tx key.\n",
-   key);
+   netdev_dbg(ieee->dev,
+  "Setting key %d as default Tx key.\n", key);
ieee->crypt_info.tx_keyidx = key;
sec.active_key = key;
sec.flags |= SEC_ACTIVE_KEY;
@@ -449,7 +449,7 @@ int rtllib_wx_set_encode(struct rtllib_device

[PATCH v3 01/33] staging: rtl8192e: Declare ethernet addresses as __aligned(2)

2015-05-09 Thread Mateusz Kulikowski
Add __aligned(2) into ethernet addresses allocated on stack or in non-packed
structures. Use ETH_ALEN as array length in places where it was hardcoded to 6.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  3 ++-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |  5 +++--
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |  7 ---
 drivers/staging/rtl8192e/rtl819x_Qos.h |  4 ++--
 drivers/staging/rtl8192e/rtl819x_TS.h  |  2 +-
 drivers/staging/rtl8192e/rtllib.h  | 10 +-
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   |  3 ++-
 drivers/staging/rtl8192e/rtllib_rx.c   |  6 +-
 drivers/staging/rtl8192e/rtllib_softmac.c  |  8 
 drivers/staging/rtl8192e/rtllib_tx.c   |  3 ++-
 10 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index aad5cc9..a3fbbb9 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -321,7 +321,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
u8 ICVer8192, ICVer8256;
u16 i, usValue, IC_Version;
u16 EEPROMId;
-   u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
+   u8 bMac_Tmp_Addr[ETH_ALEN] __aligned(2) = {0x00, 0xe0, 0x4c,
+  0x00, 0x00, 0x01};
 
RT_TRACE(COMP_INIT, "> rtl8192_read_eeprom_info\n");
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 47b5aad..bcf3b46 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2573,8 +2573,9 @@ static int rtl8192_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
int ret = -1;
struct rtllib_device *ieee = priv->rtllib;
u32 key[4];
-   u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-   u8 zero_addr[6] = {0};
+   u8 broadcast_addr[ETH_ALEN] __aligned(2) = {0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff};
+   u8 zero_addr[ETH_ALEN] __aligned(2) = {0};
struct iw_point *p = &wrq->u.data;
struct ieee_param *ipw = NULL;
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 8d6a109..5aa6c57 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -193,7 +193,7 @@ static int r8192_wx_force_mic_error(struct net_device *dev,
 
 #define MAX_ADHOC_PEER_NUM 64
 struct adhoc_peer_entry {
-   unsigned char MacAddr[ETH_ALEN];
+   unsigned char MacAddr[ETH_ALEN] __aligned(2);
unsigned char WirelessMode;
unsigned char bCurTxBW40MHz;
 };
@@ -987,8 +987,9 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
 
ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
{
-   u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-   u8 zero[6] = {0};
+   u8 broadcast_addr[ETH_ALEN] __aligned(2) = {0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff};
+   u8 zero[ETH_ALEN] __aligned(2) = {0};
u32 key[4] = {0};
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
struct iw_point *encoding = &wrqu->encoding;
diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h 
b/drivers/staging/rtl8192e/rtl819x_Qos.h
index 55ef7ec..4bdb176 100644
--- a/drivers/staging/rtl8192e/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192e/rtl819x_Qos.h
@@ -255,8 +255,8 @@ union qos_tclas {
u8  Priority;
u8  ClassifierType;
u8  Mask;
-   u8  SrcAddr[6];
-   u8  DstAddr[6];
+   u8  SrcAddr[ETH_ALEN] __aligned(2);
+   u8  DstAddr[ETH_ALEN] __aligned(2);
u16 Type;
} TYPE0_ETH;
 
diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h 
b/drivers/staging/rtl8192e/rtl819x_TS.h
index 8601b1a..28c91fb 100644
--- a/drivers/staging/rtl8192e/rtl819x_TS.h
+++ b/drivers/staging/rtl8192e/rtl819x_TS.h
@@ -35,7 +35,7 @@ struct ts_common_info {
struct list_headList;
struct timer_list   SetupTimer;
struct timer_list   InactTimer;
-   u8  Addr[6];
+   u8  Addr[ETH_ALEN] __aligned(2);
union tspec_body TSpec;
union qos_tclas TClass[TCLAS_NUM];
u8  TClasProc;
diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index bfec4fd..3674c8b 100644
--- a/drivers/s

[PATCH v3 08/33] staging: rtl8192e: Remove RTLLIB_ERROR() and RTLLIB_WARNING()

2015-05-09 Thread Mateusz Kulikowski
Use pr_* where needed (rtllib init code).

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h| 2 --
 drivers/staging/rtl8192e/rtllib_module.c | 8 +++-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 3674c8b..5f47d75 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -701,8 +701,6 @@ do {
\
 #define RTLLIB_DL_TRACE   (1<<29)
 #define RTLLIB_DL_DATA(1<<30)
 #define RTLLIB_DL_ERR (1<<31)
-#define RTLLIB_ERROR(f, a...) pr_err("rtllib: " f, ## a)
-#define RTLLIB_WARNING(f, a...) pr_warn("rtllib: " f, ## a)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
 #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
diff --git a/drivers/staging/rtl8192e/rtllib_module.c 
b/drivers/staging/rtl8192e/rtllib_module.c
index 32cc8df..b8c7df5 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -107,7 +107,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 
dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
if (!dev) {
-   RTLLIB_ERROR("Unable to network device.\n");
+   pr_err("Unable to allocate net_device.\n");
return NULL;
}
ieee = (struct rtllib_device *)netdev_priv_rsl(dev);
@@ -116,8 +116,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 
err = rtllib_networks_allocate(ieee);
if (err) {
-   RTLLIB_ERROR("Unable to allocate beacon storage: %d\n",
-   err);
+   pr_err("Unable to allocate beacon storage: %d\n", err);
goto failed;
}
rtllib_networks_initialize(ieee);
@@ -240,8 +239,7 @@ static int __init rtllib_init(void)
rtllib_debug_level = debug;
rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
if (rtllib_proc == NULL) {
-   RTLLIB_ERROR("Unable to create " DRV_NAME
-   " proc directory\n");
+   pr_err("Unable to create " DRV_NAME " proc directory\n");
return -EIO;
}
e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops);
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 07/33] staging: rtl8192e: Replace RTLLIB_DEBUG(DL_ERR) with netdev_*()

2015-05-09 Thread Mateusz Kulikowski
Replace all RTLLIB_DEBUG(RTLLIB_DL_ERR, *) calls with netdev_err()
for errors that really should be reported to user.
Use netdev_warn() for the rest.
Rephrase some of the messages to make them more readable/compact.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c| 79 +---
 drivers/staging/rtl8192e/rtl819x_HTProc.c| 23 
 drivers/staging/rtl8192e/rtl819x_TSProc.c| 19 ---
 drivers/staging/rtl8192e/rtllib_rx.c | 15 --
 drivers/staging/rtl8192e/rtllib_softmac.c|  6 +--
 drivers/staging/rtl8192e/rtllib_softmac_wx.c |  6 +--
 6 files changed, 75 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 5b72bce..7d72c19 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -88,12 +88,12 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
 ">%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n",
 __func__, type, Dst, ieee->dev);
if (pBA == NULL) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA is NULL\n");
+   netdev_warn(ieee->dev, "pBA is NULL\n");
return NULL;
}
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
if (skb == NULL) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+   netdev_err(ieee->dev, "Can't alloc skb for ADDBA_REQ\n");
return NULL;
}
 
@@ -159,7 +159,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
 
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
if (skb == NULL) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+   netdev_err(ieee->dev, "Can't alloc skb for DELBA_REQ\n");
return NULL;
}
 
@@ -247,10 +247,9 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct 
sk_buff *skb)
struct rx_ts_record *pTS = NULL;
 
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-" Invalid skb len in BAREQ(%d / %d)\n",
-(int)skb->len,
-(int)(sizeof(struct rtllib_hdr_3addr) + 9));
+   netdev_warn(ieee->dev, "Invalid skb len in BAREQ(%d / %d)\n",
+   (int)skb->len,
+   (int)(sizeof(struct rtllib_hdr_3addr) + 9));
return -1;
}
 
@@ -270,24 +269,24 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct 
sk_buff *skb)
(ieee->pHTInfo->bCurrentHTSupport == false) ||
(ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) {
rc = ADDBA_STATUS_REFUSED;
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"Failed to reply on ADDBA_REQ as some capability 
is not ready(%d, %d)\n",
-ieee->current_network.qos_data.active,
-ieee->pHTInfo->bCurrentHTSupport);
+   netdev_warn(ieee->dev,
+   "Failed to reply on ADDBA_REQ as some capability is 
not ready(%d, %d)\n",
+   ieee->current_network.qos_data.active,
+   ieee->pHTInfo->bCurrentHTSupport);
goto OnADDBAReq_Fail;
}
if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
(u8)(pBaParamSet->field.TID), RX_DIR, true)) {
rc = ADDBA_STATUS_REFUSED;
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__);
+   netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
goto OnADDBAReq_Fail;
}
pBA = &pTS->RxAdmittedBARecord;
 
if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) {
rc = ADDBA_STATUS_INVALID_PARAM;
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"BA Policy is not correct in %s()\n", __func__);
+   netdev_warn(ieee->dev, "%s(): BA Policy is not correct\n",
+   __func__);
goto OnADDBAReq_Fail;
}
 
@@ -334,10 +333,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct 
sk_buff *skb)
u16 ReasonCode;
 
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"Invalid skb len in BARSP(%d / %d)\n",
-(int)skb->len,
-

[PATCH v3 10/33] staging: rtl8192e: Simplify rtllib_proces_probe_response()

2015-05-09 Thread Mateusz Kulikowski
- Extract frame_ctl once and use it as variable.
- Drop endian conversion in is_beacon() function
  (used in simplified function only)
- Simplify debug messages
- Invert STYPE checks in debug messages - it is valid
  as only BEACON and PROBE_RESP are allowed

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 37 +++-
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 286e374..e553b1f 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2430,9 +2430,9 @@ static inline void update_network(struct rtllib_network 
*dst,
dst->BssCcxVerNumber = src->BssCcxVerNumber;
 }
 
-static inline int is_beacon(__le16 fc)
+static inline int is_beacon(u16 fc)
 {
-   return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON);
+   return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON);
 }
 
 static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
@@ -2473,6 +2473,7 @@ static inline void rtllib_process_probe_response(
short renew;
struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network),
 GFP_ATOMIC);
+   u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl);
 
if (!network)
return;
@@ -2501,12 +2502,9 @@ static inline void rtllib_process_probe_response(
if (rtllib_network_init(ieee, beacon, network, stats)) {
RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n",
  escape_essid(info_element->data,
- info_element->len),
- beacon->header.addr3,
- WLAN_FC_GET_STYPE(
- 
le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
+ info_element->len), beacon->header.addr3,
+ is_beacon(frame_ctl) ? "BEACON" :
+"PROBE RESPONSE");
goto free_network;
}
 
@@ -2514,8 +2512,7 @@ static inline void rtllib_process_probe_response(
if (!rtllib_legal_channel(ieee, network->channel))
goto free_network;
 
-   if (WLAN_FC_GET_STYPE(le16_to_cpu(beacon->header.frame_ctl)) ==
-   RTLLIB_STYPE_PROBE_RESP) {
+   if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) {
if (IsPassiveChannel(ieee, network->channel)) {
netdev_info(ieee->dev,
"GetScanInfo(): For Global Domain, filter 
probe response at channel(%d).\n",
@@ -2548,7 +2545,7 @@ static inline void rtllib_process_probe_response(
else
ieee->current_network.buseprotection = false;
}
-   if (is_beacon(beacon->header.frame_ctl)) {
+   if (is_beacon(frame_ctl)) {
if (ieee->state >= RTLLIB_LINKED)
ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
}
@@ -2585,22 +2582,18 @@ static inline void rtllib_process_probe_response(
RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n",
  escape_essid(network->ssid,
  network->ssid_len), network->bssid,
- WLAN_FC_GET_STYPE(
- 
le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
+ is_beacon(frame_ctl) ? "BEACON" :
+"PROBE RESPONSE");
memcpy(target, network, sizeof(*target));
list_add_tail(&target->list, &ieee->network_list);
if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
rtllib_softmac_new_net(ieee, network);
} else {
RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n",
- escape_essid(target->ssid,
- target->ssid_len), target->bssid,
- WLAN_FC_GET_STYPE(
- 
le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
-   

[PATCH v3 04/33] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param()

2015-05-09 Thread Mateusz Kulikowski
Move MFIE_TYPE_GENERIC handler to rtllib_parse_mife_generic() function.
Code was not altered significantly, therefore in some places it generates
LONG_LINE checkpatch.pl warnings.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 364 +--
 1 file changed, 178 insertions(+), 186 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 65e4d13..c286523 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1743,6 +1743,181 @@ static inline void rtllib_extract_country_ie(
 
 }
 
+static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
+ struct rtllib_info_element *info_element,
+ struct rtllib_network *network,
+ u16 *tmp_htcap_len,
+ u16 *tmp_htinfo_len)
+{
+   u16 ht_realtek_agg_len = 0;
+   u8  ht_realtek_agg_buf[MAX_IE_LEN];
+
+   if (!rtllib_parse_qos_info_param_IE(info_element, network))
+   return;
+
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 && info_element->data[1] == 0x50 &&
+   info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) {
+   network->wpa_ie_len = min(info_element->len + 2,
+ MAX_WPA_IE_LEN);
+   memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+   return;
+   }
+
+   if (info_element->len == 7 && info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0xe0 && info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x01 && info_element->data[4] == 0x02)
+   network->Turbo_Enable = 1;
+
+   if (*tmp_htcap_len == 0) {
+   if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0x90 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x033) {
+   *tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
+   if (*tmp_htcap_len != 0) {
+   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+   network->bssht.bdHTCapLen = min_t(u16, 
*tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
+   memcpy(network->bssht.bdHTCapBuf,
+  info_element->data,
+  network->bssht.bdHTCapLen);
+   }
+   }
+   if (*tmp_htcap_len != 0) {
+   network->bssht.bdSupportHT = true;
+   network->bssht.bdHT1R = struct ht_capab_ele 
*)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+   } else {
+   network->bssht.bdSupportHT = false;
+   network->bssht.bdHT1R = false;
+   }
+   }
+
+
+   if (*tmp_htinfo_len == 0) {
+   if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0x90 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x034) {
+   *tmp_htinfo_len = min_t(u8, info_element->len,
+   MAX_IE_LEN);
+   if (*tmp_htinfo_len != 0) {
+   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+   network->bssht.bdHTInfoLen = min_t(u16, 
*tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
+   memcpy(network->bssht.bdHTInfoBuf,
+  info_element->data,
+  network->bssht.bdHTInfoLen);
+   }
+
+   }
+   }
+
+   if (ieee->aggregation) {
+   if (network->bssht.bdSupportHT) {
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0xe0 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x02) {
+   ht_realtek_agg_len = min_t(u8,
+  info_element->len,
+  MAX_IE_LEN);
+   memcpy(ht_realtek_agg

[PATCH v3 12/33] staging: rtl8192e: Remove RTLLIB_DEBUG_(FRAG|EAP|DROP|STATE|TX|RX)()

2015-05-09 Thread Mateusz Kulikowski
Use netdev_dbg() instead.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|  6 
 drivers/staging/rtl8192e/rtllib_rx.c | 58 
 drivers/staging/rtl8192e/rtllib_tx.c |  5 ++--
 3 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index f7b741e..12a4b1f 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,13 +703,7 @@ do {   
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_STATE(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
-#define RTLLIB_DEBUG_FRAG(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
-#define RTLLIB_DEBUG_EAP(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
-#define RTLLIB_DEBUG_DROP(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
-#define RTLLIB_DEBUG_TX(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
-#define RTLLIB_DEBUG_RX(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
 #define RTLLIB_DEBUG_QOS(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
 
 #ifndef ETH_P_PAE
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 9b57c7e..edd0a86 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -69,9 +69,9 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned 
int seq,
entry = &ieee->frag_cache[tid][i];
if (entry->skb != NULL &&
time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
-   RTLLIB_DEBUG_FRAG(
-   "expiring fragment cache entry seq=%u 
last_frag=%u\n",
-   entry->seq, entry->last_frag);
+   netdev_dbg(ieee->dev,
+  "expiring fragment cache entry seq=%u 
last_frag=%u\n",
+  entry->seq, entry->last_frag);
dev_kfree_skb_any(entry->skb);
entry->skb = NULL;
}
@@ -187,8 +187,9 @@ static int rtllib_frag_cache_invalidate(struct 
rtllib_device *ieee,
  hdr->addr1);
 
if (entry == NULL) {
-   RTLLIB_DEBUG_FRAG(
-   "could not invalidate fragment cache entry (seq=%u)\n", 
seq);
+   netdev_dbg(ieee->dev,
+  "Couldn't invalidate fragment cache entry 
(seq=%u)\n",
+  seq);
return -1;
}
 
@@ -305,11 +306,12 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, 
struct sk_buff *skb,
res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
atomic_dec(&crypt->refcnt);
if (res < 0) {
-   RTLLIB_DEBUG_DROP(
-   "decryption failed (SA= %pM) res=%d\n", hdr->addr2, 
res);
+   netdev_dbg(ieee->dev, "decryption failed (SA= %pM) res=%d\n",
+  hdr->addr2, res);
if (res == -2)
-   RTLLIB_DEBUG_DROP("Decryption failed ICV mismatch (key 
%d)\n",
-skb->data[hdrlen + 3] >> 6);
+   netdev_dbg(ieee->dev,
+  "Decryption failed ICV mismatch (key %d)\n",
+  skb->data[hdrlen + 3] >> 6);
ieee->ieee_stats.rx_discards_undecryptable++;
return -1;
}
@@ -844,7 +846,8 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct 
sk_buff *skb,
sub_skb->dev = ieee->dev;
rxb->subframes[rxb->nr_subframes++] = sub_skb;
if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
-   RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! 
Packets dropped!\n");
+   netdev_dbg(ieee->dev,
+  "ParseSubframe(): Too many Subframes! 
Packets dropped!\n");
break;
}
skb_pull(skb, nSubframe_Length);
@@ -995,9 +998,9 @@ static int rtllib_rx_data_filter(struct rtllib_device 
*ieee, u16 fc,
stype != RTLLIB_STYPE_DATA_CFACKPOLL &&
stype != RTLLIB_STYPE_QOS_DATA) {
if (stype != RTLLIB_STYPE_NULLFUNC)
-   RTLLIB_DEBUG_DROP(
-   "RX: dropped data frame with no data 
(type=0x%

[PATCH v3 24/33] staging: rtl8192e: Fix OOM_MESSAGE warnings

2015-05-09 Thread Mateusz Kulikowski
Remove alloc failed messages where not needed to make checkpatch.pl happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 25765b8..60f536c 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -92,10 +92,8 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
return NULL;
}
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-   if (skb == NULL) {
-   netdev_err(ieee->dev, "Can't alloc skb for ADDBA_REQ\n");
+   if (skb == NULL)
return NULL;
-   }
 
memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr));
 
@@ -160,10 +158,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
 
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-   if (skb == NULL) {
-   netdev_err(ieee->dev, "Can't alloc skb for DELBA_REQ\n");
+   if (skb == NULL)
return NULL;
-   }
 
skb_reserve(skb, ieee->tx_headroom);
 
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 19/33] staging: rtl8192e: Remove assert() macro

2015-05-09 Thread Mateusz Kulikowski
Assert macro printed warning message (and was used once).
Remove it, and add netdev_warn() in place where it was called.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 +++--
 drivers/staging/rtl8192e/rtllib_debug.h  | 8 
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index bcf3b46..36c150d 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1885,8 +1885,9 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct 
net_device *dev,
return;
}
 
-   assert(queue_index != TXCMD_QUEUE);
-
+   if (queue_index != TXCMD_QUEUE)
+   netdev_warn(dev, "%s(): queue index != TXCMD_QUEUE\n",
+   __func__);
 
memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
skb_push(skb, priv->rtllib->tx_headroom);
diff --git a/drivers/staging/rtl8192e/rtllib_debug.h 
b/drivers/staging/rtl8192e/rtllib_debug.h
index 6df8df1..42e88d6 100644
--- a/drivers/staging/rtl8192e/rtllib_debug.h
+++ b/drivers/staging/rtl8192e/rtllib_debug.h
@@ -76,12 +76,4 @@ do { \
printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\
 } while (0)
 
-#define assert(expr) \
-do {   \
-   if (!(expr)) {\
-   pr_info("Assertion failed! %s,%s,%s,line=%d\n", \
-   #expr, __FILE__, __func__, __LINE__); \
-   }   \
-} while (0)
-
 #endif
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 13/33] staging: rtl8192e: Remove RTLLIB_DEBUG_QOS()

2015-05-09 Thread Mateusz Kulikowski
- Pass extra argument (rtllib_device) to rtllib_parse_qos_info_param_IE()
  and update_network()
- Replace RTLLIB_DEBUG_QOS() with netdev_dbg()
- Remove RTLLIB_DEBUG_QOS()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|  1 -
 drivers/staging/rtl8192e/rtllib_rx.c | 26 ++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 12a4b1f..a9b9cb9 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -704,7 +704,6 @@ do {
\
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
-#define RTLLIB_DEBUG_QOS(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
 
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index edd0a86..1efdace 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1661,9 +1661,10 @@ static int rtllib_qos_convert_ac_to_parameters(struct 
rtllib_qos_parameter_info
  * parameters element. check the information element length to decide
  * which type to read
  */
-static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element
+static int rtllib_parse_qos_info_param_IE(struct rtllib_device *ieee,
+ struct rtllib_info_element
 *info_element,
-struct rtllib_network *network)
+ struct rtllib_network *network)
 {
int rc = 0;
struct rtllib_qos_information_element qos_info_element;
@@ -1688,7 +1689,7 @@ static int rtllib_parse_qos_info_param_IE(struct 
rtllib_info_element
}
 
if (rc == 0) {
-   RTLLIB_DEBUG_QOS("QoS is supported\n");
+   netdev_dbg(ieee->dev, "QoS is supported\n");
network->qos_data.supported = 1;
}
return rc;
@@ -1765,7 +1766,7 @@ static void rtllib_parse_mife_generic(struct 
rtllib_device *ieee,
u16 ht_realtek_agg_len = 0;
u8  ht_realtek_agg_buf[MAX_IE_LEN];
 
-   if (!rtllib_parse_qos_info_param_IE(info_element, network))
+   if (!rtllib_parse_qos_info_param_IE(ieee, info_element, network))
return;
 
if (info_element->len >= 4 &&
@@ -2325,7 +2326,8 @@ static inline int is_same_network(struct rtllib_network 
*src,
 }
 
 
-static inline void update_network(struct rtllib_network *dst,
+static inline void update_network(struct rtllib_device *ieee,
+ struct rtllib_network *dst,
  struct rtllib_network *src)
 {
int qos_active;
@@ -2399,12 +2401,12 @@ static inline void update_network(struct rtllib_network 
*dst,
   sizeof(struct rtllib_qos_data));
if (dst->qos_data.supported == 1) {
if (dst->ssid_len)
-   RTLLIB_DEBUG_QOS
-   ("QoS the network %s is QoS supported\n",
-   dst->ssid);
+   netdev_dbg(ieee->dev,
+  "QoS the network %s is QoS supported\n",
+  dst->ssid);
else
-   RTLLIB_DEBUG_QOS
-   ("QoS the network is QoS supported\n");
+   netdev_dbg(ieee->dev,
+  "QoS the network is QoS supported\n");
}
dst->qos_data.active = qos_active;
dst->qos_data.old_param_count = old_param;
@@ -2540,7 +2542,7 @@ static inline void rtllib_process_probe_response(
spin_lock_irqsave(&ieee->lock, flags);
if (is_same_network(&ieee->current_network, network,
   (network->ssid_len ? 1 : 0))) {
-   update_network(&ieee->current_network, network);
+   update_network(ieee, &ieee->current_network, network);
if ((ieee->current_network.mode == IEEE_N_24G ||
 ieee->current_network.mode == IEEE_G)
 && ieee->current_network.berp_info_valid) {
@@ -2610,7 +2612,7 @@ static inline void rtllib_process_probe_response(
network->ssid_len) == 0) &&
(ieee->state == RTLLIB_NOLINK
renew = 1;
-   update_network(target, network);
+   update_network(ieee, target, network);
if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
 

[PATCH v3 18/33] staging: rtl8192e: Remove remains of RTLLIB_*_DEBUG() (including proc entry)

2015-05-09 Thread Mateusz Kulikowski
Remove rest of rtllib "debug" system - it is no longer used -
proper netdev_* functions are used in most cases.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h| 45 --
 drivers/staging/rtl8192e/rtllib_module.c | 55 
 2 files changed, 100 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 0ee0107..8c614e0 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -641,51 +641,6 @@ enum wireless_network_type {
 #define OUI_SUBTYPE_WMM_PARAM  1
 #define OUI_SUBTYPE_QOS_CAPABI 5
 
-/* debug macros */
-/* To use the debug system;
- *
- * If you are defining a new debug classification, simply add it to the #define
- * list here in the form of:
- *
- * #define RTLLIB_DL_ VALUE
- *
- * shifting value to the left one bit from the previous entry.   should be
- * the name of the classification (for example, WEP)
- *
- * You then need to either add a RTLLIB__DEBUG() macro definition for your
- * classification, or use RTLLIB_DEBUG(RTLLIB_DL_, ...) whenever you want
- * to send output to that classification.
- *
- * To add your debug level to the list of levels seen when you perform
- *
- * % cat /proc/net/ipw/debug_level
- *
- * you simply need to add your entry to the ipw_debug_levels array.
- */
-
-#define RTLLIB_DL_INFO   (1<<0)
-#define RTLLIB_DL_WX   (1<<1)
-#define RTLLIB_DL_SCAN   (1<<2)
-#define RTLLIB_DL_STATE (1<<3)
-#define RTLLIB_DL_MGMT   (1<<4)
-#define RTLLIB_DL_FRAG   (1<<5)
-#define RTLLIB_DL_EAP (1<<6)
-#define RTLLIB_DL_DROP   (1<<7)
-
-#define RTLLIB_DL_TX   (1<<8)
-#define RTLLIB_DL_RX   (1<<9)
-
-#define RTLLIB_DL_HT  (1<<10)
-#define RTLLIB_DL_BA  (1<<11)
-#define RTLLIB_DL_TS  (1<<12)
-#define RTLLIB_DL_QOS (1<<13)
-#define RTLLIB_DL_REORDER (1<<14)
-#define RTLLIB_DL_IOT (1<<15)
-#define RTLLIB_DL_IPS (1<<16)
-#define RTLLIB_DL_TRACE   (1<<29)
-#define RTLLIB_DL_DATA(1<<30)
-#define RTLLIB_DL_ERR (1<<31)
-
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_IP   0x0800  /* Internet Protocol packet */
diff --git a/drivers/staging/rtl8192e/rtllib_module.c 
b/drivers/staging/rtl8192e/rtllib_module.c
index b61035b..845d9b8 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -196,68 +196,13 @@ void free_rtllib(struct net_device *dev)
 }
 EXPORT_SYMBOL(free_rtllib);
 
-u32 rtllib_debug_level;
-static int debug = RTLLIB_DL_ERR;
-static struct proc_dir_entry *rtllib_proc;
-
-static int show_debug_level(struct seq_file *m, void *v)
-{
-   seq_printf(m, "0x%08X\n", rtllib_debug_level);
-
-   return 0;
-}
-
-static ssize_t write_debug_level(struct file *file, const char __user *buffer,
-size_t count, loff_t *ppos)
-{
-   unsigned long val;
-   int err = kstrtoul_from_user(buffer, count, 0, &val);
-
-   if (err)
-   return err;
-   rtllib_debug_level = val;
-   return count;
-}
-
-static int open_debug_level(struct inode *inode, struct file *file)
-{
-   return single_open(file, show_debug_level, NULL);
-}
-
-static const struct file_operations fops = {
-   .open = open_debug_level,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .write = write_debug_level,
-   .release = single_release,
-};
-
 static int __init rtllib_init(void)
 {
-   struct proc_dir_entry *e;
-
-   rtllib_debug_level = debug;
-   rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
-   if (rtllib_proc == NULL) {
-   pr_err("Unable to create " DRV_NAME " proc directory\n");
-   return -EIO;
-   }
-   e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops);
-   if (!e) {
-   remove_proc_entry(DRV_NAME, init_net.proc_net);
-   rtllib_proc = NULL;
-   return -EIO;
-   }
return 0;
 }
 
 static void __exit rtllib_exit(void)
 {
-   if (rtllib_proc) {
-   remove_proc_entry("debug_level", rtllib_proc);
-   remove_proc_entry(DRV_NAME, init_net.proc_net);
-   rtllib_proc = NULL;
-   }
 }
 
 module_init(rtllib_init);
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 14/33] staging: rtl8192e: Remove RTLLIB_DEBUG_MGMT()

2015-05-09 Thread Mateusz Kulikowski
- Use netdev_dbg() instead of RTLLIB_DEBUG_MGMT()
- Remove RTLLIB_DEBUG_MGMT()
- Pass net_device to auth_parse(), auth_rq_parse() and assoc_rq_parse()
- Remove duplicated messages

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h |  2 -
 drivers/staging/rtl8192e/rtllib_rx.c  | 71 +++
 drivers/staging/rtl8192e/rtllib_softmac.c | 50 ++
 3 files changed, 58 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index a9b9cb9..faf94b4 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,8 +703,6 @@ do {
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
-
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_IP   0x0800  /* Internet Protocol packet */
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 1efdace..1c4eec2 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1925,8 +1925,8 @@ static void rtllib_parse_mife_generic(struct 
rtllib_device *ieee,
if (info_element->len > 4  && info_element->data[0] == 0x00 &&
info_element->data[1] == 0x50 && info_element->data[2] == 0xf2 &&
info_element->data[3] == 0x04) {
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n",
- info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_WZC: %d bytes\n",
+  info_element->len);
network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN);
memcpy(network->wzc_ie, info_element, network->wzc_ie_len);
}
@@ -1947,10 +1947,10 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
 
while (length >= sizeof(*info_element)) {
if (sizeof(*info_element) + info_element->len > length) {
-   RTLLIB_DEBUG_MGMT("Info elem: parse failed: 
info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
-info_element->len +
-sizeof(*info_element),
-length, info_element->id);
+   netdev_dbg(ieee->dev,
+  "Info elem: parse failed: info_element->len 
+ 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
+  info_element->len + sizeof(*info_element),
+  length, info_element->id);
/* We stop processing but don't return an error here
 * because some misbehaviour APs break this rule. ie.
 * Orinoco AP1000.
@@ -1973,8 +1973,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
memset(network->ssid + network->ssid_len, 0,
   IW_ESSID_MAX_SIZE - network->ssid_len);
 
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
-network->ssid, network->ssid_len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_SSID: '%s' len=%d.\n",
+  network->ssid, network->ssid_len);
break;
 
case MFIE_TYPE_RATES:
@@ -2001,8 +2001,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
}
}
 
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
-rates_str, network->rates_len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_RATES: '%s' (%d)\n",
+  rates_str, network->rates_len);
break;
 
case MFIE_TYPE_RATES_EX:
@@ -2024,22 +2024,22 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
}
}
 
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
-rates_str, network->rates_ex_len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_RATES_EX: '%s' (%d)\n",
+  rates_str, network->rates_ex_len);
  

[PATCH v3 16/33] staging: rtl8192e: Remove RTLLIB_DEBUG()

2015-05-09 Thread Mateusz Kulikowski
- Use netdev_dbg or netdev_vdbg instead of RTLLIB_DEBUG()
- Reformat some messages for better readability
- Remove RTLLIB_DEBUG messages that make no sense

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c | 35 +
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 21 ++---
 drivers/staging/rtl8192e/rtl819x_TSProc.c | 35 +
 drivers/staging/rtl8192e/rtllib.h |  5 ---
 drivers/staging/rtl8192e/rtllib_rx.c  | 52 +--
 5 files changed, 67 insertions(+), 81 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 7d72c19..39d28e3 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -84,9 +84,9 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
u8 *tag = NULL;
u16 len = ieee->tx_headroom + 9;
 
-   RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA,
-">%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n",
-__func__, type, Dst, ieee->dev);
+   netdev_dbg(ieee->dev, "%s(): frame(%d) sentd to: %pM, ieee->dev:%p\n",
+  __func__, type, Dst, ieee->dev);
+
if (pBA == NULL) {
netdev_warn(ieee->dev, "pBA is NULL\n");
return NULL;
@@ -148,9 +148,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
u16 len = 6 + ieee->tx_headroom;
 
if (net_ratelimit())
-   RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA,
-">%s(), ReasonCode(%d) sentd to: %pM\n",
-__func__, ReasonCode, dst);
+   netdev_dbg(ieee->dev, "%s(): ReasonCode(%d) sentd to: %pM\n",
+  __func__, ReasonCode, dst);
 
memset(&DelbaParamSet, 0, 2);
 
@@ -186,9 +185,6 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
tag += 2;
 
RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
-   if (net_ratelimit())
-   RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=%s()\n",
-__func__);
return skb;
 }
 
@@ -203,8 +199,7 @@ static void rtllib_send_ADDBAReq(struct rtllib_device 
*ieee, u8 *dst,
RT_TRACE(COMP_DBG, ">to send ADDBAREQ!\n");
softmac_mgmt_xmit(skb, ieee);
} else {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"alloc skb error in function %s()\n", __func__);
+   netdev_dbg(ieee->dev, "Failed to generate ADDBAReq packet.\n");
}
 }
 
@@ -217,8 +212,7 @@ static void rtllib_send_ADDBARsp(struct rtllib_device 
*ieee, u8 *dst,
if (skb)
softmac_mgmt_xmit(skb, ieee);
else
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"alloc skb error in function %s()\n", __func__);
+   netdev_dbg(ieee->dev, "Failed to generate ADDBARsp packet.\n");
 }
 
 static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
@@ -231,8 +225,7 @@ static void rtllib_send_DELBA(struct rtllib_device *ieee, 
u8 *dst,
if (skb)
softmac_mgmt_xmit(skb, ieee);
else
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"alloc skb error in function %s()\n", __func__);
+   netdev_dbg(ieee->dev, "Failed to generate DELBA packet.\n");
 }
 
 int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
@@ -374,20 +367,20 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct 
sk_buff *skb)
 
 
if (pAdmittedBA->bValid == true) {
-   RTLLIB_DEBUG(RTLLIB_DL_BA,
-"OnADDBARsp(): Recv ADDBA Rsp. Drop because 
already admit it!\n");
+   netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n",
+  __func__);
return -1;
} else if ((pPendingBA->bValid == false) ||
   (*pDialogToken != pPendingBA->DialogToken)) {
netdev_warn(ieee->dev,
-   "%s(): Recv ADDBA Rsp. BA invalid, DELBA!\n",
+   "%s(): ADDBA Rsp. BA invalid, DELBA!\n",
__func__);
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
} else {
-   RTLLIB_DEBUG(RTLLIB_DL_BA,
-"OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! 
Status code:%X\n",
-*pStatusCode);
+   netdev_dbg(ieee->dev,
+   

[PATCH v3 25/33] staging: rtl8192e: Remove unused rtl_crypto.h

2015-05-09 Thread Mateusz Kulikowski
This header is not used - remove it to make driver code smaller.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h | 382 -
 1 file changed, 382 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h
deleted file mode 100644
index ee57c0f..000
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Scatterlist Cryptographic API.
- *
- * Copyright (c) 2002 James Morris 
- * Copyright (c) 2002 David S. Miller (da...@redhat.com)
- *
- * Portions derived from Cryptoapi, by Alexander Kjeldaas 
- * and Nettle, by Niels Mé°ˆler.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- */
-#ifndef _LINUX_CRYPTO_H
-#define _LINUX_CRYPTO_H
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define crypto_register_alg crypto_register_alg_rsl
-#define crypto_unregister_alg crypto_unregister_alg_rsl
-#define crypto_alloc_tfm crypto_alloc_tfm_rsl
-#define crypto_free_tfm crypto_free_tfm_rsl
-#define crypto_alg_available crypto_alg_available_rsl
-
-/*
- * Algorithm masks and types.
- */
-#define CRYPTO_ALG_TYPE_MASK   0x00ff
-#define CRYPTO_ALG_TYPE_CIPHER 0x0001
-#define CRYPTO_ALG_TYPE_DIGEST 0x0002
-#define CRYPTO_ALG_TYPE_COMPRESS   0x0004
-
-/*
- * Transform masks and values (for crt_flags).
- */
-#define CRYPTO_TFM_MODE_MASK   0x00ff
-#define CRYPTO_TFM_REQ_MASK0x000fff00
-#define CRYPTO_TFM_RES_MASK0xfff0
-
-#define CRYPTO_TFM_MODE_ECB0x0001
-#define CRYPTO_TFM_MODE_CBC0x0002
-#define CRYPTO_TFM_MODE_CFB0x0004
-#define CRYPTO_TFM_MODE_CTR0x0008
-
-#define CRYPTO_TFM_REQ_WEAK_KEY0x0100
-#define CRYPTO_TFM_RES_WEAK_KEY0x0010
-#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x0020
-#define CRYPTO_TFM_RES_BAD_KEY_SCHED   0x0040
-#define CRYPTO_TFM_RES_BAD_BLOCK_LEN   0x0080
-#define CRYPTO_TFM_RES_BAD_FLAGS   0x0100
-
-/*
- * Miscellaneous stuff.
- */
-#define CRYPTO_UNSPEC  0
-#define CRYPTO_MAX_ALG_NAME64
-
-struct scatterlist;
-
-/*
- * Algorithms: modular crypto algorithm implementations, managed
- * via crypto_register_alg() and crypto_unregister_alg().
- */
-struct cipher_alg {
-   unsigned int cia_min_keysize;
-   unsigned int cia_max_keysize;
-   int (*cia_setkey)(void *ctx, const u8 *key,
- unsigned int keylen, u32 *flags);
-   void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src);
-   void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src);
-};
-
-struct digest_alg {
-   unsigned int dia_digestsize;
-   void (*dia_init)(void *ctx);
-   void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
-   void (*dia_final)(void *ctx, u8 *out);
-   int (*dia_setkey)(void *ctx, const u8 *key,
- unsigned int keylen, u32 *flags);
-};
-
-struct compress_alg {
-   int (*coa_init)(void *ctx);
-   void (*coa_exit)(void *ctx);
-   int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
-   u8 *dst, unsigned int *dlen);
-   int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen);
-};
-
-#define cra_cipher cra_u.cipher
-#define cra_digest cra_u.digest
-#define cra_compress   cra_u.compress
-
-struct crypto_alg {
-   struct list_head cra_list;
-   u32 cra_flags;
-   unsigned int cra_blocksize;
-   unsigned int cra_ctxsize;
-   const char cra_name[CRYPTO_MAX_ALG_NAME];
-
-   union {
-   struct cipher_alg cipher;
-   struct digest_alg digest;
-   struct compress_alg compress;
-   } cra_u;
-
-   struct module *cra_module;
-};
-
-/*
- * Algorithm registration interface.
- */
-int crypto_register_alg(struct crypto_alg *alg);
-int crypto_unregister_alg(struct crypto_alg *alg);
-
-/*
- * Algorithm query interface.
- */
-int crypto_alg_available(const char *name, u32 flags);
-
-/*
- * Transforms: user-instantiated objects which encapsulate algorithms
- * and core processing logic.  Managed via crypto_alloc_tfm() and
- * crypto_free_tfm(), as well as the various helpers below.
- */
-struct crypto_tfm;
-
-struct cipher_tfm {
-   void *cit_iv;
-   unsigned int cit_ivsize;
-   u32 cit_mode;
-   int (*cit_setkey)(struct crypto_tfm *tfm,
- const u8 *key, unsigned int keylen);
-   int (*cit_encrypt)(struct crypto_tfm *tfm

[PATCH v3 21/33] staging: rtl8192e: Fix LONG_LINE warnings

2015-05-09 Thread Mateusz Kulikowski
Fix most of simple LONG_LINE warnings. None of the changes should affect
behaviour of code, so several modifications are included in this patch:
- Code is reindented where needed
- Local variable names are compacted (priv -> p)
- Unnecessary casts are removed
- Nested ifs are replaced with logical and
- a = b = c = d expressions are split
- Replace if/then series with clamp_t()
- Removed unneeded scopes

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/dot11d.h  |   4 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  22 +--
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|  29 ++--
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c |   4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |   3 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 191 +
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |   3 +-
 drivers/staging/rtl8192e/rtl819x_HTProc.c  |   3 +-
 drivers/staging/rtl8192e/rtl819x_TSProc.c  |  21 ++-
 drivers/staging/rtl8192e/rtllib_rx.c   | 171 +++---
 drivers/staging/rtl8192e/rtllib_softmac.c  |  36 ++--
 drivers/staging/rtl8192e/rtllib_tx.c   |  41 ++---
 12 files changed, 314 insertions(+), 214 deletions(-)

diff --git a/drivers/staging/rtl8192e/dot11d.h 
b/drivers/staging/rtl8192e/dot11d.h
index aad3394..69e0f8f 100644
--- a/drivers/staging/rtl8192e/dot11d.h
+++ b/drivers/staging/rtl8192e/dot11d.h
@@ -74,8 +74,8 @@ static inline void cpMacAddr(unsigned char *des, unsigned 
char *src)
(GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
 
 #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa)\
-
ether_addr_equal_unaligned(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, \
-   __pTa)
+ether_addr_equal_unaligned( \
+   GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
 #define UPDATE_CIE_SRC(__pIeeeDev, __pTa)  \
cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index eb803dc..dd42097 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -30,7 +30,8 @@
 #include "rtl_dm.h"
 #include "rtl_wx.h"
 
-static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, 
EDCAPARA_VO};
+static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI,
+EDCAPARA_VO};
 
 void rtl8192e_start_beacon(struct net_device *dev)
 {
@@ -187,22 +188,21 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 
variable, u8 *val)
u8  u1bAIFS;
u32 u4bAcParam;
u8 mode = priv->rtllib->mode;
-   struct rtllib_qos_parameters *qos_parameters =
+   struct rtllib_qos_parameters *qop =
 &priv->rtllib->current_network.qos_data.parameters;
 
-   u1bAIFS = qos_parameters->aifs[pAcParam] *
+   u1bAIFS = qop->aifs[pAcParam] *
  ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime;
 
dm_init_edca_turbo(dev);
 
-   u4bAcParam = (((le16_to_cpu(
-   qos_parameters->tx_op_limit[pAcParam])) 
<<
-AC_PARAM_TXOP_LIMIT_OFFSET) |
-((le16_to_cpu(qos_parameters->cw_max[pAcParam])) <<
-AC_PARAM_ECW_MAX_OFFSET) |
-((le16_to_cpu(qos_parameters->cw_min[pAcParam])) <<
-AC_PARAM_ECW_MIN_OFFSET) |
-(((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
+   u4bAcParam = (le16_to_cpu(qop->tx_op_limit[pAcParam]) <<
+ AC_PARAM_TXOP_LIMIT_OFFSET) |
+   ((le16_to_cpu(qop->cw_max[pAcParam])) <<
+AC_PARAM_ECW_MAX_OFFSET) |
+   ((le16_to_cpu(qop->cw_min[pAcParam])) <<
+AC_PARAM_ECW_MIN_OFFSET) |
+   (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET);
 
RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n",
 __func__, eACI, u4bAcParam);
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index c465f87..02c5b0a 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -230,7 +230,7 @@ bool init_firmware(struct net_device *dev)
 
u32 file_length = 0;
u8  *mapped_file = NULL;
-   u8  init_step = 0;
+   u8  i = 0;
enum opt_rst_type rst_opt = OPT_SY

[PATCH v3 30/33] staging: rtl8192e: rtl8192_phy_checkBBAndRF(): Don't check MAC

2015-05-09 Thread Mateusz Kulikowski
This function never supported checking of MAC block.
Instead of printing several warnings - print it once and exit.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 0765c97..6c4832c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -504,13 +504,15 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev,
WriteAddr[HW90_BLOCK_RF] = 0x3;
RT_TRACE(COMP_PHY, "===>%s(), CheckBlock:%d\n", __func__,
 CheckBlock);
+
+   if (CheckBlock == HW90_BLOCK_MAC) {
+   netdev_warn(dev, "%s(): No checks available for MAC block.\n",
+   __func__);
+   return ret;
+   }
+
for (i = 0; i < CheckTimes; i++) {
switch (CheckBlock) {
-   case HW90_BLOCK_MAC:
-   RT_TRACE(COMP_ERR,
-"PHY_CheckBBRFOK(): Never Write 0x100 here!");
-   break;
-
case HW90_BLOCK_PHY0:
case HW90_BLOCK_PHY1:
write_nic_dword(dev, WriteAddr[CheckBlock],
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 26/33] staging: rtl8192e: Replace ?: with max_t

2015-05-09 Thread Mateusz Kulikowski
Improve readability and make checkpatch happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 2b337c4..5a08935 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1689,7 +1689,7 @@ static int rtllib_qos_convert_ac_to_parameters(struct 
rtllib_qos_parameter_info
qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
 
/* WMM spec P.11: The minimum value for AIFSN shall be 2 */
-   qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : 
qos_param->aifs[aci];
+   qos_param->aifs[aci] = max_t(u8, qos_param->aifs[aci], 2);
 
qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max &
 0x0F);
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 20/33] staging: rtl8192e: Fix PREFER_PR_LEVEL warnings

2015-05-09 Thread Mateusz Kulikowski
Fix most of remaining PREFER_PR_LEVEL warnings in rtllib.
Replace printk() with netdev_* if possible, pr_* in other cases.
All pr_* use __func__ to easily trace message back to rtllib

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_crypt_ccmp.c |  2 +-
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 63 
 drivers/staging/rtl8192e/rtllib_rx.c |  5 ++-
 3 files changed, 31 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c 
b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 7d486e8..3b596b2 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -69,7 +69,7 @@ static void *rtllib_ccmp_init(int key_idx)
 
priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tfm)) {
-   pr_debug("rtllib_crypt_ccmp: could not allocate crypto API 
aes\n");
+   pr_debug("%s(): could not allocate crypto API aes\n", __func__);
priv->tfm = NULL;
goto fail;
}
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c 
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 9ec2b48..d4882a3 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -68,8 +68,8 @@ static void *rtllib_tkip_init(int key_idx)
priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_arc4)) {
-   printk(KERN_DEBUG
-  "rtllib_crypt_tkip: could not allocate crypto API 
arc4\n");
+   pr_debug("%s(): could not allocate crypto API arc4\n",
+__func__);
priv->tx_tfm_arc4 = NULL;
goto fail;
}
@@ -77,8 +77,8 @@ static void *rtllib_tkip_init(int key_idx)
priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_michael)) {
-   printk(KERN_DEBUG
-  "rtllib_crypt_tkip: could not allocate crypto API 
michael_mic\n");
+   pr_debug("%s(): could not allocate crypto API michael_mic\n",
+__func__);
priv->tx_tfm_michael = NULL;
goto fail;
}
@@ -86,8 +86,8 @@ static void *rtllib_tkip_init(int key_idx)
priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm_arc4)) {
-   printk(KERN_DEBUG
-  "rtllib_crypt_tkip: could not allocate crypto API 
arc4\n");
+   pr_debug("%s(): could not allocate crypto API arc4\n",
+__func__);
priv->rx_tfm_arc4 = NULL;
goto fail;
}
@@ -95,8 +95,8 @@ static void *rtllib_tkip_init(int key_idx)
priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm_michael)) {
-   printk(KERN_DEBUG
-  "rtllib_crypt_tkip: could not allocate crypto API 
michael_mic\n");
+   pr_debug("%s: could not allocate crypto API michael_mic\n",
+__func__);
priv->rx_tfm_michael = NULL;
goto fail;
}
@@ -403,24 +403,21 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
if (net_ratelimit()) {
-   printk(KERN_DEBUG
-  "TKIP: received packet without ExtIV flag from 
%pM\n",
-  hdr->addr2);
+   pr_debug("%s(): received packet without ExtIV flag from 
%pM\n",
+__func__, hdr->addr2);
}
return -2;
}
keyidx >>= 6;
if (tkey->key_idx != keyidx) {
-   printk(KERN_DEBUG
-  "TKIP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
-  tkey->key_idx, keyidx, priv);
+   pr_debug("%s(): RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
+__func__, tkey->key_idx, keyidx, priv);
return -6;
}
if (!tkey->key_set) {
if (net_ratelimit()) {
-   printk(KERN_DEBUG
-  "TKIP: received packet from %pM with keyid=%d 
that does not have a configured key\n",
-  hdr-&g

[PATCH v3 22/33] staging: rtl8192e: Fix LONG_LING in rtllib_parse_info_param()

2015-05-09 Thread Mateusz Kulikowski
Take out MIFE_TYPE_HT_CAP processing into separate function -
rtllib_parse_mfie_ht_cap()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 49 +---
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 0843027..2b337c4 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1984,6 +1984,33 @@ static void rtllib_parse_mife_generic(struct 
rtllib_device *ieee,
}
 }
 
+static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element,
+struct rtllib_network *network,
+u16 *tmp_htcap_len)
+{
+   struct bss_ht *ht = &network->bssht;
+
+   *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
+   if (*tmp_htcap_len != 0) {
+   ht->bdHTSpecVer = HT_SPEC_VER_EWC;
+   ht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+  sizeof(ht->bdHTCapBuf));
+   memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen);
+
+   ht->bdSupportHT = true;
+   ht->bdHT1R = struct ht_capab_ele *)
+   ht->bdHTCapBuf))->MCS[1]) == 0;
+
+   ht->bdBandWidth = (enum ht_channel_width)
+(((struct ht_capab_ele *)
+(ht->bdHTCapBuf))->ChlWidth);
+   } else {
+   ht->bdSupportHT = false;
+   ht->bdHT1R = false;
+   ht->bdBandWidth = HT_CHANNEL_WIDTH_20;
+   }
+}
+
 int rtllib_parse_info_param(struct rtllib_device *ieee,
struct rtllib_info_element *info_element,
u16 length,
@@ -2165,27 +2192,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
case MFIE_TYPE_HT_CAP:
netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
   info_element->len);
-   tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
-   if (tmp_htcap_len != 0) {
-   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-   network->bssht.bdHTCapLen = tmp_htcap_len > 
sizeof(network->bssht.bdHTCapBuf) ?
-   sizeof(network->bssht.bdHTCapBuf) : 
tmp_htcap_len;
-   memcpy(network->bssht.bdHTCapBuf,
-  info_element->data,
-  network->bssht.bdHTCapLen);
 
-   network->bssht.bdSupportHT = true;
-   network->bssht.bdHT1R = struct ht_capab_ele 
*)
-   
network->bssht.bdHTCapBuf))->MCS[1]) == 0;
-
-   network->bssht.bdBandWidth = (enum 
ht_channel_width)
-(((struct 
ht_capab_ele *)
-
(network->bssht.bdHTCapBuf))->ChlWidth);
-   } else {
-   network->bssht.bdSupportHT = false;
-   network->bssht.bdHT1R = false;
-   network->bssht.bdBandWidth = 
HT_CHANNEL_WIDTH_20;
-   }
+   rtllib_parse_mfie_ht_cap(info_element, network,
+&tmp_htcap_len);
break;
 
 
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 23/33] staging: rtl8192e: Remove unimplemented iwpriv handlers

2015-05-09 Thread Mateusz Kulikowski
Remove the following private variables:
- force_mic_error - changes force_mic_error that is not used
- radio - changes sw_radio_on that is not used
- adhoc_peer_list - unimplemented
- firm_ver - unimplemented

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c |  1 -
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h |  1 -
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c   | 86 ++--
 drivers/staging/rtl8192e/rtllib.h|  1 -
 4 files changed, 4 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index c7c03f3..5ef87ba 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1118,7 +1118,6 @@ static void rtl8192_init_priv_variable(struct net_device 
*dev)
priv->bDriverIsGoingToUnload = false;
priv->being_init_adapter = false;
priv->initialized_at_probe = false;
-   priv->sw_radio_on = true;
priv->bdisable_nic = false;
priv->bfirst_init = false;
priv->txringcount = 64;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index 0640e76..6127e92 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -626,7 +626,6 @@ struct r8192_priv {
u8  RegCWinMin;
u8  keepAliveLevel;
 
-   boolsw_radio_on;
boolbHwRadioOff;
boolpwrdown;
boolblinked_ingpio;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 2ae2885..f1c066d 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -175,48 +175,6 @@ static int r8192_wx_force_reset(struct net_device *dev,
 
 }
 
-static int r8192_wx_force_mic_error(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
-{
-   struct r8192_priv *priv = rtllib_priv(dev);
-   struct rtllib_device *ieee = priv->rtllib;
-
-   down(&priv->wx_sem);
-
-   RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__);
-   ieee->force_mic_error = true;
-   up(&priv->wx_sem);
-   return 0;
-
-}
-
-#define MAX_ADHOC_PEER_NUM 64
-struct adhoc_peer_entry {
-   unsigned char MacAddr[ETH_ALEN] __aligned(2);
-   unsigned char WirelessMode;
-   unsigned char bCurTxBW40MHz;
-};
-struct adhoc_peers_info {
-   struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM];
-   unsigned char num;
-};
-
-static int r8192_wx_get_adhoc_peers(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
-{
-   return 0;
-}
-
-
-static int r8191se_wx_get_firm_version(struct net_device *dev,
-   struct iw_request_info *info,
-   struct iw_param *wrqu, char *extra)
-{
-   return 0;
-}
-
 static int r8192_wx_adapter_power_status(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -247,28 +205,6 @@ static int r8192_wx_adapter_power_status(struct net_device 
*dev,
return 0;
 }
 
-static int r8192se_wx_set_radio(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
-{
-   struct r8192_priv *priv = rtllib_priv(dev);
-
-   down(&priv->wx_sem);
-
-   netdev_info(dev, "%s(): set radio ! extra is %d\n", __func__, *extra);
-   if ((*extra != 0) && (*extra != 1)) {
-   RT_TRACE(COMP_ERR,
-"%s(): set radio an err value,must 0(radio off) or 
1(radio on)\n",
-__func__);
-   up(&priv->wx_sem);
-   return -1;
-   }
-   priv->sw_radio_on = *extra;
-   up(&priv->wx_sem);
-   return 0;
-
-}
-
 static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -1241,21 +1177,10 @@ static const struct iw_priv_args r8192_private_args[] = 
{
SIOCIWFIRSTPRIV + 0x3,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
}, {
-   SIOCIWFIRSTPRIV + 0x4,
-   IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error"
-   }, {
-   SIOCIWFIRSTPRIV + 0x5,
-   IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
-   "firm_ver"
-   }, {
SIOCIWFIRSTPRIV + 0x6,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
  

[PATCH v3 11/33] staging: rtl8192e: Remove RTLLIB_DEBUG_SCAN()

2015-05-09 Thread Mateusz Kulikowski
Use netdev_dbg() instead, remove duplicated logs.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|   1 -
 drivers/staging/rtl8192e/rtllib_rx.c | 101 ---
 drivers/staging/rtl8192e/rtllib_wx.c |  12 +++--
 3 files changed, 54 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 4edbc87..f7b741e 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,7 +703,6 @@ do {
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_SCAN(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
 #define RTLLIB_DEBUG_STATE(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
 #define RTLLIB_DEBUG_FRAG(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index e553b1f..9b57c7e 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2103,8 +2103,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
 
case MFIE_TYPE_HT_CAP:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
+  info_element->len);
tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
if (tmp_htcap_len != 0) {
network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
@@ -2130,8 +2130,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
 
 
case MFIE_TYPE_HT_INFO:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n",
+  info_element->len);
tmp_htinfo_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
if (tmp_htinfo_len) {
network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
@@ -2146,8 +2146,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
 
case MFIE_TYPE_AIRONET:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_AIRONET: %d bytes\n",
+  info_element->len);
if (info_element->len > IE_CISCO_FLAG_POSITION) {
network->bWithAironetIE = true;
 
@@ -2169,8 +2169,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
 
case MFIE_TYPE_COUNTRY:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_COUNTRY: %d bytes\n",
+  info_element->len);
rtllib_extract_country_ie(ieee, info_element, network,
  network->bssid);
break;
@@ -2277,10 +2277,9 @@ static inline int rtllib_network_init(
}
 
if (network->mode == 0) {
-   RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' network.\n",
-escape_essid(network->ssid,
- network->ssid_len),
-network->bssid);
+   netdev_dbg(ieee->dev, "Filtered out '%s (%pM)' network.\n",
+  escape_essid(network->ssid, network->ssid_len),
+  network->bssid);
return 1;
}
 
@@ -2478,33 +2477,32 @@ static inline void rtllib_process_probe_response(
if (!network)
return;
 
-   RTLLIB_DEBUG_SCAN(
-   "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
-   escape_essid(info_element->data, info_element->len),
-   beacon->header.addr3,
-   (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0',
-   (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1'

[PATCH v3 31/33] staging: rtl8192e: Replace RT_TRACE(COMP_ERR, ...) with netdev_*

2015-05-09 Thread Mateusz Kulikowski
- Use netdev_* with log level depending on how serious error is
- Rework some messages to be more readable
- Pass net_device where needed for pretty prints

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c |  24 +++--
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  31 ---
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|  13 +--
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 100 ++---
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c|  18 ++--
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |  65 ++
 drivers/staging/rtl8192e/rtl8192e/rtl_ps.c |   4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |  14 ++-
 8 files changed, 127 insertions(+), 142 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
index f080a91..facc6f1 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
@@ -47,8 +47,8 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
0x0e, bMask12Bits, 0x021);
 
} else {
-   RT_TRACE(COMP_ERR,
-"PHY_SetRF8256Bandwidth(): unknown 
hardware version\n");
+   netdev_warn(dev, "%s(): Unknown HW version.\n",
+   __func__);
}
 
break;
@@ -66,16 +66,15 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
 0x0e, bMask12Bits, 0x0e1);
 
} else {
-   RT_TRACE(COMP_ERR,
-"PHY_SetRF8256Bandwidth(): unknown 
hardware version\n");
+   netdev_warn(dev, "%s(): Unknown HW version.\n",
+   __func__);
}
 
 
break;
default:
-   RT_TRACE(COMP_ERR,
-"PHY_SetRF8256Bandwidth(): unknown Bandwidth: 
%#X\n",
-Bandwidth);
+   netdev_err(dev, "%s(): Unknown bandwidth: %#X\n",
+  __func__, Bandwidth);
break;
 
}
@@ -139,9 +138,8 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF,
(enum rf90_radio_path)eRFPath);
if (!rtStatus) {
-   RT_TRACE(COMP_ERR,
-"PHY_RF8256_Config():Check Radio[%d] Fail!!\n",
-eRFPath);
+   netdev_err(dev, "%s(): Failed to check RF Path %d.\n",
+  __func__, eRFPath);
goto phy_RF8256_Config_ParaFile_Fail;
}
 
@@ -227,9 +225,9 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
}
 
if (ret) {
-   RT_TRACE(COMP_ERR,
-"phy_RF8256_Config_ParaFile():Radio[%d] 
Fail!!",
-eRFPath);
+   netdev_err(dev,
+  "%s(): Failed to initialize RF Path %d.\n",
+  __func__, eRFPath);
goto phy_RF8256_Config_ParaFile_Fail;
}
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index dd42097..fc58dfe 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -328,8 +328,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 
EEPROMId = eprom_read(dev, 0);
if (EEPROMId != RTL8190_EEPROM_ID) {
-   RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n",
-EEPROMId, RTL8190_EEPROM_ID);
+   netdev_err(dev, "%s(): Invalid EEPROM ID: %x\n", __func__,
+  EEPROMId);
priv->AutoloadFailFlag = true;
} else {
priv->AutoloadFailFlag = false;
@@ -738,9 +738,8 @@ start:
else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
ulRegRead |= CPU_GEN_FIRMWARE_RESET;
else
-   RT_TRACE(COMP_ERR,
-"ERROR in %s(): undefined firmware state(%d)\n",
-__func__,   priv->pFirmware->firmware_status);
+   netdev_err(dev, "%s(): undefined firmware stat

[PATCH v3 17/33] staging: rtl8192e: Remove RTLLIB_DEBUG_DATA()

2015-05-09 Thread Mateusz Kulikowski
Use print_hex_dump_bytes() if VERBOSE_DEBUG is enabled.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c | 20 
 drivers/staging/rtl8192e/rtl819x_HTProc.c |  7 +--
 drivers/staging/rtl8192e/rtllib.h | 11 ---
 drivers/staging/rtl8192e/rtllib_tx.c  |  5 -
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 39d28e3..25765b8 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -133,7 +133,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
tag += 2;
}
 
-   RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+   print_hex_dump_bytes("rtllib_ADDBA(): ", DUMP_PREFIX_NONE, skb->data,
+skb->len);
+#endif
return skb;
 }
 
@@ -184,7 +187,10 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
put_unaligned_le16(ReasonCode, tag);
tag += 2;
 
-   RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+   print_hex_dump_bytes("rtllib_DELBA(): ", DUMP_PREFIX_NONE, skb->data,
+skb->len);
+#endif
return skb;
 }
 
@@ -246,7 +252,10 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct 
sk_buff *skb)
return -1;
}
 
-   RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+   print_hex_dump_bytes("rtllib_rx_ADDBAReq(): ", DUMP_PREFIX_NONE,
+skb->data, skb->len);
+#endif
 
req = (struct rtllib_hdr_3addr *) skb->data;
tag = (u8 *)req;
@@ -442,7 +451,10 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct 
sk_buff *skb)
return -1;
}
 
-   RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+   print_hex_dump_bytes("rtllib_rx_DELBA(): ", DUMP_PREFIX_NONE, skb->data,
+skb->len);
+#endif
delba = (struct rtllib_hdr_3addr *)skb->data;
dst = (u8 *)(&delba->addr2[0]);
delba += sizeof(struct rtllib_hdr_3addr);
diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 584f7a9..3edd5d1 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -553,8 +553,11 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
else
pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf);
 
-   RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap,
- sizeof(struct ht_capab_ele));
+
+#ifdef VERBOSE_DEBUG
+   print_hex_dump_bytes("HTOnAssocRsp(): ", DUMP_PREFIX_NONE,
+pPeerHTCap, sizeof(struct ht_capab_ele));
+#endif
HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth),
  (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset));
pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ?
diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index e294234..0ee0107 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -642,17 +642,6 @@ enum wireless_network_type {
 #define OUI_SUBTYPE_QOS_CAPABI 5
 
 /* debug macros */
-extern u32 rtllib_debug_level;
-
-#define RTLLIB_DEBUG_DATA(level, data, datalen)\
-   do {\
-   if ((rtllib_debug_level & (level)) == (level)) {\
-   printk(KERN_DEBUG "rtllib: %s()\n", __func__);  \
-   print_hex_dump_bytes(KERN_DEBUG, DUMP_PREFIX_NONE, \
-data, datalen); \
-   }   \
-   } while (0)
-
 /* To use the debug system;
  *
  * If you are defining a new debug classification, simply add it to the #define
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c 
b/drivers/staging/rtl8192e/rtllib_tx.c
index d0672f0..05cf95c 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -260,7 +260,10 @@ static int rtllib_classify(struct sk_buff *skb, u8 
bIsAmsdu)
if (eth->h_proto != htons(ETH_P_IP))
return 0;
 
-   RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+   print_hex_dump_bytes("rtllib_classify(): ", DUMP_PREFIX_NONE, skb->data,
+skb->len);
+#endif
ip = ip_hdr(skb);
 

[PATCH v3 29/33] staging: rtl8192e: Remove unneeded RT_TRACE(COMP_ERR, ...)

2015-05-09 Thread Mateusz Kulikowski
This messages are not needed, as failure is reported earlier in code.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c  | 1 -
 drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
index 01d2201..f080a91 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
@@ -239,7 +239,6 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
return true;
 
 phy_RF8256_Config_ParaFile_Fail:
-   RT_TRACE(COMP_ERR, "PHY Initialization failed\n");
return false;
 }
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index 02c5b0a..54e430e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -171,7 +171,6 @@ static bool CPUcheck_firmware_ready(struct net_device *dev)
return rt_status;
 
 CPUCheckFirmwareReady_Fail:
-   RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
rt_status = false;
return rt_status;
 
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 32/33] staging: rtl8192e: Fix trivial LONG_LINE errors

2015-05-09 Thread Mateusz Kulikowski
Reindent lines to make checkpatch happy.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 83 +++---
 drivers/staging/rtl8192e/rtllib_rx.c   | 18 ---
 2 files changed, 65 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index a921857..d480229 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -403,16 +403,16 @@ static void dm_check_rate_adaptive(struct net_device *dev)
((bshort_gi_enabled) ? BIT31 : 0);
 
if (pra->ratr_state == DM_RATR_STA_HIGH) {
-   HighRSSIThreshForRA = 
pra->high2low_rssi_thresh_for_ra;
-   LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
+   HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra;
+   LowRSSIThreshForRA = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
(pra->low_rssi_thresh_for_ra40M) : 
(pra->low_rssi_thresh_for_ra20M);
} else if (pra->ratr_state == DM_RATR_STA_LOW) {
-   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
-   LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
+   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+   LowRSSIThreshForRA = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
(pra->low2high_rssi_thresh_for_ra40M) : 
(pra->low2high_rssi_thresh_for_ra20M);
} else {
-   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
-   LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
+   HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+   LowRSSIThreshForRA = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
(pra->low_rssi_thresh_for_ra40M) : 
(pra->low_rssi_thresh_for_ra20M);
}
 
@@ -749,7 +749,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
 "Avg_TSSI_Meas_from_driver = %d\n",
 Avg_TSSI_Meas_from_driver);
TSSI_13dBm = priv->TSSI_13dBm;
-   RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", 
TSSI_13dBm);
+   RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n",
+TSSI_13dBm);
 
if (Avg_TSSI_Meas_from_driver > TSSI_13dBm)
delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm;
@@ -828,11 +829,13 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
 "priv->CCKPresentAttentuation = %d\n",
 priv->CCKPresentAttentuation);
 
-   if (priv->CCKPresentAttentuation_difference <= -12 || 
priv->CCKPresentAttentuation_difference >= 24) {
+   if (priv->CCKPresentAttentuation_difference <= -12 ||
+   priv->CCKPresentAttentuation_difference >= 24) {
priv->rtllib->bdynamic_txpower_enable = true;
write_nic_byte(dev, Pw_Track_Flag, 0);
write_nic_byte(dev, FW_Busy_Flag, 0);
-   RT_TRACE(COMP_POWER_TRACKING, "tx power 
track--->limited\n");
+   RT_TRACE(COMP_POWER_TRACKING,
+"tx power track--->limited\n");
return;
}
 
@@ -1233,18 +1236,28 @@ static void dm_bb_initialgain_restore(struct net_device 
*dev)
return;
 
rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);
-   rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, 
(u32)priv->initgain_backup.xaagccore1);
-   rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, 
(u32)priv->initgain_backup.xbagccore1);
-   rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, 
(u32)priv->initgain_backup.xcagccore1);
-   rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, 
(u32)priv->initgain_backup.xdagccore1);
+   rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask,
+(u32)priv->initgain_backup.xaagccore1);
+   rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask,
+(u32)priv->initgain_backup.xbagccore1);
+   rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask,
+(u32)pri

[PATCH v3 28/33] staging: rtl8192e: Replace ?: with max

2015-05-09 Thread Mateusz Kulikowski
Warninig is printed if precision is lost - it can't happen at moment as
all get_key implementations return either -1 or small buffers.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_wx.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index 2ac1617..22bea5a 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -510,7 +510,10 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
return 0;
}
len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
-   erq->length = (len >= 0 ? len : 0);
+   if (len > U16_MAX)
+   netdev_err(ieee->dev, "Too long key returned.\n");
+
+   erq->length = max(len, 0);
 
erq->flags |= IW_ENCODE_ENABLED;
 
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 27/33] staging: rtl8192e: Replace ?: with min_t

2015-05-09 Thread Mateusz Kulikowski
Replace :? with min_t for readability. Remove check that is always false.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 8 +---
 drivers/staging/rtl8192e/rtllib_wx.c | 3 +--
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c 
b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index d5e13a5..86f52ac7 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -454,13 +454,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
 
proto_started = ieee->proto_started;
 
-   len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length :
-  IW_ESSID_MAX_SIZE;
-
-   if (len > IW_ESSID_MAX_SIZE) {
-   ret = -E2BIG;
-   goto out;
-   }
+   len = min_t(__u16, wrqu->essid.length, IW_ESSID_MAX_SIZE);
 
if (ieee->iw_mode == IW_MODE_MONITOR) {
ret = -1;
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index 2812a77..2ac1617 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -851,8 +851,7 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 
*ie, size_t len)
if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2],
 wps_oui, 4))) {
 
-   ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len) :
-  (MAX_WZC_IE_LEN);
+   ieee->wps_ie_len = min_t(size_t, len, MAX_WZC_IE_LEN);
buf = kmemdup(ie, ieee->wps_ie_len, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 33/33] staging: rtl8192e: rtl8192E_suspend(): Fix WOL reporting

2015-05-09 Thread Mateusz Kulikowski
WOL capability was reported in an awkward way - print it nicely.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_pm.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
index ca6ecfc..e4908672 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
@@ -57,10 +57,8 @@ int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t 
state)
write_nic_byte(dev, MacBlkCtrl, 0xa);
}
 out_pci_suspend:
-   netdev_info(dev, "r8192E support WOL call??\n");
-   if (priv->rtllib->bSupportRemoteWakeUp)
-   RT_TRACE(COMP_POWER,
-"r8192E support WOL call!!.\n");
+   netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ?
+   "Supported" : "Not supported");
pci_save_state(pdev);
pci_disable_device(pdev);
pci_enable_wake(pdev, pci_choose_state(pdev, state),
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 01/33] staging: rtl8192e: Declare ethernet addresses as __aligned(2)

2015-05-12 Thread Mateusz Kulikowski
On 10.05.2015 00:29, Joe Perches wrote:
> On Sat, 2015-05-09 at 23:18 +0200, Mateusz Kulikowski wrote:
>> Add __aligned(2) into ethernet addresses allocated on stack or in non-packed
>> structures. Use ETH_ALEN as array length in places where it was hardcoded to 
>> 6.
> []
>> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
>> b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> []
>> @@ -321,7 +321,8 @@ static void rtl8192_read_eeprom_info(struct net_device 
>> *dev)
>>  u8 ICVer8192, ICVer8256;
>>  u16 i, usValue, IC_Version;
>>  u16 EEPROMId;
>> -u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
>> +u8 bMac_Tmp_Addr[ETH_ALEN] __aligned(2) = {0x00, 0xe0, 0x4c,
>> +   0x00, 0x00, 0x01};
> 
> While this is safe, as this follows a u16, it's unnecessary.
> 
> Also, ideally, this would be
>   u8 foo[ETH_ALEN] = {
>   1, 2, 3, 4, 5, 6
>   };
> or just left on a single line.

I put __aligned to most places to show authors intention and to prevent someone 
from breaking it by 
(for example) removing u16 above due some refactoring.

If you insist - I will remove it.

> 
>> diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
>> b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
> []
>> @@ -2573,8 +2573,9 @@ static int rtl8192_ioctl(struct net_device *dev, 
>> struct ifreq *rq, int cmd)
>>  int ret = -1;
>>  struct rtllib_device *ieee = priv->rtllib;
>>  u32 key[4];
>> -u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
>> -u8 zero_addr[6] = {0};
>> +u8 broadcast_addr[ETH_ALEN] __aligned(2) = {0xff, 0xff, 0xff,
>> +0xff, 0xff, 0xff};
>> +u8 zero_addr[ETH_ALEN] __aligned(2) = {0};
> 
> If these are used only in tests, these are probably better
> being removed and using is__ether_addr or maybe
> if these used in things other than tests, being converted
> to static const so they are not reinitialized on each
> call of the function.
> 

zero_addr in fact is used only for comparison - I'll use is_eth_zero_addr;

broadcast is used as parameter so will make it static const (and update used 
functions to accept const ethaddr)

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 02/33] staging: rtl8192e: Fix PREFER_ETHER_ADDR_COPY warnings

2015-05-12 Thread Mateusz Kulikowski
On 10.05.2015 15:19, Greg KH wrote:
> On Sat, May 09, 2015 at 11:18:50PM +0200, Mateusz Kulikowski wrote:
>> Replace memcpy() with ether_addr_copy() where possible to make
>> checkpatch.pl happy.
> 
> I need proof that this is ok to do, please provide that in the changelog
> entry.

What kind of proof do you expect?

I've added BUG into ether_addr_copy (on unaligned addresses) and did some basic 
networking tests (pings using WPA2/CCMP AP). Of course I haven't done 100% 
coverage 
test to driver.

Additionally I manually analyzed code (although human errors are possible).

Do you want me to run some static analyzer as well? Or are this two enough 
(just add them to changelog).


Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 03/33] staging: rtl8192e: Mark unaligned memcpy()

2015-05-12 Thread Mateusz Kulikowski
On 11.05.2015 10:26, Dan Carpenter wrote:
(...)
>>   */
>>  skb_pull(sub_skb, SNAP_SIZE);
>> -memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
>> ETH_ALEN);
>> -memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
>> ETH_ALEN);
>> +memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src,
>> +   ETH_ALEN); /* Must be unaligned */
> 
> 
> Which part isn't aligned?  I think they both are.
> 
struct rtllib_rxb *prxb = prxbIndicateArray[j];

struct rtllib_rxb {
u8 nr_subframes;
struct sk_buff *subframes[MAX_SUBFRAME_COUNT == 64];
u8 dst[ETH_ALEN]; // here
u8 src[ETH_ALEN]; // here
} __packed;

Either I forgot alignment / packing rules or this fields are never aligned "by 
design".

If I remember correctly - I missed it in the first version as well, but then 
added BUG into ether_addr_copy().

Regards, 
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 03/33] staging: rtl8192e: Mark unaligned memcpy()

2015-05-12 Thread Mateusz Kulikowski
On 10.05.2015 15:20, Greg KH wrote:
> On Sat, May 09, 2015 at 11:18:51PM +0200, Mateusz Kulikowski wrote:
>> Comment unaligned memcpy() that trigger PREFER_ETHER_ADDR_COPY
>> checkpatch.pl warning.
>> It will prevent accidential "Fix" to ether_addr_copy().
> 
> What do you mean by this?  Why will the comment remove the issue?
> 

It will not, It will prevent people from sending checkpatch 'fixes' 
until I (or someone else) will submit ultimate fix - that is  
ether_addr_copy_unaligned().

I didn't included it into this series, as this requires cross-tree 
synchronization (net + staging) and I prefer to do it later in a 
smaller changeset (2 patches - one for net, one for staging).

If you think it's unnecessary, I'll throw it away in v4.

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 28/33] staging: rtl8192e: Replace ?: with max

2015-05-12 Thread Mateusz Kulikowski
On 11.05.2015 15:22, Dan Carpenter wrote:
> On Sat, May 09, 2015 at 11:19:16PM +0200, Mateusz Kulikowski wrote:
(...)
>>  len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
>> -erq->length = (len >= 0 ? len : 0);
>> +if (len > U16_MAX)
>> +netdev_err(ieee->dev, "Too long key returned.\n");
> 
> Just delete the check if it can't happen or handle the error properly.
> Never printed messages can be annoying.  Static checkers assume all
> conditions can happen so never true conditions are confusing.  It wastes
> RAM.

Ok, will do, thanks.

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 20/33] staging: rtl8192e: Fix PREFER_PR_LEVEL warnings

2015-05-12 Thread Mateusz Kulikowski
On 10.05.2015 00:37, Joe Perches wrote:
> On Sat, 2015-05-09 at 23:19 +0200, Mateusz Kulikowski wrote:
>> Fix most of remaining PREFER_PR_LEVEL warnings in rtllib.
>> Replace printk() with netdev_* if possible, pr_* in other cases.
>> All pr_* use __func__ to easily trace message back to rtllib
> 
> It's more common to use %s: and not %s():
> but it's generally even better not to use these
> at all and use dynamic_debug to add the function
> name when desired.

I wasn't aware of that - thanks for the tip.
In that case I'll throw away function names in all _dbg messages for v4.

>> diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c 
>> b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
(...)
>>  hdr = (struct rtllib_hdr_4addr *) skb->data;
>> -printk(KERN_DEBUG
>> -   "%s: Michael MIC verification failed for MSDU from %pM 
>> keyidx=%d\n",
>> -   skb->dev ? skb->dev->name : "N/A", hdr->addr2,
>> -   keyidx);
>> -printk(KERN_DEBUG "%d\n",
>> -   memcmp(mic, skb->data + skb->len - 8, 8) != 0);
>> +pr_debug("%s: Michael MIC verification failed for MSDU from %pM 
>> keyidx=%d\n",
>> + skb->dev ? skb->dev->name : "N/A", hdr->addr2,
>> + keyidx);
> 
> Not that it's necessary, but are this and below
> missing __func__?

It prints device name in an awkward way - I must missed this one during review 
as 
it is the place where netdev_dbg() should be used.

Will do it the right way in v4.

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 07/33] staging: rtl8192e: Replace RTLLIB_DEBUG(DL_ERR) with netdev_*()

2015-05-12 Thread Mateusz Kulikowski
On 10.05.2015 09:53, Sudip Mukherjee wrote:
> On Sat, May 09, 2015 at 11:18:55PM +0200, Mateusz Kulikowski wrote:
>> Replace all RTLLIB_DEBUG(RTLLIB_DL_ERR, *) calls with netdev_err()
>> for errors that really should be reported to user.
>> Use netdev_warn() for the rest.
>> Rephrase some of the messages to make them more readable/compact.
> checkpatch is saying :
> CHECK: Alignment should match open parenthesis
> #332: FILE: drivers/staging/rtl8192e/rtl819x_TSProc.c:82:
> + netdev_warn(ieee->dev,
> +"%s(): Rx Reorder struct buffer full\n",
> 

That's clearly a typo - thanks - will fix it - checkpatch didn't noticed 
that in non-strict mode.

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 04/33] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param()

2015-05-12 Thread Mateusz Kulikowski
On 11.05.2015 15:48, Dan Carpenter wrote:
> On Sat, May 09, 2015 at 11:18:52PM +0200, Mateusz Kulikowski wrote:
>> +if (info_element->len >= 4 &&
>> +info_element->data[0] == 0x00 && info_element->data[1] == 0x50 &&
>> +info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) {
> 
> 
> This if statement was actually easier to read in the original code:
> 
>   if (info_element->len >= 4 &&
>   info_element->data[0] == 0x00 &&
>   info_element->data[1] == 0x50 &&
>   info_element->data[2] == 0xf2 &&
>   info_element->data[3] == 0x01) {
> 
> Your eye can immediately spot the bits which are different on each line
> when they are lined up like that.

You're right - will fix that.

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 04/33] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param()

2015-05-12 Thread Mateusz Kulikowski
On 10.05.2015 09:49, Sudip Mukherjee wrote:
> On Sat, May 09, 2015 at 11:18:52PM +0200, Mateusz Kulikowski wrote:
>> Move MFIE_TYPE_GENERIC handler to rtllib_parse_mife_generic() function.
>> Code was not altered significantly, therefore in some places it generates
>> LONG_LINE checkpatch.pl warnings.
> apart from long line it is also giving warnings for:

You're running checkpatch --strict right?

> 1) multiple blank lines
> 2) Blank lines aren't necessary before a close brace
> 3) spaces preferred around that '+'

I will fix them (as they're pretty straightforward), and will 
probably do --strict checks for my patches in future;

I will not fix more complex checks in such cases, because patch like this
was supposed to simplify function (i.e. split it) - without changing 
it's code too much.

Is it ok with you?

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 02/33] staging: rtl8192e: Fix PREFER_ETHER_ADDR_COPY warnings

2015-05-14 Thread Mateusz Kulikowski
On 12.05.2015 23:19, Greg KH wrote:
> On Tue, May 12, 2015 at 09:52:01PM +0200, Mateusz Kulikowski wrote:
>> On 10.05.2015 15:19, Greg KH wrote:
>>> On Sat, May 09, 2015 at 11:18:50PM +0200, Mateusz Kulikowski wrote:
>>>> Replace memcpy() with ether_addr_copy() where possible to make
>>>> checkpatch.pl happy.
>>>
>>> I need proof that this is ok to do, please provide that in the changelog
>>> entry.
>>
>> What kind of proof do you expect?
> 
> Something, you can't just have this single line here and assume that I
> "know" you actually checked this...
> 

Of course - I understand that (now).

What I meant by this question was - Are the steps I took to verify patch
enough for you (so I'll add information about them to v4 changelog) or do you 
require 
more checks from my side (for example using static code analyzer).

I assume it's enough and just put it into changelog.


Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 03/33] staging: rtl8192e: Mark unaligned memcpy()

2015-05-14 Thread Mateusz Kulikowski
On 13.05.2015 10:22, Dan Carpenter wrote:
> On Tue, May 12, 2015 at 10:00:13PM +0200, Mateusz Kulikowski wrote:
>> On 11.05.2015 10:26, Dan Carpenter wrote:
(...)
>>>
>>> Which part isn't aligned?  I think they both are.
>>>
>> struct rtllib_rxb *prxb = prxbIndicateArray[j];
>>
>> struct rtllib_rxb {
>>  u8 nr_subframes;
>>  struct sk_buff *subframes[MAX_SUBFRAME_COUNT == 64];
>>  u8 dst[ETH_ALEN]; // here
>>  u8 src[ETH_ALEN]; // here
>> } __packed;
>>
>> Either I forgot alignment / packing rules or this fields are never aligned 
>> "by design".
> 
> You must have forgotten something...  Everything after the pointer is
> going to be aligned sizeof(void *).

That would be true, if structure was not __packed:

$ pahole drivers/staging/rtl8192e/rtllib.ko -C rtllib_rxb
struct rtllib_rxb {
u8 nr_subframes; /* 0 1 */
struct sk_buff *   subframes[64];/* 1   256 */
/* --- cacheline 4 boundary (256 bytes) was 1 bytes ago --- */
u8 dst[6];   /*   257 6 */
u8 src[6];   /*   263 6 */

/* size: 269, cachelines: 5, members: 4 */
/* last cacheline: 13 bytes */
};

Am I right?

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 03/33] staging: rtl8192e: Mark unaligned memcpy()

2015-05-17 Thread Mateusz Kulikowski
On 15.05.2015 01:14, Dan Carpenter wrote:
> On Thu, May 14, 2015 at 10:29:39PM +0200, Mateusz Kulikowski wrote:
>> On 13.05.2015 10:22, Dan Carpenter wrote:
>>> On Tue, May 12, 2015 at 10:00:13PM +0200, Mateusz Kulikowski wrote:
>>>> On 11.05.2015 10:26, Dan Carpenter wrote:
>> (...)
>>>>>
>>>>> Which part isn't aligned?  I think they both are.
>>>>>
>>>> struct rtllib_rxb *prxb = prxbIndicateArray[j];
>>>>
>>>> struct rtllib_rxb {
>>>>u8 nr_subframes;
>>>>struct sk_buff *subframes[MAX_SUBFRAME_COUNT == 64];
>>>>u8 dst[ETH_ALEN]; // here
>>>>u8 src[ETH_ALEN]; // here
>>>> } __packed;
(...)
> 
> I'm not positive it's "by design" though, this is staging code so maybe
> they just added __packed to every struct.  In fact, I'm pretty sure
> unaligned pointers don't work on some arches so the __packed is probably
> a bug.
> 

I doubt anyone uses it on anything else than some low cost x86 netbooks. 

I removed __packed and did a small test today (download 10mb of garbage, check 
md5)
- it doesn't seem to affect driver (on staging-testing, without this patchset).

Nevertheless I would prefer to leave it like that for this patch set if it's
OK with you and perhaps include it for next series I'll work on.

Regards,
Mateusz

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192e: replace printk with subsystem debug

2015-05-18 Thread Mateusz Kulikowski
Hi,

On 18.05.2015 13:27, Gujulan Elango, Hari Prasath (H.) wrote:
> replace the printk with netdev subsystem debug infrastructure.
> 
> Signed-off-by: Hari Prasath Gujulan Elango 
> ---
>  drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
> b/drivers/staging/rtl8192e/rtllib_rx.c
> index fe3e7e12..f6e3f83 100644
> --- a/drivers/staging/rtl8192e/rtllib_rx.c
> +++ b/drivers/staging/rtl8192e/rtllib_rx.c
> @@ -344,7 +344,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, 
> struct sk_buff *skb,
>   res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
>   atomic_dec(&crypt->refcnt);
>   if (res < 0) {
> - printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed 
> (SA= %pM keyidx=%d)\n",
> + netdev_dbg(ieee->dev, "%s: MSDU decryption/MIC verification 
> failed (SA= %pM keyidx=%d)\n",
>  ieee->dev->name, hdr->addr2, keyidx);
>   return -1;
>   }
> 
I posted it already in one of my patches (v2, v3 - now I'm working on v4 with 
this change as well):
https://lkml.org/lkml/2015/5/9/200 <- v3
https://lkml.org/lkml/2015/4/13 <- v2

Regards,
Mateusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 02/35] staging: rtl8192e: Declare ethernet addresses as __aligned(2)

2015-05-21 Thread Mateusz Kulikowski
Add __aligned(2) into ethernet addresses allocated on stack or in non-packed
structures. Use ETH_ALEN as array length in places where it was hardcoded to 6.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  4 +++-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |  8 
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |  8 +---
 drivers/staging/rtl8192e/rtl819x_Qos.h |  4 ++--
 drivers/staging/rtl8192e/rtl819x_TS.h  |  2 +-
 drivers/staging/rtl8192e/rtllib.h  | 10 +-
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   |  3 ++-
 drivers/staging/rtl8192e/rtllib_rx.c   |  6 +-
 drivers/staging/rtl8192e/rtllib_softmac.c  | 10 ++
 drivers/staging/rtl8192e/rtllib_tx.c   |  3 ++-
 10 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index aad5cc9..9c6dc82 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -321,7 +321,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
u8 ICVer8192, ICVer8256;
u16 i, usValue, IC_Version;
u16 EEPROMId;
-   u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
+   static const u8 bMac_Tmp_Addr[ETH_ALEN] __aligned(2) = {
+   0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01
+   };
 
RT_TRACE(COMP_INIT, "> rtl8192_read_eeprom_info\n");
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 6d60ac4..c25984d 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2573,8 +2573,9 @@ static int rtl8192_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
int ret = -1;
struct rtllib_device *ieee = priv->rtllib;
u32 key[4];
-   u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-   u8 zero_addr[6] = {0};
+   static const u8 broadcast_addr[ETH_ALEN] __aligned(2) = {
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+   };
struct iw_point *p = &wrq->u.data;
struct ieee_param *ipw = NULL;
 
@@ -2611,8 +2612,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
}
 
if (ieee->pairwise_key_type) {
-   if (memcmp(ieee->ap_mac_addr, zero_addr,
-   6) == 0)
+   if 
(is_zero_ether_addr(ieee->ap_mac_addr))
ieee->iw_mode = IW_MODE_ADHOC;
memcpy((u8 *)key, ipw->u.crypt.key, 16);
EnableHWSecurityConfig8192(dev);
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 8d6a109..76b8b7c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -193,7 +193,7 @@ static int r8192_wx_force_mic_error(struct net_device *dev,
 
 #define MAX_ADHOC_PEER_NUM 64
 struct adhoc_peer_entry {
-   unsigned char MacAddr[ETH_ALEN];
+   unsigned char MacAddr[ETH_ALEN] __aligned(2);
unsigned char WirelessMode;
unsigned char bCurTxBW40MHz;
 };
@@ -987,8 +987,10 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
 
ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
{
-   u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-   u8 zero[6] = {0};
+   static const u8 broadcast_addr[ETH_ALEN] __aligned(2) = {
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+   };
+   static const u8 zero[ETH_ALEN] __aligned(2) = {0};
u32 key[4] = {0};
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
struct iw_point *encoding = &wrqu->encoding;
diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h 
b/drivers/staging/rtl8192e/rtl819x_Qos.h
index 55ef7ec..4bdb176 100644
--- a/drivers/staging/rtl8192e/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192e/rtl819x_Qos.h
@@ -255,8 +255,8 @@ union qos_tclas {
u8  Priority;
u8  ClassifierType;
u8  Mask;
-   u8  SrcAddr[6];
-   u8  DstAddr[6];
+   u8  SrcAddr[ETH_ALEN] __aligned(2);
+   u8  DstAddr[ETH_ALEN] __aligned(2);
u16 Type;
} TYPE0_ETH;
 
diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h 
b/drivers/staging/rtl8192e/rtl819x_TS.h
index 8601b1a..

[PATCH v4 03/35] staging: rtl8192e: Fix PREFER_ETHER_ADDR_COPY warnings

2015-05-21 Thread Mateusz Kulikowski
Replace memcpy() with ether_addr_copy() where possible to make
checkpatch.pl happy.
Change was target tested (download 1Mb file over WPA2 network)
with BUG trap for unaligned addresses in ether_addr_copy()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  2 +-
 drivers/staging/rtl8192e/rtl819x_BAProc.c  | 13 +++---
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   | 19 
 drivers/staging/rtl8192e/rtllib_rx.c   | 46 +-
 drivers/staging/rtl8192e/rtllib_softmac.c  | 64 +-
 drivers/staging/rtl8192e/rtllib_softmac_wx.c   |  4 +-
 drivers/staging/rtl8192e/rtllib_tx.c   | 24 +-
 7 files changed, 89 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 9c6dc82..6966fd4 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -385,7 +385,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
*(u16 *)(&dev->dev_addr[i]) = usValue;
}
} else {
-   memcpy(dev->dev_addr, bMac_Tmp_Addr, 6);
+   ether_addr_copy(dev->dev_addr, bMac_Tmp_Addr);
}
 
RT_TRACE(COMP_INIT, "Permanent Address = %pM\n",
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 26258ea..5b72bce 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -18,6 +18,7 @@
 **/
 #include 
 #include 
+#include 
 #include "rtllib.h"
 #include "rtl819x_BA.h"
 
@@ -103,10 +104,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
BAReq = (struct rtllib_hdr_3addr *)skb_put(skb,
 sizeof(struct rtllib_hdr_3addr));
 
-   memcpy(BAReq->addr1, Dst, ETH_ALEN);
-   memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
+   ether_addr_copy(BAReq->addr1, Dst);
+   ether_addr_copy(BAReq->addr2, ieee->dev->dev_addr);
 
-   memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
+   ether_addr_copy(BAReq->addr3, ieee->current_network.bssid);
BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
tag = (u8 *)skb_put(skb, 9);
@@ -167,9 +168,9 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
Delba = (struct rtllib_hdr_3addr *) skb_put(skb,
 sizeof(struct rtllib_hdr_3addr));
 
-   memcpy(Delba->addr1, dst, ETH_ALEN);
-   memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
-   memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
+   ether_addr_copy(Delba->addr1, dst);
+   ether_addr_copy(Delba->addr2, ieee->dev->dev_addr);
+   ether_addr_copy(Delba->addr3, ieee->current_network.bssid);
Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
 
tag = (u8 *)skb_put(skb, 6);
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c 
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index eda68b9..9ec2b48 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rtllib.h"
 
@@ -533,20 +534,20 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
switch (le16_to_cpu(hdr11->frame_ctl) &
(RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_TODS:
-   memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr3); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */
break;
case RTLLIB_FCTL_FROMDS:
-   memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr1); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr3); /* SA */
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
-   memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr3); /* DA */
+   ether_addr_copy(hdr + ETH_ALEN, hdr11->addr4); /* SA */
break;
case 0:
-   memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-   memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+   ether_addr_copy(hdr, hdr11->addr1); /* DA */
+   ethe

[PATCH v4 07/35] staging: rtl8192e: Remove rtllib_crypt.[ch]

2015-05-21 Thread Mateusz Kulikowski
It is neither compiled nor used in rtl8192e.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_crypt.c | 254 
 drivers/staging/rtl8192e/rtllib_crypt.h |  34 -
 2 files changed, 288 deletions(-)
 delete mode 100644 drivers/staging/rtl8192e/rtllib_crypt.c
 delete mode 100644 drivers/staging/rtl8192e/rtllib_crypt.h

diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c 
b/drivers/staging/rtl8192e/rtllib_crypt.c
deleted file mode 100644
index 1e6ae9b..000
--- a/drivers/staging/rtl8192e/rtllib_crypt.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Host AP crypto routines
- *
- * Copyright (c) 2002-2003, Jouni Malinen 
- * Portions Copyright (C) 2004, Intel Corporation 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "rtllib.h"
-
-struct rtllib_crypto_alg {
-   struct list_head list;
-   struct lib80211_crypto_ops *ops;
-};
-
-
-struct rtllib_crypto {
-   struct list_head algs;
-   spinlock_t lock;
-};
-
-static struct rtllib_crypto *hcrypt;
-
-void rtllib_crypt_deinit_entries(struct lib80211_crypt_info *info,
-  int force)
-{
-   struct list_head *ptr, *n;
-   struct lib80211_crypt_data *entry;
-
-   for (ptr = info->crypt_deinit_list.next, n = ptr->next;
-ptr != &info->crypt_deinit_list; ptr = n, n = ptr->next) {
-   entry = list_entry(ptr, struct lib80211_crypt_data, list);
-
-   if (atomic_read(&entry->refcnt) != 0 && !force)
-   continue;
-
-   list_del(ptr);
-
-   if (entry->ops)
-   entry->ops->deinit(entry->priv);
-   kfree(entry);
-   }
-}
-EXPORT_SYMBOL(rtllib_crypt_deinit_entries);
-
-void rtllib_crypt_deinit_handler(unsigned long data)
-{
-   struct lib80211_crypt_info *info = (struct lib80211_crypt_info *)data;
-   unsigned long flags;
-
-   spin_lock_irqsave(info->lock, flags);
-   rtllib_crypt_deinit_entries(info, 0);
-   if (!list_empty(&info->crypt_deinit_list)) {
-   printk(KERN_DEBUG
-  "%s: entries remaining in delayed crypt deletion list\n",
-  info->name);
-   info->crypt_deinit_timer.expires = jiffies + HZ;
-   add_timer(&info->crypt_deinit_timer);
-   }
-   spin_unlock_irqrestore(info->lock, flags);
-
-}
-EXPORT_SYMBOL(rtllib_crypt_deinit_handler);
-
-void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info,
-struct lib80211_crypt_data **crypt)
-{
-   struct lib80211_crypt_data *tmp;
-   unsigned long flags;
-
-   if (*crypt == NULL)
-   return;
-
-   tmp = *crypt;
-   *crypt = NULL;
-
-   /* must not run ops->deinit() while there may be pending encrypt or
-* decrypt operations. Use a list of delayed deinits to avoid needing
-* locking.
-*/
-
-   spin_lock_irqsave(info->lock, flags);
-   list_add(&tmp->list, &info->crypt_deinit_list);
-   if (!timer_pending(&info->crypt_deinit_timer)) {
-   info->crypt_deinit_timer.expires = jiffies + HZ;
-   add_timer(&info->crypt_deinit_timer);
-   }
-   spin_unlock_irqrestore(info->lock, flags);
-}
-EXPORT_SYMBOL(rtllib_crypt_delayed_deinit);
-
-int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops)
-{
-   unsigned long flags;
-   struct rtllib_crypto_alg *alg;
-
-   if (hcrypt == NULL)
-   return -1;
-
-   alg = kzalloc(sizeof(*alg), GFP_KERNEL);
-   if (alg == NULL)
-   return -ENOMEM;
-
-   alg->ops = ops;
-
-   spin_lock_irqsave(&hcrypt->lock, flags);
-   list_add(&alg->list, &hcrypt->algs);
-   spin_unlock_irqrestore(&hcrypt->lock, flags);
-
-   printk(KERN_DEBUG "rtllib_crypt: registered algorithm '%s'\n",
-  ops->name);
-
-   return 0;
-}
-EXPORT_SYMBOL(rtllib_register_crypto_ops);
-
-int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
-{
-   unsigned long flags;
-   struct list_head *ptr;
-   struct rtllib_crypto_alg *del_alg = NULL;
-
-   if (hcrypt == NULL)
-   return -1;
-
-   spin_lock_irqsave(&hcrypt->lock, flags);
-   for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
-   struct rtllib_crypto_alg *alg =
-   (struct rtllib_crypto_alg *) ptr;
-   if (alg->ops == ops) {
-

[PATCH v4 09/35] staging: rtl8192e: Remove RTLLIB_ERROR() and RTLLIB_WARNING()

2015-05-21 Thread Mateusz Kulikowski
Use pr_* where needed (rtllib init code).

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h| 2 --
 drivers/staging/rtl8192e/rtllib_module.c | 8 +++-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 3674c8b..5f47d75 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -701,8 +701,6 @@ do {
\
 #define RTLLIB_DL_TRACE   (1<<29)
 #define RTLLIB_DL_DATA(1<<30)
 #define RTLLIB_DL_ERR (1<<31)
-#define RTLLIB_ERROR(f, a...) pr_err("rtllib: " f, ## a)
-#define RTLLIB_WARNING(f, a...) pr_warn("rtllib: " f, ## a)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
 #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
diff --git a/drivers/staging/rtl8192e/rtllib_module.c 
b/drivers/staging/rtl8192e/rtllib_module.c
index 32cc8df..b8c7df5 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -107,7 +107,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 
dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
if (!dev) {
-   RTLLIB_ERROR("Unable to network device.\n");
+   pr_err("Unable to allocate net_device.\n");
return NULL;
}
ieee = (struct rtllib_device *)netdev_priv_rsl(dev);
@@ -116,8 +116,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 
err = rtllib_networks_allocate(ieee);
if (err) {
-   RTLLIB_ERROR("Unable to allocate beacon storage: %d\n",
-   err);
+   pr_err("Unable to allocate beacon storage: %d\n", err);
goto failed;
}
rtllib_networks_initialize(ieee);
@@ -240,8 +239,7 @@ static int __init rtllib_init(void)
rtllib_debug_level = debug;
rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
if (rtllib_proc == NULL) {
-   RTLLIB_ERROR("Unable to create " DRV_NAME
-   " proc directory\n");
+   pr_err("Unable to create " DRV_NAME " proc directory\n");
return -EIO;
}
e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops);
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 08/35] staging: rtl8192e: Replace RTLLIB_DEBUG(DL_ERR) with netdev_*()

2015-05-21 Thread Mateusz Kulikowski
Replace all RTLLIB_DEBUG(RTLLIB_DL_ERR, *) calls with netdev_err()
for errors that really should be reported to user.
Use netdev_warn() for the rest.
Rephrase some of the messages to make them more readable/compact.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c| 79 +---
 drivers/staging/rtl8192e/rtl819x_HTProc.c| 23 
 drivers/staging/rtl8192e/rtl819x_TSProc.c| 19 ---
 drivers/staging/rtl8192e/rtllib_rx.c | 15 --
 drivers/staging/rtl8192e/rtllib_softmac.c|  6 +--
 drivers/staging/rtl8192e/rtllib_softmac_wx.c |  6 +--
 6 files changed, 75 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 5b72bce..7d72c19 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -88,12 +88,12 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device 
*ieee, u8 *Dst,
 ">%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n",
 __func__, type, Dst, ieee->dev);
if (pBA == NULL) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA is NULL\n");
+   netdev_warn(ieee->dev, "pBA is NULL\n");
return NULL;
}
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
if (skb == NULL) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+   netdev_err(ieee->dev, "Can't alloc skb for ADDBA_REQ\n");
return NULL;
}
 
@@ -159,7 +159,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device 
*ieee, u8 *dst,
 
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
if (skb == NULL) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+   netdev_err(ieee->dev, "Can't alloc skb for DELBA_REQ\n");
return NULL;
}
 
@@ -247,10 +247,9 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct 
sk_buff *skb)
struct rx_ts_record *pTS = NULL;
 
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-" Invalid skb len in BAREQ(%d / %d)\n",
-(int)skb->len,
-(int)(sizeof(struct rtllib_hdr_3addr) + 9));
+   netdev_warn(ieee->dev, "Invalid skb len in BAREQ(%d / %d)\n",
+   (int)skb->len,
+   (int)(sizeof(struct rtllib_hdr_3addr) + 9));
return -1;
}
 
@@ -270,24 +269,24 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct 
sk_buff *skb)
(ieee->pHTInfo->bCurrentHTSupport == false) ||
(ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) {
rc = ADDBA_STATUS_REFUSED;
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"Failed to reply on ADDBA_REQ as some capability 
is not ready(%d, %d)\n",
-ieee->current_network.qos_data.active,
-ieee->pHTInfo->bCurrentHTSupport);
+   netdev_warn(ieee->dev,
+   "Failed to reply on ADDBA_REQ as some capability is 
not ready(%d, %d)\n",
+   ieee->current_network.qos_data.active,
+   ieee->pHTInfo->bCurrentHTSupport);
goto OnADDBAReq_Fail;
}
if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
(u8)(pBaParamSet->field.TID), RX_DIR, true)) {
rc = ADDBA_STATUS_REFUSED;
-   RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__);
+   netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
goto OnADDBAReq_Fail;
}
pBA = &pTS->RxAdmittedBARecord;
 
if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) {
rc = ADDBA_STATUS_INVALID_PARAM;
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"BA Policy is not correct in %s()\n", __func__);
+   netdev_warn(ieee->dev, "%s(): BA Policy is not correct\n",
+   __func__);
goto OnADDBAReq_Fail;
}
 
@@ -334,10 +333,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct 
sk_buff *skb)
u16 ReasonCode;
 
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
-   RTLLIB_DEBUG(RTLLIB_DL_ERR,
-"Invalid skb len in BARSP(%d / %d)\n",
-(int)skb->len,
-

[PATCH v4 06/35] staging: rtl8192e: Replace memcmp() with ether_addr_equal_unaligned()

2015-05-21 Thread Mateusz Kulikowski
Use dedicated macro to compare ethernet addresses in probe_rq_parse().

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index 8689b16..65297a0 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1853,7 +1853,8 @@ static short probe_rq_parse(struct rtllib_device *ieee, 
struct sk_buff *skb,
return -1; /* corrupted */
 
bssid_match =
- (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) &&
+ (!ether_addr_equal_unaligned(header->addr3,
+  ieee->current_network.bssid)) &&
  (!is_broadcast_ether_addr(header->addr3));
if (bssid_match)
return -1;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 05/35] staging: rtl8192e: Fix DEEP_INDENTATION warning in rtllib_parse_info_param()

2015-05-21 Thread Mateusz Kulikowski
Move MFIE_TYPE_GENERIC handler to rtllib_parse_mife_generic() function.
Code was not altered significantly, therefore in some places it generates
LONG_LINE checkpatch.pl warnings.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 397 ++-
 1 file changed, 210 insertions(+), 187 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 65e4d13..2080e5d 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1743,6 +1743,213 @@ static inline void rtllib_extract_country_ie(
 
 }
 
+static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
+ struct rtllib_info_element *info_element,
+ struct rtllib_network *network,
+ u16 *tmp_htcap_len,
+ u16 *tmp_htinfo_len)
+{
+   u16 ht_realtek_agg_len = 0;
+   u8  ht_realtek_agg_buf[MAX_IE_LEN];
+
+   if (!rtllib_parse_qos_info_param_IE(info_element, network))
+   return;
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0x50 &&
+   info_element->data[2] == 0xf2 &&
+   info_element->data[3] == 0x01) {
+   network->wpa_ie_len = min(info_element->len + 2,
+ MAX_WPA_IE_LEN);
+   memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+   return;
+   }
+   if (info_element->len == 7 &&
+   info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0xe0 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x01 &&
+   info_element->data[4] == 0x02)
+   network->Turbo_Enable = 1;
+
+   if (*tmp_htcap_len == 0) {
+   if (info_element->len >= 4 &&
+  info_element->data[0] == 0x00 &&
+  info_element->data[1] == 0x90 &&
+  info_element->data[2] == 0x4c &&
+  info_element->data[3] == 0x033) {
+
+   *tmp_htcap_len = min_t(u8, info_element->len,
+  MAX_IE_LEN);
+   if (*tmp_htcap_len != 0) {
+   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+   network->bssht.bdHTCapLen = min_t(u16, 
*tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
+   memcpy(network->bssht.bdHTCapBuf,
+  info_element->data,
+  network->bssht.bdHTCapLen);
+   }
+   }
+   if (*tmp_htcap_len != 0) {
+   network->bssht.bdSupportHT = true;
+   network->bssht.bdHT1R = struct ht_capab_ele 
*)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+   } else {
+   network->bssht.bdSupportHT = false;
+   network->bssht.bdHT1R = false;
+   }
+   }
+
+
+   if (*tmp_htinfo_len == 0) {
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0x90 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x034) {
+   *tmp_htinfo_len = min_t(u8, info_element->len,
+   MAX_IE_LEN);
+   if (*tmp_htinfo_len != 0) {
+   network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+   network->bssht.bdHTInfoLen = min_t(u16, 
*tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
+   memcpy(network->bssht.bdHTInfoBuf,
+  info_element->data,
+  network->bssht.bdHTInfoLen);
+   }
+
+   }
+   }
+
+   if (ieee->aggregation) {
+   if (network->bssht.bdSupportHT) {
+   if (info_element->len >= 4 &&
+   info_element->data[0] == 0x00 &&
+   info_element->data[1] == 0xe0 &&
+   info_element->data[2] == 0x4c &&
+   info_element->data[3] == 0x02) {
+   ht_realtek_agg_len = min_t(u8,
+  info_e

[PATCH v4 10/35] staging: rtl8192e: Remove RTLLIB_DEBUG_WX()

2015-05-21 Thread Mateusz Kulikowski
Use netdev_dbg() instead of RTLLIB_DEBUG_WX().
Rewrite some messages to be more readable.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|  1 -
 drivers/staging/rtl8192e/rtllib_wx.c | 33 -
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 5f47d75..4edbc87 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,7 +703,6 @@ do {
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
 #define RTLLIB_DEBUG_SCAN(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
 #define RTLLIB_DEBUG_STATE(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index 6234aae..c2c5f0d 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -266,7 +266,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
int i = 0;
int err = 0;
 
-   RTLLIB_DEBUG_WX("Getting scan\n");
+   netdev_dbg(ieee->dev, "Getting scan\n");
down(&ieee->wx_sem);
spin_lock_irqsave(&ieee->lock, flags);
 
@@ -293,7 +293,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
wrqu->data.length = ev -  extra;
wrqu->data.flags = 0;
 
-   RTLLIB_DEBUG_WX("exit: %d networks returned.\n", i);
+   netdev_dbg(ieee->dev, "%s(): %d networks returned.\n", __func__, i);
 
return err;
 }
@@ -311,7 +311,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
int i, key, key_provided, len;
struct lib80211_crypt_data **crypt;
 
-   RTLLIB_DEBUG_WX("SET_ENCODE\n");
+   netdev_dbg(ieee->dev, "%s()\n", __func__);
 
key = erq->flags & IW_ENCODE_INDEX;
if (key) {
@@ -324,16 +324,16 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
key = ieee->crypt_info.tx_keyidx;
}
 
-   RTLLIB_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
+   netdev_dbg(ieee->dev, "Key: %d [%s]\n", key, key_provided ?
   "provided" : "default");
crypt = &ieee->crypt_info.crypt[key];
if (erq->flags & IW_ENCODE_DISABLED) {
if (key_provided && *crypt) {
-   RTLLIB_DEBUG_WX("Disabling encryption on key %d.\n",
-  key);
+   netdev_dbg(ieee->dev,
+  "Disabling encryption on key %d.\n", key);
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
} else
-   RTLLIB_DEBUG_WX("Disabling encryption.\n");
+   netdev_dbg(ieee->dev, "Disabling encryption.\n");
 
/* Check all the keys to see if any are still configured,
 * and if no key index was provided, de-init them all
@@ -405,9 +405,9 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
if (len > erq->length)
memset(sec.keys[key] + erq->length, 0,
   len - erq->length);
-   RTLLIB_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
-  key, escape_essid(sec.keys[key], len),
-  erq->length, len);
+   netdev_dbg(ieee->dev, "Setting key %d to '%s' (%d:%d bytes)\n",
+  key, escape_essid(sec.keys[key], len), erq->length,
+  len);
sec.key_sizes[key] = len;
(*crypt)->ops->set_key(sec.keys[key], len, NULL,
   (*crypt)->priv);
@@ -436,8 +436,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
 
/* No key data - just set the default TX key index */
if (key_provided) {
-   RTLLIB_DEBUG_WX("Setting key %d to default Tx key.\n",
-   key);
+   netdev_dbg(ieee->dev,
+  "Setting key %d as default Tx key.\n", key);
ieee->crypt_info.tx_keyidx = key;
sec.active_key = key;
sec.flags |= SEC_ACTIVE_KEY;
@@ -449,7 +449,7 @@ int rtllib_wx_set_encode(struct rtllib_device

[PATCH v4 11/35] staging: rtl8192e: Simplify rtllib_process_probe_response()

2015-05-21 Thread Mateusz Kulikowski
- Extract frame_ctl once and use it as variable.
- Drop endian conversion in is_beacon() function
  (used in simplified function only)
- Simplify debug messages
- Invert STYPE checks in debug messages - it is valid
  as only BEACON and PROBE_RESP are allowed

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib_rx.c | 37 +++-
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 29c330a..b6de742 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2461,9 +2461,9 @@ static inline void update_network(struct rtllib_network 
*dst,
dst->BssCcxVerNumber = src->BssCcxVerNumber;
 }
 
-static inline int is_beacon(__le16 fc)
+static inline int is_beacon(u16 fc)
 {
-   return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON);
+   return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON);
 }
 
 static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
@@ -2504,6 +2504,7 @@ static inline void rtllib_process_probe_response(
short renew;
struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network),
 GFP_ATOMIC);
+   u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl);
 
if (!network)
return;
@@ -2532,12 +2533,9 @@ static inline void rtllib_process_probe_response(
if (rtllib_network_init(ieee, beacon, network, stats)) {
RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n",
  escape_essid(info_element->data,
- info_element->len),
- beacon->header.addr3,
- WLAN_FC_GET_STYPE(
- 
le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
+ info_element->len), beacon->header.addr3,
+ is_beacon(frame_ctl) ? "BEACON" :
+"PROBE RESPONSE");
goto free_network;
}
 
@@ -2545,8 +2543,7 @@ static inline void rtllib_process_probe_response(
if (!rtllib_legal_channel(ieee, network->channel))
goto free_network;
 
-   if (WLAN_FC_GET_STYPE(le16_to_cpu(beacon->header.frame_ctl)) ==
-   RTLLIB_STYPE_PROBE_RESP) {
+   if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) {
if (IsPassiveChannel(ieee, network->channel)) {
netdev_info(ieee->dev,
"GetScanInfo(): For Global Domain, filter 
probe response at channel(%d).\n",
@@ -2579,7 +2576,7 @@ static inline void rtllib_process_probe_response(
else
ieee->current_network.buseprotection = false;
}
-   if (is_beacon(beacon->header.frame_ctl)) {
+   if (is_beacon(frame_ctl)) {
if (ieee->state >= RTLLIB_LINKED)
ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
}
@@ -2616,22 +2613,18 @@ static inline void rtllib_process_probe_response(
RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n",
  escape_essid(network->ssid,
  network->ssid_len), network->bssid,
- WLAN_FC_GET_STYPE(
- 
le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
+ is_beacon(frame_ctl) ? "BEACON" :
+"PROBE RESPONSE");
memcpy(target, network, sizeof(*target));
list_add_tail(&target->list, &ieee->network_list);
if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
rtllib_softmac_new_net(ieee, network);
} else {
RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n",
- escape_essid(target->ssid,
- target->ssid_len), target->bssid,
- WLAN_FC_GET_STYPE(
- 
le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
-   

[PATCH v4 12/35] staging: rtl8192e: Remove RTLLIB_DEBUG_SCAN()

2015-05-21 Thread Mateusz Kulikowski
Use netdev_dbg() instead, remove duplicated logs.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|   1 -
 drivers/staging/rtl8192e/rtllib_rx.c | 101 ---
 drivers/staging/rtl8192e/rtllib_wx.c |  12 +++--
 3 files changed, 54 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 4edbc87..f7b741e 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,7 +703,6 @@ do {
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_SCAN(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
 #define RTLLIB_DEBUG_STATE(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
 #define RTLLIB_DEBUG_FRAG(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index b6de742..d08fd8d 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2134,8 +2134,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
 
case MFIE_TYPE_HT_CAP:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
+  info_element->len);
tmp_htcap_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
if (tmp_htcap_len != 0) {
network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
@@ -2161,8 +2161,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
 
 
case MFIE_TYPE_HT_INFO:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n",
+  info_element->len);
tmp_htinfo_len = min_t(u8, info_element->len, 
MAX_IE_LEN);
if (tmp_htinfo_len) {
network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
@@ -2177,8 +2177,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
 
case MFIE_TYPE_AIRONET:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_AIRONET: %d bytes\n",
+  info_element->len);
if (info_element->len > IE_CISCO_FLAG_POSITION) {
network->bWithAironetIE = true;
 
@@ -2200,8 +2200,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
 
case MFIE_TYPE_COUNTRY:
-   RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
-info_element->len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_COUNTRY: %d bytes\n",
+  info_element->len);
rtllib_extract_country_ie(ieee, info_element, network,
  network->bssid);
break;
@@ -2308,10 +2308,9 @@ static inline int rtllib_network_init(
}
 
if (network->mode == 0) {
-   RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' network.\n",
-escape_essid(network->ssid,
- network->ssid_len),
-network->bssid);
+   netdev_dbg(ieee->dev, "Filtered out '%s (%pM)' network.\n",
+  escape_essid(network->ssid, network->ssid_len),
+  network->bssid);
return 1;
}
 
@@ -2509,33 +2508,32 @@ static inline void rtllib_process_probe_response(
if (!network)
return;
 
-   RTLLIB_DEBUG_SCAN(
-   "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
-   escape_essid(info_element->data, info_element->len),
-   beacon->header.addr3,
-   (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0',
-   (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1'

[PATCH v4 14/35] staging: rtl8192e: Remove RTLLIB_DEBUG_QOS()

2015-05-21 Thread Mateusz Kulikowski
- Pass extra argument (rtllib_device) to rtllib_parse_qos_info_param_IE()
  and update_network()
- Replace RTLLIB_DEBUG_QOS() with netdev_dbg()
- Remove RTLLIB_DEBUG_QOS()

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h|  1 -
 drivers/staging/rtl8192e/rtllib_rx.c | 26 ++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 12a4b1f..a9b9cb9 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -704,7 +704,6 @@ do {
\
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
 #define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
-#define RTLLIB_DEBUG_QOS(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
 
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index c3f7bdb..6aa6e61 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1661,9 +1661,10 @@ static int rtllib_qos_convert_ac_to_parameters(struct 
rtllib_qos_parameter_info
  * parameters element. check the information element length to decide
  * which type to read
  */
-static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element
+static int rtllib_parse_qos_info_param_IE(struct rtllib_device *ieee,
+ struct rtllib_info_element
 *info_element,
-struct rtllib_network *network)
+ struct rtllib_network *network)
 {
int rc = 0;
struct rtllib_qos_information_element qos_info_element;
@@ -1688,7 +1689,7 @@ static int rtllib_parse_qos_info_param_IE(struct 
rtllib_info_element
}
 
if (rc == 0) {
-   RTLLIB_DEBUG_QOS("QoS is supported\n");
+   netdev_dbg(ieee->dev, "QoS is supported\n");
network->qos_data.supported = 1;
}
return rc;
@@ -1765,7 +1766,7 @@ static void rtllib_parse_mife_generic(struct 
rtllib_device *ieee,
u16 ht_realtek_agg_len = 0;
u8  ht_realtek_agg_buf[MAX_IE_LEN];
 
-   if (!rtllib_parse_qos_info_param_IE(info_element, network))
+   if (!rtllib_parse_qos_info_param_IE(ieee, info_element, network))
return;
if (info_element->len >= 4 &&
info_element->data[0] == 0x00 &&
@@ -2356,7 +2357,8 @@ static inline int is_same_network(struct rtllib_network 
*src,
 }
 
 
-static inline void update_network(struct rtllib_network *dst,
+static inline void update_network(struct rtllib_device *ieee,
+ struct rtllib_network *dst,
  struct rtllib_network *src)
 {
int qos_active;
@@ -2430,12 +2432,12 @@ static inline void update_network(struct rtllib_network 
*dst,
   sizeof(struct rtllib_qos_data));
if (dst->qos_data.supported == 1) {
if (dst->ssid_len)
-   RTLLIB_DEBUG_QOS
-   ("QoS the network %s is QoS supported\n",
-   dst->ssid);
+   netdev_dbg(ieee->dev,
+  "QoS the network %s is QoS supported\n",
+  dst->ssid);
else
-   RTLLIB_DEBUG_QOS
-   ("QoS the network is QoS supported\n");
+   netdev_dbg(ieee->dev,
+  "QoS the network is QoS supported\n");
}
dst->qos_data.active = qos_active;
dst->qos_data.old_param_count = old_param;
@@ -2571,7 +2573,7 @@ static inline void rtllib_process_probe_response(
spin_lock_irqsave(&ieee->lock, flags);
if (is_same_network(&ieee->current_network, network,
   (network->ssid_len ? 1 : 0))) {
-   update_network(&ieee->current_network, network);
+   update_network(ieee, &ieee->current_network, network);
if ((ieee->current_network.mode == IEEE_N_24G ||
 ieee->current_network.mode == IEEE_G)
 && ieee->current_network.berp_info_valid) {
@@ -2641,7 +2643,7 @@ static inline void rtllib_process_probe_response(
network->ssid_len) == 0) &&
(ieee->state == RTLLIB_NOLINK
renew = 1;
-   update_network(target, network);
+   update_network(ieee, target, network);
if (renew && (ieee

[PATCH v4 15/35] staging: rtl8192e: Remove RTLLIB_DEBUG_MGMT()

2015-05-21 Thread Mateusz Kulikowski
- Use netdev_dbg() instead of RTLLIB_DEBUG_MGMT()
- Remove RTLLIB_DEBUG_MGMT()
- Pass net_device to auth_parse(), auth_rq_parse() and assoc_rq_parse()
- Remove duplicated messages

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h |  2 -
 drivers/staging/rtl8192e/rtllib_rx.c  | 78 +++
 drivers/staging/rtl8192e/rtllib_softmac.c | 50 +---
 3 files changed, 61 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index a9b9cb9..faf94b4 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -703,8 +703,6 @@ do {
\
 #define RTLLIB_DL_ERR (1<<31)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
-#define RTLLIB_DEBUG_MGMT(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
-
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_IP   0x0800  /* Internet Protocol packet */
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
b/drivers/staging/rtl8192e/rtllib_rx.c
index 6aa6e61..6870a62 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1955,12 +1955,10 @@ static void rtllib_parse_mife_generic(struct 
rtllib_device *ieee,
info_element->data[1] == 0x50 &&
info_element->data[2] == 0xf2 &&
info_element->data[3] == 0x04) {
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n",
- info_element->len);
-   network->wzc_ie_len = min(info_element->len+2,
- MAX_WZC_IE_LEN);
-   memcpy(network->wzc_ie, info_element,
-  network->wzc_ie_len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_WZC: %d bytes\n",
+  info_element->len);
+   network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN);
+   memcpy(network->wzc_ie, info_element, network->wzc_ie_len);
}
 }
 
@@ -1979,10 +1977,10 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
 
while (length >= sizeof(*info_element)) {
if (sizeof(*info_element) + info_element->len > length) {
-   RTLLIB_DEBUG_MGMT("Info elem: parse failed: 
info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
-info_element->len +
-sizeof(*info_element),
-length, info_element->id);
+   netdev_dbg(ieee->dev,
+  "Info elem: parse failed: info_element->len 
+ 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
+  info_element->len + sizeof(*info_element),
+  length, info_element->id);
/* We stop processing but don't return an error here
 * because some misbehaviour APs break this rule. ie.
 * Orinoco AP1000.
@@ -2005,8 +2003,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
memset(network->ssid + network->ssid_len, 0,
   IW_ESSID_MAX_SIZE - network->ssid_len);
 
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
-network->ssid, network->ssid_len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_SSID: '%s' len=%d.\n",
+  network->ssid, network->ssid_len);
break;
 
case MFIE_TYPE_RATES:
@@ -2033,8 +2031,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
}
}
 
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
-rates_str, network->rates_len);
+   netdev_dbg(ieee->dev, "MFIE_TYPE_RATES: '%s' (%d)\n",
+  rates_str, network->rates_len);
break;
 
case MFIE_TYPE_RATES_EX:
@@ -2056,22 +2054,22 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
}
}
 
-   RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
-rates_str, network->rates_ex_len);
+

[PATCH v4 19/35] staging: rtl8192e: Remove remains of RTLLIB_*_DEBUG() (including proc entry)

2015-05-21 Thread Mateusz Kulikowski
Remove rest of rtllib "debug" system - it is no longer used -
proper netdev_* functions are used in most cases.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtllib.h| 45 --
 drivers/staging/rtl8192e/rtllib_module.c | 55 
 2 files changed, 100 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 0ee0107..8c614e0 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -641,51 +641,6 @@ enum wireless_network_type {
 #define OUI_SUBTYPE_WMM_PARAM  1
 #define OUI_SUBTYPE_QOS_CAPABI 5
 
-/* debug macros */
-/* To use the debug system;
- *
- * If you are defining a new debug classification, simply add it to the #define
- * list here in the form of:
- *
- * #define RTLLIB_DL_ VALUE
- *
- * shifting value to the left one bit from the previous entry.   should be
- * the name of the classification (for example, WEP)
- *
- * You then need to either add a RTLLIB__DEBUG() macro definition for your
- * classification, or use RTLLIB_DEBUG(RTLLIB_DL_, ...) whenever you want
- * to send output to that classification.
- *
- * To add your debug level to the list of levels seen when you perform
- *
- * % cat /proc/net/ipw/debug_level
- *
- * you simply need to add your entry to the ipw_debug_levels array.
- */
-
-#define RTLLIB_DL_INFO   (1<<0)
-#define RTLLIB_DL_WX   (1<<1)
-#define RTLLIB_DL_SCAN   (1<<2)
-#define RTLLIB_DL_STATE (1<<3)
-#define RTLLIB_DL_MGMT   (1<<4)
-#define RTLLIB_DL_FRAG   (1<<5)
-#define RTLLIB_DL_EAP (1<<6)
-#define RTLLIB_DL_DROP   (1<<7)
-
-#define RTLLIB_DL_TX   (1<<8)
-#define RTLLIB_DL_RX   (1<<9)
-
-#define RTLLIB_DL_HT  (1<<10)
-#define RTLLIB_DL_BA  (1<<11)
-#define RTLLIB_DL_TS  (1<<12)
-#define RTLLIB_DL_QOS (1<<13)
-#define RTLLIB_DL_REORDER (1<<14)
-#define RTLLIB_DL_IOT (1<<15)
-#define RTLLIB_DL_IPS (1<<16)
-#define RTLLIB_DL_TRACE   (1<<29)
-#define RTLLIB_DL_DATA(1<<30)
-#define RTLLIB_DL_ERR (1<<31)
-
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_IP   0x0800  /* Internet Protocol packet */
diff --git a/drivers/staging/rtl8192e/rtllib_module.c 
b/drivers/staging/rtl8192e/rtllib_module.c
index b61035b..845d9b8 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -196,68 +196,13 @@ void free_rtllib(struct net_device *dev)
 }
 EXPORT_SYMBOL(free_rtllib);
 
-u32 rtllib_debug_level;
-static int debug = RTLLIB_DL_ERR;
-static struct proc_dir_entry *rtllib_proc;
-
-static int show_debug_level(struct seq_file *m, void *v)
-{
-   seq_printf(m, "0x%08X\n", rtllib_debug_level);
-
-   return 0;
-}
-
-static ssize_t write_debug_level(struct file *file, const char __user *buffer,
-size_t count, loff_t *ppos)
-{
-   unsigned long val;
-   int err = kstrtoul_from_user(buffer, count, 0, &val);
-
-   if (err)
-   return err;
-   rtllib_debug_level = val;
-   return count;
-}
-
-static int open_debug_level(struct inode *inode, struct file *file)
-{
-   return single_open(file, show_debug_level, NULL);
-}
-
-static const struct file_operations fops = {
-   .open = open_debug_level,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .write = write_debug_level,
-   .release = single_release,
-};
-
 static int __init rtllib_init(void)
 {
-   struct proc_dir_entry *e;
-
-   rtllib_debug_level = debug;
-   rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
-   if (rtllib_proc == NULL) {
-   pr_err("Unable to create " DRV_NAME " proc directory\n");
-   return -EIO;
-   }
-   e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops);
-   if (!e) {
-   remove_proc_entry(DRV_NAME, init_net.proc_net);
-   rtllib_proc = NULL;
-   return -EIO;
-   }
return 0;
 }
 
 static void __exit rtllib_exit(void)
 {
-   if (rtllib_proc) {
-   remove_proc_entry("debug_level", rtllib_proc);
-   remove_proc_entry(DRV_NAME, init_net.proc_net);
-   rtllib_proc = NULL;
-   }
 }
 
 module_init(rtllib_init);
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 01/35] staging: rtl8192e: accept const MAC address

2015-05-21 Thread Mateusz Kulikowski
Make set_swcam, setKey and rtllib_probe_resp parameter (MAC address)
const.

Signed-off-by: Mateusz Kulikowski 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 4 ++--
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 4 ++--
 drivers/staging/rtl8192e/rtllib_softmac.c   | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
index 41b025e..0ffade4 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
@@ -81,7 +81,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 }
 
 void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
-  u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh)
+  const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh)
 {
struct r8192_priv *priv = rtllib_priv(dev);
struct rtllib_device *ieee = priv->rtllib;
@@ -100,7 +100,7 @@ void set_swcam(struct net_device *dev, u8 EntryNo, u8 
KeyIndex, u16 KeyType,
 }
 
 void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
-   u8 *MacAddr, u8 DefaultKey, u32 *KeyContent)
+   const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent)
 {
u32 TargetCommand = 0;
u32 TargetContent = 0;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
index 3c4c0e6..864a7f6 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
@@ -31,9 +31,9 @@ struct net_device;
 void CamResetAllEntry(struct net_device *dev);
 void EnableHWSecurityConfig8192(struct net_device *dev);
 void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
-   u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
+   const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
 void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
-  u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh);
+  const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh);
 void CamPrintDbgReg(struct net_device *dev);
 
 u32 read_cam(struct net_device *dev, u8 addr);
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index 98afd3b..cd758fe 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -832,7 +832,8 @@ inline struct sk_buff *rtllib_authentication_req(struct 
rtllib_network *beacon,
return skb;
 }
 
-static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
+static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee,
+const u8 *dest)
 {
u8 *tag;
int beacon_size;
-- 
1.8.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   3   4   5   6   7   >