Re: [PATCH 02/14] rtlwifi_new: Remove RT_TRACE messages that use DBG_EMERG

2016-12-11 Thread Larry Finger

On 12/11/2016 04:50 AM, Joe Perches wrote:

On Sat, 2016-12-10 at 23:44 -0600, Larry Finger wrote:

These messages are always logged and reprresent error conditions, thus
we can use pr_err().

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/base.c  | 15 -
 drivers/net/wireless/realtek/rtlwifi/cam.c   | 14 +++--
 drivers/net/wireless/realtek/rtlwifi/core.c  | 21 +
 drivers/net/wireless/realtek/rtlwifi/debug.c |  9 ++
 drivers/net/wireless/realtek/rtlwifi/debug.h |  2 +-
 drivers/net/wireless/realtek/rtlwifi/efuse.c |  3 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c   | 36 --
 drivers/net/wireless/realtek/rtlwifi/ps.c|  3 +-
 drivers/net/wireless/realtek/rtlwifi/rc.c|  3 +-
 drivers/net/wireless/realtek/rtlwifi/usb.c   | 46 +---
 10 files changed, 53 insertions(+), 99 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c

[]

@@ -207,8 +207,7 @@ static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
 *highest supported RX rate
 */
if (rtlpriv->dm.supp_phymode_switch) {
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
-"Support phy mode switch\n");
+   pr_err("rtlwifi: Support phy mode switch\n");


I believe most all of these are already prefixed
by the wifi.h that has a #define pr_fmt


Yes, I missed that. V2 will not include the module name.

Larry

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


Re: [PATCH] staging: rtl: fix possible NULL pointer dereference

2017-01-11 Thread Larry Finger

On 01/11/2017 08:53 AM, Arnd Bergmann wrote:

gcc-7 detects that wlanhdr_to_ethhdr() in two drivers calls memcpy() with
a destination argument that an earlier function call may have set to NULL:

staging/rtl8188eu/core/rtw_recv.c: In function 'wlanhdr_to_ethhdr':
staging/rtl8188eu/core/rtw_recv.c:1318:2: warning: argument 1 null where 
non-null expected [-Wnonnull]
staging/rtl8712/rtl871x_recv.c: In function 'r8712_wlanhdr_to_ethhdr':
staging/rtl8712/rtl871x_recv.c:649:2: warning: argument 1 null where non-null 
expected [-Wnonnull]

I'm fixing this by adding a NULL pointer check and returning failure
from the function, which is hopefully already handled properly.

This seems to date back to when the drivers were originally added,
so backporting the fix to stable seems appropriate. There are other
related realtek drivers in the kernel, but none of them contain a
function with a similar name or produce this warning.


Aced-by: Larry Finger <larry.fin...@lwfinger.net>

Arnd,

Please let me now if gcc-7 shows any warnings for the code in 
drivers/net/wireless/realtek/rtlwifi/. My distro supplies gcc-4.8, and it wouod 
be a lot of work to implement gcc-7.


Larry



Cc: sta...@vger.kernel.org
Fixes: 1cc18a22b96b ("staging: r8188eu: Add files for new driver - part 5")
Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline 
kernel")
Signed-off-by: Arnd Bergmann <a...@arndb.de>
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 2 ++
 drivers/staging/rtl8712/rtl871x_recv.c| 7 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 1bc7b97bf2ad..f2021fed704c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -1313,6 +1313,8 @@ static int wlanhdr_to_ethhdr(struct recv_frame 
*precvframe)
pattrib->eth_type = eth_type;

ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr) + 
(bsnaphdr ? 2 : 0)));
+   if (!ptr)
+   return _FAIL;

memcpy(ptr, pattrib->dst, ETH_ALEN);
memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN);
diff --git a/drivers/staging/rtl8712/rtl871x_recv.c 
b/drivers/staging/rtl8712/rtl871x_recv.c
index 4388ddf02b2c..147b75beea73 100644
--- a/drivers/staging/rtl8712/rtl871x_recv.c
+++ b/drivers/staging/rtl8712/rtl871x_recv.c
@@ -640,11 +640,16 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
/* append rx status for mp test packets */
ptr = recvframe_pull(precvframe, (rmv_len -
  sizeof(struct ethhdr) + 2) - 24);
+   if (!ptr)
+   return _FAIL;
memcpy(ptr, get_rxmem(precvframe), 24);
ptr += 24;
-   } else
+   } else {
ptr = recvframe_pull(precvframe, (rmv_len -
  sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
+   if (!ptr)
+   return _FAIL;
+   }

memcpy(ptr, pattrib->dst, ETH_ALEN);
memcpy(ptr + ETH_ALEN, pattrib->src, ETH_ALEN);



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


[PATCH 7/7] rtlwifi: btcoexist control to enter/leave LPS

2016-12-03 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

Bluetooth coexistence needs to be able to control the power-save
state. This patch turns the building of btcoexist back on.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/base.c|  8 +++
 .../wireless/realtek/rtlwifi/btcoexist/Makefile|  2 +
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   |  7 ++-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 18 ++
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |  3 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c| 63 ++---
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c| 64 +++---
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c| 64 +++---
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  8 +--
 9 files changed, 206 insertions(+), 31 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index a1cfec3..d0aa23c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1758,12 +1758,20 @@ void rtl_watchdog_wq_callback(void *data)
false;
}
 
+   /* PS is controlled by coex. */
+   if (rtlpriv->cfg->ops->get_btc_status() &&
+   rtlpriv->btcoexist.btc_ops->btc_is_bt_ctrl_lps(rtlpriv))
+   goto label_lps_done;
+
if (((rtlpriv->link_info.num_rx_inperiod +
  rtlpriv->link_info.num_tx_inperiod) > 8) ||
(rtlpriv->link_info.num_rx_inperiod > 2))
rtl_lps_leave(hw);
else
rtl_lps_enter(hw);
+
+label_lps_done:
+   ;
}
 
rtlpriv->link_info.num_rx_inperiod = 0;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/Makefile 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/Makefile
index c7df4e6..3657e8b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/Makefile
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/Makefile
@@ -6,5 +6,7 @@ btcoexist-objs :=   halbtc8192e2ant.o   \
halbtcoutsrc.o  \
rtl_btc.o
 
+obj-$(CONFIG_RTLBTCOEXIST) += btcoexist.o
+
 ccflags-y += -D__CHECK_ENDIAN__
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 6e0c0af..c50d5c4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -276,14 +276,19 @@ static void halbtc_enter_lps(struct btc_coexist 
*btcoexist)
}
 
btcoexist->bt_info.bt_ctrl_lps = true;
-   btcoexist->bt_info.bt_lps_on = false;
+   btcoexist->bt_info.bt_lps_on = true;
rtl_lps_enter(rtlpriv->mac80211.hw);
 }
 
 static void halbtc_normal_lps(struct btc_coexist *btcoexist)
 {
+   struct rtl_priv *rtlpriv;
+
+   rtlpriv = btcoexist->adapter;
+
if (btcoexist->bt_info.bt_ctrl_lps) {
btcoexist->bt_info.bt_lps_on = false;
+   rtl_lps_leave(rtlpriv->mac80211.hw);
btcoexist->bt_info.bt_ctrl_lps = false;
}
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index b1f8fd2..0b70d35 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -47,6 +47,9 @@ static struct rtl_btc_ops rtl_btc_operation = {
.btc_is_bt_disabled = rtl_btc_is_bt_disabled,
.btc_special_packet_notify = rtl_btc_special_packet_notify,
.btc_record_pwr_mode = rtl_btc_record_pwr_mode,
+   .btc_get_lps_val = rtl_btc_get_lps_val,
+   .btc_get_rpwm_val = rtl_btc_get_rpwm_val,
+   .btc_is_bt_ctrl_lps = rtl_btc_is_bt_ctrl_lps,
 };
 
 void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 *buf, u8 len)
@@ -61,6 +64,21 @@ void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 
*buf, u8 len)
memcpy(gl_bt_coexist.pwr_mode_val, buf, safe_len);
 }
 
+u8 rtl_btc_get_lps_val(struct rtl_priv *rtlpriv)
+{
+   return gl_bt_coexist.bt_info.lps_val;
+}
+
+u8 rtl_btc_get_rpwm_val(struct rtl_priv *rtlpriv)
+{
+   return gl_bt_coexist.bt_info.rpwm_val;
+}
+
+bool rtl_btc_is_bt_ctrl_lps(struct rtl_priv *rtlpriv)
+{
+   return gl_bt_coexist.bt_info.bt_ctrl_lps;
+}
+
 void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
 {
exhalbtc_initlize_variables();
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index d145909..81c378e 1

[PATCH 0/7] rtlwifi: btcoexist: Rewrite BT coexistence routines

2016-12-03 Thread Larry Finger
This set of patches implement a major rewrite of the BT coexistence
routines.

These patches must follow [PATCH 14/14] rtlwifi: Add work queue for c2h cmd.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>

Ping-Ke Shih (7)
  rtlwifi: btcoexist: Update routines for RTL8192EE
  rtlwifi: btcoexist: Rewrite halbtc8723b1ant code
  rtlwifi: btcoexist: Rewrite of halbtc8723b2ant
  rtlwifi: btcoexist: Rewrite routine halbtc8821a1ant
  rtlwifi: btcoexist: Rewrite routine halbtc8821a2ant
  rtlwifi: Add btcoex record_pwr_mode
  rtlwifi: btcoexist control to enter/leave LPS

 drivers/net/wireless/realtek/rtlwifi/base.c|8 +
 .../wireless/realtek/rtlwifi/btcoexist/Makefile|7 +-
 .../realtek/rtlwifi/btcoexist/halbt_precomp.h  |   22 +
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.c| 4598 ---
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.h|  243 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.c| 5165 +++--
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.h|  342 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c| 5495 +++---
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h|  287 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c| 3233 ++-
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h|  148 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.c| 6122 +++-
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h|  273 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 1018 +++-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  364 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |   74 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |5 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|   67 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|4 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|   68 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|   23 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c|2 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|   68 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|   33 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h|5 +
 25 files changed, 16246 insertions(+), 11428 deletions(-)

-- 
2.10.2

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


[PATCH 6/7] rtlwifi: Add btcoex record_pwr_mode

2016-12-03 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

Add code to set the power mode bits in the descriptor. These bits are
valid in RTL8723BE, RTL8821AE, RTL8812AE, and RTL8192EE.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 13 +
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |  1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|  6 +++-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|  4 ++-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|  6 +++-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h| 23 +--
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|  6 +++-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h| 33 --
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  1 +
 9 files changed, 65 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index b1f0f2b..b1f8fd2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -46,8 +46,21 @@ static struct rtl_btc_ops rtl_btc_operation = {
.btc_is_disable_edca_turbo = rtl_btc_is_disable_edca_turbo,
.btc_is_bt_disabled = rtl_btc_is_bt_disabled,
.btc_special_packet_notify = rtl_btc_special_packet_notify,
+   .btc_record_pwr_mode = rtl_btc_record_pwr_mode,
 };
 
+void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 *buf, u8 len)
+{
+   u8 safe_len;
+
+   safe_len = sizeof(gl_bt_coexist.pwr_mode_val);
+
+   if (safe_len > len)
+   safe_len = len;
+
+   memcpy(gl_bt_coexist.pwr_mode_val, buf, safe_len);
+}
+
 void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
 {
exhalbtc_initlize_variables();
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index 08e50f8..d145909 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -44,6 +44,7 @@ bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv);
 void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type);
+void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 *buf, u8 len);
 
 struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
index 4fc8dee..77edf0d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
@@ -500,7 +500,7 @@ void rtl92ee_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 
mode)
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 u1_h2c_set_pwrmode[H2C_92E_PWEMODE_LENGTH] = { 0 };
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-   u8 rlbm , power_state = 0;
+   u8 rlbm, power_state = 0, byte5 = 0x40;
 
RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD , "FW LPS mode = %d\n", mode);
 
@@ -518,10 +518,14 @@ void rtl92ee_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, 
u8 mode)
else
power_state |= FW_PWR_STATE_RF_OFF;
SET_H2CCMD_PWRMODE_PARM_PWR_STATE(u1_h2c_set_pwrmode, power_state);
+   SET_H2CCMD_PWRMODE_PARM_BYTE5(u1_h2c_set_pwrmode, byte5);
 
RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
  "rtl92c_set_fw_pwrmode(): u1_h2c_set_pwrmode\n",
  u1_h2c_set_pwrmode, H2C_92E_PWEMODE_LENGTH);
+   rtlpriv->btcoexist.btc_ops->btc_record_pwr_mode(rtlpriv,
+   u1_h2c_set_pwrmode,
+   H2C_92E_PWEMODE_LENGTH);
rtl92ee_fill_h2c_cmd(hw, H2C_92E_SETPWRMODE, H2C_92E_PWEMODE_LENGTH,
 u1_h2c_set_pwrmode);
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
index 72da3f9..7dcb57a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
@@ -37,7 +37,7 @@
 #define USE_OLD_WOWLAN_DEBUG_FW 0
 
 #define H2C_92E_RSVDPAGE_LOC_LEN   5
-#define H2C_92E_PWEMODE_LENGTH 5
+#define H2C_92E_PWEMODE_LENGTH 7
 #define H2C_92E_JOINBSSRPT_LENGTH  1
 #define H2C_92E_AP_OFFLOAD_LENGTH  3
 #define H2C_92E_WOWLAN_LENGTH  3
@@ -154,6 +154,8 @@ enum rtl8192e_c2h_evt {
SET_BITS_TO_LE_1BYTE((__cmd)+3, 0, 8, __val)
 #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__cmd, __val)\
SET_BITS_TO_LE_1BYTE((__cmd)+4, 0, 8

[PATCH 12/14] rtlwifi: btcoexist: Add vendor definition for new btcoexist

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

Routine halbtc_get() will need to be able to get the vendor ID.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 3 +++
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 7 +++
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index be451473..9a89ae0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -364,6 +364,9 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, 
void *out_buf)
case BTC_GET_U4_BT_PATCH_VER:
*u32_tmp = halbtc_get_bt_patch_version(btcoexist);
break;
+   case BTC_GET_U4_VENDOR:
+   *u32_tmp = BTC_VENDOR_OTHER;
+   break;
case BTC_GET_U1_WIFI_DOT11_CHNL:
*u8_tmp = rtlphy->current_channel;
break;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index d4da3a1..103abd8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -251,6 +251,7 @@ enum btc_get_type {
BTC_GET_U4_WIFI_FW_VER,
BTC_GET_U4_WIFI_LINK_STATUS,
BTC_GET_U4_BT_PATCH_VER,
+   BTC_GET_U4_VENDOR,
 
/* type u1Byte */
BTC_GET_U1_WIFI_DOT11_CHNL,
@@ -268,6 +269,12 @@ enum btc_get_type {
BTC_GET_MAX
 };
 
+enum btc_vendor {
+   BTC_VENDOR_LENOVO,
+   BTC_VENDOR_ASUS,
+   BTC_VENDOR_OTHER
+};
+
 enum btc_set_type {
/* type bool */
BTC_SET_BL_BT_DISABLE,
-- 
2.10.2

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


[PATCH 14/14] rtlwifi: Add work queue for c2h cmd.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

btcoex needs to sleep, thus it must run in thread context.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/base.c| 92 ++
 drivers/net/wireless/realtek/rtlwifi/base.h|  3 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c| 15 +++-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|  3 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|  1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c| 18 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|  3 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|  1 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c| 18 -
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|  3 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|  1 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h| 14 
 12 files changed, 159 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index edab6ec..a1cfec3 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -478,6 +478,8 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
  (void *)rtl_swlps_rfon_wq_callback);
INIT_DELAYED_WORK(>works.fwevt_wq,
  (void *)rtl_fwevt_wq_callback);
+   INIT_DELAYED_WORK(>works.c2hcmd_wq,
+ (void *)rtl_c2hcmd_wq_callback);
 
 }
 
@@ -492,6 +494,7 @@ void rtl_deinit_deferred_work(struct ieee80211_hw *hw)
cancel_delayed_work(>works.ps_work);
cancel_delayed_work(>works.ps_rfon_wq);
cancel_delayed_work(>works.fwevt_wq);
+   cancel_delayed_work(>works.c2hcmd_wq);
 }
 EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
 
@@ -559,6 +562,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
spin_lock_init(>locks.rf_lock);
spin_lock_init(>locks.waitq_lock);
spin_lock_init(>locks.entry_list_lock);
+   spin_lock_init(>locks.c2hcmd_lock);
spin_lock_init(>locks.cck_and_rw_pagea_lock);
spin_lock_init(>locks.check_sendpkt_lock);
spin_lock_init(>locks.fw_ps_lock);
@@ -566,6 +570,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
spin_lock_init(>locks.iqk_lock);
/* <5> init list */
INIT_LIST_HEAD(>entry_list);
+   INIT_LIST_HEAD(>c2hcmd_list);
 
rtlmac->link_state = MAC80211_NOLINK;
 
@@ -578,6 +583,7 @@ EXPORT_SYMBOL_GPL(rtl_init_core);
 
 void rtl_deinit_core(struct ieee80211_hw *hw)
 {
+   rtl_c2hcmd_launcher(hw, 0);
 }
 EXPORT_SYMBOL_GPL(rtl_deinit_core);
 
@@ -1826,6 +1832,92 @@ void rtl_fwevt_wq_callback(void *data)
 
rtlpriv->cfg->ops->c2h_command_handle(hw);
 }
+
+void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   unsigned long flags;
+   struct rtl_c2hcmd *c2hcmd;
+
+   c2hcmd = kmalloc(sizeof(*c2hcmd), GFP_KERNEL);
+
+   if (!c2hcmd)
+   goto label_err;
+
+   c2hcmd->val = kmalloc(len, GFP_KERNEL);
+
+   if (!c2hcmd->val)
+   goto label_err2;
+
+   /* fill data */
+   c2hcmd->tag = tag;
+   c2hcmd->len = len;
+   memcpy(c2hcmd->val, val, len);
+
+   /* enqueue */
+   spin_lock_irqsave(>locks.c2hcmd_lock, flags);
+
+   list_add_tail(>list, >c2hcmd_list);
+
+   spin_unlock_irqrestore(>locks.c2hcmd_lock, flags);
+
+   /* wake up wq */
+   queue_delayed_work(rtlpriv->works.rtl_wq, >works.c2hcmd_wq, 0);
+
+   return;
+
+label_err2:
+   kfree(c2hcmd);
+
+label_err:
+   RT_TRACE(rtlpriv, COMP_CMD, DBG_WARNING,
+"C2H cmd enqueue fail.\n");
+}
+EXPORT_SYMBOL(rtl_c2hcmd_enqueue);
+
+void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   unsigned long flags;
+   struct rtl_c2hcmd *c2hcmd;
+
+   while (true) {
+   /* dequeue a task */
+   spin_lock_irqsave(>locks.c2hcmd_lock, flags);
+
+   c2hcmd = list_first_entry_or_null(>c2hcmd_list,
+ struct rtl_c2hcmd, list);
+
+   if (c2hcmd)
+   list_del(>list);
+
+   spin_unlock_irqrestore(>locks.c2hcmd_lock, flags);
+
+   /* do it */
+   if (!c2hcmd)
+   break;
+
+   if (rtlpriv->cfg->ops->c2h_content_parsing && exec)
+   rtlpriv->cfg->ops->c2h_content_parsing(hw,
+   c2hcmd->tag, c2hcmd->len, c2hcmd->val);
+
+   /* free */
+   kf

[PATCH 05/14] rtlwifi: Add TX report and disable key will wait until report acked.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

When using EAPOL to do a PTK rekey, there is a possible race condition.
When msg 3/4 is received, the supplicant will send msg 4/4 and install
the new key immediately; however, the driver must make sure that msg 4/4
is sent before installing the new key. We use TX report to ensure it is
sent.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/base.c| 117 ++---
 drivers/net/wireless/realtek/rtlwifi/base.h|   7 ++
 drivers/net/wireless/realtek/rtlwifi/core.c|   2 +
 drivers/net/wireless/realtek/rtlwifi/debug.c   |   2 +-
 drivers/net/wireless/realtek/rtlwifi/debug.h   |   1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |   8 ++
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |   8 ++
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.h   |  12 +++
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|   3 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |   8 ++
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.h   |  13 +++
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  10 ++
 14 files changed, 180 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index fa2d26a..edab6ec 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1107,6 +1107,9 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
if (txrate)
tcb_desc->hw_rate = txrate->hw_value;
 
+   if (rtl_is_tx_report_skb(hw, skb))
+   tcb_desc->use_spe_rpt = 1;
+
if (ieee80211_is_data(fc)) {
/*
 *we set data rate INX 0
@@ -1315,21 +1318,13 @@ static void setup_arp_tx(struct rtl_priv *rtlpriv, 
struct rtl_ps_ctl *ppsc)
ppsc->last_delaylps_stamp_jiffies = jiffies;
 }
 
-/*should call before software enc*/
-u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
-  bool is_enc)
+static const u8 *rtl_skb_ether_type_ptr(struct ieee80211_hw *hw,
+   struct sk_buff *skb, bool is_enc)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
-   struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-   __le16 fc = rtl_get_fc(skb);
-   u16 ether_type;
u8 mac_hdr_len = ieee80211_get_hdrlen_from_skb(skb);
u8 encrypt_header_len = 0;
u8 offset;
-   const struct iphdr *ip;
-
-   if (!ieee80211_is_data(fc))
-   goto end;
 
switch (rtlpriv->sec.pairwise_enc_algorithm) {
case WEP40_ENCRYPTION:
@@ -1349,10 +1344,29 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,
offset = mac_hdr_len + SNAP_SIZE;
if (is_enc)
offset += encrypt_header_len;
-   ether_type = be16_to_cpup((__be16 *)(skb->data + offset));
+
+   return skb->data + offset;
+}
+
+/*should call before software enc*/
+u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
+  bool is_enc)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
+   __le16 fc = rtl_get_fc(skb);
+   u16 ether_type;
+   const u8 *ether_type_ptr;
+   const struct iphdr *ip;
+
+   if (!ieee80211_is_data(fc))
+   goto end;
+
+   ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, is_enc);
+   ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
 
if (ETH_P_IP == ether_type) {
-   ip = (struct iphdr *)((u8 *)skb->data + offset +
+   ip = (struct iphdr *)((u8 *)ether_type_ptr +
 PROTOC_TYPE_SIZE);
if (IPPROTO_UDP == ip->protocol) {
struct udphdr *udp = (struct udphdr *)((u8 *)ip +
@@ -1402,6 +1416,85 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,
 }
 EXPORT_SYMBOL_GPL(rtl_is_special_data);
 
+bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+   u16 ether_type;
+   const u8 *ether_type_ptr;
+
+   ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, true);
+   ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
+
+   /* EAPOL */
+   if (ether_type == ETH_P_PAE)
+   return true;
+
+   return false;
+}
+
+u16 rtl_get_tx_report_sn(struct ieee80211_hw *hw)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_tx_report *tx_report = >tx_report;
+   u16 sn;
+
+   sn = atomic_inc_return(_report->sn) & 0x0FFF;
+
+   tx_report->last_sent_sn = sn;
+   tx_report->last_sent_time = j

[PATCH 11/14] rtlwifi: Add a new enumeration value to btc_set_type

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

The new value is needed for future capability.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index 190826f..d4da3a1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -286,6 +286,7 @@ enum btc_set_type {
/* type trigger some action */
BTC_SET_ACT_GET_BT_RSSI,
BTC_SET_ACT_AGGREGATE_CTRL,
+   BTC_SET_ACT_ANTPOSREGRISTRY_CTRL,
 
/* for 1Ant **/
/* type bool */
-- 
2.10.2

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


[PATCH 08/14] rtlwifi: rtl8723be: btcoex: add package_type function to btcoex

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

The new code handles the package-type of the chip.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   |  7 +
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |  2 ++
 drivers/net/wireless/realtek/rtlwifi/efuse.c   |  5 ++--
 drivers/net/wireless/realtek/rtlwifi/efuse.h   |  1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c| 33 ++
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  9 ++
 6 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index d69bf32..d2e4960 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -163,6 +163,13 @@ u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
return num;
 }
 
+u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
+{
+   struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+
+   return rtlhal->package_type;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index bba7e23e..fff5117 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -50,6 +50,8 @@ u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv);
+u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv);
+
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c 
b/drivers/net/wireless/realtek/rtlwifi/efuse.c
index 7becfef..a6985e1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/efuse.c
+++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c
@@ -70,8 +70,6 @@ static void efuse_word_enable_data_read(u8 word_en, u8 
*sourdata,
u8 *targetdata);
 static u8 enable_efuse_data_write(struct ieee80211_hw *hw,
  u16 efuse_addr, u8 word_en, u8 *data);
-static void efuse_power_switch(struct ieee80211_hw *hw, u8 write,
-  u8 pwrstate);
 static u16 efuse_get_current_size(struct ieee80211_hw *hw);
 static u8 efuse_calculate_word_cnts(u8 word_en);
 
@@ -1121,7 +1119,7 @@ static u8 enable_efuse_data_write(struct ieee80211_hw *hw,
return badworden;
 }
 
-static void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate)
+void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -1207,6 +1205,7 @@ static void efuse_power_switch(struct ieee80211_hw *hw, 
u8 write, u8 pwrstate)
}
}
 }
+EXPORT_SYMBOL(efuse_power_switch);
 
 static u16 efuse_get_current_size(struct ieee80211_hw *hw)
 {
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.h 
b/drivers/net/wireless/realtek/rtlwifi/efuse.h
index 51aa121..49a5fb2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/efuse.h
+++ b/drivers/net/wireless/realtek/rtlwifi/efuse.h
@@ -109,6 +109,7 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw);
 void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw);
 void efuse_force_write_vendor_Id(struct ieee80211_hw *hw);
 void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx);
+void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate);
 int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
   int max_size, u8 *hwinfo, int *params);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 54a26da..c2cd99f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2022,6 +2022,37 @@ static void 
_rtl8723be_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
"eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
 }
 
+static u8 _rtl8723be_read_package_type(struct ieee80211_hw *hw)
+{
+   u8 package_type;
+   u8 value;
+
+   efuse_power_switch(hw, false, true);
+   if (!efuse_one_byte_read(hw, 0x1FB, ))
+   value = 0;
+   efuse_power_switch(hw, false, false);
+
+   switch (value & 0x7) {
+   case 0x4:
+   package_type = PACKAGE_TFBGA79;
+   break;
+   case 0x5:
+   package_type = PACKAGE_TFBGA90;
+   break;
+   

[PATCH 13/14] rtlwifi: rtl8723be: fix ant_sel code

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

When ant_sel is set, we need to fill single_ant_path to select correct
antenna path.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index c2cd99f..00473a6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2700,9 +2700,13 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct 
ieee80211_hw *hw,
}
 
/* override ant_num / ant_path */
-   if (mod_params->ant_sel)
+   if (mod_params->ant_sel) {
rtlpriv->btcoexist.btc_info.ant_num =
(mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
+
+   rtlpriv->btcoexist.btc_info.single_ant_path =
+   (mod_params->ant_sel == 1 ? 0 : 1);
+   }
 }
 
 void rtl8723be_bt_reg_init(struct ieee80211_hw *hw)
-- 
2.10.2

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


[PATCH 10/14] rtlwifi: Add BTC_TRACE_STRING to new btcoex

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

Add a new debugging function.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   | 23 ++
 drivers/net/wireless/realtek/rtlwifi/debug.h   | 14 +
 2 files changed, 37 insertions(+)

Index: 
wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
===
--- 
wireless-drivers-next.orig/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ 
wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -27,6 +27,29 @@
 
 #include   "../wifi.h"
 
+#ifdef CONFIG_RTLWIFI_DEBUG
+
+#define BTC_SPRINTF(ptr, ...)  snprintf(ptr, ##__VA_ARGS__)
+#define BTC_TRACE(fmt) \
+do {   \
+   struct rtl_priv *rtlpriv = gl_bt_coexist.adapter;   \
+   if (!rtlpriv)   \
+   break;  \
+   RT_TRACE_STRING(rtlpriv, COMP_COEX, DBG_LOUD, fmt); \
+} while (0)
+
+#else
+
+static inline void BTC_SPRINTF(char *ptr, ...)
+{
+}
+
+static inline void BTC_TRACE(const char *ptr)
+{
+}
+
+#endif
+
 #defineNORMAL_EXEC false
 #defineFORCE_EXEC  true
 
Index: wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/debug.h
===
--- wireless-drivers-next.orig/drivers/net/wireless/realtek/rtlwifi/debug.h
+++ wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/debug.h
@@ -194,6 +194,15 @@ do {   
\
}   \
 } while (0)
 
+#define RT_TRACE_STRING(__priv, comp, level, string)   \
+do {   \
+   if (unlikely(((comp) & __priv->dbg.global_debugcomponents) &&   \
+((level) <= __priv->dbg.global_debuglevel))) { \
+   printk(KBUILD_MODNAME ":%s():<%lx> %s", \
+  __func__, in_interrupt(), string);   \
+   }   \
+} while (0)
+
 #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata,  \
  _hexdatalen)  \
 do {   \
@@ -230,6 +239,11 @@ static inline void RTPRINT(struct rtl_pr
 {
 }
 
+static inline void RT_TRACE_STRING(struct rtl_priv *rtlpriv,
+  u64 comp, int level, const char *string)
+{
+}
+
 static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
 u64 comp, int level,
 const char *titlestring,
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/14] rtlwifi: ibtcoex: move bt_type declaration

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

Routine rtl_get_hwpg_bt_type() is better in halbtcoutsrc.c than in
rtl_btc.c.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 5 +
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c  | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index d2e4960..be451473 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -151,6 +151,11 @@ u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
return rtlpriv->btcoexist.btc_info.single_ant_path;
 }
 
+u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
+{
+   return rtlpriv->btcoexist.btc_info.bt_type;
+}
+
 u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
 {
u8 num;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index 54e893c..46e0fa6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -198,11 +198,6 @@ u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
return rtlpriv->btcoexist.btc_info.btcoexist;
 }
 
-u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
-{
-   return rtlpriv->btcoexist.btc_info.bt_type;
-}
-
 MODULE_AUTHOR("Page He <page...@realsil.com.cn>");
 MODULE_AUTHOR("Realtek WlanFAE <wlan...@realtek.com>");
 MODULE_AUTHOR("Larry Finger<larry.fin...@lwfinger.net>");
-- 
2.10.2

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


[PATCH 03/14] rtlwifi: Set retry limit depends on vif type.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

We assign different retry limit according to vif type, because
it can boost performance in field.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: shaofu <sha...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/core.c | 21 ++---
 drivers/net/wireless/realtek/rtlwifi/pci.c  |  7 +++
 drivers/net/wireless/realtek/rtlwifi/ps.c   |  3 +++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index 7c2ac24..35b620a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -234,6 +234,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
int err = 0;
+   u8 retry_limit = 0x30;
 
if (mac->vif) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
@@ -272,6 +273,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
(u8 *)(>basic_rates));
 
+   retry_limit = 0x07;
break;
case NL80211_IFTYPE_P2P_GO:
mac->p2p = P2P_ROLE_GO;
@@ -288,6 +290,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
mac->basic_rates = 0xff0;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
  (u8 *)(>basic_rates));
+
+   retry_limit = 0x07;
break;
case NL80211_IFTYPE_MESH_POINT:
RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
@@ -301,6 +305,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
mac->basic_rates = 0xff0;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
(u8 *)(>basic_rates));
+
+   retry_limit = 0x07;
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
@@ -322,6 +328,10 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
 
+   mac->retry_long = retry_limit;
+   mac->retry_short = retry_limit;
+   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
+   (u8 *)(_limit));
 out:
mutex_unlock(>locks.conf_mutex);
return err;
@@ -647,10 +657,15 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 
changed)
RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
 hw->conf.long_frame_max_tx_count);
-   mac->retry_long = hw->conf.long_frame_max_tx_count;
-   mac->retry_short = hw->conf.long_frame_max_tx_count;
-   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
+   /* brought up everything changes (changed == ~0) indicates first
+* open, so use our default value instead of that of wiphy.
+*/
+   if (changed != ~0) {
+   mac->retry_long = hw->conf.long_frame_max_tx_count;
+   mac->retry_short = hw->conf.long_frame_max_tx_count;
+   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
(u8 *)(>conf.long_frame_max_tx_count));
+   }
}
 
if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c 
b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 8bfe020..0991298 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -1214,6 +1214,10 @@ static void _rtl_pci_init_struct(struct ieee80211_hw *hw,
mac->current_ampdu_density = 7;
mac->current_ampdu_factor = 3;
 
+   /*Retry Limit*/
+   mac->retry_short = 7;
+   mac->retry_long = 7;
+
/*QOS*/
rtlpci->acm_method = EACMWAY2_SW;
 
@@ -1820,6 +1824,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
+   struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
 
int err;
 
@@ -1837,6 +1842,8 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
 "Failed to config hardware!\n");
return err;
   

[PATCH 02/14] rtlwifi: Fix programing CAM content sequence.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

There is a potential race condition when the control byte of a CAM
entry is written first. Write in reverse order to correct the condition.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: shaofu <sha...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/cam.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/cam.c 
b/drivers/net/wireless/realtek/rtlwifi/cam.c
index 8fe8b4c..5d58ec0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/cam.c
+++ b/drivers/net/wireless/realtek/rtlwifi/cam.c
@@ -45,12 +45,13 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, 
u32 entry_no,
 
u32 target_command;
u32 target_content = 0;
-   u8 entry_i;
+   s8 entry_i;
 
RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_DMESG, "Key content :",
  key_cont_128, 16);
 
-   for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
+   /* 0-1 config + mac, 2-5 fill 128key,6-7 are reserved */
+   for (entry_i = CAM_CONTENT_COUNT - 1; entry_i >= 0; entry_i--) {
target_command = entry_i + CAM_CONTENT_COUNT * entry_no;
target_command = target_command | BIT(31) | BIT(16);
 
@@ -102,7 +103,6 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, 
u32 entry_no,
target_content);
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
target_command);
-   udelay(100);
 
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
 "WRITE A4: %x\n", target_content);
-- 
2.10.2

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


[PATCH 01/14] rtlwifi: Correct power save capability while init mac80211

2016-12-01 Thread Larry Finger
Set IEEE80211_HW_SUPPORTS_PS when driver is fwlps
Because mac80211 control SW-LPS only, we add constraints to avoid errors.

Signed-off-by: Vincent Fann <vincent_f...@realtek.com>
Signed-off-by: shaofu <sha...@realtek.com>
Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/core.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 4ac928b..fa2d26a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -406,6 +406,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
ieee80211_hw_set(hw, SUPPORTS_PS);
ieee80211_hw_set(hw, PS_NULLFUNC_STACK);
}
+   if (rtlpriv->psc.fwctrl_lps)
+   ieee80211_hw_set(hw, SUPPORTS_PS);
hw->wiphy->interface_modes =
BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_STATION) |
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index 2caa4ad..7c2ac24 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -620,7 +620,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 
changed)
}
 
/*For LPS */
-   if (changed & IEEE80211_CONF_CHANGE_PS) {
+   if ((changed & IEEE80211_CONF_CHANGE_PS) &&
+   rtlpriv->psc.swctrl_lps && !rtlpriv->psc.fwctrl_lps) {
cancel_delayed_work(>works.ps_work);
cancel_delayed_work(>works.ps_rfon_wq);
if (conf->flags & IEEE80211_CONF_PS) {
-- 
2.10.2

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


[PATCH 06/14] rtlwifi: rtl8723be: btcoexist: Add single_ant_path

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

Some devices with RTL8732BE wifi/Bluetooth adapters are shipped with only
a single antenna. On a subset of these, the EEPROM is incorectly coded
to indicate the wrong connection. The resulting problems have been fixed
for wifi. This change handles them for BT.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 5 +
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h  | 1 +
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c   | 1 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h   | 1 +
 4 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 91cc139..0a47f135 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -146,6 +146,11 @@ static u8 halbtc_get_wifi_central_chnl(struct btc_coexist 
*btcoexist)
return chnl;
 }
 
+u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
+{
+   return rtlpriv->btcoexist.btc_info.single_ant_path;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index ccd5a0f..65c1c52 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -49,6 +49,7 @@ struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
 u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
+u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv);
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index aba60c3..5e98c26 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2661,6 +2661,7 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct 
ieee80211_hw *hw,
rtlpriv->btcoexist.btc_info.btcoexist = 0;
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
rtlpriv->btcoexist.btc_info.ant_num = ANT_X2;
+   rtlpriv->btcoexist.btc_info.single_ant_path = 0;
}
 
/* override ant_num / ant_path */
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 80e6f5e..4e3b441 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2471,6 +2471,7 @@ struct rtl_btc_info {
u8 bt_type;
u8 btcoexist;
u8 ant_num;
+   u8 single_ant_path;
 };
 
 struct bt_coexist_info {
-- 
2.10.2

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


[PATCH 07/14] rtlwifi: move btcoex's ant_num declaration

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih <pks...@realtek.com>

File halbtcoutsrc.c is a better place for routine rtl_get_hwpg_ant_num()
than file rtl_btc.c.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c| 12 
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c | 11 ---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c  |  2 ++
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 0a47f135..d69bf32 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -151,6 +151,18 @@ u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
return rtlpriv->btcoexist.btc_info.single_ant_path;
 }
 
+u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
+{
+   u8 num;
+
+   if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
+   num = 2;
+   else
+   num = 1;
+
+   return num;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index d3fd921..54e893c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -178,17 +178,6 @@ struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
 }
 EXPORT_SYMBOL(rtl_btc_get_ops_pointer);
 
-u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
-{
-   u8 num;
-
-   if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
-   num = 2;
-   else
-   num = 1;
-
-   return num;
-}
 
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw)
 {
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index 65c1c52..bba7e23e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -46,9 +46,9 @@ void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, 
u8 pkt_type);
 
 struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
 
-u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
+u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv);
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 5e98c26..54a26da 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2657,6 +2657,8 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct 
ieee80211_hw *hw,
value = hwinfo[EEPROM_RF_BT_SETTING_8723B];
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
rtlpriv->btcoexist.btc_info.ant_num = (value & 0x1);
+   rtlpriv->btcoexist.btc_info.single_ant_path =
+(value & 0x40);/*0xc3[6]*/
} else {
rtlpriv->btcoexist.btc_info.btcoexist = 0;
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
-- 
2.10.2

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


[PATCH 00/14] rtlwifi: Various updates

2016-12-01 Thread Larry Finger
Realtek has finished an extensive review and rewrite of the rtlwifi
drivers. Much of that work resulted in major changes to btcoexist.
Those changes are not included here, but will be submitted later.

These 14 changes fix a number of deficiencies. None of them are
serious enough to be pushed to stable; however they help in the
stability of the drivers, and in the robustness of authentication/
association.

This material should be sent to the 4.11 stream.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>

Vincent Fann (1)
  rtlwifi: Correct power save capability while init mac80211
Ping-Ke Shih (13)
  rtlwifi: Fix programing CAM content sequence.
  rtlwifi: Set retry limit depends on vif type.
  rtlwifi: extend debug_comp to u64
  rtlwifi: Add TX report and disable key will wait until report acked.
  rtlwifi: rtl8723be: btcoexist: Add single_ant_path
  rtlwifi: move btcoex's ant_num declaration
  rtlwifi: rtl8723be: btcoex: add package_type function to btcoex
  rtlwifi: ibtcoex: move bt_type declaration
  rtlwifi: Add BTC_TRACE_STRING to new btcoex
  rtlwifi: Add a new enumeration value to btc_set_type
  rtlwifi: btcoexist: Add vendor definition for new btcoexist
  rtlwifi: rtl8723be: fix ant_sel code
  rtlwifi: Add work queue for c2h cmd.

 drivers/net/wireless/realtek/rtlwifi/base.c| 211 +++--
 drivers/net/wireless/realtek/rtlwifi/base.h|  10 +
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   |  32 
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  31 +++
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |  16 --
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   5 +-
 drivers/net/wireless/realtek/rtlwifi/cam.c |   6 +-
 drivers/net/wireless/realtek/rtlwifi/core.c|  26 ++-
 drivers/net/wireless/realtek/rtlwifi/debug.c   |   4 +-
 drivers/net/wireless/realtek/rtlwifi/debug.h   |  19 +-
 drivers/net/wireless/realtek/rtlwifi/efuse.c   |   5 +-
 drivers/net/wireless/realtek/rtlwifi/efuse.h   |   1 +
 drivers/net/wireless/realtek/rtlwifi/pci.c |   7 +
 drivers/net/wireless/realtek/rtlwifi/ps.c  |   3 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|  16 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |   8 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|  19 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c|  42 +++-
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |   8 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.h   |  12 ++
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|  21 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|   3 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |   8 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.h   |  13 ++
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  34 
 30 files changed, 512 insertions(+), 57 deletions(-)

-- 
2.10.2

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


[PATCH 03/14] rtlwifi: extend debug_comp to u64

2016-12-01 Thread Larry Finger
The number of debugging conditions will exceed the capabilities of a
32-bit word.

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/debug.c | 2 +-
 drivers/net/wireless/realtek/rtlwifi/debug.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c 
b/drivers/net/wireless/realtek/rtlwifi/debug.c
index 33905bb..3e75ebc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.c
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.c
@@ -50,7 +50,7 @@ void rtl_dbgp_flag_init(struct ieee80211_hw *hw)
 EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
 
 #ifdef CONFIG_RTLWIFI_DEBUG
-void _rtl_dbg_trace(struct rtl_priv *rtlpriv, int comp, int level,
+void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
const char *modname, const char *fmt, ...)
 {
if (unlikely((comp & rtlpriv->dbg.global_debugcomponents) &&
diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.h 
b/drivers/net/wireless/realtek/rtlwifi/debug.h
index 6156a79..9c77ddaf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.h
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.h
@@ -178,7 +178,7 @@ do {
\
 struct rtl_priv;
 
 __printf(5, 6)
-void _rtl_dbg_trace(struct rtl_priv *rtlpriv, int comp, int level,
+void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
const char *modname, const char *fmt, ...);
 
 #define RT_TRACE(rtlpriv, comp, level, fmt, ...)   \
@@ -217,7 +217,7 @@ static inline void RT_ASSERT(int exp, const char *fmt, ...)
 
 __printf(4, 5)
 static inline void RT_TRACE(struct rtl_priv *rtlpriv,
-   int comp, int level,
+   u64 comp, int level,
const char *fmt, ...)
 {
 }
@@ -230,7 +230,7 @@ static inline void RTPRINT(struct rtl_priv *rtlpriv,
 }
 
 static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
-int comp, int level,
+u64 comp, int level,
 const char *titlestring,
 const void *hexdata, size_t hexdatalen)
 {
-- 
2.10.2

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


Re: [PATCH 1/7] rtlwifi: btcoexist: Update routines for RTL8192EE

2016-12-05 Thread Larry Finger

On 12/05/2016 05:38 AM, Dan Carpenter wrote:

On Sat, Dec 03, 2016 at 11:32:01AM -0600, Larry Finger wrote:

From: Ping-Ke Shih <pks...@realtek.com>

The btcoexist routines for the RTL8192EE have been extensively rewritten.



This patch does a million things and is totally unreviewable.  The
patch description doesn't say what patch does or why.  It's 5k lines
of diff.  What the heck???


I am caught in a bind. The BT coexistence routines are written by a Realtek 
contractor. As I cannot get the individual patches from Realtek, there is no 
chance of getting them from a 3rd party.


Larry


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


Re: [PATCH 10/14] rtlwifi: Add BTC_TRACE_STRING to new btcoex

2016-12-05 Thread Larry Finger

On 12/05/2016 03:34 PM, Dan Carpenter wrote:

On Thu, Dec 01, 2016 at 07:48:29PM -0600, Larry Finger wrote:

--- 
wireless-drivers-next.orig/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ 
wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -27,6 +27,29 @@

 #include   "../wifi.h"

+#ifdef CONFIG_RTLWIFI_DEBUG
+
+#define BTC_SPRINTF(ptr, ...)  snprintf(ptr, ##__VA_ARGS__)
+#define BTC_TRACE(fmt) \
+do {   \
+   struct rtl_priv *rtlpriv = gl_bt_coexist.adapter;   \
+   if (!rtlpriv)   \
+   break;  \
+   RT_TRACE_STRING(rtlpriv, COMP_COEX, DBG_LOUD, fmt); \
+} while (0)
+


This sort of macro is exactly when the rtl drivers spent so long in
staging...  Subsystems should not invent their own tracing but in
particular these macros are so very very ugly.

It's just super frustrating to even look at this...

There are a lot of staging drivers I feel good about when they leave.
The HyperV drivers.  The IIO stuff.  A lot of the media stuff and
generally the media tree is getting better and better.  I like comedi
and unisys, those are in staging, but they are great and could move out
any time as far as I'm concerned.

But this patch just makes me super discouraged.  What are we doing???


Dan,

It would not matter to me if these drivers got moved to staging, but there are a 
lot of users whose distros do not build staging drivers that would be very unhappy.


Can you point me to a driver with a better way to conditionally dump a debugging 
string to the logs?


Larry

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


[PATCH] rtlwifi: Fix kernel oops introduced with commit e49656147359

2016-12-19 Thread Larry Finger
With commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of
kfree_skb"), the method used to free an skb was changed because the
kfree_skb() was inside a spinlock. What was forgotten is that kfree_skb()
guards against a NULL value for the argument. Routine dev_kfree_skb_irq()
does not, and a test is needed to prevent kernel panics.

Fixes: commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of 
kfree_skb")
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Stable <sta...@vger.kernel.org> (4.9+)
Cc: Wei Yongjun <weiyongj...@huawei.com>
---
Kalle,

This change should be sent to mainline during the 4.10 merge period,
or as soon as possible.

Thanks,

Larry
---
 drivers/net/wireless/realtek/rtlwifi/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index 955055b..df8b977 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -1823,7 +1823,8 @@ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct 
sk_buff *skb)
 
spin_lock_irqsave(>locks.irq_th_lock, flags);
pskb = __skb_dequeue(>queue);
-   dev_kfree_skb_irq(pskb);
+   if (pskb)
+   dev_kfree_skb_irq(pskb);
 
/*this is wrong, fill_tx_cmddesc needs update*/
pdesc = >desc[0];
-- 
2.10.2

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


[PATCH] rtlwifi: rtl_usb: Fix missing entry in USB driver's private data

2016-12-21 Thread Larry Finger
These drivers need to be able to reference "struct ieee80211_hw" from
the driver's private data, and vice versa. The USB driver failed to
store the address of ieee80211_hw in the private data. Although this
bug has been present for a long time, it was not exposed until
commit ba9f93f82aba ("rtlwifi: Fix enter/exit power_save").

Fixes: ba9f93f82aba ("rtlwifi: Fix enter/exit power_save")
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---

Kalle,

This patch needs to be included in 4.10.

Larry
---
 drivers/net/wireless/realtek/rtlwifi/usb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c 
b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 40160c7..bf00399 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1047,6 +1047,7 @@ int rtl_usb_probe(struct usb_interface *intf,
return -ENOMEM;
}
rtlpriv = hw->priv;
+   rtlpriv->hw = hw;
rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
GFP_KERNEL);
if (!rtlpriv->usb_data)
-- 
2.10.2

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


Re: [PATCH] rtlwifi: Fix kernel oops introduced with commit e49656147359

2016-12-20 Thread Larry Finger

On 12/20/2016 05:21 AM, Kalle Valo wrote:

Larry Finger <larry.fin...@lwfinger.net> writes:


With commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of
kfree_skb"), the method used to free an skb was changed because the
kfree_skb() was inside a spinlock. What was forgotten is that kfree_skb()
guards against a NULL value for the argument. Routine dev_kfree_skb_irq()
does not, and a test is needed to prevent kernel panics.

Fixes: commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of 
kfree_skb")


This should be:

Fixes: e49656147359 ("rtlwifi: Use dev_kfree_skb_irq instead of kfree_skb")


Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Stable <sta...@vger.kernel.org> (4.9+)


And this:

Cc: Stable <sta...@vger.kernel.org> # 4.9+

I can fix both of them.


Cc: Wei Yongjun <weiyongj...@huawei.com>
---
Kalle,

This change should be sent to mainline during the 4.10 merge period,
or as soon as possible.


Ok, I'll queue this to 4.10. Most likely I'll send a pull request to
Dave later this week or so.


Thanks for the suggested changes, and for the quick action.

Larry


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


Re: [PATCH 10/14] rtlwifi: Add BTC_TRACE_STRING to new btcoex

2016-12-07 Thread Larry Finger

On 12/07/2016 07:32 AM, Dan Carpenter wrote:

On Wed, Dec 07, 2016 at 02:16:06PM +0200, Kalle Valo wrote:

We have disccused this before, but for wireless it's not really that
simple. AFAIK with dyndbg you can only control the messages per line
(painful to enable group of messages) or per file (enables too many
messages). In wireless we have cases when we need to enable group of
messages, but not all.


You can turn them on by the function or a range of lines, then disable
the spammy lines.  With these new debug macros you can't do that so this
is a step backwards.

If I'm totally honest, I've never seen uglier macros than these.  I work
in staging and I've spent a lot of time in ancient code but these ones
really take the cake.


They will be coming out. The Realtek engineer and I are learning more about the 
various options to see what to use. The dynamic debugging options seem to be the 
best at the moment.


Larry


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


Re: [PATCH] staging: rtl8723bs: remove null test before kfree

2017-04-10 Thread Larry Finger

On 04/10/2017 08:43 AM, Aishwarya Pant wrote:

kfree(..) on a NULL pointer is a no-op; the null test here is redundant.
Detected by coccicheck.

Signed-off-by: Aishwarya Pant <aishp...@gmail.com>


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

Thanks,

Larry


---
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c |  6 ++
 drivers/staging/rtl8723bs/hal/sdio_ops.c  |  6 ++
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  8 ++-
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c| 26 ++-
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c |  6 ++
 5 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index d40ad03..910f7fa 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -995,8 +995,7 @@ if (1) {
rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_USAGE, (u8 
*)_usage);
}

-   if (efuseTbl)
-   kfree(efuseTbl);
+   kfree(efuseTbl);
 }

 static void hal_ReadEFuse_BT(
@@ -1128,8 +1127,7 @@ static void hal_ReadEFuse_BT(
}

 exit:
-   if (efuseTbl)
-   kfree(efuseTbl);
+   kfree(efuseTbl);
 }

 static void Hal_ReadEFuse(
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c 
b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index cf09a0a..6285b72 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -602,8 +602,7 @@ static s32 _sdio_local_read(
if (!err)
memcpy(pbuf, ptmpbuf, cnt);

-   if (ptmpbuf)
-   kfree(ptmpbuf);
+   kfree(ptmpbuf);

return err;
 }
@@ -646,8 +645,7 @@ s32 sdio_local_read(
if (!err)
memcpy(pbuf, ptmpbuf, cnt);

-   if (ptmpbuf)
-   kfree(ptmpbuf);
+   kfree(ptmpbuf);

return err;
 }
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index d2c6604..52aa65b 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1170,10 +1170,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, 
struct net_device *ndev,
}

 addkey_end:
-   if (param)
-   {
-   kfree((u8 *)param);
-   }
+   kfree((u8 *)param);

return ret;

@@ -1968,8 +1965,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter 
*padapter, u8 *pie, size_t iel
pairwise_cipher, padapter->securitypriv.ndisencryptstatus, 
padapter->securitypriv.ndisauthtype));

 exit:
-   if (buf)
-   kfree(buf);
+   kfree(buf);
if (ret)
_clr_fwstate_(>mlmepriv, WIFI_UNDER_WPS);
return ret;
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index fe3c42a..e11045f 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -766,9 +766,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,

 exit:

-   if (pwep) {
-   kfree((u8 *)pwep);
-   }
+   kfree((u8 *)pwep);
return ret;
 }

@@ -926,7 +924,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char 
*pie, unsigned short ie

 exit:

-   if (buf) kfree(buf);
+   kfree(buf);

return ret;
 }
@@ -2502,10 +2500,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
ret =  wpa_set_encryption(dev, param, param_len);

 exit:
-   if (param)
-   {
-   kfree((u8 *)param);
-   }
+   kfree((u8 *)param);

return ret;
 }
@@ -4135,11 +4130,7 @@ static int rtw_set_encryption(struct net_device *dev, 
struct ieee_param *param,
}

 exit:
-
-   if (pwep)
-   {
-   kfree((u8 *)pwep);
-   }
+   kfree((u8 *)pwep);

return ret;

@@ -5785,12 +5776,9 @@ static int rtw_ioctl_wext_private(struct net_device 
*dev, union iwreq_data *wrq_
}

 exit:
-   if (input)
-   kfree(input);
-   if (buffer)
-   kfree(buffer);
-   if (output)
-   kfree(output);
+   kfree(input);
+   kfree(buffer);
+   kfree(output);

return err;
 }
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c 
b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 66dfec1..7696816 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -76,10 +76,8 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, 
struct xmit_buf *pxmitb

 void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf 
*pxmitbuf, u32 free_sz, u8 flag)
 {
-   if (free_sz > 0) {
-   if (pxmitbuf->pallocated_buf)
-   kfr

Re: [PATCH 06/22] staging: rtl8723bs: Fix various errors in os_dep/ioctl_cfg80211.c

2017-04-09 Thread Larry Finger

On 04/09/2017 10:28 AM, Bastien Nocera wrote:

On Sat, 2017-04-08 at 11:07 -0500, Larry Finger wrote:

Smatch lists the following:

  CHECK   drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:470
rtw_cfg80211_ibss_indicate_connect() error: we previously assumed
'scanned' could be null (see line 466)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:942
rtw_cfg80211_set_encryption() warn: inconsistent indenting
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:955
rtw_cfg80211_set_encryption() error: buffer overflow 'psecuritypriv-

dot11DefKey' 4 <= 4

drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1017
rtw_cfg80211_set_encryption() error: buffer overflow 'padapter-

securitypriv.dot118021XGrpKey' 5 <= 5

drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1216
cfg80211_rtw_set_default_key() warn: inconsistent indenting
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2498
rtw_cfg80211_monitor_if_xmit_entry() error: we previously assumed
'skb' could be null (see line 2495)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2850
cfg80211_rtw_start_ap() warn: if statement not indented
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2860
cfg80211_rtw_start_ap() warn: if statement not indented
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:3417
rtw_cfg80211_preinit_wiphy() warn: inconsistent indenting
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:3547
rtw_wdev_alloc() info: ignoring unreachable code.

The indenting warnings were fixed by simple white space changes.

The section where 'scanned' could be null required an immediate exit
from
the routine at that point. A similar fix was required where 'skb'
could be null.

The two buffer overflow errors were caused by off-by-one errors.
While
locating these problems, another one was found in
os_dep/ioctl_linux.c.


Could you please split those up into patches that fix one kind of
problem? Makes it easier to review.


These patches were merged earlier today. Thanks for the reviews.

Larry


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


[PATCH 04/22] staging: rtl8723bs: Fix indenting warning in os_dep/os_intfs.c

2017-04-08 Thread Larry Finger
Smatch logs the following warning:

  CHECK   drivers/staging/rtl8723bs/os_dep/os_intfs.c
drivers/staging/rtl8723bs/os_dep/os_intfs.c:1082 ips_netdrv_open() warn: 
inconsistent indenting

A simple change in the white space handles this warning.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c 
b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 2ed3067b4af0..843be2cc6c10 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -1079,7 +1079,7 @@ static int  ips_netdrv_open(struct adapter *padapter)
 
_set_timer(>mlmepriv.dynamic_chk_timer, 2000);
 
-return _SUCCESS;
+   return _SUCCESS;
 
 netdev_open_error:
/* padapter->bup = false; */
-- 
2.12.0

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


[PATCH 05/22] staging: rtl8723bs: Fix indenting mistake in os_dep/mlme_linux.c

2017-04-08 Thread Larry Finger
Smatch reports the following warning:

  CHECK   drivers/staging/rtl8723bs/os_dep/mlme_linux.c
drivers/staging/rtl8723bs/os_dep/mlme_linux.c:149 rtw_os_indicate_disconnect() 
warn: inconsistent indenting

Again, a simple change in the white space fixes this problem.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c 
b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
index aa1793389797..46315d1a82f7 100644
--- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
@@ -145,8 +145,8 @@ void rtw_os_indicate_disconnect(struct adapter *adapter)
 
rtw_indicate_wx_disassoc_event(adapter);
 
-/* modify for CONFIG_IEEE80211W, none 11w also can use the same 
command */
-rtw_reset_securitypriv_cmd(adapter);
+   /* modify for CONFIG_IEEE80211W, none 11w also can use the same command 
*/
+   rtw_reset_securitypriv_cmd(adapter);
 }
 
 void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
-- 
2.12.0

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


[PATCH 08/22] staging: rtl8723bs: Fix indenting problems in hal/HalHWImg8723B_BB.c

2017-04-08 Thread Larry Finger
Smatch lists the following:

  CHECK   drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c:314 
ODM_ReadAndConfig_MP_8723B_AGC_TAB() warn: for statement not indented
drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c:583 
ODM_ReadAndConfig_MP_8723B_PHY_REG() warn: for statement not indented
drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c:586 
ODM_ReadAndConfig_MP_8723B_PHY_REG() warn: inconsistent indenting

These were all fixed with white-space changes.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c 
b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
index b42f06076f93..51d4219177d3 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
@@ -312,7 +312,7 @@ void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm)
*   Discard the following (offset, data) pairs.
*/
while (v1 < 0x4000 && i < ArrayLen-2)
-   READ_NEXT_PAIR(v1, v2, i);
+   READ_NEXT_PAIR(v1, v2, i);
 
i -= 2; /*  prevent from for-loop += 2 */
} else {
@@ -581,9 +581,9 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm)
*   Discard the following (offset, data) pairs.
*/
while (v1 < 0x4000 && i < ArrayLen-2)
-   READ_NEXT_PAIR(v1, v2, i);
+   READ_NEXT_PAIR(v1, v2, i);
 
-   i -= 2; /*  prevent from for-loop += 2 
*/
+   i -= 2; /*  prevent from for-loop += 2 */
} else { /*  Configure matched pairs and skip to end of 
if-else. */
while (v1 < 0x4000 && i < ArrayLen-2) {
odm_ConfigBB_PHY_8723B(pDM_Odm, v1, 
bMaskDWord, v2);
-- 
2.12.0

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


[PATCH 06/22] staging: rtl8723bs: Fix various errors in os_dep/ioctl_cfg80211.c

2017-04-08 Thread Larry Finger
Smatch lists the following:

  CHECK   drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:470 
rtw_cfg80211_ibss_indicate_connect() error: we previously assumed 'scanned' 
could be null (see line 466)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:942 
rtw_cfg80211_set_encryption() warn: inconsistent indenting
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:955 
rtw_cfg80211_set_encryption() error: buffer overflow 
'psecuritypriv->dot11DefKey' 4 <= 4
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1017 
rtw_cfg80211_set_encryption() error: buffer overflow 
'padapter->securitypriv.dot118021XGrpKey' 5 <= 5
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1216 
cfg80211_rtw_set_default_key() warn: inconsistent indenting
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2498 
rtw_cfg80211_monitor_if_xmit_entry() error: we previously assumed 'skb' could 
be null (see line 2495)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2850 cfg80211_rtw_start_ap() 
warn: if statement not indented
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2860 cfg80211_rtw_start_ap() 
warn: if statement not indented
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:3417 
rtw_cfg80211_preinit_wiphy() warn: inconsistent indenting
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:3547 rtw_wdev_alloc() info: 
ignoring unreachable code.

The indenting warnings were fixed by simple white space changes.

The section where 'scanned' could be null required an immediate exit from
the routine at that point. A similar fix was required where 'skb' could be null.

The two buffer overflow errors were caused by off-by-one errors. While
locating these problems, another one was found in os_dep/ioctl_linux.c.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 38 +--
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c|  2 +-
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index ce7cca68ff7a..d2c66041a561 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -463,9 +463,10 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter 
*padapter)
}
else
{
-   if (scanned == NULL)
+   if (scanned == NULL) {
rtw_warn_on(1);
-
+   return;
+   }
if (!memcmp(&(scanned->network.Ssid), 
&(pnetwork->Ssid), sizeof(struct ndis_802_11_ssid))
&& !memcmp(scanned->network.MacAddress, 
pnetwork->MacAddress, sizeof(NDIS_802_11_MAC_ADDRESS))
) {
@@ -906,7 +907,7 @@ static int rtw_cfg80211_set_encryption(struct net_device 
*dev, struct ieee_param
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
{
if (param->u.crypt.idx >= WEP_KEYS
-   && param->u.crypt.idx > BIP_MAX_KEYID
+   || param->u.crypt.idx >= BIP_MAX_KEYID
)
{
ret = -EINVAL;
@@ -927,7 +928,7 @@ static int rtw_cfg80211_set_encryption(struct net_device 
*dev, struct ieee_param
wep_key_idx = param->u.crypt.idx;
wep_key_len = param->u.crypt.key_len;
 
-   if ((wep_key_idx > WEP_KEYS) || (wep_key_len <= 0))
+   if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0))
{
ret = -EINVAL;
goto exit;
@@ -939,7 +940,7 @@ static int rtw_cfg80211_set_encryption(struct net_device 
*dev, struct ieee_param
 
wep_key_len = wep_key_len <= 5 ? 5 : 13;
 
-   psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
+   psecuritypriv->ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
 
@@ -1213,11 +1214,8 @@ static int cfg80211_rtw_set_default_key(struct wiphy 
*wiphy,
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = >securitypriv;
 
-   DBG_871X(FUNC_NDEV_FMT" key_index =%d"
-   ", unicast =%d, multicast =%d"
-   ".\n", FUNC_NDEV_ARG(ndev), key_index
-   , unicast, multicast
-   );
+   DBG_871X(FUNC_NDEV_FMT" key_index =%d, unicast =%d, multicast =%d\n",
+FUNC_NDEV_ARG(ndev), key_index, unicast, mult

[PATCH 07/22] staging: rtl8723bs: Fix potential usage while NULL error in hal/rtl8723b_hal_init.c

2017-04-08 Thread Larry Finger
Smatch logs the following:

  CHECK   drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:518 
rtl8723b_FirmwareDownload() error: we previously assumed 'pFirmware' could be 
null (see line 382)

Fixing this error required a rewrite of the error exits from this routine.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index b7f6dc7ce318..d40ad03e99a3 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -377,13 +377,13 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, 
bool  bUsedWoWLANFw)
RT_TRACE(_module_hal_init_c_, _drv_notice_, ("+%s, bUsedWoWLANFw:%d\n", 
__func__, bUsedWoWLANFw));
 #endif
pFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
+   if (!pFirmware)
+   return _FAIL;
pBTFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
-
-   if (!pFirmware || !pBTFirmware) {
-   rtStatus = _FAIL;
-   goto exit;
+   if (!pBTFirmware) {
+   kfree(pFirmware);
+   return _FAIL;
}
-
tmp_ps = rtw_read8(padapter, 0xa3);
tmp_ps &= 0xf8;
tmp_ps |= 0x02;
@@ -441,7 +441,7 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, 
bool  bUsedWoWLANFw)
if (pFirmware->ulFwLength > FW_8723B_SIZE) {
rtStatus = _FAIL;
DBG_871X_LEVEL(_drv_emerg_, "Firmware size:%u exceed %u\n", 
pFirmware->ulFwLength, FW_8723B_SIZE);
-   goto exit;
+   goto release_fw1;
}
 
pFirmwareBuf = pFirmware->szFwBuffer;
@@ -517,6 +517,7 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, 
bool  bUsedWoWLANFw)
 exit:
kfree(pFirmware->szFwBuffer);
kfree(pFirmware);
+release_fw1:
kfree(pBTFirmware);
DBG_871X(" <=== rtl8723b_FirmwareDownload()\n");
return rtStatus;
-- 
2.12.0

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


[PATCH 01/22] staging: rtl8723bs: Fix indenting warning in os_dep/xmit_linux.c

2017-04-08 Thread Larry Finger
Smatch issues the warning

  CHECK   drivers/staging/rtl8723bs/os_dep/xmit_linux.c
drivers/staging/rtl8723bs/os_dep/xmit_linux.c:42 _rtw_pktfile_read() warn: 
inconsistent indenting

A simple indent changes fixes this.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c 
b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 5ede3b6fbdec..66dfec18f770 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -39,7 +39,7 @@ uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, 
uint rlen)
len =  rtw_remainder_len(pfile);
len = (rlen > len)? len: rlen;
 
-   if (rmem)
+   if (rmem)
skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, 
len);
 
pfile->cur_addr += len;
-- 
2.12.0

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


[PATCH 02/22] staging: rtl8723bs: Fix indenting warning in os_dep/rtw_proc.c

2017-04-08 Thread Larry Finger
Smatch lists the following warning:

  CHECK   drivers/staging/rtl8723bs/os_dep/rtw_proc.c
drivers/staging/rtl8723bs/os_dep/rtw_proc.c:102 rtw_drv_proc_open() warn: 
inconsistent indenting

This warning is fixed with a simple change in the white space.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/os_dep/rtw_proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c 
b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
index 4088381dff35..a2011e06d719 100644
--- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
+++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
@@ -99,7 +99,8 @@ static int rtw_drv_proc_open(struct inode *inode, struct file 
*file)
/* struct net_device *dev = proc_get_parent_data(inode); */
ssize_t index = (ssize_t)PDE_DATA(inode);
const struct rtw_proc_hdl *hdl = drv_proc_hdls+index;
-   return single_open(file, hdl->show, NULL);
+
+   return single_open(file, hdl->show, NULL);
 }
 
 static ssize_t rtw_drv_proc_write(struct file *file, const char __user 
*buffer, size_t count, loff_t *pos)
-- 
2.12.0

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


[PATCH 00/22] staging: rtl87232bs: Fix errors and warnings detected by Smatch

2017-04-08 Thread Larry Finger
A number of routines have indenting, off by one, and possible usage
while null warnings or errors listed by Smatch. This set of patches
fix all but one of these, and it is in code that will be removed in a
subsequent patch.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>


Larry Finger (22):
  staging: rtl8723bs: Fix indenting warning in os_dep/xmit_linux.c
  staging: rtl8723bs: Fix indenting warning in os_dep/rtw_proc.c
  staging: rtl8723bs: Fix dereference before check warning in
os_dep/recv_linux.c
  staging: rtl8723bs: Fix indenting warning in os_dep/os_intfs.c
  staging: rtl8723bs: Fix indenting mistake in os_dep/mlme_linux.c
  staging: rtl8723bs: Fix various errors in os_dep/ioctl_cfg80211.c
  staging: rtl8723bs: Fix potential usage while NULL error in
hal/rtl8723b_hal_init.c
  staging: rtl8723bs: Fix indenting problems in hal/HalHWImg8723B_BB.c
  staging: rtl8723bs: Fix indening problem in hal/hal_com_phycfg.c
  staging: rtl8723bs: Fix indenting problem for hal/hal_com.c
  staging: rtl8723bs: Fix indenting problems in core/rtw_xmit.c
  staging: rtl8723bs: Fix possible usage of NULL pointer in
core/rtw_debug.c
  staging: rtl8723bs: Fix indenting mistake in core/rtw_ap.c
  staging: rtl8723bs: Fix indenting mistakes in core/rtw_ieee80211.c
  staging: rtl8723bs: Fix indenting mistakes in core/rtw_mlme.c
  staging: rtl8723bs: Fix some indenting problems and a potential data
overrun
  staging: rtl8723bs: Fix indenting problem in core/rtw_sta_mgt.c
  staging: rtl8723bs: Fix some white-space errors in core/rtw_security.c
  staging: rtl8723bs: Fix white-space errors in core/rtw_recv.c
  staging rtl8723bs: Fix indenting errors and an off-by-one mistake in
core/rtw_mlme_ext.c
  staging: rtl8723bs: Fix indenting problems in core/rtw_odm.c
  staging: rtlwifi: Fix indenting error in core/rtw_pwrctrl.c

 drivers/staging/rtl8723bs/core/rtw_ap.c   |  99 +++--
 drivers/staging/rtl8723bs/core/rtw_debug.c|   1 -
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c|  13 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c |  37 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  25 +-
 drivers/staging/rtl8723bs/core/rtw_odm.c  |  10 +-
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  |   2 +-
 drivers/staging/rtl8723bs/core/rtw_recv.c |  21 +-
 drivers/staging/rtl8723bs/core/rtw_security.c | 469 +++---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c  |   2 +-
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c|  10 +-
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  10 +-
 drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c  |   6 +-
 drivers/staging/rtl8723bs/hal/hal_com.c   |  10 +-
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c|   2 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c |  13 +-
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  38 +-
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c|   2 +-
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c |   4 +-
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   |   2 +-
 drivers/staging/rtl8723bs/os_dep/recv_linux.c |   3 +-
 drivers/staging/rtl8723bs/os_dep/rtw_proc.c   |   3 +-
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c |   2 +-
 23 files changed, 375 insertions(+), 409 deletions(-)

-- 
2.12.0

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


[PATCH 03/22] staging: rtl8723bs: Fix dereference before check warning in os_dep/recv_linux.c

2017-04-08 Thread Larry Finger
Smatch lists the following warning:

  CHECK   drivers/staging/rtl8723bs/os_dep/recv_linux.c
drivers/staging/rtl8723bs/os_dep/recv_linux.c:353 rtw_recv_indicatepkt() warn: 
variable dereferenced before check 'precv_frame' (see line 312)

This warning is fixed by removing the test at line 353.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/os_dep/recv_linux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c 
b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index c677a5216b54..e731ab4e2bd7 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -350,8 +350,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union 
recv_frame *precv_frame
 _recv_indicatepkt_drop:
 
 /* enqueue back to free_recv_queue */
-if (precv_frame)
-rtw_free_recvframe(precv_frame, pfree_recv_queue);
+rtw_free_recvframe(precv_frame, pfree_recv_queue);
 
 DBG_COUNTER(padapter->rx_logs.os_indicate_err);
 return _FAIL;
-- 
2.12.0

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


Re: [PATCH] staging: rtl8723bs: core: drop unneeded null tests

2017-04-08 Thread Larry Finger

On 04/08/2017 12:32 PM, Julia Lawall wrote:



On Sat, 8 Apr 2017, Hans de Goede wrote:


Hi Julia,

On 08-04-17 19:10, Julia Lawall wrote:

kfree returns immediately on NULL so the tests are not needed.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

CC: Hans de Goede <hdego...@redhat.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>


Thank you for these patches. Larry Finger has just
posted a large cleanup series for the rtl8723bs
driver, which will likely conflict with these.

Can you rebase and resend these patches once Larry's
series has been merged please?


OK, thanks for the update.  There were a bunch of other coccicheck
warnings.  But I will wait for the improved version.


Julia,

Rather than fixing checkpatch or coccicheck problems, my intent is to now strip 
out unneeded code such as the part that handles 5G channels. That should make a 
lot of formatting patches not be needed. I did the Smatch fixes because a number 
of them were potentially able to cause crashes.


As I am not sure how soon I will be doing the next fixes, I will not submit any 
more patches until yours are rebased and merged.


Larry


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


[PATCH 18/22] staging: rtl8723bs: Fix some white-space errors in core/rtw_security.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_security.c
drivers/staging/rtl8723bs/core/rtw_security.c:266 rtw_wep_encrypt() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:433 rtw_seccalctkipmic() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:749 rtw_tkip_encrypt() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:865 rtw_tkip_decrypt() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1383 aes_cipher() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1415 aes_cipher() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1430 aes_cipher() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1582 rtw_aes_encrypt() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1651 aes_decipher() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1739 aes_decipher() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_security.c:1792 aes_decipher() warn: curly 
braces intended?
drivers/staging/rtl8723bs/core/rtw_security.c:1809 aes_decipher() warn: 
inconsistent indenting

All of the above are fixed with white-space changes. A few unneeded
blank lines are deleted.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_security.c | 469 +-
 1 file changed, 229 insertions(+), 240 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c 
b/drivers/staging/rtl8723bs/core/rtw_security.c
index 698e11e5d0a9..e832f16997b7 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -262,17 +262,15 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
*pxmitframe)
arcfour_encrypt(, payload+length, 
crc, 4);
 
} else{
-   length = 
pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
+   length = 
pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
*((__le32 *)crc) = getcrc32(payload, length);
arcfour_init(, wepkey, 3+keylength);
arcfour_encrypt(, payload, payload, 
length);
arcfour_encrypt(, payload+length, 
crc, 4);
 
-   pframe += pxmitpriv->frag_len;
-   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
-
+   pframe += pxmitpriv->frag_len;
+   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
}
-
}
 
WEP_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
@@ -429,7 +427,7 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 
data_len, u8 *mic_cod
 
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
if (header[1]&1) {   /* ToDS == 1 */
-   rtw_secmicappend(, [16], 6);  /* DA */
+   rtw_secmicappend(, [16], 6);  /* DA */
if (header[1]&2)  /* From Ds == 1 */
rtw_secmicappend(, [24], 6);
else
@@ -746,9 +744,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 
*pxmitframe)
arcfour_encrypt(, payload, 
payload, length);
arcfour_encrypt(, 
payload+length, crc, 4);
 
-   pframe += pxmitpriv->frag_len;
-   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
-
+   pframe += pxmitpriv->frag_len;
+   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
}
}
 
@@ -791,10 +788,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 
*precvframe)
 
/* 4 start to decrypt recvframe */
if (prxattrib->encrypt == _TKIP_) {
-
stainfo = rtw_get_stainfo(>stapriv, 
>ta[0]);
if (stainfo != NULL) {
-
if (IS_MCAST(prxattrib->ra)) {
static unsigned long start = 0;
static u32 no_gkey_bc_cnt = 0;
@@ -860,8 +855,9 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 
*precvframe)
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, 
length-4));
 
if (crc[3] != payload[length-1] || crc[2] != 
payload[length-2] || crc[1] != payload[length-3] || crc[0] != 
payload[length-4]) {
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || 
crc[2](%x)!=payload[length-2](%x) || crc

[PATCH 17/22] staging: rtl8723bs: Fix indenting problem in core/rtw_sta_mgt.c

2017-04-08 Thread Larry Finger
Sparse reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c:25 _rtw_init_stainfo() warn: 
inconsistent indenting

This problem is fixed with a white-spcae change.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index d7eee6dd7e3b..cb43ec90a648 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -22,7 +22,7 @@ void _rtw_init_stainfo(struct sta_info *psta)
 {
memset((u8 *)psta, 0, sizeof(struct sta_info));
 
-spin_lock_init(>lock);
+   spin_lock_init(>lock);
INIT_LIST_HEAD(>list);
INIT_LIST_HEAD(>hash_list);
/* INIT_LIST_HEAD(>asoc_list); */
-- 
2.12.0

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


[PATCH 11/22] staging: rtl8723bs: Fix indenting problems in core/rtw_xmit.c

2017-04-08 Thread Larry Finger
Smatch logs the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_xmit.c
drivers/staging/rtl8723bs/core/rtw_xmit.c:277 _rtw_init_xmit_priv() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_xmit.c:294 _rtw_free_xmit_priv() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_xmit.c:295 _rtw_free_xmit_priv() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_xmit.c:946 xmitframe_addmic() warn: 
inconsistent indenting

These are fixed with white-space changes.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c 
b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 60585540069a..8f2c9a6658bf 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -274,7 +274,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 
adapter *padapter)
rtw_alloc_hwxmits(padapter);
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
 
-  for (i = 0; i < 4; i++) {
+   for (i = 0; i < 4; i++) {
pxmitpriv->wmm_para_seq[i] = i;
}
 
@@ -290,8 +290,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 
adapter *padapter)
 
 void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv)
 {
-   int i;
-  struct adapter *padapter = pxmitpriv->adapter;
+   int i;
+   struct adapter *padapter = pxmitpriv->adapter;
struct xmit_frame   *pxmitframe = (struct xmit_frame *) 
pxmitpriv->pxmit_frame_buf;
struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
 
@@ -942,8 +942,8 @@ static s32 xmitframe_addmic(struct adapter *padapter, 
struct xmit_frame *pxmitfr
 
}
 
-  /* if (pqospriv->qos_option == 1) */
-  if (pattrib->qos_en)
+   /* if (pqospriv->qos_option == 1) */
+   if (pattrib->qos_en)
priority[0] = (u8)pxmitframe->attrib.priority;
 
 
-- 
2.12.0

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


[PATCH 12/22] staging: rtl8723bs: Fix possible usage of NULL pointer in core/rtw_debug.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_debug.c
drivers/staging/rtl8723bs/core/rtw_debug.c:454 proc_get_survey_info() error: we 
previously assumed 'phead' could be null (see line 453)
drivers/staging/rtl8723bs/core/rtw_debug.c:455 proc_get_survey_info() warn: 
variable dereferenced before check 'phead' (see line 454)

In the code, there are two successive calls to get_head(). The second
is removed.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_debug.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c 
b/drivers/staging/rtl8723bs/core/rtw_debug.c
index d34747b29309..51cef55d3f76 100644
--- a/drivers/staging/rtl8723bs/core/rtw_debug.c
+++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
@@ -451,7 +451,6 @@ int proc_get_survey_info(struct seq_file *m, void *v)
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
phead = get_list_head(queue);
plist = phead ? get_next(phead) : NULL;
-   plist = get_next(phead);
if ((!phead) || (!plist)) {
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
return 0;
-- 
2.12.0

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


[PATCH 13/22] staging: rtl8723bs: Fix indenting mistake in core/rtw_ap.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_ap.c
drivers/staging/rtl8723bs/core/rtw_ap.c:382 expire_timeout_chk() warn: 
inconsistent indenting

Fixing this requires changing the indentatikon of a long for loop.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_ap.c | 99 -
 1 file changed, 47 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 9c71692a3a05..68b750275dff 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -379,70 +379,65 @@ void expire_timeout_chk(struct adapter *padapter)
 
spin_unlock_bh(>asoc_list_lock);
 
-if (chk_alive_num) {
+   if (chk_alive_num) {
+   u8 backup_oper_channel = 0;
+   struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
+
+   /* switch to correct channel of current network  before issue 
keep-alive frames */
+   if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) {
+   backup_oper_channel = rtw_get_oper_ch(padapter);
+   SelectChannel(padapter, pmlmeext->cur_channel);
+   }
 
-   u8 backup_oper_channel = 0;
-   struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
-   /* switch to correct channel of current network  before issue 
keep-alive frames */
-   if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) {
-   backup_oper_channel = rtw_get_oper_ch(padapter);
-   SelectChannel(padapter, pmlmeext->cur_channel);
-   }
+   /* issue null data to check sta alive*/
+   for (i = 0; i < chk_alive_num; i++) {
+   int ret = _FAIL;
 
-   /* issue null data to check sta alive*/
-   for (i = 0; i < chk_alive_num; i++) {
-   int ret = _FAIL;
+   psta = rtw_get_stainfo_by_offset(pstapriv, 
chk_alive_list[i]);
+   if (!(psta->state & _FW_LINKED))
+   continue;
 
-   psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
-   if (!(psta->state & _FW_LINKED))
-   continue;
+   if (psta->state & WIFI_SLEEP_STATE)
+   ret = issue_nulldata(padapter, psta->hwaddr, 0, 
1, 50);
+   else
+   ret = issue_nulldata(padapter, psta->hwaddr, 0, 
3, 50);
 
-   if (psta->state & WIFI_SLEEP_STATE)
-   ret = issue_nulldata(padapter, psta->hwaddr, 0, 1, 50);
-   else
-   ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50);
+   psta->keep_alive_trycnt++;
+   if (ret == _SUCCESS) {
+   DBG_871X(
+   "asoc check, sta(" MAC_FMT ") is 
alive\n",
+   MAC_ARG(psta->hwaddr)
+   );
+   psta->expire_to = pstapriv->expire_to;
+   psta->keep_alive_trycnt = 0;
+   continue;
+   } else if (psta->keep_alive_trycnt <= 3) {
 
-   psta->keep_alive_trycnt++;
-   if (ret == _SUCCESS) {
+   DBG_871X(
+   "ack check for asoc expire, 
keep_alive_trycnt =%d\n",
+   psta->keep_alive_trycnt);
+   psta->expire_to = 1;
+   continue;
+   }
 
-   DBG_871X(
-   "asoc check, sta(" MAC_FMT ") is alive\n",
-   MAC_ARG(psta->hwaddr)
-   );
-   psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
-   continue;
-   } else if (psta->keep_alive_trycnt <= 3) {
-
-
DBG_871X(
-   "ack check for asoc expire, keep_alive_trycnt 
=%d\n",
-   psta->keep_alive_trycnt
-   );
-   psta->expire_to = 1;
-   continue;
-   }
-
-   psta->keep_alive_trycnt = 0;
-   DBG_871X(
-   "asoc expire "MAC_FMT", state = 0x%x\n",
-   MAC_ARG(psta->hwaddr),
-   psta->state
-   );
-   spin_lock_bh(>asoc_list_lock);
-

[PATCH 10/22] staging: rtl8723bs: Fix indenting problem for hal/hal_com.c

2017-04-08 Thread Larry Finger
Smatch lists the following:

  CHECK   drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c:2090 
Hal_ChannelPlanToRegulation() warn: inconsistent indenting

Fixed by changing the white space.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/hal/hal_com.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c 
b/drivers/staging/rtl8723bs/hal/hal_com.c
index 093978d8f2a4..1880d4140bee 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -1731,11 +1731,11 @@ void rtw_bb_rf_gain_offset(struct adapter *padapter)
for (i = 0; i < ArrayLen; i += 2) {
v1 = Array[i];
v2 = Array[i+1];
-if (v1 == 
padapter->eeprompriv.EEPROMRFGainVal) {
-   DBG_871X("Offset RF Gain. got 
v1 = 0x%x , v2 = 0x%x\n", v1, v2);
-   target = v2;
-   break;
-}
+   if (v1 == padapter->eeprompriv.EEPROMRFGainVal) 
{
+   DBG_871X("Offset RF Gain. got v1 = 0x%x 
, v2 = 0x%x\n", v1, v2);
+   target = v2;
+   break;
+   }
}
DBG_871X("padapter->eeprompriv.EEPROMRFGainVal = 0x%x , 
Gain offset Target Value = 0x%x\n", padapter->eeprompriv.EEPROMRFGainVal, 
target);
PHY_SetRFReg(padapter, RF_PATH_A, 
REG_RF_BB_GAIN_OFFSET, BIT18|BIT17|BIT16|BIT15, target);
-- 
2.12.0

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


[PATCH 14/22] staging: rtl8723bs: Fix indenting mistakes in core/rtw_ieee80211.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_ieee80211.c
drivers/staging/rtl8723bs/core/rtw_ieee80211.c:83 rtw_is_cckrates_included() 
warn: if statement not indented
drivers/staging/rtl8723bs/core/rtw_ieee80211.c:98 
rtw_is_cckratesonly_included() warn: if statement not indented

These warnings are fixed with white-space changes.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index af44a8cd26f8..4670e72368e5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -81,8 +81,8 @@ uint  rtw_is_cckrates_included(u8 *rate)
 
while (rate[i] !=  0) {
if  rate[i]) & 0x7f) == 2)  || (((rate[i]) & 0x7f) 
== 4) ||
-   (((rate[i]) & 0x7f) == 11)  || (((rate[i]) & 0x7f) == 
22))
-   return true;
+(((rate[i]) & 0x7f) == 11)  || (((rate[i]) & 0x7f) 
== 22))
+   return true;
i++;
}
 
@@ -95,16 +95,13 @@ uintrtw_is_cckratesonly_included(u8 *rate)
 
 
while (rate[i] != 0) {
-   if  rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) 
!= 4) &&
-   (((rate[i]) & 0x7f) != 11)  && (((rate[i]) & 
0x7f) != 22))
-
+   if  rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
+(((rate[i]) & 0x7f) != 11)  && (((rate[i]) & 0x7f) != 22))
return false;
-
-   i++;
+   i++;
}
 
return true;
-
 }
 
 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
-- 
2.12.0

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


[PATCH 16/22] staging: rtl8723bs: Fix some indenting problems and a potential data overrun

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_wlan_util.c
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:67 cckrates_included() warn: if 
statement not indented
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:81 cckratesonly_included() warn: 
if statement not indented
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:815 rtw_camid_alloc() warn: 
should '1 << (cam_id)' be a 64 bit type?

The first two are fixed with white-space changes. The third is fixed by
restricting cam_id to be less than 32.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index c966241df2ea..f485f541e36d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -65,8 +65,8 @@ int cckrates_included(unsigned char *rate, int ratelen)
 
for (i = 0; i < ratelen; i++) {
if  rate[i]) & 0x7f) == 2)  || (((rate[i]) & 0x7f) == 4) ||
-  (((rate[i]) & 0x7f) == 11)  || (((rate[i]) & 0x7f) 
== 22))
-   return true;
+(((rate[i]) & 0x7f) == 11)  || (((rate[i]) & 0x7f) == 22))
+   return true;
}
 
return false;
@@ -79,8 +79,8 @@ int cckratesonly_included(unsigned char *rate, int ratelen)
 
for (i = 0; i < ratelen; i++) {
if  rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
-  (((rate[i]) & 0x7f) != 11)  && (((rate[i]) & 0x7f) 
!= 22))
-   return false;
+(((rate[i]) & 0x7f) != 11)  && (((rate[i]) & 0x7f) != 22))
+   return false;
}
 
return true;
@@ -811,7 +811,7 @@ s16 rtw_camid_alloc(struct adapter *adapter, struct 
sta_info *sta, u8 kid)
}
 
 bitmap_handle:
-   if (cam_id >= 0)
+   if (cam_id >= 0 && cam_id < 32)
cam_ctl->bitmap |= BIT(cam_id);
 
spin_unlock_bh(_ctl->lock);
-- 
2.12.0

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


[PATCH 20/22] staging rtl8723bs: Fix indenting errors and an off-by-one mistake in core/rtw_mlme_ext.c

2017-04-08 Thread Larry Finger
Smatch lists the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:525 _mgt_dispatcher() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:1595 OnAssocReq() error: buffer 
overflow 'pstapriv->sta_aid' 32 <= 32
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:2391 dump_mgntframe_and_wait() 
warn: inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:2420 
dump_mgntframe_and_wait_ack() warn: inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:4969 process_80211d() error: 
testing array offset 'i' after use.
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:5738 linked_status_chk() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:6459 sitesurvey_cmd_hdl() warn: 
inconsistent indenting

The indenting problems were fixed with white-space changes. The error at
line 1595 was the result of an off-by-one error in a for loop. The error
at line 4969 was not fixed as that code lies inside a block of code that
only is needed for 5G channels. This chip only works at 2.4 GHz.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index e0a3cd64777f..18e78d5198c3 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -522,15 +522,14 @@ static void _mgt_dispatcher(struct adapter *padapter, 
struct mlme_handler *ptabl
u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
u8 *pframe = precv_frame->u.hdr.rx_data;
 
- if (ptable->func) {
-/* receive the frames that ra(a1) is my address or ra(a1) is 
bc address. */
-   if (memcmp(GetAddr1Ptr(pframe), 
myid(>eeprompriv), ETH_ALEN) &&
-   memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN))
-   return;
-
-   ptable->func(padapter, precv_frame);
-   }
+   if (ptable->func) {
+   /* receive the frames that ra(a1) is my address or ra(a1) is bc 
address. */
+   if (memcmp(GetAddr1Ptr(pframe), myid(>eeprompriv), 
ETH_ALEN) &&
+   memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN))
+   return;
 
+   ptable->func(padapter, precv_frame);
+   }
 }
 
 void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
@@ -1575,7 +1574,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
if (pstat->aid > 0) {
DBG_871X("  old AID %d\n", pstat->aid);
} else {
-   for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++)
+   for (pstat->aid = 1; pstat->aid < NUM_STA; pstat->aid++)
if (pstapriv->sta_aid[pstat->aid - 1] == NULL)
break;
 
@@ -2388,7 +2387,7 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, 
struct xmit_frame *pmgntfr
pxmitbuf->sctx = NULL;
spin_unlock_irqrestore(>lock_sctx, irqL);
 
-return ret;
+   return ret;
 }
 
 s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame 
*pmgntframe)
@@ -2417,7 +2416,7 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, 
struct xmit_frame *pmg
mutex_unlock(>ack_tx_mutex);
}
 
-return ret;
+   return ret;
 }
 
 static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
@@ -5735,7 +5734,7 @@ void linked_status_chk(struct adapter *padapter)
#else
rx_chk_limit = 8;
#endif
-   link_count_limit = 7; /*  16 sec */
+   link_count_limit = 7; /*  16 sec */
 
/*  Marked by Kurt 20130715 */
/*  For WiDi 3.5 and latered on, they don't ask WiDi sink to do 
roaming, so we could not check rx limit that strictly. */
@@ -6456,7 +6455,7 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)
Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false);
 
/* config the initial gain under scaning, need to write the BB 
registers */
-   initialgain = 0x1e;
+   initialgain = 0x1e;
 
rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 
*)());
 
-- 
2.12.0

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


[PATCH 22/22] staging: rtl8723bs: Fix indenting error in core/rtw_pwrctrl.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c:641 LeaveAllPowerSaveModeDirect() 
warn: inconsistent indenting

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index c5dd794dac4b..f708dbf5bfd4 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -638,7 +638,7 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
 
rtw_set_rpwm(Adapter, PS_STATE_S4);
 
-   up(>lock);
+   up(>lock);
 
rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0);
} else{
-- 
2.12.0

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


[PATCH 15/22] staging: rtl8723bs: Fix indenting mistakes in core/rtw_mlme.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_mlme.c
drivers/staging/rtl8723bs/core/rtw_mlme.c:862 rtw_survey_event_callback() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme.c:1102 rtw_free_assoc_resources() warn: 
if statement not indented
drivers/staging/rtl8723bs/core/rtw_mlme.c:1165 rtw_indicate_disconnect() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme.c:2830 rtw_restructure_ht_ie() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_mlme.c:2991 rtw_update_ht_cap() warn: 
inconsistent indenting

All of there are simple white-space errors. A typo is also fixed.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 37 +++
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index c95e0626b522..53755e5b97a6 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -856,7 +856,7 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
/*  lock pmlmepriv->lock when you accessing network_q */
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) {
- if (pnetwork->Ssid.Ssid[0] == 0) {
+   if (pnetwork->Ssid.Ssid[0] == 0) {
pnetwork->Ssid.SsidLength = 0;
}
rtw_add_network(adapter, pnetwork);
@@ -1100,8 +1100,7 @@ void rtw_free_assoc_resources(struct adapter *adapter, 
int lock_scanned_queue)
}
 
if (lock_scanned_queue)
-
-   adapter->securitypriv.key_mask = 0;
+   adapter->securitypriv.key_mask = 0;
 
rtw_reset_rx_info(pdbgpriv);
 }
@@ -1162,7 +1161,7 @@ void rtw_indicate_disconnect(struct adapter *padapter)
/* set ips_deny_time to avoid enter IPS before LPS leave */
rtw_set_ips_deny(padapter, 3000);
 
- _clr_fwstate_(pmlmepriv, _FW_LINKED);
+   _clr_fwstate_(pmlmepriv, _FW_LINKED);
 
rtw_clear_scan_deny(padapter);
}
@@ -2826,8 +2825,8 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
if (stbc_rx_enable)
ht_capie.cap_info |= 
cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_1R);/* RX STBC One spatial stream */
 
-   set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R);
-   break;
+   set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R);
+   break;
 
case RF_2T2R:
case RF_1T2R:
@@ -2984,22 +2983,22 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 
*pie, uint ie_len, u8 channe
 #else /* CONFIG_DISABLE_MCS13TO15 */

set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
 #endif /* CONFIG_DISABLE_MCS13TO15 */
-   }
+   }
 
-   /* switch to the 40M Hz mode accoring to the AP */
-   /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */
-   switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) {
-   case EXTCHNL_OFFSET_UPPER:
-   pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
-   break;
+   /* switch to the 40M Hz mode according to the AP */
+   /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */
+   switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) {
+   case EXTCHNL_OFFSET_UPPER:
+   pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
+   break;
 
-   case EXTCHNL_OFFSET_LOWER:
-   pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
-   break;
+   case EXTCHNL_OFFSET_LOWER:
+   pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
+   break;
 
-   default:
-   pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-   break;
+   default:
+   pmlmeext->cur_ch_offset = 
HAL_PRIME_CHNL_OFFSET_DONT_CARE;
+   break;
}
}
 
-- 
2.12.0

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


[PATCH 21/22] staging: rtl8723bs: Fix indenting problems in core/rtw_odm.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_odm.c
drivers/staging/rtl8723bs/core/rtw_odm.c:109 rtw_odm_dbg_comp_msg() warn: if 
statement not indented
drivers/staging/rtl8723bs/core/rtw_odm.c:146 rtw_odm_ability_msg() warn: if 
statement not indented

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_odm.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_odm.c 
b/drivers/staging/rtl8723bs/core/rtw_odm.c
index 5bc573386ad1..3144e8ec2fa2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_odm.c
+++ b/drivers/staging/rtl8723bs/core/rtw_odm.c
@@ -107,8 +107,9 @@ void rtw_odm_dbg_comp_msg(void *sel, struct adapter 
*adapter)
DBG_871X_SEL_NL(sel, "odm.DebugComponents = 0x%016llx\n", dbg_comp);
for (i = 0; i < RTW_ODM_COMP_MAX; i++) {
if (odm_comp_str[i])
-   DBG_871X_SEL_NL(sel, "%cBIT%-2d %s\n",
-   (BIT0 << i) & dbg_comp ? '+' : ' ', i, odm_comp_str[i]);
+   DBG_871X_SEL_NL(sel, "%cBIT%-2d %s\n",
+   (BIT0 << i) & dbg_comp ? '+' : ' ',
+   i, odm_comp_str[i]);
}
 }
 
@@ -144,8 +145,9 @@ void rtw_odm_ability_msg(void *sel, struct adapter *adapter)
DBG_871X_SEL_NL(sel, "odm.SupportAbility = 0x%08x\n", ability);
for (i = 0; i < RTW_ODM_ABILITY_MAX; i++) {
if (odm_ability_str[i])
-   DBG_871X_SEL_NL(sel, "%cBIT%-2d %s\n",
-   (BIT0 << i) & ability ? '+' : ' ', i, 
odm_ability_str[i]);
+   DBG_871X_SEL_NL(sel, "%cBIT%-2d %s\n",
+   (BIT0 << i) & ability ? '+' : ' ', i,
+   odm_ability_str[i]);
}
 }
 
-- 
2.12.0

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


[PATCH 19/22] staging: rtl8723bs: Fix white-space errors in core/rtw_recv.c

2017-04-08 Thread Larry Finger
Smart reports the following:

  CHECK   drivers/staging/rtl8723bs/core/rtw_recv.c
drivers/staging/rtl8723bs/core/rtw_recv.c:598 portctrl() warn: inconsistent 
indenting
drivers/staging/rtl8723bs/core/rtw_recv.c:838 sta2sta_data_frame() warn: 
inconsistent indenting
drivers/staging/rtl8723bs/core/rtw_recv.c:1547 validate_recv_frame() warn: 
inconsistent indenting

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 864538e8299d..6e98a1bd3e77 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -595,7 +595,7 @@ union recv_frame *portctrl(struct adapter *adapter, union 
recv_frame *precv_fram
memcpy(_tmp, ptr, 2);
ether_type = ntohs(be_tmp);
 
- if (ether_type == eapol_type)
+   if (ether_type == eapol_type)
prtnframe = precv_frame;
else {
/* free this frame */
@@ -827,17 +827,14 @@ sint sta2sta_data_frame(
sta_addr = pattrib->src;
 
} else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
-   {
-   /*  For Station mode, sa and bssid should always be 
BSSID, and DA is my mac-address */
-   if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) {
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("bssid != TA under STATION_MODE; drop pkt\n"));
-   ret = _FAIL;
-   goto exit;
-   }
-
-   sta_addr = pattrib->bssid;
+   /*  For Station mode, sa and bssid should always be BSSID, and 
DA is my mac-address */
+   if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) {
+   RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid != 
TA under STATION_MODE; drop pkt\n"));
+   ret = _FAIL;
+   goto exit;
}
 
+   sta_addr = pattrib->bssid;
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
if (bmcast) {
/*  For AP mode, if DA == MCAST, then BSSID should be 
also MCAST */
@@ -1517,6 +1514,7 @@ sint validate_recv_frame(struct adapter *adapter, union 
recv_frame *precv_frame)
u8 type;
u8 subtype;
sint retval = _SUCCESS;
+   u8 bDumpRxPkt;
 
struct rx_pkt_attrib *pattrib = _frame->u.hdr.attrib;
 
@@ -1544,8 +1542,6 @@ sint validate_recv_frame(struct adapter *adapter, union 
recv_frame *precv_frame)
pattrib->mdata = GetMData(ptr);
pattrib->privacy = GetPrivacy(ptr);
pattrib->order = GetOrder(ptr);
-{
-   u8 bDumpRxPkt;
rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt));
if (bDumpRxPkt == 1) /* dump all rx packets */
dump_rx_packet(ptr);
@@ -1553,7 +1549,6 @@ sint validate_recv_frame(struct adapter *adapter, union 
recv_frame *precv_frame)
dump_rx_packet(ptr);
else if ((bDumpRxPkt == 3) && (type == WIFI_DATA_TYPE))
dump_rx_packet(ptr);
-}
 
switch (type) {
case WIFI_MGT_TYPE: /* mgnt */
-- 
2.12.0

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


[PATCH 09/22] staging: rtl8723bs: Fix indening problem in hal/hal_com_phycfg.c

2017-04-08 Thread Larry Finger
Smatch reports the following:

  CHECK   drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c:2090 
Hal_ChannelPlanToRegulation() warn: inconsistent indenting

This warning is fixed with a white-space change.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c 
b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 95fff20e9c4b..566b6f0997da 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -2087,7 +2087,7 @@ void Hal_ChannelPlanToRegulation(struct adapter *Adapter, 
u16 ChannelPlan)
case RT_CHANNEL_DOMAIN_WORLD_FCC2:
pHalData->Regulation2_4G = TXPWR_LMT_FCC;
pHalData->Regulation5G = TXPWR_LMT_FCC;
-   break;
+   break;
case RT_CHANNEL_DOMAIN_WORLD_FCC3:
pHalData->Regulation2_4G = TXPWR_LMT_FCC;
pHalData->Regulation5G = TXPWR_LMT_FCC;
-- 
2.12.0

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


Re: [PATCH v2 4/4] Staging: rtl8712 : ieee80211.c: fixed camelcase coding style issue

2017-06-29 Thread Larry Finger

On 06/29/2017 01:43 AM, Jaya Durga wrote:

The following variables and struct name
are renamed to avoid camelcase issue

Configuration to configuration
BeaconPeriod  to beacon_period
DSConfig  to ds_config
ATIMWindowto atim_window
pnic_Config   to pnic_config
FHConfig  to fh_config
HopPatternto hop_pattern
HopSetto hop_set
DwellTime to dwell_time

Signed-off-by: Jaya Durga 


You are doing more than a simple change of camelcase variables. For example

-   *(__le16 *)ie = 
cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
+   *(__le16 *)ie = cpu_to_le16(cfg->beacon_period);

What you did is not wrong as you set "cfg = _network->Configuration", but 
your commit message does not mention such refactoring. For that reason,


NACK

Larry


---
  drivers/staging/rtl8712/ieee80211.c   |  7 ---
  drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 21 ++---
  drivers/staging/rtl8712/rtl871x_ioctl_rtl.c   |  8 
  drivers/staging/rtl8712/rtl871x_mlme.c| 20 ++--
  drivers/staging/rtl8712/wlan_bssdef.h | 16 
  5 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8712/ieee80211.c 
b/drivers/staging/rtl8712/ieee80211.c
index f35121e..4e20de6 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -168,13 +168,14 @@ int r8712_generate_ie(struct registry_priv *pregistrypriv)
  {
int sz = 0, rateLen;
struct wlan_bssid_ex *pdev_network = >dev_network;
+   struct NDIS_802_11_CONFIGURATION *cfg = _network->configuration;
u8 *ie = pdev_network->IEs;
  
  	/*timestamp will be inserted by hardware*/

sz += 8;
ie += sz;
/*beacon interval : 2bytes*/
-   *(__le16 *)ie = 
cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
+   *(__le16 *)ie = cpu_to_le16(cfg->beacon_period);
sz += 2;
ie += 2;
/*capability info*/
@@ -202,10 +203,10 @@ int r8712_generate_ie(struct registry_priv *pregistrypriv)
  rateLen, pdev_network->rates, );
/*DS parameter set*/
ie = r8712_set_ie(ie, _DSSET_IE_, 1,
- (u8 *)_network->Configuration.DSConfig, );
+ (u8 *)_network->configuration.ds_config, );
/*IBSS Parameter Set*/
ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2,
- (u8 *)_network->Configuration.ATIMWindow, );
+ (u8 *)_network->configuration.atim_window, );
return sz;
  }
  
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c

index e30a5be..1711d66 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -150,12 +150,12 @@ static noinline_for_stack char *translate_scan(struct 
_adapter *padapter,
u16 cap, ht_cap = false, mcs_rate;
u8 rssi;
  
-	if ((pnetwork->network.Configuration.DSConfig < 1) ||

-   (pnetwork->network.Configuration.DSConfig > 14)) {
-   if (pnetwork->network.Configuration.DSConfig < 1)
-   pnetwork->network.Configuration.DSConfig = 1;
+   if ((pnetwork->network.configuration.ds_config < 1) ||
+   (pnetwork->network.configuration.ds_config > 14)) {
+   if (pnetwork->network.configuration.ds_config < 1)
+   pnetwork->network.configuration.ds_config = 1;
else
-   pnetwork->network.Configuration.DSConfig = 14;
+   pnetwork->network.configuration.ds_config = 14;
}
/* AP MAC address */
iwe.cmd = SIOCGIWAP;
@@ -212,18 +212,17 @@ static noinline_for_stack char *translate_scan(struct 
_adapter *padapter,
iwe.cmd = SIOCGIWFREQ;
{
/*  check legal index */
-   u8 dsconfig = pnetwork->network.Configuration.DSConfig;
+   u8 dsconfig = pnetwork->network.configuration.ds_config;
  
  		if (dsconfig >= 1 && dsconfig <= sizeof(

ieee80211_wlan_frequencies) / sizeof(long))
iwe.u.freq.m = (s32)(ieee80211_wlan_frequencies[
-  pnetwork->network.Configuration.
-  DSConfig - 1] * 10);
+  dsconfig - 1] * 10);
else
iwe.u.freq.m = 0;
}
iwe.u.freq.e = (s16)1;
-   iwe.u.freq.i = (u8)pnetwork->network.Configuration.DSConfig;
+   iwe.u.freq.i = (u8)pnetwork->network.configuration.ds_config;
start = iwe_stream_add_event(info, start, stop, ,
IW_EV_FREQ_LEN);
/* Add encryption capability */
@@ -699,9 +698,9 @@ static int r8711_wx_get_freq(struct net_device *dev,
return -ENOLINK;
  
  	wrqu->freq.m = 

Re: [PATCH 4/7] staging: rtl8723bs: Move braces to same line as conditional

2017-04-27 Thread Larry Finger

On 04/27/2017 07:09 PM, Justin Vreeland wrote:

Signed-off-by: Justin Vreeland 
---
 drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c | 15 +--
 drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c |  9 +++--
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c  |  6 ++
 3 files changed, 10 insertions(+), 20 deletions(-)




Fix the over-long lines and add a commit message.

Larry


diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
index 28d1a229c3a6..2838d5cdd1de 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
@@ -385,8 +385,7 @@ s32 PHY_MACConfig8723B(struct adapter *Adapter)
/*  Config MAC */
/*  */
rtStatus = phy_ConfigMACWithParaFile(Adapter, pszMACRegFile);
-   if (rtStatus == _FAIL)
-   {
+   if (rtStatus == _FAIL) {
ODM_ConfigMACWithHeaderFile(>odmpriv);
rtStatus = _SUCCESS;
}
@@ -459,8 +458,7 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)
Adapter->registrypriv.RegEnableTxPowerLimit == 1 ||
(Adapter->registrypriv.RegEnableTxPowerLimit == 2 && 
pHalData->EEPROMRegulatory == 1)
) {
-   if (PHY_ConfigRFWithPowerLimitTableParaFile(Adapter, 
pszRFTxPwrLmtFile) == _FAIL)
-   {
+   if (PHY_ConfigRFWithPowerLimitTableParaFile(Adapter, 
pszRFTxPwrLmtFile) == _FAIL) {
if (HAL_STATUS_SUCCESS != 
ODM_ConfigRFWithHeaderFile(>odmpriv, CONFIG_RF_TXPWR_LMT, 
(ODM_RF_RADIO_PATH_E)0))
rtStatus = _FAIL;
}
@@ -474,8 +472,7 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)
/*  */
/*  1. Read PHY_REG.TXT BB INIT!! */
/*  */
-   if (phy_ConfigBBWithParaFile(Adapter, pszBBRegFile, CONFIG_BB_PHY_REG) 
== _FAIL)
-   {
+   if (phy_ConfigBBWithParaFile(Adapter, pszBBRegFile, CONFIG_BB_PHY_REG) 
== _FAIL) {
if (HAL_STATUS_SUCCESS != 
ODM_ConfigBBWithHeaderFile(>odmpriv, CONFIG_BB_PHY_REG))
rtStatus = _FAIL;
}
@@ -491,8 +488,7 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)
Adapter->registrypriv.RegEnableTxPowerByRate == 1 ||
(Adapter->registrypriv.RegEnableTxPowerByRate == 2 && 
pHalData->EEPROMRegulatory != 2)
) {
-   if (phy_ConfigBBWithPgParaFile(Adapter, pszBBRegPgFile) == 
_FAIL)
-   {
+   if (phy_ConfigBBWithPgParaFile(Adapter, pszBBRegPgFile) == 
_FAIL) {
if (HAL_STATUS_SUCCESS != 
ODM_ConfigBBWithHeaderFile(>odmpriv, CONFIG_BB_PHY_REG_PG))
rtStatus = _FAIL;
}
@@ -514,8 +510,7 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)
/*  */
/*  2. Read BB AGC table Initialization */
/*  */
-   if (phy_ConfigBBWithParaFile(Adapter, pszAGCTableFile, 
CONFIG_BB_AGC_TAB) == _FAIL)
-   {
+   if (phy_ConfigBBWithParaFile(Adapter, pszAGCTableFile, 
CONFIG_BB_AGC_TAB) == _FAIL) {
if (HAL_STATUS_SUCCESS != 
ODM_ConfigBBWithHeaderFile(>odmpriv, CONFIG_BB_AGC_TAB))
rtStatus = _FAIL;
}
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
index 3a85d0cddfda..b2a31a174a7e 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
@@ -144,15 +144,13 @@ static int phy_RF6052_Config_ParaFile(struct adapter 
*Adapter)
/*Initialize RF fom connfiguration file*/
switch (eRFPath) {
case RF_PATH_A:
-   if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, 
eRFPath) == _FAIL)
-   {
+   if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, 
eRFPath) == _FAIL) {
if (HAL_STATUS_FAILURE == 
ODM_ConfigRFWithHeaderFile(>odmpriv, CONFIG_RF_RADIO, 
(ODM_RF_RADIO_PATH_E)eRFPath))
rtStatus = _FAIL;
}
break;
case RF_PATH_B:
-   if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, 
eRFPath) == _FAIL)
-   {
+   if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, 
eRFPath) == _FAIL) {
if (HAL_STATUS_FAILURE == 
ODM_ConfigRFWithHeaderFile(>odmpriv, CONFIG_RF_RADIO, 
(ODM_RF_RADIO_PATH_E)eRFPath))
rtStatus = _FAIL;
}
@@ -186,8 +184,7 @@ static int phy_RF6052_Config_ParaFile(struct adapter 
*Adapter)
/* 3 Configuration of Tx Power Tracking */
/* 3 

Re: [PATCH 3/7] staging: rtl8723bs: Macros with complex values should be enclosed in parentheses

2017-04-27 Thread Larry Finger

On 04/27/2017 07:09 PM, Justin Vreeland wrote:

Signed-off-by: Justin Vreeland 
---
 drivers/staging/rtl8723bs/hal/odm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/hal/odm.h 
b/drivers/staging/rtl8723bs/hal/odm.h
index 0b3541a91548..13c4aebd178e 100644
--- a/drivers/staging/rtl8723bs/hal/odm.h
+++ b/drivers/staging/rtl8723bs/hal/odm.h
@@ -209,7 +209,7 @@ typedef struct _ODM_RATE_ADAPTIVE {

 #define AVG_THERMAL_NUM8
 #define IQK_Matrix_REG_NUM 8
-#define IQK_Matrix_Settings_NUM14+24+21 /*  Channels_2_4G_NUM + 
Channels_5G_20M_NUM + Channels_5G */
+#define IQK_Matrix_Settings_NUM(14+24+21) /*  Channels_2_4G_NUM + 
Channels_5G_20M_NUM + Channels_5G */


You should also put spaces around the plus signs, and fix the lines with more 
then 80 columns.


The comment about non-blank commit messages also applies.

Larry



 #defineDM_Type_ByFW0
 #defineDM_Type_ByDriver1



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


Re: [PATCH 2/7] staging: rtl8723bs: Wrap multi-line macros in do-while loop

2017-04-27 Thread Larry Finger

On 04/27/2017 07:09 PM, Justin Vreeland wrote:

Signed-off-by: Justin Vreeland 
---


The patch is OK, but most maintainers require a non-blank commit message.

Larry


 drivers/staging/rtl8723bs/hal/odm_debug.h | 80 +--
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/odm_debug.h 
b/drivers/staging/rtl8723bs/hal/odm_debug.h
index a89690ea6ba9..f720eafe46fe 100644
--- a/drivers/staging/rtl8723bs/hal/odm_debug.h
+++ b/drivers/staging/rtl8723bs/hal/odm_debug.h
@@ -105,51 +105,59 @@

 #if DBG
 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)\
-   if (\
-   (comp & pDM_Odm->DebugComponents) &&\
-   (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS)\
-   ) {\
-   RT_PRINTK fmt;\
-   }
+   do {\
+   if (\
+   (comp & pDM_Odm->DebugComponents) &&\
+   (level <= pDM_Odm->DebugLevel || level == 
ODM_DBG_SERIOUS)\
+   ) {\
+   RT_PRINTK fmt;\
+   } \
+   } while (0)

 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)\
-   if (\
-   (comp & pDM_Odm->DebugComponents) &&\
-   (level <= pDM_Odm->DebugLevel)\
-   ) {\
-   RT_PRINTK fmt;\
-   }
+   do {\
+   if (\
+   (comp & pDM_Odm->DebugComponents) &&\
+   (level <= pDM_Odm->DebugLevel)\
+   ) {\
+   RT_PRINTK fmt;\
+   } \
+   } while (0)

 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)\
-   if (!expr) {\
-   DbgPrint("Assertion failed! %s at ..\n", #expr);\
-   DbgPrint(\
-   "  ..%s,%s, line =%d\n",\
-   __FILE__,\
-   __func__,\
-   __LINE__\
-   );\
-   RT_PRINTK fmt;\
-   ASSERT(false);\
-   }
+   do {\
+   if (!expr) {\
+   DbgPrint("Assertion failed! %s at ..\n", #expr);\
+   DbgPrint(\
+   "  ..%s,%s, line =%d\n",\
+   __FILE__,\
+   __func__,\
+   __LINE__\
+   );\
+   RT_PRINTK fmt;\
+   ASSERT(false);\
+   } \
+   } while (0)
 #define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
 #define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
 #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }

 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)\
-   if (\
-   (comp & pDM_Odm->DebugComponents) &&\
-   (level <= pDM_Odm->DebugLevel)\
-   ) {\
-   int __i;\
-   u8 *__ptr = (u8 *)ptr;\
-   DbgPrint("[ODM] ");\
-   DbgPrint(title_str);\
-   DbgPrint(" ");\
-   for (__i = 0; __i < 6; __i++)\
-   DbgPrint("%02X%s", __ptr[__i], (__i == 5) ? "" : "-");\
-   DbgPrint("\n");\
-   }
+   do {\
+   if (\
+   (comp & pDM_Odm->DebugComponents) &&\
+   (level <= pDM_Odm->DebugLevel)\
+   ) {\
+   int __i;\
+   u8 *__ptr = (u8 *)ptr;\
+   DbgPrint("[ODM] ");\
+   DbgPrint(title_str);\
+   DbgPrint(" ");\
+   for (__i = 0; __i < 6; __i++)\
+   DbgPrint("%02X%s", __ptr[__i], (__i == 5) ? "" : 
"-");\
+   DbgPrint("\n");\
+   } \
+   } while (0)
 #else
 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)
 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)



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


Re: Thoughts on staging and on fixing up drivers?

2017-08-17 Thread Larry Finger

On 08/17/2017 04:07 PM, tedheadster wrote:


Larry, you've migrated a bunch of staging code, and tried various
approaches.  Do you have any lessons on what has worked and what hasn't
and if there is anything we can do to make the process better?


I am also quite interested in such work. We asked for a Birds of
Feather discussion at the upcoming Linux Plumbers conference on
exactly this sort of work.


Matthew and Dan,

I will try to answer the question as best I can.

I got started in working with Realtek wireless devices at roughly the time that 
staging was created. At that time, Realtek published drivers sporadically. They 
would accumulate fixes in their internal svn repositories, then take a snapshot, 
and publish that with no information regarding what was changed. Even trying to 
diff the two versions was not useful. Obviously this mode of code development is 
not consistent with the Linux model.


After I was able to get driver r8712u into staging, I received an E-mail from 
Realtek asking if I would be willing to help them get their drivers into the 
kernel. They have provided sample chips and extenders to let me test drivers on 
my laptops, but I have not gotten any remuneration from Realtek. This 
collaboration has led to the rtlwifi family of drivers. A few of them have gone 
through staging because there was some urgency in getting them added to Linux. 
That is the case for today's submission of a driver for the RTL8822BE, which is 
appearing in some computers. This particular device implements a new Realtek 
model for hardware abstraction of the MAC, PHY, and dynamic management 
functions, which has increased the number of new lines of code to about 120K. 
Getting that much new code through the review process in the wireless tree would 
take a lot of time. Essentially, staging allows users to have access to the 
functionality while that review is in progress. Another card now appearing in 
the wild is the RTL8723DE. It will likely also reside initially in staging.


Besides getting wifi drivers for these cards into Linux, I have also been 
training the Realtek engineers and getting them to issue fixes as many small 
changes. That part of my "job" has been going very well, and I will soon be 
getting them to submit their material directly. That change is necessary as I am 
now 77, with the question of how long I will be continuing.


As you can tell, I am very pleased with the staging tree and its usage for new 
drivers, particularly where the regular trees move more slowly than the 
marketplace. Staging is a big help in supporting the users that otherwise will 
have no wifi under Linux. Their distro may not build staging drivers in their 
standard kernels, but configuring and building kernels is not too difficult.


The part that does not work is best exemplified by the driver that got me 
started, namely r8712u. The USB section at Realtek has not been as cooperative 
as the PCI/SDIO group. As a result, there is no path from staging to wireless 
and that driver will be left in staging as long as GregKH allows it. Now, I put 
that sort of material in a GitHub repo and force users to build it as an 
out-of-kernel driver. Of course, that method has its own problems. How many 
times a week do you want to tell another user that they need to install the 
kernel-headers, and no, I do not know how to do it on your distro. Now we have 
one example (rtl8723bs) where the GitHub driver was placed in staging. That one 
is likely to be moved to wireless.


This reply is getting rather long. I will be happy to answer any further 
questions.

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


[PATCH 8/8] staging: rtlwifi: Reviewers fixes

2017-08-17 Thread Larry Finger
This commit adds the TODO file and implements some reviewers comments
made against some patches to the wireless tree.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
---
 drivers/staging/rtlwifi/TODO |  8 
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c | 23 +++
 drivers/staging/rtlwifi/debug.c  |  5 +
 drivers/staging/rtlwifi/rtl8822be/sw.c   |  2 +-
 4 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtlwifi/TODO b/drivers/staging/rtlwifi/TODO
index 52a85cdf453c..4a084f2fc5d0 100644
--- a/drivers/staging/rtlwifi/TODO
+++ b/drivers/staging/rtlwifi/TODO
@@ -1,11 +1,11 @@
 TODO:
-- checkpatch.pl fixes - most of the remaining ones are lines too long. Many
-  of them will require refactoring
-- merge Realtek's bugfixes and new features into the driver
 - find and remove code blocks guarded by never set CONFIG_FOO defines
 - convert any remaining unusual variable types
 - find codes that can use %pM and %Nph formatting
-- fix any reviewer's comments regarding movin the driver to 
drivers/net/wireless
+- checkpatch.pl fixes - most of the remaining ones are lines too long. Many
+  of them will require refactoring
+- merge Realtek's bugfixes and new features into the driver
+- address any reviewers comments
 
 Please send any patches to Greg Kroah-Hartman <gre...@linuxfoundation.org>,
 and Larry Finger <larry.fin...@lwfinger.net>.
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
index 39229cdb8045..52620b72cfa9 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -791,18 +791,17 @@ static void halbtc_display_wifi_status(struct btc_coexist 
*btcoexist,
   struct seq_file *m)
 {
struct rtl_priv *rtlpriv = btcoexist->adapter;
-   s32 wifi_rssi = 0, bt_hs_rssi = 0;
-   boolscan = false, link = false, roam = false, wifi_busy = false,
-   wifi_under_b_mode = false,
-   wifi_under_5g = false;
-   u32 wifi_bw = BTC_WIFI_BW_HT20,
-   wifi_traffic_dir = BTC_WIFI_TRAFFIC_TX,
-   wifi_freq = BTC_FREQ_2_4G;
-   u32 wifi_link_status = 0x0;
-   boolbt_hs_on = false, under_ips = false, under_lps = false,
-   low_power = false, dc_mode = false;
-   u8  wifi_chnl = 0, wifi_hs_chnl = 0, fw_ps_state;
-   u8  ap_num = 0;
+   s32 wifi_rssi = 0, bt_hs_rssi = 0;
+   bool scan = false, link = false, roam = false, wifi_busy = false;
+   bool wifi_under_b_mode = false, wifi_under_5g = false;
+   u32 wifi_bw = BTC_WIFI_BW_HT20;
+   u32 wifi_traffic_dir = BTC_WIFI_TRAFFIC_TX;
+   u32 wifi_freq = BTC_FREQ_2_4G;
+   u32 wifi_link_status = 0x0;
+   bool bt_hs_on = false, under_ips = false, under_lps = false;
+   bool low_power = false, dc_mode = false;
+   u8 wifi_chnl = 0, wifi_hs_chnl = 0, fw_ps_state;
+   u8 ap_num = 0;
 
wifi_link_status = halbtc_get_wifi_link_status(btcoexist);
seq_printf(m, "\n %-35s = %d/ %d/ %d/ %d/ %d",
diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c
index ed26267393be..b9fd47aeaa9b 100644
--- a/drivers/staging/rtlwifi/debug.c
+++ b/drivers/staging/rtlwifi/debug.c
@@ -511,10 +511,7 @@ void rtl_debug_add_one(struct ieee80211_hw *hw)
 
rtlpriv->dbg.msg_buf = vzalloc(80 * 25);
 
-   snprintf(rtlpriv->dbg.debugfs_name, 18, "%02x-%02x-%02x-%02x-%02x-%02x",
-rtlefuse->dev_addr[0], rtlefuse->dev_addr[1],
-rtlefuse->dev_addr[2], rtlefuse->dev_addr[3],
-rtlefuse->dev_addr[4], rtlefuse->dev_addr[5]);
+   snprintf(rtlpriv->dbg.debugfs_name, 18, "%pMF", rtlefuse->dev_addr);
 
rtlpriv->dbg.debugfs_dir =
debugfs_create_dir(rtlpriv->dbg.debugfs_name, debugfs_topdir);
diff --git a/drivers/staging/rtlwifi/rtl8822be/sw.c 
b/drivers/staging/rtlwifi/rtl8822be/sw.c
index 913fec4f1eea..91b784b6d1c5 100644
--- a/drivers/staging/rtlwifi/rtl8822be/sw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/sw.c
@@ -432,7 +432,7 @@ static struct rtl_hal_cfg rtl8822be_hal_cfg = {
.maps[RTL_RC_VHT_RATE_2SS_MCS9] = DESC_RATEVHT2SS_MCS9,
 };
 
-static struct pci_device_id rtl8822be_pci_ids[] = {
+static const struct pci_device_id rtl8822be_pci_ids[] = {
{RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xB822, rtl8822be_hal_cfg)},
{},
 };
-- 
2.12.3

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


[PATCH 7/8] staging: r8822be: Add Makefiles and Kconfig for new driver

2017-08-17 Thread Larry Finger
The RTL8822BE, an 802.11ac wireless network card, is now appearing in
new computers. Its driver is being placed in staging to reduce the time
that users of this new card will have access to in-kernel drivers.

This commit enables building of the new driver. For this version, all
routines are built into a single module r8822be. When this driver is
moved to the wireless tree, halmac, phydm, and rtl8822be will become
new modules.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
---
 drivers/staging/Kconfig   |   2 +
 drivers/staging/Makefile  |   1 +
 drivers/staging/rtlwifi/Kconfig   |  22 ++
 drivers/staging/rtlwifi/Makefile  |  70 ++
 drivers/staging/rtlwifi/TODO  |  11 +
 drivers/staging/rtlwifi/btcoexist/Makefile|   8 +
 drivers/staging/rtlwifi/btcoexist/halbt_precomp.h |   5 -
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c  | 257 ++
 drivers/staging/rtlwifi/rtl8822be/Makefile|   7 +
 9 files changed, 137 insertions(+), 246 deletions(-)
 create mode 100644 drivers/staging/rtlwifi/Kconfig
 create mode 100644 drivers/staging/rtlwifi/Makefile
 create mode 100644 drivers/staging/rtlwifi/TODO
 create mode 100644 drivers/staging/rtlwifi/btcoexist/Makefile
 create mode 100644 drivers/staging/rtlwifi/rtl8822be/Makefile

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index e97d72e3bc40..1b0a1bed8e11 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -40,6 +40,8 @@ source "drivers/staging/rtl8712/Kconfig"
 
 source "drivers/staging/rtl8188eu/Kconfig"
 
+source "drivers/staging/rtlwifi/Kconfig"
+
 source "drivers/staging/rts5208/Kconfig"
 
 source "drivers/staging/octeon/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 993ed0c1556c..2b61cbd44d13 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_RTL8192E)+= rtl8192e/
 obj-$(CONFIG_RTL8723BS)+= rtl8723bs/
 obj-$(CONFIG_R8712U)   += rtl8712/
 obj-$(CONFIG_R8188EU)  += rtl8188eu/
+obj-$(CONFIG_R8822BE)  += rtlwifi/
 obj-$(CONFIG_RTS5208)  += rts5208/
 obj-$(CONFIG_NETLOGIC_XLR_NET) += netlogic/
 obj-$(CONFIG_OCTEON_ETHERNET)  += octeon/
diff --git a/drivers/staging/rtlwifi/Kconfig b/drivers/staging/rtlwifi/Kconfig
new file mode 100644
index ..fc482b49f9aa
--- /dev/null
+++ b/drivers/staging/rtlwifi/Kconfig
@@ -0,0 +1,22 @@
+config R8822BE
+   tristate "Realtek RTL8822BE Wireless Network Adapter"
+   depends on PCI && m
+   select FW_LOADER
+   ---help---
+   This is the staging driver for Realtek RTL8822BE 802.11ac PCIe
+   wireless network adapters.
+
+config RTLHALMAC_ST
+   tristate
+   depends on R8822BE
+   default m
+
+config RTLPHYDM_ST
+   tristate
+   depends on R8822BE
+   default m
+
+config RTLWIFI_DEBUG_ST
+   boolean
+   depends on R8822BE
+   default y
diff --git a/drivers/staging/rtlwifi/Makefile b/drivers/staging/rtlwifi/Makefile
new file mode 100644
index ..0d738c18b29c
--- /dev/null
+++ b/drivers/staging/rtlwifi/Makefile
@@ -0,0 +1,70 @@
+obj-$(CONFIG_R8822BE)  += r8822be.o
+
+r8822be-objs   :=  \
+   base.o  \
+   cam.o   \
+   core.o  \
+   debug.o \
+   efuse.o \
+   ps.o\
+   rc.o\
+   regd.o  \
+   stats.o \
+   pci.o   \
+   rtl8822be/fw.o  \
+   rtl8822be/hw.o  \
+   rtl8822be/led.o \
+   rtl8822be/phy.o \
+   rtl8822be/sw.o  \
+   rtl8822be/trx.o \
+   btcoexist/halbtc8822b2ant.o \
+   btcoexist/halbtc8822b1ant.o \
+   btcoexist/halbtc8822bwifionly.o \
+   btcoexist/halbtcoutsrc.o\
+   btcoexist/rtl_btc.o \
+   halmac/halmac_api.o \
+   halmac/halmac_88xx/halmac_api_88xx_usb.o\
+   halmac/halmac_88xx/halmac_api_88xx_sdio.o   \
+   halmac/halmac_88xx/halmac_api_88xx.o\
+   halmac/halmac_88xx/halmac_api_88xx_pcie.o   \
+   halmac/halmac_88xx/halmac_func_88xx.o   \
+   halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.o \
+   halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.o \
+   halmac/halmac_88xx/h

[PATCH] staging: rtl8822be: Keep array subscript no lower than zero

2017-09-23 Thread Larry Finger
The kbuild test robot reports the following:
   drivers/staging//rtlwifi/phydm/phydm_dig.c: In function 'odm_pause_dig':
   drivers/staging//rtlwifi/phydm/phydm_dig.c:494:45: warning: array subscript 
is below array bounds [-Warray-bounds]
  odm_write_dig(dm, dig_tab->pause_dig_value[max_level]);

This condition is caused when a loop falls through. The fix is to pin
max_level to be >= 0.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
c: kbuild test robot <fengguang...@intel.com>
Fixes: 9ce99b04b5b82fdf11e4c76b60a5f82c1e541297 staging: r8822be: Add phydm 
mini driver
---
 drivers/staging/rtlwifi/phydm/phydm_dig.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtlwifi/phydm/phydm_dig.c 
b/drivers/staging/rtlwifi/phydm/phydm_dig.c
index 31a4f3fcad19..c88b9788363a 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_dig.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_dig.c
@@ -490,6 +490,8 @@ void odm_pause_dig(void *dm_void, enum phydm_pause_type 
pause_type,
break;
}
 
+   /* pin max_level to be >= 0 */
+   max_level = max_t(s8, 0, max_level);
/* write IGI of lower level */
odm_write_dig(dm, dig_tab->pause_dig_value[max_level]);
ODM_RT_TRACE(dm, ODM_COMP_DIG,
-- 
2.12.3

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


[PATCH] rtlwifi: Fix typo in if ... else if ... else construct

2017-10-14 Thread Larry Finger
The kbuild test robot reports two conditions with no effect (if == else).
These are the result of copy and paste typographical errors.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
Cc: kbuild-...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
---
 drivers/staging/rtlwifi/base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index b88b0e8edd3d..1a0331cf63ee 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c
@@ -920,7 +920,7 @@ static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw 
*hw,
else if ((tx_mcs_map  & 0x000c) >> 2 ==
IEEE80211_VHT_MCS_SUPPORT_0_8)
hw_rate =
-   rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
+   rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS8];
else
hw_rate =
rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
@@ -932,7 +932,7 @@ static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw 
*hw,
else if ((tx_mcs_map  & 0x0003) ==
IEEE80211_VHT_MCS_SUPPORT_0_8)
hw_rate =
-   rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
+   rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS8];
else
hw_rate =
rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
-- 
2.12.3

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


Re: [PATCH] staging: r8822be: Fix typo for CONFIG_RTLWIFI_DEBUG

2017-08-30 Thread Larry Finger

On 08/30/2017 02:58 AM, Andreas Ziegler wrote:

Indeed, sorry I missed that as well.

So what should we make of that #ifdef? The code inside it doesn't compile
(anymore? I didn't find any development history for that patch except the
original mail), as there is no definition of struct submit_ctx in the headers
(for other rtl drivers - 8188eu, 8723bs - that struct lives in
include/rtw_xmit.h). Is a comparable header simply missing?

Regards,

Andreas


Andreas,

I'm sorry that I did not have time yesterday to properly analyze the situation. 
All I knew is that your patch was not the correct one. It turns out that the 
extra code was left over from the original writing/testing of the driver and 
should have been deleted. I have prepared a patch that does that and will submit 
it soon.


When the extraneous code was deleted, addition simplifications of the code were 
apparent. I am currently testing that change, and will submit the two patches at 
the same time.


Larry


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


[PATCH 0/2] staging: r8822be: Remove some left-over debug code

2017-08-30 Thread Larry Finger
Some useless debugging code from the initial writing of the driver was not
removed before it was submitted. That oversight is now fixed and the
remaining code in routine deinit_priv() is simplified.

Larry

Larry Finger (2):
  staging: r8822be: Remove some dead code
  staging: r8822be: Simplify deinit_priv()

 drivers/staging/rtlwifi/halmac/rtl_halmac.c | 28 +---
 1 file changed, 1 insertion(+), 27 deletions(-)

-- 
2.12.3

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


[PATCH 1/2] staging: r8822be: Remove some dead code

2017-08-30 Thread Larry Finger
The code found inside an #ifdef CONFIG_RTL_DEBUG ... #endif section
is left over from debugging of the original driver, and should be
deleted.

Reported by: Andreas Ziegler <andreas.zieg...@fau.de>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
---
 drivers/staging/rtlwifi/halmac/rtl_halmac.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c 
b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index 031bf2c6078f..2b1c5fae64ef 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -386,26 +386,6 @@ static void deinit_priv(struct rtl_halmac *halmac)
u32 count, size;
 
count = HALMAC_FEATURE_ALL + 1;
-#ifdef CONFIG_RTL_DEBUG
-   {
-   struct submit_ctx *sctx;
-   u32 i;
-
-   for (i = 0; i < count; i++) {
-   if (!indicator[i].sctx)
-   continue;
-
-   RT_TRACE(
-   rtlpriv, COMP_HALMAC, DBG_LOUD,
-   "%s:  %s id(%d) sctx still 
exist!!\n",
-   __func__, RTL_HALMAC_FEATURE_NAME[i],
-   i);
-   sctx = indicator[i].sctx;
-   indicator[i].sctx = NULL;
-   rtl_mfree((u8 *)sctx, sizeof(*sctx));
-   }
-   }
-#endif /* !CONFIG_RTL_DEBUG */
size = sizeof(*indicator) * count;
kfree((u8 *)indicator);
}
-- 
2.12.3

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


[PATCH 2/2] staging: r8822be: Simplify deinit_priv()

2017-08-30 Thread Larry Finger
Now that the extraneous debugging code is removed, routine deinit_priv()
clearly contains code that serves no useful purpose.

A null test before a call to kfree() and a spurious cast are also removed.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
---
 drivers/staging/rtlwifi/halmac/rtl_halmac.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c 
b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index 2b1c5fae64ef..6448a8bfc14b 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -382,13 +382,7 @@ static void deinit_priv(struct rtl_halmac *halmac)
 
indicator = halmac->indicator;
halmac->indicator = NULL;
-   if (indicator) {
-   u32 count, size;
-
-   count = HALMAC_FEATURE_ALL + 1;
-   size = sizeof(*indicator) * count;
-   kfree((u8 *)indicator);
-   }
+   kfree(indicator);
 }
 
 int rtl_halmac_init_adapter(struct rtl_priv *rtlpriv)
-- 
2.12.3

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


Re: [PATCH 2/3] staging: rtlwifi: use kcalloc instead of multiply

2017-09-05 Thread Larry Finger

On 09/05/2017 01:53 AM, Tobin C. Harding wrote:

checkpatch emits multiple warnings of type

WARNING:ALLOC_WITH_MULTIPLY: Prefer kcalloc over kzalloc with multiply

Replace two calls to kzalloc() with calls to kcalloc().


I have previously discussed this kind of change. This recommendation by 
checkpatch.pl is just plain stupid!! NACK.


Larry


---
  drivers/staging/rtlwifi/efuse.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtlwifi/efuse.c b/drivers/staging/rtlwifi/efuse.c
index 6d5e657..d74c80d 100644
--- a/drivers/staging/rtlwifi/efuse.c
+++ b/drivers/staging/rtlwifi/efuse.c
@@ -252,12 +252,11 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 
_size_byte, u8 *pbuf)
sizeof(u8), GFP_ATOMIC);
if (!efuse_tbl)
return;
-   efuse_word = kzalloc(EFUSE_MAX_WORD_UNIT * sizeof(u16 *), GFP_ATOMIC);
+   efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
if (!efuse_word)
goto out;
for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
-   efuse_word[i] = kzalloc(efuse_max_section * sizeof(u16),
-   GFP_ATOMIC);
+   efuse_word[i] = kcalloc(efuse_max_section, sizeof(u16), 
GFP_ATOMIC);
if (!efuse_word[i])
goto done;
}



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


Re: [PATCH 3/3] staging: rtlwifi: remove unused functions

2017-09-05 Thread Larry Finger

On 09/05/2017 01:53 AM, Tobin C. Harding wrote:

Functions rtl_rfreg_delay() and rtl_bb_delay() are unused within the
driver. Both functions call rtl_addr_delay(), this function is unused
outside of these call sites.The driver (and kernel) code base is cleaner
if unused functions are removed.

Remove unused functions.


While it is true that those routines are unused in the staging instance of 
rtlwifi, they are needed in the copy in drivers/net/wireless/... I would prefer 
to keep the differences between these two versions as small as possible; 
therefore, NACK


Larry
.

---
  drivers/staging/rtlwifi/core.c | 37 -
  drivers/staging/rtlwifi/core.h |  4 
  2 files changed, 41 deletions(-)

diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index 6ddf7e8..43b8b9ef 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -49,43 +49,6 @@ u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = {
42, 58, 106, 122, 138, 155, 171
  };
  
-void rtl_addr_delay(u32 addr)

-{
-   if (addr == 0xfe)
-   mdelay(50);
-   else if (addr == 0xfd)
-   msleep(5);
-   else if (addr == 0xfc)
-   msleep(1);
-   else if (addr == 0xfb)
-   usleep_range(50, 100);
-   else if (addr == 0xfa)
-   usleep_range(5, 10);
-   else if (addr == 0xf9)
-   usleep_range(1, 2);
-}
-
-void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
-u32 mask, u32 data)
-{
-   if (addr >= 0xf9 && addr <= 0xfe) {
-   rtl_addr_delay(addr);
-   } else {
-   rtl_set_rfreg(hw, rfpath, addr, mask, data);
-   udelay(1);
-   }
-}
-
-void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
-{
-   if (addr >= 0xf9 && addr <= 0xfe) {
-   rtl_addr_delay(addr);
-   } else {
-   rtl_set_bbreg(hw, addr, MASKDWORD, data);
-   udelay(1);
-   }
-}
-
  static void rtl_fw_do_work(const struct firmware *firmware, void *context,
   bool is_wow)
  {
diff --git a/drivers/staging/rtlwifi/core.h b/drivers/staging/rtlwifi/core.h
index 782ac2f..4c2b694 100644
--- a/drivers/staging/rtlwifi/core.h
+++ b/drivers/staging/rtlwifi/core.h
@@ -75,10 +75,6 @@ enum dm_dig_connect_e {
  extern const struct ieee80211_ops rtl_ops;
  void rtl_fw_cb(const struct firmware *firmware, void *context);
  void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
-void rtl_addr_delay(u32 addr);
-void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
-u32 mask, u32 data);
-void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
  bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
  bool rtl_btc_status_false(void);
  void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval);



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


Re: [PATCH 1/2] staging: rtlwifi: silence underflow warning

2017-09-29 Thread Larry Finger

On 09/29/2017 02:51 AM, Dan Carpenter wrote:

I'm not totally certain that it's necessary to put an upper limit here.
I think it happens at lower levels.  But if we are going to do that then
we should have a lower bound as well.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index 43b8b9efe25f..b55e18304a60 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -412,7 +412,8 @@ static void _rtl_add_wowlan_patterns(struct ieee80211_hw 
*hw,
for (i = 0; i < wow->n_patterns; i++) {
memset(_pattern, 0, sizeof(struct rtl_wow_pattern));
memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
-   if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
+   if (patterns[i].pattern_len < 0 ||
+   patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
 "Pattern[%d] is too long\n", i);
continue;


In principle, both patches are correct, but perhaps the debug message should be 
something like

'"Pattern[%d] has bad length of %d\n", i, patterns[i].pattern_len'

Larry

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


Re: Two rtlwifi drivers?

2017-08-24 Thread Larry Finger

On 08/24/2017 07:14 AM, Kalle Valo wrote:

Dan Carpenter  writes:


Smatch is distrustful of the "capab" value and marks it as user
controlled.  I think it actually comes from the firmware?  Anyway, I
looked at other drivers and they added a bounds check and it seems like
a harmless thing to have so I have added it here as well.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index f7f207cbaee3..a30b928d5ee1 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c


I'm getting slightly annoyed that we now apparently have two duplicate
rtlwifi drivers (with the same name!) and I'm being spammed by staging
patches. Was this really a smart thing to do? And what will be the
future of these two drivers?

(Of course this is not directed to Dan, he is just fixing bugs found by
smatch, but more like a general question.)


That was the decision that you and Greg made. The version in wireless-drivers 
needs many patches to handle the new device. The progress in applying these to 
wireless-drivers was very slow for many reasons. Keeping a single version of 
that code would have required coordination between you and Greg, which was 
discouraged.


The future, as stated in the TODO in staging, is to merge all the changes in the 
support drivers into wireless-drivers, and then move the new RTL8822BE driver 
out of staging.


I'm sorry about the fallout affecting you, and I probably should have changed 
the directory names. In any case, ignore any patches that belong in staging. If 
I see any that do not include GregKH in the "To" list, I will NACK them and 
request proper routing.


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


Re: [PATCH] staging: r8822be: fix null pointer dereference with a null driver_adapter

2017-08-24 Thread Larry Finger

On 08/23/2017 10:07 AM, Colin King wrote:

From: Colin Ian King <colin.k...@canonical.com>

The call to _rtl_dbg_trace via macro HALMAC_RT_TRACE will trigger a null
pointer deference on the null driver_adapter.  Fix this by assigning
driver_adapter earlier to halmac_adapter->driver_adapter before the tracing
call so that a non-null driver_adapter is passed instead.

Detected by CoverityScan, CID#1454613 ("Explicit null dereferenced")

Fixes: 938a0447f094 ("staging: r8822be: Add code for halmac sub-driver")
Signed-off-by: Colin Ian King <colin.k...@canonical.com>


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

Thanks,

Larry


---
  drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c 
b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
index a6c8a87f755f..3a24e33228f8 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
@@ -4447,7 +4447,7 @@ halmac_func_p2pps_88xx(struct halmac_adapter 
*halmac_adapter,
  {
u8 h2c_buff[HALMAC_H2C_CMD_SIZE_88XX] = {0};
u16 h2c_seq_mum = 0;
-   void *driver_adapter = NULL;
+   void *driver_adapter = halmac_adapter->driver_adapter;
struct halmac_api *halmac_api;
struct halmac_h2c_header_info h2c_header_info;
enum halmac_ret_status status = HALMAC_RET_SUCCESS;
@@ -4455,7 +4455,6 @@ halmac_func_p2pps_88xx(struct halmac_adapter 
*halmac_adapter,
HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
"[TRACE]halmac_p2pps !!\n");
  
-	driver_adapter = halmac_adapter->driver_adapter;

halmac_api = (struct halmac_api *)halmac_adapter->halmac_api;
  
  	P2PPS_SET_OFFLOAD_EN(h2c_buff, p2p_ps->offload_en);




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


Re: [PATCH 3/3] staging: rtlwifi: simplify logical operation

2017-08-24 Thread Larry Finger

On 08/23/2017 08:22 AM, Arnd Bergmann wrote:

gcc notices a very complicated way to check a value
for being equal to one, and warns about it:

drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c: In function 
'halbtc8822b1ant_set_ext_ant_switch':
drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c:2105:9: error: '~' on a 
boolean expression [-Werror=bool-operation]
  ~switch_polatiry_inverse :
  ^
drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c:2105:9: note: did you mean 
to use logical not?
  ~switch_polatiry_inverse :
  ^

This simplifies this expression to make it more readable
and to make gcc happy.

Fixes: 56bde846304e ("staging: r8822be: Add existing rtlwifi and rtl_pci parts for 
new driver")
Signed-off-by: Arnd Bergmann <a...@arndb.de>


Yes, it should have bee logical not rather than a bitwise inversion. Your 
version is much more readable. In a followup, I will fix the spelling of 
polarity, but yours is fine.


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

Larry


---
  drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c 
b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
index 933d188d52b4..157395b85405 100644
--- a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
+++ b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
@@ -2101,9 +2101,7 @@ static void halbtc8822b1ant_set_ext_ant_switch(struct 
btc_coexist *btcoexist,
 * 0xcbd[1:0] = 2b'01 => Ant to BTG,
 * 0xcbd[1:0] = 2b'10 => Ant to WLG
 */
-   switch_polatiry_inverse = (rfe_type->ext_ant_switch_ctrl_polarity == 1 ?
-  ~switch_polatiry_inverse :
-  switch_polatiry_inverse);
+   switch_polatiry_inverse = rfe_type->ext_ant_switch_ctrl_polarity == 1;
  
  	switch (pos_type) {

default:



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


Re: [PATCH 2/3] staging: rtlwifi: add MAC80211 dependency

2017-08-24 Thread Larry Finger

On 08/23/2017 08:22 AM, Arnd Bergmann wrote:

Like the version in drivers/net/wireless, this driver requires the
MAC80211 framework, otherwise we run into a link error:

ERROR: "ieee80211_rx_irqsafe" [drivers/staging/rtlwifi/r8822be.ko] undefined!
ERROR: "cfg80211_unlink_bss" [drivers/staging/rtlwifi/r8822be.ko] undefined!
ERROR: "ieee80211_beacon_get_tim" [drivers/staging/rtlwifi/r8822be.ko] 
undefined!
ERROR: "ieee80211_resume_disconnect" [drivers/staging/rtlwifi/r8822be.ko] 
undefined!

This adds the Kconfig dependency for it.

Fixes: 56bde846304e ("staging: r8822be: Add existing rtlwifi and rtl_pci parts for 
new driver")
Signed-off-by: Arnd Bergmann 


Greg,

I lost track of which version of this patch you are taking. The one that Randy 
Dunlap sent that added NETDEVICES was better than the initial version, but this 
one with MAC80211 is the correct one. Randy's patch is in the latest pull I did 
on staging.


Do you want an updated patch?

Larry


---
  drivers/staging/rtlwifi/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtlwifi/Kconfig b/drivers/staging/rtlwifi/Kconfig
index fc482b49f9aa..cb3a29ae764b 100644
--- a/drivers/staging/rtlwifi/Kconfig
+++ b/drivers/staging/rtlwifi/Kconfig
@@ -1,6 +1,6 @@
  config R8822BE
tristate "Realtek RTL8822BE Wireless Network Adapter"
-   depends on PCI && m
+   depends on PCI && MAC80211 && m
select FW_LOADER
---help---
This is the staging driver for Realtek RTL8822BE 802.11ac PCIe



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


Re: [PATCH] staging: rtlwifi: check for array overflow

2017-08-24 Thread Larry Finger

On 08/24/2017 05:08 AM, Dan Carpenter wrote:

Smatch is distrustful of the "capab" value and marks it as user
controlled.  I think it actually comes from the firmware?  Anyway, I
looked at other drivers and they added a bounds check and it seems like
a harmless thing to have so I have added it here as well.

Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

Thanks,

Larry



diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index f7f207cbaee3..a30b928d5ee1 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c
@@ -1414,6 +1414,10 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx)
  le16_to_cpu(mgmt->u.action.u.addba_req.capab);
tid = (capab &
   IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
+   if (tid >= MAX_TID_COUNT) {
+   rcu_read_unlock();
+   return true;
+   }
tid_data = _entry->tids[tid];
if (tid_data->agg.rx_agg_state ==
RTL_RX_AGG_START)



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


[PATCH] staging: rtlwifi: Improve debugging by using debugfs

2017-08-24 Thread Larry Finger
The changes in this commit are also being sent to the main rtlwifi
drivers in wireless-next; however, these changes will also be useful for
any debugging of r8822be before it gets moved into the main tree.

Use debugfs to dump register and btcoex status, and also write registers
and h2c.

We create topdir in /sys/kernel/debug/rtlwifi/, and use the MAC address
as subdirectory with several entries to dump mac_reg, bb_reg, rf_reg etc.
An example is
/sys/kernel/debug/rtlwifi/00-11-22-33-44-55-66/mac_0

This change permits examination of device registers in a dynamic manner,
a feature not available with the current debug mechanism.

We use seq_file to replace RT_TRACE to dump status, then we can use 'cat'
to access btcoex's status through debugfs.
(i.e. /sys/kernel/debug/rtlwifi/00-11-22-33-44-55-66/btcoex)
Other related changes are
1. implement btc_disp_dbg_msg() to access btcoex's common status.
2. remove obsolete field bt_exist

Signed-off-by: Ping-Ke Shih <pks...@realtek.com>
Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
---
 drivers/staging/rtlwifi/debug.c | 226 
 1 file changed, 135 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c
index b9fd47aeaa9b..7446d71c41d1 100644
--- a/drivers/staging/rtlwifi/debug.c
+++ b/drivers/staging/rtlwifi/debug.c
@@ -80,9 +80,11 @@ void _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, 
int level,
}
 }
 
-struct rtl_debgufs_priv {
+struct rtl_debugfs_priv {
struct rtl_priv *rtlpriv;
-   int (*cb)(struct seq_file *m, void *v);
+   int (*cb_read)(struct seq_file *m, void *v);
+   ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
+   size_t count, loff_t *loff);
u32 cb_data;
 };
 
@@ -90,9 +92,9 @@ static struct dentry *debugfs_topdir;
 
 static int rtl_debug_get_common(struct seq_file *m, void *v)
 {
-   struct rtl_debgufs_priv *debugfs_priv = m->private;
+   struct rtl_debugfs_priv *debugfs_priv = m->private;
 
-   return debugfs_priv->cb(m, v);
+   return debugfs_priv->cb_read(m, v);
 }
 
 static int dl_debug_open_common(struct inode *inode, struct file *file)
@@ -109,7 +111,7 @@ static const struct file_operations file_ops_common = {
 
 static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
 {
-   struct rtl_debgufs_priv *debugfs_priv = m->private;
+   struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
u32 page = debugfs_priv->cb_data;
int i, n;
@@ -126,8 +128,8 @@ static int rtl_debug_get_mac_page(struct seq_file *m, void 
*v)
 }
 
 #define RTL_DEBUG_IMPL_MAC_SERIES(page, addr)  \
-struct rtl_debgufs_priv rtl_debug_priv_mac_ ##page = { \
-   .cb = rtl_debug_get_mac_page,   \
+struct rtl_debugfs_priv rtl_debug_priv_mac_ ##page = { \
+   .cb_read = rtl_debug_get_mac_page,  \
.cb_data = addr,\
 }
 
@@ -150,7 +152,7 @@ RTL_DEBUG_IMPL_MAC_SERIES(17, 0x1700);
 
 static int rtl_debug_get_bb_page(struct seq_file *m, void *v)
 {
-   struct rtl_debgufs_priv *debugfs_priv = m->private;
+   struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
struct ieee80211_hw *hw = rtlpriv->hw;
u32 page = debugfs_priv->cb_data;
@@ -168,8 +170,8 @@ static int rtl_debug_get_bb_page(struct seq_file *m, void 
*v)
 }
 
 #define RTL_DEBUG_IMPL_BB_SERIES(page, addr)   \
-struct rtl_debgufs_priv rtl_debug_priv_bb_ ##page = {  \
-   .cb = rtl_debug_get_bb_page,\
+struct rtl_debugfs_priv rtl_debug_priv_bb_ ##page = {  \
+   .cb_read = rtl_debug_get_bb_page,   \
.cb_data = addr,\
 }
 
@@ -192,7 +194,7 @@ RTL_DEBUG_IMPL_BB_SERIES(1f, 0x1f00);
 
 static int rtl_debug_get_reg_rf(struct seq_file *m, void *v)
 {
-   struct rtl_debgufs_priv *debugfs_priv = m->private;
+   struct rtl_debugfs_priv *debugfs_priv = m->private;
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
struct ieee80211_hw *hw = rtlpriv->hw;
enum radio_path rfpath = debugfs_priv->cb_data;
@@ -215,8 +217,8 @@ static int rtl_debug_get_reg_rf(struct seq_file *m, void *v)
 }
 
 #define RTL_DEBUG_IMPL_RF_SERIES(page, addr)   \
-struct rtl_debgufs_priv rtl_debug_priv_rf_ ##page = {  \
-   .cb = rtl_debug_get_reg_rf, \
+struct rtl_debugfs_priv rtl_debug_priv_rf_ ##page = {  \
+   .cb_read = rtl_debug_get_reg_rf,\
.cb_data = addr,

Re: [PATCH] Staging rtlwifi efuse fix up a warning kzalloc

2017-08-26 Thread Larry Finger

On 08/26/2017 08:01 AM, Yurii Pavlenko wrote:

Hello,

I have attached a small patch to fix a warning "Prefer kcalloc over kzalloc with 
multiply"
for efuse.c as part of challenge 10 of Eudyptula.

Best regards,
Yurii Pavlenko


Signed-off-by: Yurii Pavlenko 


Before you waste any more of our time, please read the material about patch 
submission at Documentation/process/submitting-patches.rst in your source tree. 
In its present form, this patch is not usable!


I also disagree with the checkpatch warning. To me, there is no difference 
between specifying the size of the allocation as "EFUSE_MAX_WORD_UNIT, 
sizeof(u16 *)" or "EFUSE_MAX_WORD_UNIT * sizeof(u16 *)". In  fact, the only real 
difference is that the source is ONE character larger with the kzalloc version! 
Is that important? Certainly not to me! One thing that is readily apparent is 
that kzalloc() zeros the allocated space. Of course, so does kcalloc(), but it 
is not apparent from the name.


Most of the checkpatch warnings improve readability of the source, and do find 
real or potential errors. This particular one does not, and I will NACK every 
patch that tries to force code that I maintain to use kcalloc over kzalloc.


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


Re: [PATCH] staging: rtl8723bs: remove null check before kfree

2017-08-27 Thread Larry Finger

On 08/26/2017 03:47 PM, Himanshu Jha wrote:

Kfree on NULL pointer is a no-op and therefore checking is redundant.

Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
---


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

For some reason not fully explained, gmail is placing ALL your E-mails in my 
spam folder. You might wish to explore that situation.


Larry


  drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 18 ++
  1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index c7bad64..d5e5f83 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -4120,10 +4120,8 @@ static int rtw_set_wps_beacon(struct net_device *dev, 
struct ieee_param *param,
ie_len = len-12-2;/*  12 = param header, 2:no packed */
  
  
-	if (pmlmepriv->wps_beacon_ie) {

-   kfree(pmlmepriv->wps_beacon_ie);
-   pmlmepriv->wps_beacon_ie = NULL;
-   }
+   kfree(pmlmepriv->wps_beacon_ie);
+   pmlmepriv->wps_beacon_ie = NULL;
  
  	if (ie_len>0) {

pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len);
@@ -4160,10 +4158,8 @@ static int rtw_set_wps_probe_resp(struct net_device 
*dev, struct ieee_param *par
ie_len = len-12-2;/*  12 = param header, 2:no packed */
  
  
-	if (pmlmepriv->wps_probe_resp_ie) {

-   kfree(pmlmepriv->wps_probe_resp_ie);
-   pmlmepriv->wps_probe_resp_ie = NULL;
-   }
+   kfree(pmlmepriv->wps_probe_resp_ie);
+   pmlmepriv->wps_probe_resp_ie = NULL;
  
  	if (ie_len>0) {

pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len);
@@ -4195,10 +4191,8 @@ static int rtw_set_wps_assoc_resp(struct net_device 
*dev, struct ieee_param *par
ie_len = len-12-2;/*  12 = param header, 2:no packed */
  
  
-	if (pmlmepriv->wps_assoc_resp_ie) {

-   kfree(pmlmepriv->wps_assoc_resp_ie);
-   pmlmepriv->wps_assoc_resp_ie = NULL;
-   }
+   kfree(pmlmepriv->wps_assoc_resp_ie);
+   pmlmepriv->wps_assoc_resp_ie = NULL;
  
  	if (ie_len>0) {

pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len);



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


Re: [PATCH] staging: rtlwifi: Improve debugging by using debugfs

2017-08-25 Thread Larry Finger

On 08/24/2017 08:54 PM, Andrew Lunn wrote:

netdev frowns upon debugfs. You should try to keep this altogether,
making it easy to throw away before the driver is moved out of
staging.

You might want to look at ethtool -d. That will be accepted.


Andrew,

What is the problem with debugfs?

Please suggest which driver has the best example of an ethtool -d implementation 
that we might study.


The first version of the debugfs changes were sent to wireless-drivers on July 
2. Why are we first hearing of this objection nearly 2 months later?


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


Re: [PATCH] staging: r8822be: remove some dead code

2017-08-25 Thread Larry Finger

On 08/25/2017 03:42 AM, Dan Carpenter wrote:

"hdr" can't be NULL.  We take skb->data which is non-NULL and add an
offset to get "hdr".

Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>


Thanks. Looks good.

Acked-by: Larry Finger <larry.fin...@lwfinger.net>

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


[PATCH 2/8] staging: r8822be: Copy existing btcoexist code into staging

2017-08-17 Thread Larry Finger
The RTL8822BE, an 802.11ac wireless network card, is now appearing in
new computers. Its driver is being placed in staging to reduce the time
that users of this new card will have access to in-kernel drivers.

This commit copies the existing routines from .../rtlwifi/btcoexist/
into staging. There are no changes other than removing all EXPORT
statements, and the fixing of checkpatch messages. The latter will
be backported to the wireless tree.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>
---
 drivers/staging/rtlwifi/btcoexist/halbt_precomp.h |   90 +
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c  | 2107 +
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h  |  802 
 drivers/staging/rtlwifi/btcoexist/rtl_btc.c   |  528 ++
 drivers/staging/rtlwifi/btcoexist/rtl_btc.h   |   75 +
 5 files changed, 3602 insertions(+)
 create mode 100644 drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
 create mode 100644 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
 create mode 100644 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h
 create mode 100644 drivers/staging/rtlwifi/btcoexist/rtl_btc.c
 create mode 100644 drivers/staging/rtlwifi/btcoexist/rtl_btc.h

diff --git a/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h 
b/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
new file mode 100644
index ..1cd3ce54b6a2
--- /dev/null
+++ b/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
@@ -0,0 +1,90 @@
+/**
+ *
+ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ * more details.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called LICENSE.
+ *
+ * Contact Information:
+ * wlanfae <wlan...@realtek.com>
+ * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
+ * Hsinchu 300, Taiwan.
+ * Larry Finger <larry.fin...@lwfinger.net>
+ *
+ 
**/
+
+#ifndef__HALBT_PRECOMP_H__
+#define __HALBT_PRECOMP_H__
+/*
+ * include files
+ */
+#include "../wifi.h"
+#include "../efuse.h"
+#include "../base.h"
+#include "../regd.h"
+#include "../cam.h"
+#include "../ps.h"
+#include "../pci.h"
+
+#include "halbtcoutsrc.h"
+
+/* Interface type */
+#define RT_PCI_INTERFACE   1
+#define RT_USB_INTERFACE   2
+#define RT_SDIO_INTERFACE  3
+#define DEV_BUS_TYPE   RT_PCI_INTERFACE
+
+#include "halbtc8192e2ant.h"
+#include "halbtc8723b1ant.h"
+#include "halbtc8723b2ant.h"
+#include "halbtc8821a2ant.h"
+#include "halbtc8821a1ant.h"
+#include "halbtc8822b1ant.h"
+#include "halbtc8822b2ant.h"
+#include "halbtc8822bwifionly.h"
+
+#define GETDEFAULTADAPTER(padapter)padapter
+
+#define BIT0   0x0001
+#define BIT1   0x0002
+#define BIT2   0x0004
+#define BIT3   0x0008
+#define BIT4   0x0010
+#define BIT5   0x0020
+#define BIT6   0x0040
+#define BIT7   0x0080
+#define BIT8   0x0100
+#define BIT9   0x0200
+#define BIT10  0x0400
+#define BIT11  0x0800
+#define BIT12  0x1000
+#define BIT13  0x2000
+#define BIT14  0x4000
+#define BIT15  0x8000
+#define BIT16  0x0001
+#define BIT17  0x0002
+#define BIT18  0x0004
+#define BIT19  0x0008
+#define BIT20  0x0010
+#define BIT21  0x0020
+#define BIT22  0x0040
+#define BIT23  0x0080
+#define BIT24  0x0100
+#define BIT25  0x0200
+#define BIT26  0x0400
+#define BIT27  0x0800
+#define BIT28  0x1000
+#define BIT29  0x2000
+#define BIT30  0x4000
+#define BIT31  0x8000
+
+#endif /* __HALBT_PRECOMP_H__ */
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
new file mode 100644
index ..e5c25c0babfb
--- /dev/null
+++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -0,0 +1,2107 @@
+/**
+ *
+

[PATCH 0/8] staging: Add new driver for RTL8822BE

2017-08-17 Thread Larry Finger
The RTL8822BE, an 802.11ac wireless network card, is now appearing in
new computers. Its driver is being placed in staging to reduce the time
that users of this new card will have access to in-kernel drivers.

Residence in staging should be relatively short as we soon plan to start
introducing the code into the main wireless tree in small pieces.

To minimize interference between the rtlwifi drivers in the wireless tree
and this new driver, the new one can only be built as a module. In
addition, all code is built into a single module.

Larry Finger

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
Cc: Ping-Ke Shih <pks...@realtek.com>
Cc: Yan-Hsuan Chuang <yhchu...@realtek.com>
Cc: Birming Chiu <birm...@realtek.com>
Cc: Shaofu <sha...@realtek.com>
Cc: Steven Ting <stevent...@realtek.com>

Larry Finger (8):
  staging: r8822be: Add existing rtlwifi and rtl_pci parts for new
driver
  staging: r8822be: Copy existing btcoexist code into staging
  staging: r8822be: Add r8822be btcoexist routines to staging
  staging: r8822be: Add code for halmac sub-driver
  staging: r8822be: Add phydm mini driver
  staging: r8822be: Add the driver code
  staging: r8822be: Add Makefiles and Kconfig for new driver
  staging: rtlwifi: Reviewers fixes

 drivers/staging/Kconfig| 2 +
 drivers/staging/Makefile   | 1 +
 drivers/staging/rtlwifi/Kconfig|22 +
 drivers/staging/rtlwifi/Makefile   |70 +
 drivers/staging/rtlwifi/TODO   |11 +
 drivers/staging/rtlwifi/base.c |  2826 
 drivers/staging/rtlwifi/base.h |   186 +
 drivers/staging/rtlwifi/btcoexist/Makefile | 8 +
 drivers/staging/rtlwifi/btcoexist/halbt_precomp.h  |85 +
 .../staging/rtlwifi/btcoexist/halbtc8822b1ant.c|  5246 
 .../staging/rtlwifi/btcoexist/halbtc8822b1ant.h|   444 +
 .../staging/rtlwifi/btcoexist/halbtc8822b2ant.c|  5225 
 .../staging/rtlwifi/btcoexist/halbtc8822b2ant.h|   498 +
 .../rtlwifi/btcoexist/halbtc8822bwifionly.c|65 +
 .../rtlwifi/btcoexist/halbtc8822bwifionly.h|35 +
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c   |  1881 +++
 drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h   |   802 ++
 drivers/staging/rtlwifi/btcoexist/rtl_btc.c|   528 +
 drivers/staging/rtlwifi/btcoexist/rtl_btc.h|75 +
 drivers/staging/rtlwifi/cam.c  |   326 +
 drivers/staging/rtlwifi/cam.h  |50 +
 drivers/staging/rtlwifi/core.c |  2046 +++
 drivers/staging/rtlwifi/core.h |86 +
 drivers/staging/rtlwifi/debug.c|   592 +
 drivers/staging/rtlwifi/debug.h|   234 +
 drivers/staging/rtlwifi/efuse.c|  1342 ++
 drivers/staging/rtlwifi/efuse.h|   120 +
 drivers/staging/rtlwifi/halmac/halmac_2_platform.h |52 +
 .../halmac_88xx/halmac_8822b/halmac_8822b_cfg.h|   132 +
 .../halmac_88xx/halmac_8822b/halmac_8822b_phy.c|   106 +
 .../halmac_8822b/halmac_8822b_pwr_seq.c|   563 +
 .../halmac_8822b/halmac_8822b_pwr_seq.h|40 +
 .../halmac_88xx/halmac_8822b/halmac_api_8822b.c|   343 +
 .../halmac_88xx/halmac_8822b/halmac_api_8822b.h|44 +
 .../halmac_8822b/halmac_api_8822b_pcie.c   |   323 +
 .../halmac_8822b/halmac_api_8822b_pcie.h   |53 +
 .../halmac_8822b/halmac_api_8822b_sdio.c   |   184 +
 .../halmac_8822b/halmac_api_8822b_sdio.h   |42 +
 .../halmac_8822b/halmac_api_8822b_usb.c|   185 +
 .../halmac_8822b/halmac_api_8822b_usb.h|45 +
 .../halmac_88xx/halmac_8822b/halmac_func_8822b.c   |   414 +
 .../halmac_88xx/halmac_8822b/halmac_func_8822b.h   |38 +
 .../rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h   |   171 +
 .../rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c   |  5980 +
 .../rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h   |   396 +
 .../halmac/halmac_88xx/halmac_api_88xx_pcie.c  |   329 +
 .../halmac/halmac_88xx/halmac_api_88xx_pcie.h  |71 +
 .../halmac/halmac_88xx/halmac_api_88xx_sdio.c  |   974 ++
 .../halmac/halmac_88xx/halmac_api_88xx_sdio.h  |84 +
 .../halmac/halmac_88xx/halmac_api_88xx_usb.c   |   554 +
 .../halmac/halmac_88xx/halmac_api_88xx_usb.h   |73 +
 .../rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c  |  4499 +++
 .../rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h  |   321 +
 drivers/staging/rtlwifi/halmac/halmac_api.c|   426 +
 drivers/staging/rtlwifi/halmac/halmac_api.h|82 +
 drivers/staging/rtlwifi/halmac/halmac_bit2.h   | 13407 +++
 drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h  | 12103 +
 drivers/staging/rtlwifi/halmac/halmac_fw_info.h|   122 +
 .../rtlwifi/halmac/hal

Re: [PATCH] staging: r8822be: Fix typo for CONFIG_RTLWIFI_DEBUG

2017-08-29 Thread Larry Finger

On 08/29/2017 06:30 AM, Andreas Ziegler wrote:

The debugging output in deinit_priv is guarded by an  #ifdef using
CONFIG_RTL_DEBUG. This symbol does not exist and should be
CONFIG_RTLWIFI_DEBUG instead.

Signed-off-by: Andreas Ziegler 


NACK.

Yes, there is a problem; however, CONFIG_RTLWIFI_DEBUG is not the value that 
should be used. That one is reserved for the non-staging drivers in 
drivers/net/wireless/realtek/rtlwifi/. The correct symbol for r8822be is 
CONFIG_RTLWIFI_DEBUG_ST.


Larry


---
  drivers/staging/rtlwifi/halmac/rtl_halmac.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c 
b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
index 031bf2c..888ca43 100644
--- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c
+++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c
@@ -386,7 +386,7 @@ static void deinit_priv(struct rtl_halmac *halmac)
u32 count, size;
  
  		count = HALMAC_FEATURE_ALL + 1;

-#ifdef CONFIG_RTL_DEBUG
+#ifdef CONFIG_RTLWIFI_DEBUG
{
struct submit_ctx *sctx;
u32 i;
@@ -405,7 +405,7 @@ static void deinit_priv(struct rtl_halmac *halmac)
rtl_mfree((u8 *)sctx, sizeof(*sctx));
}
}
-#endif /* !CONFIG_RTL_DEBUG */
+#endif /* !CONFIG_RTLWIFI_DEBUG */
size = sizeof(*indicator) * count;
kfree((u8 *)indicator);
}



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


Re: Two rtlwifi drivers?

2017-10-11 Thread Larry Finger

On 10/11/2017 08:13 AM, Greg Kroah-Hartman wrote:

On Wed, Oct 11, 2017 at 12:06:00PM +0300, Kalle Valo wrote:

(Sorry for taking so long with the reply, I wanted first to check what
the rtlwifi in staging contains.)

Larry Finger <larry.fin...@lwfinger.net> writes:


On 08/24/2017 07:14 AM, Kalle Valo wrote:

Dan Carpenter <dan.carpen...@oracle.com> writes:


Smatch is distrustful of the "capab" value and marks it as user
controlled.  I think it actually comes from the firmware?  Anyway, I
looked at other drivers and they added a bounds check and it seems like
a harmless thing to have so I have added it here as well.

Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>

diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
index f7f207cbaee3..a30b928d5ee1 100644
--- a/drivers/staging/rtlwifi/base.c
+++ b/drivers/staging/rtlwifi/base.c


I'm getting slightly annoyed that we now apparently have two duplicate
rtlwifi drivers (with the same name!) and I'm being spammed by staging
patches. Was this really a smart thing to do? And what will be the
future of these two drivers?

(Of course this is not directed to Dan, he is just fixing bugs found by
smatch, but more like a general question.)


That was the decision that you and Greg made. The version in
wireless-drivers needs many patches to handle the new device. The
progress in applying these to wireless-drivers was very slow for many
reasons. Keeping a single version of that code would have required
coordination between you and Greg, which was discouraged.


I don't recall deciding anything, all I did was asking for more info
about the new code. I was against the idea since I first saw your mail
but I tried to be diplomatic and not shot it down immeadiately. Shows
that diplomacy is not really my thing...

We always take extra measures to avoid forking code, why is it now all
of sudden ok? Also this gives the wrong message to Realtek, and other
vendors, that they can just fork the driver and push all sort of crap to
staging.

So just to make clear to everyone: I think forking drivers like this is
a HORRIBLE idea and I do not want to have anything to do with that. If
schedule goes over quality then a much better approach is to move to the
whole driver to staging than to have duplicated drivers like we have
now.


I think it's horrid too.  But, if no one is able to do the real work
here, we hurt users who just need to use their hardware to get things
done.

And it seems like the company isn't willing to do the real work, so
dumping this in staging is the best we can do at the moment.

However, if this causes you problems, that's not good at all either.
Getting "real" support for this hardware is key, and hopefully can
happen somehow.  But fixing up the staging driver is almost never the
way to do it, as you know :)

So what to do?  Any ideas?  What makes your life easier?  You can just
ignore the staging tree, as it should not affect your portion of the
kernel at all, right?


Greg and Kalle,

We can all agree that this situation is bad; however, several of the points made 
in your E-mails need to be addressed.


First of all, I am not an employee of Realtek, and I have no knowledge of the 
internals of any of their chips. I have never signed a non-disclosure agreement, 
and the only thing that I have received from them are sample chips for testing. 
My main interest is in helping the user experience. As there are a number of 
users with the new RTL8822BE device, that meant getting an in-kernel driver to 
them as soon as possible. As stated earlier, adding this particular device to 
the rtlwifi family involved roughly 120K lines of new code. Given our recent 
experience in getting code accepted into the wireless tree meant that this 
additional code would not have been accepted for many months. For that reason, 
we chose the staging route. It is important that we get this right as Realtek 
tells me that there will be two additional new drivers in the coming 6 months.


As to the convergence of the rtlwifi code between staging and wireless, I 
applied the 40 or 50 patches in my queue to the wireless version to create the 
version that went into staging. If any of the current patches to wireless do not 
seem to be in the staging version, sometimes temporary changes are necessary so 
that the intermediate drivers will build and work. Yes, it is code churn, but 
necessary to keep patches small. In keeping with Kalle's requests, only a 
fraction of those patches have been submitted to him.


My intent is to have the RTL8822BE driver moved from staging to mainline no 
later than 4.17. The affected drivers rtl_pci, rtlwifi and becoex will be moved 
in that order. Of course, the required changes will need to be in wireless 
before staging is changed, which will slow the process. As I see it, the switch 
can only occur with a new version.


My opinion is that the company has gone a long ways toward meeting

[PATCH] staging: rtl8188eu:

2017-11-25 Thread Larry Finger
When not associated with an AP, wifi device drivers should respond to the
SIOCGIWESSID ioctl with a zero-length string for the SSID, which is the
behavior expected by dhcpcd.

Currently, this driver returns an error code (-1) from the ioctl call,
which causes dhcpcd to assume that the device is not a wireless interface
and therefore it fails to work correctly with it thereafter.

This problem was reported and tested at
https://github.com/lwfinger/rtl8188eu/issues/234.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index c0664dc80bf2..446310775e90 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -1395,19 +1395,13 @@ static int rtw_wx_get_essid(struct net_device *dev,
if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) {
len = pcur_bss->Ssid.SsidLength;
-
-   wrqu->essid.length = len;
-
memcpy(extra, pcur_bss->Ssid.Ssid, len);
-
-   wrqu->essid.flags = 1;
} else {
-   ret = -1;
-   goto exit;
+   len = 0;
+   *extra = 0;
}
-
-exit:
-
+   wrqu->essid.length = len;
+   wrqu->essid.flags = 1;
 
return ret;
 }
-- 
2.13.6

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


[PATCH V2] staging: rtl8188eu: Fix incorrect response to SIOCGIWESSID

2017-11-25 Thread Larry Finger
When not associated with an AP, wifi device drivers should respond to the
SIOCGIWESSID ioctl with a zero-length string for the SSID, which is the
behavior expected by dhcpcd.

Currently, this driver returns an error code (-1) from the ioctl call,
which causes dhcpcd to assume that the device is not a wireless interface
and therefore it fails to work correctly with it thereafter.

This problem was reported and tested at
https://github.com/lwfinger/rtl8188eu/issues/234.

Signed-off-by: Larry Finger <larry.fin...@lwfinger.net>
---

v2 - completed missing subject
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index c0664dc80bf2..446310775e90 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -1395,19 +1395,13 @@ static int rtw_wx_get_essid(struct net_device *dev,
if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) {
len = pcur_bss->Ssid.SsidLength;
-
-   wrqu->essid.length = len;
-
memcpy(extra, pcur_bss->Ssid.Ssid, len);
-
-   wrqu->essid.flags = 1;
} else {
-   ret = -1;
-   goto exit;
+   len = 0;
+   *extra = 0;
}
-
-exit:
-
+   wrqu->essid.length = len;
+   wrqu->essid.flags = 1;
 
return ret;
 }
-- 
2.13.6

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


Re: [PATCH] staging: rtl8822be: fix missing null check on dev_alloc_skb return

2017-11-17 Thread Larry Finger

On 11/17/2017 08:50 AM, Colin King wrote:

From: Colin Ian King <colin.k...@canonical.com>

dev_alloc_skb can potentially return NULL, so add a null check to
avoid a null pointer dereference on skb


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

Larry



Detected by CoverityScan, CID#1454558 ("Dereference on null return")

Fixes: 7e5b796cde7e ("staging: r8822be: Add the driver code")
Signed-off-by: Colin Ian King <colin.k...@canonical.com>
---
  drivers/staging/rtlwifi/rtl8822be/fw.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c 
b/drivers/staging/rtlwifi/rtl8822be/fw.c
index f45487122517..483ea85943c3 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -464,6 +464,8 @@ bool rtl8822b_halmac_cb_write_data_rsvd_page(struct 
rtl_priv *rtlpriv, u8 *buf,
int count;
  
  	skb = dev_alloc_skb(size);

+   if (!skb)
+   return false;
memcpy((u8 *)skb_put(skb, size), buf, size);
  
  	if (!_rtl8822be_send_bcn_or_cmd_packet(rtlpriv->hw, skb, BEACON_QUEUE))




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


Re: [PATCH v2 1/2] staging: rtl8712: Cleanup checkpatch issue WARNING:LONG_LINE

2017-12-09 Thread Larry Finger

On 12/09/2017 05:11 AM, Neil Singh wrote:

Cleanup below checkpatch issue:

WARNING:LONG_LINE: line over 80 characters
1000: FILE: rtl871x_security.c:1000:
+static void construct_ctr_preload(u8 *ctr_preload, sint a4_exists, sint 
qc_exists,

Signed-off-by: Neil Singh 
---
  drivers/staging/rtl8712/rtl871x_security.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_security.c 
b/drivers/staging/rtl8712/rtl871x_security.c
index 56d36f6..77a5f5d 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -997,7 +997,8 @@ static void construct_mic_header2(u8 *mic_header2, u8 
*mpdu, sint a4_exists,
  /* Builds the last MIC header block from*/
  /* header fields.   */
  //
-static void construct_ctr_preload(u8 *ctr_preload, sint a4_exists, sint 
qc_exists,
+static void construct_ctr_preload(u8 *ctr_preload,
+  sint a4_exists, sint qc_exists,
   u8 *mpdu, u8 *pn_vector, sint c)
  {
sint i;



Did you run checkpatch on these patches? My system reports the following:

---
patch_1
---
WARNING: A patch subject line should describe the change not the tool that 
found it
#95:
Subject: [PATCH v2 1/2] staging: rtl8712: Cleanup checkpatch issue 
WARNING:LONG_LINE

CHECK: Alignment should match open parenthesis
#125: FILE: drivers/staging/rtl8712/rtl871x_security.c:1001:
+static void construct_ctr_preload(u8 *ctr_preload,
+  sint a4_exists, sint qc_exists,

---
patch_2
---
WARNING: A patch subject line should describe the change not the tool that 
found it
#95:
Subject: [PATCH v2 2/2] staging: rtl8712: Cleanup checkpatch issues CODE_INDENT 
and LEADING_SPACE


Larry

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


Re: Searching help for Linux support for RTL8812AU

2017-10-25 Thread Larry Finger

On 10/24/2017 08:24 AM, txt.file wrote:

Hey Linux wireless list,

A while ago I bought an ALFA Network AWUS036AC[0] which does not yet
seem to be supported in Linux mainline. I would like to get it supported.

The problem is that I have not that much experience doing software
development.

kind regards
txt.file

PS: Please keep me in CC as I am not subscribed to the lists.

[0] https://wikidevi.com/wiki/ALFA_Network_AWUS036AC


I can provide you with an out-of-kernel driver for the RTL8812AU. Please be 
aware that these Realtek USB drivers require many changes before they can be 
accepted into even the staging tree of the kernel. One other consideration is 
that staging drivers should (must?) have a definite path for inclusion into the 
main kernel trees. For wireless, this means using mac80211. For these Realtek 
drivers with their own MAC code, that is a major change.


My suggestion is that you work to get your device handled by driver rtl8xxxu, 
which is in the kernel. I have no idea how much effort that would be, but 
certainly a lot less than converting the Realtek driver.


Larry

PS: Please keep the list in the Cc as I tend to disregard private requests for 
consulting!

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


Re: [PATCH] staging: rtl8822be: fix wrong dma unmap len

2017-10-23 Thread Larry Finger

On 10/23/2017 04:35 AM, Stanislaw Gruszka wrote:

Patch fixes splat:

r8822be :04:00.0: DMA-API: device driver frees DMA memory with different 
size
[device address=0x78477000] [map size=4096 bytes] [unmap size=424 bytes]

Call Trace:
   debug_dma_unmap_page+0xa5/0xb0
   ? unmap_single+0x2f/0x40
   _rtl8822be_send_bcn_or_cmd_packet+0x2c5/0x300 [r8822be]
   ? _rtl8822be_send_bcn_or_cmd_packet+0x2c5/0x300 [r8822be]
   rtl8822b_halmac_cb_write_data_rsvd_page+0x51/0xc0 [r8822be]
   _halmac_write_data_rsvd_page+0x22/0x30 [r8822be]
   halmac_download_rsvd_page_88xx+0xee/0x1f0 [r8822be]
   halmac_dlfw_to_mem_88xx+0x80/0x120 [r8822be]
   halmac_download_firmware_88xx.part.47+0x477/0x600 [r8822be]
   halmac_download_firmware_88xx+0x32/0x40 [r8822be]
   rtl_halmac_dlfw+0x70/0x120 [r8822be]
   rtl_halmac_init_hal+0x5f/0x1b0 [r8822be]
   rtl8822be_hw_init+0x8a2/0x1040 [r8822be]

Signed-off-by: Stanislaw Gruszka <sgrus...@redhat.com>


Acked-by: Larry Finger <larry.fin...@lwfinger.net>

Thanks Stanislaw. It is amazing how long I can stare at a piece of code without 
seeing the problem.


Larry


---
  drivers/staging/rtlwifi/rtl8822be/fw.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c 
b/drivers/staging/rtlwifi/rtl8822be/fw.c
index 8e24da1..a2cc548 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -419,7 +419,7 @@ static bool _rtl8822be_send_bcn_or_cmd_packet(struct 
ieee80211_hw *hw,
dma_addr = rtlpriv->cfg->ops->get_desc(
hw, (u8 *)pbd_desc, true, HW_DESC_TXBUFF_ADDR);
  
-		pci_unmap_single(rtlpci->pdev, dma_addr, skb->len,

+   pci_unmap_single(rtlpci->pdev, dma_addr, pskb->len,
 PCI_DMA_TODEVICE);
kfree_skb(pskb);
  



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


Re: [PATCH] staging: rtlwifi: add identifier names to function definition arguments

2018-01-28 Thread Larry Finger

On 01/28/2018 08:05 AM, Erik Liodden wrote:

Add identifier names to function definition arguments to comply with
the kernel coding style and the naming convention in the rest of the
file.

Issues found by checkpatch.

Signed-off-by: Erik Liodden 
---


As far as I am concerned, this patch is merely churning the source. Those 
prototypes correctly describe the calling sequence to the compiler, which is all 
that is necessary. Checkpatch is a moving specification. These were NOT 
ERRORS/WARNINGS/CHECKS when this code was first introduced. Why should it be 
made to conform to it now? Besides, you should use checkpatch in an advisory role.


NACK.

Larry


  drivers/staging/rtlwifi/wifi.h | 29 +++--
  1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtlwifi/wifi.h b/drivers/staging/rtlwifi/wifi.h
index ca0243f..a23bb17 100644
--- a/drivers/staging/rtlwifi/wifi.h
+++ b/drivers/staging/rtlwifi/wifi.h
@@ -2379,16 +2379,17 @@ struct rtl_hal_usbint_cfg {
u32 rx_max_size;
  
  	/* op - rx */

-   void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
-   void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
-struct sk_buff_head *);
+   void (*usb_rx_hdl)(struct ieee80211_hw *hw, struct sk_buff *skb);
+   void (*usb_rx_segregate_hdl)(struct ieee80211_hw *hw,
+struct sk_buff *skb,
+struct sk_buff_head *skbh);
  
  	/* tx */

-   void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
-   int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
-  struct sk_buff *);
-   struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
-   struct sk_buff_head *);
+   void (*usb_tx_cleanup)(struct ieee80211_hw *hw, struct sk_buff *skb);
+   int (*usb_tx_post_hdl)(struct ieee80211_hw *hw, struct urb *urb,
+  struct sk_buff *skb);
+   struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *hw,
+   struct sk_buff_head *skbh);
  
  	/* endpoint mapping */

int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
@@ -2693,12 +2694,12 @@ struct rtl_btc_ops {
  };
  
  struct rtl_halmac_ops {

-   int (*halmac_init_adapter)(struct rtl_priv *);
-   int (*halmac_deinit_adapter)(struct rtl_priv *);
-   int (*halmac_init_hal)(struct rtl_priv *);
-   int (*halmac_deinit_hal)(struct rtl_priv *);
-   int (*halmac_poweron)(struct rtl_priv *);
-   int (*halmac_poweroff)(struct rtl_priv *);
+   int (*halmac_init_adapter)(struct rtl_priv *rtlpriv);
+   int (*halmac_deinit_adapter)(struct rtl_priv *rtlpriv);
+   int (*halmac_init_hal)(struct rtl_priv *rtlpriv);
+   int (*halmac_deinit_hal)(struct rtl_priv *rtlpriv);
+   int (*halmac_poweron)(struct rtl_priv *rtlpriv);
+   int (*halmac_poweroff)(struct rtl_priv *rtlpriv);
  
  	int (*halmac_phy_power_switch)(struct rtl_priv *rtlpriv, u8 enable);

int (*halmac_set_mac_address)(struct rtl_priv *rtlpriv, u8 hwport,



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


Re: [PATCH-next] staging: rtl8188eu: Remove unneeded cast

2018-02-20 Thread Larry Finger

On 02/20/2018 10:37 AM, Christopher Diaz Riveros wrote:

Fix Coccinelle alert:

drivers/staging//rtl8188eu/os_dep/usb_intf.c:336:13-27: WARNING: casting value 
returned by memory allocation function to (struct adapter *) is useless.

This issue was detected by using the Coccinelle software.

Signed-off-by: Christopher Diaz Riveros <chris...@gentoo.org>


Acked-by: Larry Finger <larry.fin...@lwfinger.net>



---
  drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c 
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 32c7225a831e..127ecf896fc9 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -333,7 +333,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv 
*dvobj,
struct net_device *pmondev;
int status = _FAIL;
  
-	padapter = (struct adapter *)vzalloc(sizeof(*padapter));

+   padapter = vzalloc(sizeof(*padapter));
if (padapter == NULL)
goto exit;
padapter->dvobj = dvobj;



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


Re: [PATCH 1/2] staging: fix possible_condition_with_no_effect warnings

2018-08-05 Thread Larry Finger

On 08/05/2018 02:35 PM, Umang Parmar wrote:

Remove unnecessary conditions where if and else block had same code.
Signed-off-by: Umang Parmar 


The subject should be "staging: rtlwifi: ...". If someone wants to search for 
fixes to the modules in drivers/staging/rtlwifi/, your subject would not be helpful.

---
  .../rtlwifi/btcoexist/halbtc8822b2ant.c   |  6 
  .../staging/rtlwifi/btcoexist/halbtcoutsrc.c  |  6 ++--
  drivers/staging/rtlwifi/phydm/phydm_debug.c   | 29 ++-
  drivers/staging/rtlwifi/phydm/phydm_dig.c | 10 ++-
  .../staging/rtlwifi/phydm/phydm_hwconfig.c|  4 +--
  drivers/staging/rtlwifi/phydm/phydm_psd.c |  7 +
  6 files changed, 16 insertions(+), 46 deletions(-)


Why do some of the above have "drivers/staging/..." and others have 
".../staging/..."? This looks a bit strange.


Otherwise, this patch looks OK.

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


Re: [PATCH 2/2] staging: fix unneeded_variables warnings

2018-08-05 Thread Larry Finger

On 08/05/2018 02:35 PM, Umang Parmar wrote:

Directly return value and remove unneeded variables.
Signed-off-by: Umang Parmar 


This patch also has the same problem with the subject. Otherwise it is OK.

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


Re: [PATCH] Staging:rtl8712: Style - Removed inline block comment to fix "Statements should start on a tapstop"

2018-08-08 Thread Larry Finger

On 08/08/2018 04:22 AM, Greg KH wrote:

On Sun, Aug 05, 2018 at 09:41:06PM +0200, Frank Werner-Krippendorf wrote:

Removed 5 inline comments "/*volatile*/" rtl87x_event.h, to fix
a coding style issue "Statements should start on a tabstop"
detected by checkpatch.pl script.

Signed-off-by: Frank Werner-Krippendorf 
---
  drivers/staging/rtl8712/rtl871x_event.h | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_event.h 
b/drivers/staging/rtl8712/rtl871x_event.h
index 5171379..2e59e8e 100644
--- a/drivers/staging/rtl8712/rtl871x_event.h
+++ b/drivers/staging/rtl8712/rtl871x_event.h
@@ -90,13 +90,13 @@ struct event_node {
unsigned char *node;
unsigned char evt_code;
unsigned short evt_sz;
-   /*volatile*/ int *caller_ff_tail;
+   int *caller_ff_tail;
int caller_ff_sz;
  };
  
  struct c2hevent_queue {

-   /*volatile*/ inthead;
-   /*volatile*/ inttail;


Those "volatile" seem to imply that something is needed for these
variables.  Please check to ensure that these are ok to remove in that
there is the proper locking for these types of things.


Those in-line comments are there as a warning that these variables are special. 
Just because a tool such as checkpatch says to remove them does not mean that 
you should; however, if you want to get rid of the warnings, change the space(s) 
after the "*/" into a tab. That silences the checkpatch warning without removing 
the implicit warning that these variables are special.


NACK.

Keep in mind that when this driver was submitted, it ran checkpatch cleanly. The 
fact that there are now warnings is due to changes in the tool. Following those 
will be a never-ending task.


Larry

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


[PATCH 2/2] staging: rtl8712u: Fix compiler warning about strncpy

2018-08-20 Thread Larry Finger
When strncpy() is called with source and destination strings the same
length, gcc 8 warns that there may be an unterminated string. Using
strlcpy() rather than strncpy() forces a null at the end and quiets the
warning.

Signed-off-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index c3ff7c3e6681..08e1c0957a07 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1789,7 +1789,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev,
return -ENOMEM;
param->cmd = IEEE_CMD_SET_ENCRYPTION;
eth_broadcast_addr(param->sta_addr);
-   strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
+   strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
param->u.crypt.set_tx = 0;
if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-- 
2.18.0

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


[PATCH 1/2] staging: rtl8192e: Fix compiler warning about strncpy

2018-08-20 Thread Larry Finger
When strncpy() is called with source and destination strings the same
length, gcc 8 warns that there may be an unterminated string. Using
strlcpy() rather than strncpy() forces a null at the end and quiets the
warning.

Signed-off-by: Larry Finger 
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index 919231fec09c..95a8390cb7ac 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1684,14 +1684,14 @@ inline void rtllib_softmac_new_net(struct rtllib_device 
*ieee,
 * essid provided by the user.
 */
if (!ssidbroad) {
-   strncpy(tmp_ssid, ieee->current_network.ssid,
+   strlcpy(tmp_ssid, ieee->current_network.ssid,
IW_ESSID_MAX_SIZE);
tmp_ssid_len = ieee->current_network.ssid_len;
}
memcpy(>current_network, net,
   sizeof(struct rtllib_network));
if (!ssidbroad) {
-   strncpy(ieee->current_network.ssid, tmp_ssid,
+   strlcpy(ieee->current_network.ssid, tmp_ssid,
IW_ESSID_MAX_SIZE);
ieee->current_network.ssid_len = tmp_ssid_len;
}
-- 
2.18.0

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


[PATCH 0/2] staging: Fix some warnings from strncpy()

2018-08-20 Thread Larry Finger
When the size argument in a call to strncpy() is the size of the
destimation, gcc8 issues a warning. These patches fix the potential
problem by replacing the strncpy() with strlcpy().

Signed-off-by: Larry Finger 


Larry Finger (2):
  staging: rtl8192e: Fix compiler warning about strncpy
  staging: rtl8712u: Fix compiler warning about strncpy

 drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++--
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.18.0

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


[PATCH v2 2/2] staging: rtl8712u: Fix compiler warning about strncpy

2018-08-27 Thread Larry Finger
When strncpy() is called with source and destination strings the same
length, gcc 8 warns that there may be an unterminated string. Using
strlcpy() rather than strncpy() forces a null at the end and quiets the
warning.

Signed-off-by: Larry Finger 
---
v2 - No changes.
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index c3ff7c3e6681..08e1c0957a07 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1789,7 +1789,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev,
return -ENOMEM;
param->cmd = IEEE_CMD_SET_ENCRYPTION;
eth_broadcast_addr(param->sta_addr);
-   strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
+   strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
param->u.crypt.set_tx = 0;
if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-- 
2.18.0

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


[PATCH v2 0/2] staging: Fix some warnings from strncpy()

2018-08-27 Thread Larry Finger
When the size argument in a call to strncpy() is the size of the
destimation, gcc8 issues a warning. These patches fix the potential
problem.

Signed-off-by: Larry Finger 

v2 - The code is changed to implement the comments of David Laight.

Larry Finger (2):
  staging: rtl8192e: Fix compiler warning about strncpy
  staging: rtl8712u: Fix compiler warning about strncpy

 drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++--
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.18.0

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


Re: [PATCH 01/21] staging:rtl8192u: Rename AdvCoding - Style

2018-08-29 Thread Larry Finger

On 08/29/2018 04:14 PM, Joe Perches wrote:

On Wed, 2018-08-29 at 21:35 +0100, John Whitmore wrote:

Rename the bit field element AdvCoding, as it causes a checkpatch issue
with CamelCase naming. As the element is not actually used in code it
has been renamed to 'not_used_adv_coding'.

The single line of code which initialises the bit has been removed,
as the  field is unused.

This is a purely coding style change which should have no impact
on runtime code execution.


Hi John.

Other than the somewhat useful code style cleanups, is there
a point at which you will feel comfortable doing actual code
changes to this driver?

Perhaps support for the chipset could be converted to use
mac80211 and moved into the directory with the other realtek
drivers in drivers/net/wireless/realtek/rtl8xxxu/...

Larry?  What do you think?


First of all, if a variable is not used, then it should be removed, not merely 
renamed to satisfy checkpatch.


All the Realtek USB devices should be added to rtl8xxxu, not merely moved into 
that directory. Jes Sorensen created a well-designed driver the is structured to 
permit addition of different initialization routines, etc. That said, the 
conversion will not be easy. In addition, it will require having your hands on a 
real device - a requirement that I cannot meet for the RTL8192U.


Larry

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


Re: [BUG] staging: r8822be: RTL8822be can't find any wireless AP

2018-07-05 Thread Larry Finger

On 07/05/2018 02:36 AM, Pkshih wrote:

On Wed, 2018-07-04 at 10:33 -0500, Daniel Drake wrote:

On Wed, Jul 4, 2018 at 10:13 AM, Larry Finger  wrote:

We will have to agree to disagree.

I have no idea what the vendors are doing that cause some motherboards to
need a different aspm value. What I do know is that we have had to live with
the idiocy of some vendors saving a few pennies by only including a single
antenna, rather than two, and then making a problem by miscoding the EFUSE
bit that indicates which connector is actually in use. As we have no means
that I know about to detect which boxes have the problem, a module parameter
was created, just as in this case.

I agree that drivers should work "out of the box", but finite resources and
lack of vendor cooperation make this a goal that may not be attainable.


As you touched on, the ideal situation is that Realtek solve the
issue. Ping-Ke Shih is on CC and I am adding a few more contacts from
the commit log. The context is that the r8822 driver fails on several
platforms unless setting aspm=0 (the default is 1).


It's hard to have all laptop or motherboards and all rtl8822be modules in my 
side,
so what I can do is to analyze the issue when user encountered.



https://gist.github.com/dsd/20c05f0c6d66ee2ef9bfbb17f93f18ba
https://bugzilla.kernel.org/show_bug.cgi?id=199651


If we don't get a timely fix from Realtek though, I think there is a
key difference between the antenna selection headache and this one. In
the antenna case, there isn't a good value that you can set that will
work on all systems. If you change the default behaviour you will
solve the issue for some users while simultanously introducing the
problem on other systems that were previously fine.

However in this case, it's highly likely that setting aspm=0 (off) by
default would work for everyone. It has the disadvantage of using a
bit more power, but especially with the indications that this issue
affects a significant number of systems, I think that having the
driver working out of the box everywhere is more important. The module
parameter can be left in place so that unaffected users that want to
save power can set aspm=1.



I think this issue may be due to L1 latency, so below patch would be
helpful but not sure because I don't have the same laptop.
Is there anyone can help to test?


diff --git a/drivers/staging/rtlwifi/rtl8822be/hw.c 
b/drivers/staging/rtlwifi/rtl8822be/hw.c
index 7947edb239a1..88ba5b2fea6a 100644
--- a/drivers/staging/rtlwifi/rtl8822be/hw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/hw.c
@@ -803,7 +803,7 @@ static void _rtl8822be_enable_aspm_back_door(struct 
ieee80211_hw *hw)
    return;
  
  	pci_read_config_byte(rtlpci->pdev, 0x70f, );

-   pci_write_config_byte(rtlpci->pdev, 0x70f, tmp | BIT(7));
+   pci_write_config_byte(rtlpci->pdev, 0x70f, tmp | ASPM_L1_LATENCY << 3);


This patch loses the BIT(7). Did you really mean to do that?

I now agree that this is a bug. A similar problem had been found in a few boxes 
with RTL8723BE or RTL8821AE cards, but that it might apply here completely 
slipped through the ever larger cracks in my mind.


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


<    1   2   3   4   5   6   >