All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines
@ 2016-06-27 15:52 Larry Finger
  2016-06-27 15:52 ` [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info Larry Finger
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger

The rtlwifi family of drivers use similar routines to extract hardware
information from EFUSE. This set of patches create a common routine to
extract this data, and converts most of the drivers to use this routine.

In addition, a complicated set of if ... else if ... else statements are
present in rtl8723ae. These are converted into switch statements that
are much easier to read.

The changes in the hwinfo routines was suggested by Arnd Bergmann.

All of this material is intended for kernel 4.8.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
V2 - Applied changes suggested by Joe Perches
     Fixed a bug found after V1 was submitted
     These patches require ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.

Larry Finger (10):
  rtlwifi: Create common routine to get hardware info
  rtlwifi: rtl8192ce: Convert driver to use common hardware info routine
  rtlwifi: rtl8192cu: Convert driver to use common hardware info routine
  rtlwifi: rtl8188ee: Convert driver to use common hardware info routine
  rtlwifi: rtl8192ee: Convert driver to use common hardware info routine
  rtlwifi: rtl8723ee: Convert driver to use common hardware info routine
  rtlwifi: rtl8723be: Convert driver to use common hardware info routine
  rtlwifi: rtl8821ae: Convert driver to use common hardware info routine
  rtlwifi: rtl8192de: Convert driver to use common hardware info routine
  rtlwifi: rtl8723ae: Clean up the hardware info routine

 drivers/net/wireless/realtek/rtlwifi/efuse.c       |  78 ++++++
 drivers/net/wireless/realtek/rtlwifi/efuse.h       |   2 +
 .../net/wireless/realtek/rtlwifi/rtl8188ee/hw.c    |  76 +-----
 .../net/wireless/realtek/rtlwifi/rtl8192ce/hw.c    |  83 +-----
 .../net/wireless/realtek/rtlwifi/rtl8192cu/hw.c    |  61 ++---
 .../net/wireless/realtek/rtlwifi/rtl8192de/hw.c    |  77 ++----
 .../net/wireless/realtek/rtlwifi/rtl8192ee/hw.c    |  73 +-----
 .../net/wireless/realtek/rtlwifi/rtl8723ae/hw.c    | 286 +++++++++------------
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c    |  74 +-----
 .../net/wireless/realtek/rtlwifi/rtl8821ae/hw.c    |  84 +-----
 10 files changed, 288 insertions(+), 606 deletions(-)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 21:25   ` Arnd Bergmann
  2016-06-27 15:52 ` [PATCH v2 02/10] rtlwifi: rtl8192ce: Convert driver to use common hardware info routine Larry Finger
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

All of the rtlwifi family of drivers have a similar routine that acquires
the hardware info from efuse and initializes a number of variables in the
driver's private area. A common routine is created for all drivers to use.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.
     Incorporates change suggested by Joe Perches

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 drivers/net/wireless/realtek/rtlwifi/efuse.c | 78 ++++++++++++++++++++++++++++
 drivers/net/wireless/realtek/rtlwifi/efuse.h |  2 +
 2 files changed, 80 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c
index 0b4082c..7becfef 100644
--- a/drivers/net/wireless/realtek/rtlwifi/efuse.c
+++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c
@@ -24,6 +24,7 @@
  *****************************************************************************/
 #include "wifi.h"
 #include "efuse.h"
+#include "pci.h"
 #include <linux/export.h>
 
 static const u8 MAX_PGPKT_SIZE = 9;
@@ -1243,3 +1244,80 @@ static u8 efuse_calculate_word_cnts(u8 word_en)
 	return word_cnts;
 }
 
+int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
+		   int max_size, u8 *hwinfo, int *params)
+{
+	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
+	struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw);
+	struct device *dev = &rtlpcipriv->dev.pdev->dev;
+	u16 eeprom_id;
+	u16 i, usvalue;
+
+	switch (rtlefuse->epromtype) {
+	case EEPROM_BOOT_EFUSE:
+		rtl_efuse_shadow_map_update(hw);
+		break;
+
+	case EEPROM_93C46:
+		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+			 "RTL8XXX did not boot from eeprom, check it !!\n");
+		return 1;
+
+	default:
+		dev_warn(dev, "no efuse data\n");
+		return 1;
+	}
+
+	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], max_size);
+
+	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
+		      hwinfo, max_size);
+
+	eeprom_id = *((u16 *)&hwinfo[0]);
+	if (eeprom_id != params[0]) {
+		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
+			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
+		rtlefuse->autoload_failflag = true;
+	} else {
+		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
+		rtlefuse->autoload_failflag = false;
+	}
+
+	if (rtlefuse->autoload_failflag)
+		return 1;
+
+	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[params[1]];
+	rtlefuse->eeprom_did = *(u16 *)&hwinfo[params[2]];
+	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[params[3]];
+	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[params[4]];
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+		 "EEPROMId = 0x%4x\n", eeprom_id);
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
+
+	for (i = 0; i < 6; i += 2) {
+		usvalue = *(u16 *)&hwinfo[params[5] + i];
+		*((u16 *)(&rtlefuse->dev_addr[i])) = usvalue;
+	}
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr);
+
+	rtlefuse->eeprom_channelplan = *&hwinfo[params[6]];
+	rtlefuse->eeprom_version = *(u16 *)&hwinfo[params[7]];
+	rtlefuse->txpwr_fromeprom = true;
+	rtlefuse->eeprom_oemid = *&hwinfo[params[8]];
+
+	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
+
+	/* set channel plan to world wide 13 */
+	rtlefuse->channel_plan = params[9];
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rtl_get_hwinfo);
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.h b/drivers/net/wireless/realtek/rtlwifi/efuse.h
index be02e78..51aa121 100644
--- a/drivers/net/wireless/realtek/rtlwifi/efuse.h
+++ b/drivers/net/wireless/realtek/rtlwifi/efuse.h
@@ -109,5 +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);
+int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
+		   int max_size, u8 *hwinfo, int *params);
 
 #endif
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 02/10] rtlwifi: rtl8192ce: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
  2016-06-27 15:52 ` [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 03/10] rtlwifi: rtl8192cu: " Larry Finger
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8192CE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8192ce/hw.c    | 83 ++++------------------
 1 file changed, 12 insertions(+), 71 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
index 809a021..2446079 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
@@ -1680,65 +1680,18 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	struct device *dev = &rtl_pcipriv(hw)->dev.pdev->dev;
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
-
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-		break;
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
-		return;
-
-	default:
-		dev_warn(dev, "no efuse data\n");
-		return;
-	}
-
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
-		      hwinfo, HWSET_MAX_SIZE);
-
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL8190_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-
-	if (rtlefuse->autoload_failflag)
+	int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	u8 *hwinfo;
+
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
 
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
-
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
-	}
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr);
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
 
 	_rtl92ce_read_txpower_info_from_hwpg(hw,
 					     rtlefuse->autoload_failflag,
@@ -1747,18 +1700,6 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
 	rtl8192ce_read_bt_coexist_info_from_hwpg(hw,
 						 rtlefuse->autoload_failflag,
 						 hwinfo);
-
-	rtlefuse->eeprom_channelplan = *&hwinfo[EEPROM_CHANNELPLAN];
-	rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
-	rtlefuse->txpwr_fromeprom = true;
-	rtlefuse->eeprom_oemid = *&hwinfo[EEPROM_CUSTOMER_ID];
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
-
-	/* set channel paln to world wide 13 */
-	rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13;
-
 	if (rtlhal->oem_id == RT_CID_DEFAULT) {
 		switch (rtlefuse->eeprom_oemid) {
 		case EEPROM_CID_DEFAULT:
@@ -1782,10 +1723,10 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
 		default:
 			rtlhal->oem_id = RT_CID_DEFAULT;
 			break;
-
 		}
 	}
-
+exit:
+	kfree(hwinfo);
 }
 
 static void _rtl92ce_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 03/10] rtlwifi: rtl8192cu: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
  2016-06-27 15:52 ` [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info Larry Finger
  2016-06-27 15:52 ` [PATCH v2 02/10] rtlwifi: rtl8192ce: Convert driver to use common hardware info routine Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 04/10] rtlwifi: rtl8188ee: " Larry Finger
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8192CU chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8192cu/hw.c    | 61 ++++++----------------
 1 file changed, 15 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
index ae1129f..8789752 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
@@ -347,56 +347,24 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE] = {0};
-	u16 eeprom_id;
-
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-		break;
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
+	int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			0};
+	u8 *hwinfo;
+
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
 
-	default:
-		pr_warn("rtl92cu: no efuse data\n\n");
-		return;
-	}
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, "MAP",
-		      hwinfo, HWSET_MAX_SIZE);
-	eeprom_id = le16_to_cpu(*((__le16 *)&hwinfo[0]));
-	if (eeprom_id != RTL8190_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-	if (rtlefuse->autoload_failflag)
-		return;
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
-	}
-	pr_info("MAC address: %pM\n", rtlefuse->dev_addr);
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
+
 	_rtl92cu_read_txpower_info_from_hwpg(hw,
 					   rtlefuse->autoload_failflag, hwinfo);
-	rtlefuse->eeprom_vid = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VID]);
-	rtlefuse->eeprom_did = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_DID]);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, " VID = 0x%02x PID = 0x%02x\n",
-		 rtlefuse->eeprom_vid, rtlefuse->eeprom_did);
-	rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN];
-	rtlefuse->eeprom_version =
-			 le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VERSION]);
+	_rtl92cu_read_board_type(hw, hwinfo);
+
 	rtlefuse->txpwr_fromeprom = true;
-	rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x\n",
-		 rtlefuse->eeprom_oemid);
 	if (rtlhal->oem_id == RT_CID_DEFAULT) {
 		switch (rtlefuse->eeprom_oemid) {
 		case EEPROM_CID_DEFAULT:
@@ -422,7 +390,8 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
 			break;
 		}
 	}
-	_rtl92cu_read_board_type(hw, hwinfo);
+exit:
+	kfree(hwinfo);
 }
 
 static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 04/10] rtlwifi: rtl8188ee: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (2 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 03/10] rtlwifi: rtl8192cu: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 05/10] rtlwifi: rtl8192ee: " Larry Finger
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8188EE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8188ee/hw.c    | 76 ++++------------------
 1 file changed, 13 insertions(+), 63 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
index cfdf6d8..4ab6201 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
@@ -1835,76 +1835,24 @@ static void _rtl88ee_read_adapter_info(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
-
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-		break;
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
+	int params[] = {RTL8188E_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	u8 *hwinfo;
+
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
 
-	default:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "boot from neither eeprom nor efuse, check it !!\n");
-		return;
-	}
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP\n",
-		      hwinfo, HWSET_MAX_SIZE);
-
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL8188E_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
 
-	if (rtlefuse->autoload_failflag == true)
-		return;
-	/*VID DID SVID SDID*/
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
-	/*customer ID*/
-	rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID];
 	if (rtlefuse->eeprom_oemid == 0xFF)
-		rtlefuse->eeprom_oemid =	0;
+		rtlefuse->eeprom_oemid = 0;
 
 	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
 		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
-	/*EEPROM version*/
-	rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
-	/*mac address*/
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *)(&rtlefuse->dev_addr[i])) = usvalue;
-	}
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-		 "dev_addr: %pM\n", rtlefuse->dev_addr);
-	/*channel plan */
-	rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN];
 	/* set channel plan from efuse */
 	rtlefuse->channel_plan = rtlefuse->eeprom_channelplan;
 	/*tx power*/
@@ -1978,6 +1926,8 @@ static void _rtl88ee_read_adapter_info(struct ieee80211_hw *hw)
 
 		}
 	}
+exit:
+	kfree(hwinfo);
 }
 
 static void _rtl88ee_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 05/10] rtlwifi: rtl8192ee: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (3 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 04/10] rtlwifi: rtl8188ee: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 06/10] rtlwifi: rtl8723ae: " Larry Finger
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8192EE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8192ee/hw.c    | 73 ++++------------------
 1 file changed, 12 insertions(+), 61 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
index 9d1ecba..b07af8d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
@@ -2098,75 +2098,24 @@ static void _rtl92ee_read_adapter_info(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
-
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-		break;
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
-		return;
-
-	default:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "boot from neither eeprom nor efuse, check it !!\n");
+	int params[] = {RTL8192E_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	u8 *hwinfo;
+
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
-	}
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
 
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP\n",
-		      hwinfo, HWSET_MAX_SIZE);
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
 
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL8192E_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-
-	if (rtlefuse->autoload_failflag)
-		return;
-	/*VID DID SVID SDID*/
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
-	/*customer ID*/
-	rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID];
 	if (rtlefuse->eeprom_oemid == 0xFF)
 		rtlefuse->eeprom_oemid = 0;
 
 	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
 		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
-	/*EEPROM version*/
-	rtlefuse->eeprom_version = *(u8 *)&hwinfo[EEPROM_VERSION];
-	/*mac address*/
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *)(&rtlefuse->dev_addr[i])) = usvalue;
-	}
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-		 "dev_addr: %pM\n", rtlefuse->dev_addr);
-	/*channel plan */
-	rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN];
 	/* set channel plan from efuse */
 	rtlefuse->channel_plan = rtlefuse->eeprom_channelplan;
 	/*tx power*/
@@ -2208,6 +2157,8 @@ static void _rtl92ee_read_adapter_info(struct ieee80211_hw *hw)
 			break;
 		}
 	}
+exit:
+	kfree(hwinfo);
 }
 
 static void _rtl92ee_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 06/10] rtlwifi: rtl8723ae: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (4 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 05/10] rtlwifi: rtl8192ee: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 07/10] rtlwifi: rtl8723be: " Larry Finger
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8723AE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8723ae/hw.c    | 76 ++++------------------
 1 file changed, 11 insertions(+), 65 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
index 0025e21..662c445 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
@@ -1630,67 +1630,22 @@ static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	struct device *dev = &rtl_pcipriv(hw)->dev.pdev->dev;
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
+	int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	u8 *hwinfo;
 
 	if (b_pseudo_test) {
 		/* need add */
 		return;
 	}
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
 
-	default:
-		dev_warn(dev, "no efuse data\n");
-	}
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP\n",
-		      hwinfo, HWSET_MAX_SIZE);
-
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL8190_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-
-	if (rtlefuse->autoload_failflag)
-		return;
-
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
-
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *)(&rtlefuse->dev_addr[i])) = usvalue;
-	}
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-		 "dev_addr: %pM\n", rtlefuse->dev_addr);
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
 
 	_rtl8723e_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag,
 					      hwinfo);
@@ -1698,17 +1653,6 @@ static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
 	rtl8723e_read_bt_coexist_info_from_hwpg(hw,
 			rtlefuse->autoload_failflag, hwinfo);
 
-	rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN];
-	rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
-	rtlefuse->txpwr_fromeprom = true;
-	rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID];
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
-
-	/* set channel paln to world wide 13 */
-	rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13;
-
 	if (rtlhal->oem_id == RT_CID_DEFAULT) {
 		switch (rtlefuse->eeprom_oemid) {
 		case EEPROM_CID_DEFAULT:
@@ -1836,6 +1780,8 @@ static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
 
 		}
 	}
+exit:
+	kfree(hwinfo);
 }
 
 static void _rtl8723e_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 07/10] rtlwifi: rtl8723be: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (5 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 06/10] rtlwifi: rtl8723ae: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 08/10] rtlwifi: rtl8821ae: " Larry Finger
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8723BE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c    | 74 ++++------------------
 1 file changed, 12 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 63b0df6..cb68c719 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2026,10 +2026,12 @@ static void _rtl8723be_read_adapter_info(struct ieee80211_hw *hw,
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	struct device *dev = &rtl_pcipriv(hw)->dev.pdev->dev;
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
+	int params[] = {RTL8723BE_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	u8 *hwinfo;
+	int i;
 	bool is_toshiba_smid1 = false;
 	bool is_toshiba_smid2 = false;
 	bool is_samsung_smid = false;
@@ -2057,58 +2059,12 @@ static void _rtl8723be_read_adapter_info(struct ieee80211_hw *hw,
 		return;
 	}
 
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-		break;
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
 
-	default:
-		dev_warn(dev, "no efuse data\n");
-		return;
-	}
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"),
-		      hwinfo, HWSET_MAX_SIZE);
-
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL8723BE_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-
-	if (rtlefuse->autoload_failflag)
-		return;
-
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
-
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *)(&rtlefuse->dev_addr[i])) = usvalue;
-	}
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "dev_addr: %pM\n",
-		 rtlefuse->dev_addr);
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
 
 	/*parse xtal*/
 	rtlefuse->crystalcap = hwinfo[EEPROM_XTAL_8723BE];
@@ -2122,14 +2078,6 @@ static void _rtl8723be_read_adapter_info(struct ieee80211_hw *hw,
 						 rtlefuse->autoload_failflag,
 						 hwinfo);
 
-	rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN];
-	rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
-	rtlefuse->txpwr_fromeprom = true;
-	rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID];
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
-
 	/* set channel plan from efuse */
 	rtlefuse->channel_plan = rtlefuse->eeprom_channelplan;
 
@@ -2240,6 +2188,8 @@ static void _rtl8723be_read_adapter_info(struct ieee80211_hw *hw,
 			break;
 		}
 	}
+exit:
+	kfree(hwinfo);
 }
 
 static void _rtl8723be_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 08/10] rtlwifi: rtl8821ae: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (6 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 07/10] rtlwifi: rtl8723be: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 09/10] rtlwifi: rtl8192de: " Larry Finger
  2016-06-27 15:52 ` [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the " Larry Finger
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8821AE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8821ae/hw.c    | 84 +++-------------------
 1 file changed, 11 insertions(+), 73 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index ac8836b..0cddf1a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -3101,86 +3101,22 @@ static void _rtl8821ae_read_adapter_info(struct ieee80211_hw *hw, bool b_pseudo_
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
-	struct device *dev = &rtl_pcipriv(hw)->dev.pdev->dev;
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
+	int params[] = {RTL_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
+			EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	u8 *hwinfo;
 
 	if (b_pseudo_test) {
 		;/* need add */
 	}
 
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		rtl_efuse_shadow_map_update(hw);
-		break;
-
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
-		return;
-
-	default:
-		dev_warn(dev, "no efuse data\n");
-	}
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP\n",
-		      hwinfo, HWSET_MAX_SIZE);
-
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-
-	if (rtlefuse->autoload_failflag) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL8812AE autoload_failflag, check it !!\n");
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
-	}
-
-	rtlefuse->eeprom_version = *(u8 *)&hwinfo[EEPROM_VERSION];
-	if (rtlefuse->eeprom_version == 0xff)
-			rtlefuse->eeprom_version = 0;
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM version: 0x%2x\n", rtlefuse->eeprom_version);
-
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
-
-	/*customer ID*/
-	rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID];
-	if (rtlefuse->eeprom_oemid == 0xFF)
-		rtlefuse->eeprom_oemid = 0;
-
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
-
-	for (i = 0; i < 6; i += 2) {
-		usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
-		*((u16 *)(&rtlefuse->dev_addr[i])) = usvalue;
-	}
 
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-		 "dev_addr: %pM\n", rtlefuse->dev_addr);
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
+		goto exit;
 
 	_rtl8821ae_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag,
 					       hwinfo);
@@ -3280,6 +3216,8 @@ static void _rtl8821ae_read_adapter_info(struct ieee80211_hw *hw, bool b_pseudo_
 			break;
 		}
 	}
+exit:
+	kfree(hwinfo);
 }
 
 /*static void _rtl8821ae_hal_customized_behavior(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 09/10] rtlwifi: rtl8192de: Convert driver to use common hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (7 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 08/10] rtlwifi: rtl8821ae: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 15:52 ` [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the " Larry Finger
  9 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger, Arnd Bergmann

The driver for RTL8192DE chips is converted to use the common routine
for getting the hardware information.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
V2 - Fixes bug found after V1 was submitted.

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8192de/hw.c    | 77 +++++-----------------
 1 file changed, 15 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
index 8618c32..b0f6324 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
@@ -1744,71 +1744,26 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	struct device *dev = &rtl_pcipriv(hw)->dev.pdev->dev;
-	u16 i, usvalue;
-	u8 hwinfo[HWSET_MAX_SIZE];
-	u16 eeprom_id;
-	unsigned long flags;
+	int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+			EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR_MAC0_92D,
+			EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+			COUNTRY_CODE_WORLD_WIDE_13};
+	int i;
+	u16 usvalue;
+	u8 *hwinfo;
 
-	switch (rtlefuse->epromtype) {
-	case EEPROM_BOOT_EFUSE:
-		spin_lock_irqsave(&globalmutex_for_power_and_efuse, flags);
-		rtl_efuse_shadow_map_update(hw);
-		_rtl92de_efuse_update_chip_version(hw);
-		spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags);
-		break;
-	case EEPROM_93C46:
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
-		return;
-	default:
-		dev_warn(dev, "no efuse data\n");
+	hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
+	if (!hwinfo)
 		return;
-	}
-
-	memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
-	RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
-		      hwinfo, HWSET_MAX_SIZE);
 
-	eeprom_id = *((u16 *)&hwinfo[0]);
-	if (eeprom_id != RTL8190_EEPROM_ID) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
-			 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
-		rtlefuse->autoload_failflag = true;
-	} else {
-		RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
-		rtlefuse->autoload_failflag = false;
-	}
-	if (rtlefuse->autoload_failflag) {
-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-			 "RTL819X Not boot from eeprom, check it !!\n");
+	if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
 		return;
-	}
-	rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID];
-	_rtl92de_read_macphymode_and_bandtype(hw, hwinfo);
 
-	/* VID, DID  SE     0xA-D */
-	rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
-	rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
-	rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
-	rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROMId = 0x%4x\n", eeprom_id);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
+	_rtl92de_efuse_update_chip_version(hw);
+	_rtl92de_read_macphymode_and_bandtype(hw, hwinfo);
 
-	/* Read Permanent MAC address */
-	if (rtlhal->interfaceindex == 0) {
-		for (i = 0; i < 6; i += 2) {
-			usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR_MAC0_92D + i];
-			*((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
-		}
-	} else {
+	/* Read Permanent MAC address for 2nd interface */
+	if (rtlhal->interfaceindex != 0) {
 		for (i = 0; i < 6; i += 2) {
 			usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR_MAC1_92D + i];
 			*((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
@@ -1834,10 +1789,8 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
 		rtlefuse->channel_plan = COUNTRY_CODE_FCC;
 		break;
 	}
-	rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
 	rtlefuse->txpwr_fromeprom = true;
-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
-		 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
+	kfree(hwinfo);
 }
 
 void rtl92de_read_eeprom_info(struct ieee80211_hw *hw)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the hardware info routine
  2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
                   ` (8 preceding siblings ...)
  2016-06-27 15:52 ` [PATCH v2 09/10] rtlwifi: rtl8192de: " Larry Finger
@ 2016-06-27 15:52 ` Larry Finger
  2016-06-27 21:23   ` Joe Perches
  9 siblings, 1 reply; 14+ messages in thread
From: Larry Finger @ 2016-06-27 15:52 UTC (permalink / raw)
  To: kvalo; +Cc: devel, linux-wireless, Larry Finger

This driver contains some complicated if ... else if ... else
constructions.  These are replaced by switch statements to improve
readability.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
V2 - Changes suggested by Joe Perches were incorporated

This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
	submitted by Joe Perches.
---
 .../net/wireless/realtek/rtlwifi/rtl8723ae/hw.c    | 230 +++++++++++----------
 1 file changed, 116 insertions(+), 114 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
index 662c445..132e879 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
@@ -1653,132 +1653,134 @@ static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
 	rtl8723e_read_bt_coexist_info_from_hwpg(hw,
 			rtlefuse->autoload_failflag, hwinfo);
 
-	if (rtlhal->oem_id == RT_CID_DEFAULT) {
-		switch (rtlefuse->eeprom_oemid) {
-		case EEPROM_CID_DEFAULT:
-			if (rtlefuse->eeprom_did == 0x8176) {
-				if (CHK_SVID_SMID(0x10EC, 0x6151) ||
-				    CHK_SVID_SMID(0x10EC, 0x6152) ||
-				    CHK_SVID_SMID(0x10EC, 0x6154) ||
-				    CHK_SVID_SMID(0x10EC, 0x6155) ||
-				    CHK_SVID_SMID(0x10EC, 0x6177) ||
-				    CHK_SVID_SMID(0x10EC, 0x6178) ||
-				    CHK_SVID_SMID(0x10EC, 0x6179) ||
-				    CHK_SVID_SMID(0x10EC, 0x6180) ||
-				    CHK_SVID_SMID(0x10EC, 0x7151) ||
-				    CHK_SVID_SMID(0x10EC, 0x7152) ||
-				    CHK_SVID_SMID(0x10EC, 0x7154) ||
-				    CHK_SVID_SMID(0x10EC, 0x7155) ||
-				    CHK_SVID_SMID(0x10EC, 0x7177) ||
-				    CHK_SVID_SMID(0x10EC, 0x7178) ||
-				    CHK_SVID_SMID(0x10EC, 0x7179) ||
-				    CHK_SVID_SMID(0x10EC, 0x7180) ||
-				    CHK_SVID_SMID(0x10EC, 0x8151) ||
-				    CHK_SVID_SMID(0x10EC, 0x8152) ||
-				    CHK_SVID_SMID(0x10EC, 0x8154) ||
-				    CHK_SVID_SMID(0x10EC, 0x8155) ||
-				    CHK_SVID_SMID(0x10EC, 0x8181) ||
-				    CHK_SVID_SMID(0x10EC, 0x8182) ||
-				    CHK_SVID_SMID(0x10EC, 0x8184) ||
-				    CHK_SVID_SMID(0x10EC, 0x8185) ||
-				    CHK_SVID_SMID(0x10EC, 0x9151) ||
-				    CHK_SVID_SMID(0x10EC, 0x9152) ||
-				    CHK_SVID_SMID(0x10EC, 0x9154) ||
-				    CHK_SVID_SMID(0x10EC, 0x9155) ||
-				    CHK_SVID_SMID(0x10EC, 0x9181) ||
-				    CHK_SVID_SMID(0x10EC, 0x9182) ||
-				    CHK_SVID_SMID(0x10EC, 0x9184) ||
-				    CHK_SVID_SMID(0x10EC, 0x9185))
+	if (rtlhal->oem_id != RT_CID_DEFAULT)
+		return;
+
+	switch (rtlefuse->eeprom_oemid) {
+	case EEPROM_CID_DEFAULT:
+		switch (rtlefuse->eeprom_did) {
+		case 0x8176:
+			switch (rtlefuse->eeprom_svid) {
+			case 0x10EC:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x6151 ... 0x6152:
+				case 0x6154 ... 0x6155:
+				case 0x6177 ... 0x6180:
+				case 0x7151 ... 0x7152:
+				case 0x7154 ... 0x7155:
+				case 0x7177 ... 0x7180:
+				case 0x8151 ... 0x8152:
+				case 0x8154 ... 0x8155:
+				case 0x8181 ... 0x8182:
+				case 0x8184 ... 0x8185:
+				case 0x9151 ... 0x9152:
+				case 0x9154 ... 0x9155:
+				case 0x9181 ... 0x9182:
+				case 0x9184 ... 0x9185:
 					rtlhal->oem_id = RT_CID_TOSHIBA;
-				else if (rtlefuse->eeprom_svid == 0x1025)
-					rtlhal->oem_id = RT_CID_819X_ACER;
-				else if (CHK_SVID_SMID(0x10EC, 0x6191) ||
-					 CHK_SVID_SMID(0x10EC, 0x6192) ||
-					 CHK_SVID_SMID(0x10EC, 0x6193) ||
-					 CHK_SVID_SMID(0x10EC, 0x7191) ||
-					 CHK_SVID_SMID(0x10EC, 0x7192) ||
-					 CHK_SVID_SMID(0x10EC, 0x7193) ||
-					 CHK_SVID_SMID(0x10EC, 0x8191) ||
-					 CHK_SVID_SMID(0x10EC, 0x8192) ||
-					 CHK_SVID_SMID(0x10EC, 0x8193) ||
-					 CHK_SVID_SMID(0x10EC, 0x9191) ||
-					 CHK_SVID_SMID(0x10EC, 0x9192) ||
-					 CHK_SVID_SMID(0x10EC, 0x9193))
+					break;
+				case 0x6191 ... 0x6193:
+				case 0x7191 ... 0x7193:
+				case 0x8191 ... 0x8193:
+				case 0x9191 ... 0x9193:
 					rtlhal->oem_id = RT_CID_819X_SAMSUNG;
-				else if (CHK_SVID_SMID(0x10EC, 0x8195) ||
-					 CHK_SVID_SMID(0x10EC, 0x9195) ||
-					 CHK_SVID_SMID(0x10EC, 0x7194) ||
-					 CHK_SVID_SMID(0x10EC, 0x8200) ||
-					 CHK_SVID_SMID(0x10EC, 0x8201) ||
-					 CHK_SVID_SMID(0x10EC, 0x8202) ||
-					 CHK_SVID_SMID(0x10EC, 0x9200))
-					rtlhal->oem_id = RT_CID_819X_LENOVO;
-				else if (CHK_SVID_SMID(0x10EC, 0x8197) ||
-					 CHK_SVID_SMID(0x10EC, 0x9196))
+					break;
+				case 0x8197:
+				case 0x9196:
 					rtlhal->oem_id = RT_CID_819X_CLEVO;
-				else if (CHK_SVID_SMID(0x1028, 0x8194) ||
-					 CHK_SVID_SMID(0x1028, 0x8198) ||
-					 CHK_SVID_SMID(0x1028, 0x9197) ||
-					 CHK_SVID_SMID(0x1028, 0x9198))
+					break;
+				case 0x8203:
+					rtlhal->oem_id = RT_CID_819X_PRONETS;
+					break;
+				case 0x8195:
+				case 0x9195:
+				case 0x7194:
+				case 0x8200 ... 0x8202:
+				case 0x9200:
+					rtlhal->oem_id = RT_CID_819X_LENOVO;
+					break;
+				}
+			case 0x1025:
+				rtlhal->oem_id = RT_CID_819X_ACER;
+				break;
+			case 0x1028:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x8194:
+				case 0x8198:
+				case 0x9197 ... 0x9198:
 					rtlhal->oem_id = RT_CID_819X_DELL;
-				else if (CHK_SVID_SMID(0x103C, 0x1629))
+					break;
+				}
+				break;
+			case 0x103C:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x1629:
 					rtlhal->oem_id = RT_CID_819X_HP;
-				else if (CHK_SVID_SMID(0x1A32, 0x2315))
+				}
+				break;
+			case 0x1A32:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x2315:
 					rtlhal->oem_id = RT_CID_819X_QMI;
-				else if (CHK_SVID_SMID(0x10EC, 0x8203))
-					rtlhal->oem_id = RT_CID_819X_PRONETS;
-				else if (CHK_SVID_SMID(0x1043, 0x84B5))
+					break;
+				}
+				break;
+			case 0x1043:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x84B5:
 					rtlhal->oem_id =
-						 RT_CID_819X_EDIMAX_ASUS;
-				else
-					rtlhal->oem_id = RT_CID_DEFAULT;
-			} else if (rtlefuse->eeprom_did == 0x8178) {
-				if (CHK_SVID_SMID(0x10EC, 0x6181) ||
-				    CHK_SVID_SMID(0x10EC, 0x6182) ||
-				    CHK_SVID_SMID(0x10EC, 0x6184) ||
-				    CHK_SVID_SMID(0x10EC, 0x6185) ||
-				    CHK_SVID_SMID(0x10EC, 0x7181) ||
-				    CHK_SVID_SMID(0x10EC, 0x7182) ||
-				    CHK_SVID_SMID(0x10EC, 0x7184) ||
-				    CHK_SVID_SMID(0x10EC, 0x7185) ||
-				    CHK_SVID_SMID(0x10EC, 0x8181) ||
-				    CHK_SVID_SMID(0x10EC, 0x8182) ||
-				    CHK_SVID_SMID(0x10EC, 0x8184) ||
-				    CHK_SVID_SMID(0x10EC, 0x8185) ||
-				    CHK_SVID_SMID(0x10EC, 0x9181) ||
-				    CHK_SVID_SMID(0x10EC, 0x9182) ||
-				    CHK_SVID_SMID(0x10EC, 0x9184) ||
-				    CHK_SVID_SMID(0x10EC, 0x9185))
+						RT_CID_819X_EDIMAX_ASUS;
+				}
+				break;
+			}
+		case 0x8178:
+			switch (rtlefuse->eeprom_svid) {
+			case 0x10ec:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x6181 ... 0x6182:
+				case 0x6184 ... 0x6185:
+				case 0x7181 ... 0x7182:
+				case 0x7184 ... 0x7185:
+				case 0x8181 ... 0x8182:
+				case 0x8184 ... 0x8185:
+				case 0x9181 ... 0x9182:
+				case 0x9184 ... 0x9185:
 					rtlhal->oem_id = RT_CID_TOSHIBA;
-				else if (rtlefuse->eeprom_svid == 0x1025)
-					rtlhal->oem_id = RT_CID_819X_ACER;
-				else if (CHK_SVID_SMID(0x10EC, 0x8186))
-					rtlhal->oem_id = RT_CID_819X_PRONETS;
-				else if (CHK_SVID_SMID(0x1043, 0x8486))
+					break;
+				case 0x8186:
 					rtlhal->oem_id =
-						     RT_CID_819X_EDIMAX_ASUS;
-				else
-					rtlhal->oem_id = RT_CID_DEFAULT;
-			} else {
-				rtlhal->oem_id = RT_CID_DEFAULT;
-			}
-			break;
-		case EEPROM_CID_TOSHIBA:
-			rtlhal->oem_id = RT_CID_TOSHIBA;
-			break;
-		case EEPROM_CID_CCX:
-			rtlhal->oem_id = RT_CID_CCX;
-			break;
-		case EEPROM_CID_QMI:
-			rtlhal->oem_id = RT_CID_819X_QMI;
-			break;
-		case EEPROM_CID_WHQL:
+						RT_CID_819X_PRONETS;
+					break;
+				}
 				break;
-		default:
-			rtlhal->oem_id = RT_CID_DEFAULT;
+			case 0x1025:
+				rtlhal->oem_id = RT_CID_819X_ACER;
+				break;
+			case 0x1043:
+				switch (rtlefuse->eeprom_smid) {
+				case 0x8486:
+					rtlhal->oem_id =
+					     RT_CID_819X_EDIMAX_ASUS;
+				}
+				break;
+			}
 			break;
-
 		}
+	case EEPROM_CID_TOSHIBA:
+		rtlhal->oem_id = RT_CID_TOSHIBA;
+		break;
+	case EEPROM_CID_CCX:
+		rtlhal->oem_id = RT_CID_CCX;
+		break;
+	case EEPROM_CID_QMI:
+		rtlhal->oem_id = RT_CID_819X_QMI;
+		break;
+	case EEPROM_CID_WHQL:
+		break;
+	default:
+		rtlhal->oem_id = RT_CID_DEFAULT;
+		break;
+
 	}
 exit:
 	kfree(hwinfo);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the hardware info routine
  2016-06-27 15:52 ` [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the " Larry Finger
@ 2016-06-27 21:23   ` Joe Perches
  2016-06-28  0:56     ` Larry Finger
  0 siblings, 1 reply; 14+ messages in thread
From: Joe Perches @ 2016-06-27 21:23 UTC (permalink / raw)
  To: Larry Finger, kvalo; +Cc: devel, linux-wireless

On Mon, 2016-06-27 at 10:52 -0500, Larry Finger wrote:
> This driver contains some complicated if ... else if ... else
> constructions.  These are replaced by switch statements to improve
> readability.
[]
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
[]
> @@ -1653,132 +1653,134 @@ static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
>  	rtl8723e_read_bt_coexist_info_from_hwpg(hw,
>  			rtlefuse->autoload_failflag, hwinfo);
>  
> -	if (rtlhal->oem_id == RT_CID_DEFAULT) {
> -		switch (rtlefuse->eeprom_oemid) {
> -		case EEPROM_CID_DEFAULT:
> -			if (rtlefuse->eeprom_did == 0x8176) {
> -				if (CHK_SVID_SMID(0x10EC, 0x6151) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6152) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6154) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6155) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6177) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6178) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6179) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6180) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7151) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7152) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7154) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7155) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7177) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7178) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7179) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7180) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8151) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8152) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8154) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8155) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8181) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8182) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8184) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8185) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9151) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9152) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9154) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9155) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9181) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9182) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9184) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9185))
> +	if (rtlhal->oem_id != RT_CID_DEFAULT)
> +		return;
> +
> +	switch (rtlefuse->eeprom_oemid) {
> +	case EEPROM_CID_DEFAULT:
> +		switch (rtlefuse->eeprom_did) {
> +		case 0x8176:
> +			switch (rtlefuse->eeprom_svid) {
> +			case 0x10EC:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x6151 ... 0x6152:
> +				case 0x6154 ... 0x6155:
> +				case 0x6177 ... 0x6180:
> +				case 0x7151 ... 0x7152:
> +				case 0x7154 ... 0x7155:
> +				case 0x7177 ... 0x7180:
> +				case 0x8151 ... 0x8152:
> +				case 0x8154 ... 0x8155:
> +				case 0x8181 ... 0x8182:
> +				case 0x8184 ... 0x8185:
> +				case 0x9151 ... 0x9152:
> +				case 0x9154 ... 0x9155:
> +				case 0x9181 ... 0x9182:
> +				case 0x9184 ... 0x9185:
>  					rtlhal->oem_id = RT_CID_TOSHIBA;
> -				else if (rtlefuse->eeprom_svid == 0x1025)
> -					rtlhal->oem_id = RT_CID_819X_ACER;
> -				else if (CHK_SVID_SMID(0x10EC, 0x6191) ||
> -					 CHK_SVID_SMID(0x10EC, 0x6192) ||
> -					 CHK_SVID_SMID(0x10EC, 0x6193) ||
> -					 CHK_SVID_SMID(0x10EC, 0x7191) ||
> -					 CHK_SVID_SMID(0x10EC, 0x7192) ||
> -					 CHK_SVID_SMID(0x10EC, 0x7193) ||
> -					 CHK_SVID_SMID(0x10EC, 0x8191) ||
> -					 CHK_SVID_SMID(0x10EC, 0x8192) ||
> -					 CHK_SVID_SMID(0x10EC, 0x8193) ||
> -					 CHK_SVID_SMID(0x10EC, 0x9191) ||
> -					 CHK_SVID_SMID(0x10EC, 0x9192) ||
> -					 CHK_SVID_SMID(0x10EC, 0x9193))
> +					break;
> +				case 0x6191 ... 0x6193:
> +				case 0x7191 ... 0x7193:
> +				case 0x8191 ... 0x8193:
> +				case 0x9191 ... 0x9193:
>  					rtlhal->oem_id = RT_CID_819X_SAMSUNG;
> -				else if (CHK_SVID_SMID(0x10EC, 0x8195) ||
> -					 CHK_SVID_SMID(0x10EC, 0x9195) ||
> -					 CHK_SVID_SMID(0x10EC, 0x7194) ||
> -					 CHK_SVID_SMID(0x10EC, 0x8200) ||
> -					 CHK_SVID_SMID(0x10EC, 0x8201) ||
> -					 CHK_SVID_SMID(0x10EC, 0x8202) ||
> -					 CHK_SVID_SMID(0x10EC, 0x9200))
> -					rtlhal->oem_id = RT_CID_819X_LENOVO;
> -				else if (CHK_SVID_SMID(0x10EC, 0x8197) ||
> -					 CHK_SVID_SMID(0x10EC, 0x9196))
> +					break;
> +				case 0x8197:
> +				case 0x9196:
>  					rtlhal->oem_id = RT_CID_819X_CLEVO;
> -				else if (CHK_SVID_SMID(0x1028, 0x8194) ||
> -					 CHK_SVID_SMID(0x1028, 0x8198) ||
> -					 CHK_SVID_SMID(0x1028, 0x9197) ||
> -					 CHK_SVID_SMID(0x1028, 0x9198))
> +					break;
> +				case 0x8203:
> +					rtlhal->oem_id = RT_CID_819X_PRONETS;
> +					break;
> +				case 0x8195:
> +				case 0x9195:
> +				case 0x7194:
> +				case 0x8200 ... 0x8202:
> +				case 0x9200:
> +					rtlhal->oem_id = RT_CID_819X_LENOVO;
> +					break;
> +				}

Is this supposed to be a fallthrough?
If so, a comment would be good.
Otherwise is this a missing break?

> +			case 0x1025:
> +				rtlhal->oem_id = RT_CID_819X_ACER;
> +				break;
> +			case 0x1028:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x8194:
> +				case 0x8198:
> +				case 0x9197 ... 0x9198:
>  					rtlhal->oem_id = RT_CID_819X_DELL;
> -				else if (CHK_SVID_SMID(0x103C, 0x1629))
> +					break;
> +				}
> +				break;
> +			case 0x103C:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x1629:
>  					rtlhal->oem_id = RT_CID_819X_HP;
> -				else if (CHK_SVID_SMID(0x1A32, 0x2315))
> +				}
> +				break;
> +			case 0x1A32:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x2315:
>  					rtlhal->oem_id = RT_CID_819X_QMI;
> -				else if (CHK_SVID_SMID(0x10EC, 0x8203))
> -					rtlhal->oem_id = RT_CID_819X_PRONETS;
> -				else if (CHK_SVID_SMID(0x1043, 0x84B5))
> +					break;
> +				}
> +				break;
> +			case 0x1043:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x84B5:
>  					rtlhal->oem_id =
> -						 RT_CID_819X_EDIMAX_ASUS;
> -				else
> -					rtlhal->oem_id = RT_CID_DEFAULT;
> -			} else if (rtlefuse->eeprom_did == 0x8178) {
> -				if (CHK_SVID_SMID(0x10EC, 0x6181) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6182) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6184) ||
> -				    CHK_SVID_SMID(0x10EC, 0x6185) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7181) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7182) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7184) ||
> -				    CHK_SVID_SMID(0x10EC, 0x7185) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8181) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8182) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8184) ||
> -				    CHK_SVID_SMID(0x10EC, 0x8185) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9181) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9182) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9184) ||
> -				    CHK_SVID_SMID(0x10EC, 0x9185))
> +						RT_CID_819X_EDIMAX_ASUS;

Single line?

> +				}
> +				break;
> +			}
> +		case 0x8178:
> +			switch (rtlefuse->eeprom_svid) {
> +			case 0x10ec:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x6181 ... 0x6182:
> +				case 0x6184 ... 0x6185:
> +				case 0x7181 ... 0x7182:
> +				case 0x7184 ... 0x7185:
> +				case 0x8181 ... 0x8182:
> +				case 0x8184 ... 0x8185:
> +				case 0x9181 ... 0x9182:
> +				case 0x9184 ... 0x9185:
>  					rtlhal->oem_id = RT_CID_TOSHIBA;
> -				else if (rtlefuse->eeprom_svid == 0x1025)
> -					rtlhal->oem_id = RT_CID_819X_ACER;
> -				else if (CHK_SVID_SMID(0x10EC, 0x8186))
> -					rtlhal->oem_id = RT_CID_819X_PRONETS;
> -				else if (CHK_SVID_SMID(0x1043, 0x8486))
> +					break;
> +				case 0x8186:
>  					rtlhal->oem_id =
> -						     RT_CID_819X_EDIMAX_ASUS;
> -				else
> -					rtlhal->oem_id = RT_CID_DEFAULT;
> -			} else {
> -				rtlhal->oem_id = RT_CID_DEFAULT;
> -			}
> -			break;
> -		case EEPROM_CID_TOSHIBA:
> -			rtlhal->oem_id = RT_CID_TOSHIBA;
> -			break;
> -		case EEPROM_CID_CCX:
> -			rtlhal->oem_id = RT_CID_CCX;
> -			break;
> -		case EEPROM_CID_QMI:
> -			rtlhal->oem_id = RT_CID_819X_QMI;
> -			break;
> -		case EEPROM_CID_WHQL:
> +						RT_CID_819X_PRONETS;
> +					break;
> +				}
>  				break;
> -		default:
> -			rtlhal->oem_id = RT_CID_DEFAULT;
> +			case 0x1025:
> +				rtlhal->oem_id = RT_CID_819X_ACER;
> +				break;
> +			case 0x1043:
> +				switch (rtlefuse->eeprom_smid) {
> +				case 0x8486:
> +					rtlhal->oem_id =
> +					     RT_CID_819X_EDIMAX_ASUS;
> +				}
> +				break;
> +			}
>  			break;
> -
>  		}
> +	case EEPROM_CID_TOSHIBA:
> +		rtlhal->oem_id = RT_CID_TOSHIBA;
> +		break;
> +	case EEPROM_CID_CCX:
> +		rtlhal->oem_id = RT_CID_CCX;
> +		break;
> +	case EEPROM_CID_QMI:
> +		rtlhal->oem_id = RT_CID_819X_QMI;
> +		break;
> +	case EEPROM_CID_WHQL:
> +		break;
> +	default:
> +		rtlhal->oem_id = RT_CID_DEFAULT;
> +		break;
> +
>  	}
>  exit:
>  	kfree(hwinfo);

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info
  2016-06-27 15:52 ` [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info Larry Finger
@ 2016-06-27 21:25   ` Arnd Bergmann
  0 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-06-27 21:25 UTC (permalink / raw)
  To: Larry Finger; +Cc: kvalo, devel, linux-wireless

On Monday, June 27, 2016 10:52:29 AM CEST Larry Finger wrote:
> All of the rtlwifi family of drivers have a similar routine that acquires
> the hardware info from efuse and initializes a number of variables in the
> driver's private area. A common routine is created for all drivers to use.
> 
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> V2 - Fixes bug found after V1 was submitted.
>      Incorporates change suggested by Joe Perches
> 
> This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls")
>         submitted by Joe Perches.
> 

Thanks for the follow-up on my suggestion!

The changes look good, though I'm not really qualified to say whether
they are correct.

	Arnd


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the hardware info routine
  2016-06-27 21:23   ` Joe Perches
@ 2016-06-28  0:56     ` Larry Finger
  0 siblings, 0 replies; 14+ messages in thread
From: Larry Finger @ 2016-06-28  0:56 UTC (permalink / raw)
  To: Joe Perches, kvalo; +Cc: devel, linux-wireless

On 06/27/2016 04:23 PM, Joe Perches wrote:
> On Mon, 2016-06-27 at 10:52 -0500, Larry Finger wrote:
>> This driver contains some complicated if ... else if ... else
>> constructions.  These are replaced by switch statements to improve
>> readability.
> []
>> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
> []
>> @@ -1653,132 +1653,134 @@ static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
>>   	rtl8723e_read_bt_coexist_info_from_hwpg(hw,
>>   			rtlefuse->autoload_failflag, hwinfo);
>>
>> -	if (rtlhal->oem_id == RT_CID_DEFAULT) {
>> -		switch (rtlefuse->eeprom_oemid) {
>> -		case EEPROM_CID_DEFAULT:
>> -			if (rtlefuse->eeprom_did == 0x8176) {
>> -				if (CHK_SVID_SMID(0x10EC, 0x6151) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6152) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6154) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6155) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6177) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6178) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6179) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6180) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7151) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7152) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7154) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7155) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7177) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7178) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7179) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7180) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8151) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8152) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8154) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8155) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8181) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8182) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8184) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8185) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9151) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9152) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9154) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9155) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9181) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9182) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9184) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9185))
>> +	if (rtlhal->oem_id != RT_CID_DEFAULT)
>> +		return;
>> +
>> +	switch (rtlefuse->eeprom_oemid) {
>> +	case EEPROM_CID_DEFAULT:
>> +		switch (rtlefuse->eeprom_did) {
>> +		case 0x8176:
>> +			switch (rtlefuse->eeprom_svid) {
>> +			case 0x10EC:
>> +				switch (rtlefuse->eeprom_smid) {
>> +				case 0x6151 ... 0x6152:
>> +				case 0x6154 ... 0x6155:
>> +				case 0x6177 ... 0x6180:
>> +				case 0x7151 ... 0x7152:
>> +				case 0x7154 ... 0x7155:
>> +				case 0x7177 ... 0x7180:
>> +				case 0x8151 ... 0x8152:
>> +				case 0x8154 ... 0x8155:
>> +				case 0x8181 ... 0x8182:
>> +				case 0x8184 ... 0x8185:
>> +				case 0x9151 ... 0x9152:
>> +				case 0x9154 ... 0x9155:
>> +				case 0x9181 ... 0x9182:
>> +				case 0x9184 ... 0x9185:
>>   					rtlhal->oem_id = RT_CID_TOSHIBA;
>> -				else if (rtlefuse->eeprom_svid == 0x1025)
>> -					rtlhal->oem_id = RT_CID_819X_ACER;
>> -				else if (CHK_SVID_SMID(0x10EC, 0x6191) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x6192) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x6193) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x7191) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x7192) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x7193) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x8191) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x8192) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x8193) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x9191) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x9192) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x9193))
>> +					break;
>> +				case 0x6191 ... 0x6193:
>> +				case 0x7191 ... 0x7193:
>> +				case 0x8191 ... 0x8193:
>> +				case 0x9191 ... 0x9193:
>>   					rtlhal->oem_id = RT_CID_819X_SAMSUNG;
>> -				else if (CHK_SVID_SMID(0x10EC, 0x8195) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x9195) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x7194) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x8200) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x8201) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x8202) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x9200))
>> -					rtlhal->oem_id = RT_CID_819X_LENOVO;
>> -				else if (CHK_SVID_SMID(0x10EC, 0x8197) ||
>> -					 CHK_SVID_SMID(0x10EC, 0x9196))
>> +					break;
>> +				case 0x8197:
>> +				case 0x9196:
>>   					rtlhal->oem_id = RT_CID_819X_CLEVO;
>> -				else if (CHK_SVID_SMID(0x1028, 0x8194) ||
>> -					 CHK_SVID_SMID(0x1028, 0x8198) ||
>> -					 CHK_SVID_SMID(0x1028, 0x9197) ||
>> -					 CHK_SVID_SMID(0x1028, 0x9198))
>> +					break;
>> +				case 0x8203:
>> +					rtlhal->oem_id = RT_CID_819X_PRONETS;
>> +					break;
>> +				case 0x8195:
>> +				case 0x9195:
>> +				case 0x7194:
>> +				case 0x8200 ... 0x8202:
>> +				case 0x9200:
>> +					rtlhal->oem_id = RT_CID_819X_LENOVO;
>> +					break;
>> +				}
>
> Is this supposed to be a fallthrough?
> If so, a comment would be good.
> Otherwise is this a missing break?

Good catch. There should be a break here.

>> +			case 0x1025:
>> +				rtlhal->oem_id = RT_CID_819X_ACER;
>> +				break;
>> +			case 0x1028:
>> +				switch (rtlefuse->eeprom_smid) {
>> +				case 0x8194:
>> +				case 0x8198:
>> +				case 0x9197 ... 0x9198:
>>   					rtlhal->oem_id = RT_CID_819X_DELL;
>> -				else if (CHK_SVID_SMID(0x103C, 0x1629))
>> +					break;
>> +				}
>> +				break;
>> +			case 0x103C:
>> +				switch (rtlefuse->eeprom_smid) {
>> +				case 0x1629:
>>   					rtlhal->oem_id = RT_CID_819X_HP;
>> -				else if (CHK_SVID_SMID(0x1A32, 0x2315))
>> +				}
>> +				break;
>> +			case 0x1A32:
>> +				switch (rtlefuse->eeprom_smid) {
>> +				case 0x2315:
>>   					rtlhal->oem_id = RT_CID_819X_QMI;
>> -				else if (CHK_SVID_SMID(0x10EC, 0x8203))
>> -					rtlhal->oem_id = RT_CID_819X_PRONETS;
>> -				else if (CHK_SVID_SMID(0x1043, 0x84B5))
>> +					break;
>> +				}
>> +				break;
>> +			case 0x1043:
>> +				switch (rtlefuse->eeprom_smid) {
>> +				case 0x84B5:
>>   					rtlhal->oem_id =
>> -						 RT_CID_819X_EDIMAX_ASUS;
>> -				else
>> -					rtlhal->oem_id = RT_CID_DEFAULT;
>> -			} else if (rtlefuse->eeprom_did == 0x8178) {
>> -				if (CHK_SVID_SMID(0x10EC, 0x6181) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6182) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6184) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x6185) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7181) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7182) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7184) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x7185) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8181) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8182) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8184) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x8185) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9181) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9182) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9184) ||
>> -				    CHK_SVID_SMID(0x10EC, 0x9185))
>> +						RT_CID_819X_EDIMAX_ASUS;
>
> Single line?

Nope - it reaches 81 characters. If that is better than splitting the line, then 
I will have to comment it to keep from getting several patches changing it back.

Larry


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-06-28  0:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-27 15:52 [PATCH 00/10 V2] rtlwifi: Various clean-ups for the hwinfo routines Larry Finger
2016-06-27 15:52 ` [PATCH v2 01/10] rtlwifi: Create common routine to get hardware info Larry Finger
2016-06-27 21:25   ` Arnd Bergmann
2016-06-27 15:52 ` [PATCH v2 02/10] rtlwifi: rtl8192ce: Convert driver to use common hardware info routine Larry Finger
2016-06-27 15:52 ` [PATCH v2 03/10] rtlwifi: rtl8192cu: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 04/10] rtlwifi: rtl8188ee: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 05/10] rtlwifi: rtl8192ee: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 06/10] rtlwifi: rtl8723ae: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 07/10] rtlwifi: rtl8723be: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 08/10] rtlwifi: rtl8821ae: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 09/10] rtlwifi: rtl8192de: " Larry Finger
2016-06-27 15:52 ` [PATCH v2 10/10] rtlwifi: rtl8723ae: Clean up the " Larry Finger
2016-06-27 21:23   ` Joe Perches
2016-06-28  0:56     ` Larry Finger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.