Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH 4/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word_index helper
From: Gabor Juhos @ 2013-06-26 17:55 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1372269318-30233-1-git-send-email-juhosg@openwrt.org>

Instead of assign the offset value to the
enum directly use a new helper function to
convert a rt2800_eeprom_word enum into an
index of the rt2x00_dev->eeprom array.

The patch does not change the existing
behaviour, but makes it possible to add
support for three-chain devices which are
using a different EEPROM layout.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800.h    |   76 +++++++++++++-------------
 drivers/net/wireless/rt2x00/rt2800lib.c |   88 +++++++++++++++++++++++++++++--
 2 files changed, 123 insertions(+), 41 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 0647039..bc5c695 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2207,43 +2207,45 @@ struct mac_iveiv_entry {
  */
 
 enum rt2800_eeprom_word {
-	EEPROM_CHIP_ID		= 0x0000,
-	EEPROM_VERSION		= 0x0001,
-	EEPROM_MAC_ADDR_0	= 0x0002,
-	EEPROM_MAC_ADDR_1	= 0x0003,
-	EEPROM_MAC_ADDR_2	= 0x0004,
-	EEPROM_NIC_CONF0	= 0x001a,
-	EEPROM_NIC_CONF1	= 0x001b,
-	EEPROM_FREQ		= 0x001d,
-	EEPROM_LED_AG_CONF	= 0x001e,
-	EEPROM_LED_ACT_CONF	= 0x001f,
-	EEPROM_LED_POLARITY	= 0x0020,
-	EEPROM_NIC_CONF2	= 0x0021,
-	EEPROM_LNA		= 0x0022,
-	EEPROM_RSSI_BG		= 0x0023,
-	EEPROM_RSSI_BG2		= 0x0024,
-	EEPROM_TXMIXER_GAIN_BG	= 0x0024, /* overlaps with RSSI_BG2 */
-	EEPROM_RSSI_A		= 0x0025,
-	EEPROM_RSSI_A2		= 0x0026,
-	EEPROM_TXMIXER_GAIN_A	= 0x0026, /* overlaps with RSSI_A2 */
-	EEPROM_EIRP_MAX_TX_POWER = 0x0027,
-	EEPROM_TXPOWER_DELTA	= 0x0028,
-	EEPROM_TXPOWER_BG1	= 0x0029,
-	EEPROM_TXPOWER_BG2	= 0x0030,
-	EEPROM_TSSI_BOUND_BG1	= 0x0037,
-	EEPROM_TSSI_BOUND_BG2	= 0x0038,
-	EEPROM_TSSI_BOUND_BG3	= 0x0039,
-	EEPROM_TSSI_BOUND_BG4	= 0x003a,
-	EEPROM_TSSI_BOUND_BG5	= 0x003b,
-	EEPROM_TXPOWER_A1	= 0x003c,
-	EEPROM_TXPOWER_A2	= 0x0053,
-	EEPROM_TSSI_BOUND_A1	= 0x006a,
-	EEPROM_TSSI_BOUND_A2	= 0x006b,
-	EEPROM_TSSI_BOUND_A3	= 0x006c,
-	EEPROM_TSSI_BOUND_A4	= 0x006d,
-	EEPROM_TSSI_BOUND_A5	= 0x006e,
-	EEPROM_TXPOWER_BYRATE	= 0x006f,
-	EEPROM_BBP_START	= 0x0078,
+	EEPROM_CHIP_ID = 0,
+	EEPROM_VERSION,
+	EEPROM_MAC_ADDR_0,
+	EEPROM_MAC_ADDR_1,
+	EEPROM_MAC_ADDR_2,
+	EEPROM_NIC_CONF0,
+	EEPROM_NIC_CONF1,
+	EEPROM_FREQ,
+	EEPROM_LED_AG_CONF,
+	EEPROM_LED_ACT_CONF,
+	EEPROM_LED_POLARITY,
+	EEPROM_NIC_CONF2,
+	EEPROM_LNA,
+	EEPROM_RSSI_BG,
+	EEPROM_RSSI_BG2,
+	EEPROM_TXMIXER_GAIN_BG,
+	EEPROM_RSSI_A,
+	EEPROM_RSSI_A2,
+	EEPROM_TXMIXER_GAIN_A,
+	EEPROM_EIRP_MAX_TX_POWER,
+	EEPROM_TXPOWER_DELTA,
+	EEPROM_TXPOWER_BG1,
+	EEPROM_TXPOWER_BG2,
+	EEPROM_TSSI_BOUND_BG1,
+	EEPROM_TSSI_BOUND_BG2,
+	EEPROM_TSSI_BOUND_BG3,
+	EEPROM_TSSI_BOUND_BG4,
+	EEPROM_TSSI_BOUND_BG5,
+	EEPROM_TXPOWER_A1,
+	EEPROM_TXPOWER_A2,
+	EEPROM_TSSI_BOUND_A1,
+	EEPROM_TSSI_BOUND_A2,
+	EEPROM_TSSI_BOUND_A3,
+	EEPROM_TSSI_BOUND_A4,
+	EEPROM_TSSI_BOUND_A5,
+	EEPROM_TXPOWER_BYRATE,
+	EEPROM_BBP_START,
+	/* New values must be added before this */
+	EEPROM_WORD_COUNT
 };
 
 /*
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index b59772a..9ff62b0 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -221,22 +221,99 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
 	mutex_unlock(&rt2x00dev->csr_mutex);
 }
 
+static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = {
+	[EEPROM_CHIP_ID]		= 0x0000,
+	[EEPROM_VERSION]		= 0x0001,
+	[EEPROM_MAC_ADDR_0]		= 0x0002,
+	[EEPROM_MAC_ADDR_1]		= 0x0003,
+	[EEPROM_MAC_ADDR_2]		= 0x0004,
+	[EEPROM_NIC_CONF0]		= 0x001a,
+	[EEPROM_NIC_CONF1]		= 0x001b,
+	[EEPROM_FREQ]			= 0x001d,
+	[EEPROM_LED_AG_CONF]		= 0x001e,
+	[EEPROM_LED_ACT_CONF]		= 0x001f,
+	[EEPROM_LED_POLARITY]		= 0x0020,
+	[EEPROM_NIC_CONF2]		= 0x0021,
+	[EEPROM_LNA]			= 0x0022,
+	[EEPROM_RSSI_BG]		= 0x0023,
+	[EEPROM_RSSI_BG2]		= 0x0024,
+	[EEPROM_TXMIXER_GAIN_BG]	= 0x0024, /* overlaps with RSSI_BG2 */
+	[EEPROM_RSSI_A]			= 0x0025,
+	[EEPROM_RSSI_A2]		= 0x0026,
+	[EEPROM_TXMIXER_GAIN_A]		= 0x0026, /* overlaps with RSSI_A2 */
+	[EEPROM_EIRP_MAX_TX_POWER]	= 0x0027,
+	[EEPROM_TXPOWER_DELTA]		= 0x0028,
+	[EEPROM_TXPOWER_BG1]		= 0x0029,
+	[EEPROM_TXPOWER_BG2]		= 0x0030,
+	[EEPROM_TSSI_BOUND_BG1]		= 0x0037,
+	[EEPROM_TSSI_BOUND_BG2]		= 0x0038,
+	[EEPROM_TSSI_BOUND_BG3]		= 0x0039,
+	[EEPROM_TSSI_BOUND_BG4]		= 0x003a,
+	[EEPROM_TSSI_BOUND_BG5]		= 0x003b,
+	[EEPROM_TXPOWER_A1]		= 0x003c,
+	[EEPROM_TXPOWER_A2]		= 0x0053,
+	[EEPROM_TSSI_BOUND_A1]		= 0x006a,
+	[EEPROM_TSSI_BOUND_A2]		= 0x006b,
+	[EEPROM_TSSI_BOUND_A3]		= 0x006c,
+	[EEPROM_TSSI_BOUND_A4]		= 0x006d,
+	[EEPROM_TSSI_BOUND_A5]		= 0x006e,
+	[EEPROM_TXPOWER_BYRATE]		= 0x006f,
+	[EEPROM_BBP_START]		= 0x0078,
+};
+
+static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
+					     const enum rt2800_eeprom_word word)
+{
+	const unsigned int *map;
+	unsigned int index;
+
+	if (WARN_ON(word >= EEPROM_WORD_COUNT)) {
+		rt2x00_warn(rt2x00dev, "invalid EEPROM word %d\n", word);
+		return 0;
+	}
+
+	map = rt2800_eeprom_map;
+	index = map[word];
+
+	if (WARN_ON(word != EEPROM_CHIP_ID && index == 0)) {
+		/* Index 0 is valid only for EEPROM_CHIP_ID.
+		 * Otherwise it means that the offset of the
+		 * given word is not initialized in the map,
+		 * or that the field is not usable on the
+		 * actual chipset.
+		 */
+		rt2x00_warn(rt2x00dev, "invalid access of EEPROM word %d\n",
+			    word);
+	}
+
+	return index;
+}
+
 static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev,
 				const enum rt2800_eeprom_word word)
 {
-	return rt2x00_eeprom_addr(rt2x00dev, word);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, word);
+	return rt2x00_eeprom_addr(rt2x00dev, index);
 }
 
 static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
 			       const enum rt2800_eeprom_word word, u16 *data)
 {
-	rt2x00_eeprom_read(rt2x00dev, word, data);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, word);
+	rt2x00_eeprom_read(rt2x00dev, index, data);
 }
 
 static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
 				const enum rt2800_eeprom_word word, u16 data)
 {
-	rt2x00_eeprom_write(rt2x00dev, word, data);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, word);
+	rt2x00_eeprom_write(rt2x00dev, index, data);
 }
 
 static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
@@ -244,7 +321,10 @@ static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
 					  unsigned int offset,
 					  u16 *data)
 {
-	rt2x00_eeprom_read(rt2x00dev, array + offset, data);
+	unsigned int index;
+
+	index = rt2800_eeprom_word_index(rt2x00dev, array);
+	rt2x00_eeprom_read(rt2x00dev, index + offset, data);
 }
 
 static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
-- 
1.7.10


^ permalink raw reply related

* [PATCH 5/5] rt2x00: rt2800lib: add EEPROM map for the RT3593 chipset
From: Gabor Juhos @ 2013-06-26 17:55 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1372269318-30233-1-git-send-email-juhosg@openwrt.org>

Three-chain devices are using a different
EEPROM layout than the rest of the chipsets.
Add a new map which describes the new layout
and use that for the RT3593 chipset.

The index values has been computed from the
EEPROM_EXT_* defines, which can be found in
the 'include/chip/rt3593.h' file in the
Ralink DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800.h    |    6 ++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   48 ++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index bc5c695..9216834 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2244,6 +2244,12 @@ enum rt2800_eeprom_word {
 	EEPROM_TSSI_BOUND_A5,
 	EEPROM_TXPOWER_BYRATE,
 	EEPROM_BBP_START,
+
+	/* IDs for extended EEPROM format used by three-chain devices */
+	EEPROM_EXT_LNA2,
+	EEPROM_EXT_TXPOWER_BG3,
+	EEPROM_EXT_TXPOWER_A3,
+
 	/* New values must be added before this */
 	EEPROM_WORD_COUNT
 };
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 9ff62b0..7b216f9 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -261,6 +261,48 @@ static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = {
 	[EEPROM_BBP_START]		= 0x0078,
 };
 
+static const unsigned int rt2800_eeprom_map_ext[EEPROM_WORD_COUNT] = {
+	[EEPROM_CHIP_ID]		= 0x0000,
+	[EEPROM_VERSION]		= 0x0001,
+	[EEPROM_MAC_ADDR_0]		= 0x0002,
+	[EEPROM_MAC_ADDR_1]		= 0x0003,
+	[EEPROM_MAC_ADDR_2]		= 0x0004,
+	[EEPROM_NIC_CONF0]		= 0x001a,
+	[EEPROM_NIC_CONF1]		= 0x001b,
+	[EEPROM_NIC_CONF2]		= 0x001c,
+	[EEPROM_EIRP_MAX_TX_POWER]	= 0x0020,
+	[EEPROM_FREQ]			= 0x0022,
+	[EEPROM_LED_AG_CONF]		= 0x0023,
+	[EEPROM_LED_ACT_CONF]		= 0x0024,
+	[EEPROM_LED_POLARITY]		= 0x0025,
+	[EEPROM_LNA]			= 0x0026,
+	[EEPROM_EXT_LNA2]		= 0x0027,
+	[EEPROM_RSSI_BG]		= 0x0028,
+	[EEPROM_TXPOWER_DELTA]		= 0x0028, /* Overlaps with RSSI_BG */
+	[EEPROM_RSSI_BG2]		= 0x0029,
+	[EEPROM_TXMIXER_GAIN_BG]	= 0x0029, /* Overlaps with RSSI_BG2 */
+	[EEPROM_RSSI_A]			= 0x002a,
+	[EEPROM_RSSI_A2]		= 0x002b,
+	[EEPROM_TXMIXER_GAIN_A]		= 0x002b, /* Overlaps with RSSI_A2 */
+	[EEPROM_TXPOWER_BG1]		= 0x0030,
+	[EEPROM_TXPOWER_BG2]		= 0x0037,
+	[EEPROM_EXT_TXPOWER_BG3]	= 0x003e,
+	[EEPROM_TSSI_BOUND_BG1]		= 0x0045,
+	[EEPROM_TSSI_BOUND_BG2]		= 0x0046,
+	[EEPROM_TSSI_BOUND_BG3]		= 0x0047,
+	[EEPROM_TSSI_BOUND_BG4]		= 0x0048,
+	[EEPROM_TSSI_BOUND_BG5]		= 0x0049,
+	[EEPROM_TXPOWER_A1]		= 0x004b,
+	[EEPROM_TXPOWER_A2]		= 0x0065,
+	[EEPROM_EXT_TXPOWER_A3]		= 0x007f,
+	[EEPROM_TSSI_BOUND_A1]		= 0x009a,
+	[EEPROM_TSSI_BOUND_A2]		= 0x009b,
+	[EEPROM_TSSI_BOUND_A3]		= 0x009c,
+	[EEPROM_TSSI_BOUND_A4]		= 0x009d,
+	[EEPROM_TSSI_BOUND_A5]		= 0x009e,
+	[EEPROM_TXPOWER_BYRATE]		= 0x00a0,
+};
+
 static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
 					     const enum rt2800_eeprom_word word)
 {
@@ -272,7 +314,11 @@ static unsigned int rt2800_eeprom_word_index(struct rt2x00_dev *rt2x00dev,
 		return 0;
 	}
 
-	map = rt2800_eeprom_map;
+	if (rt2x00_rt(rt2x00dev, RT3593))
+		map = rt2800_eeprom_map_ext;
+	else
+		map = rt2800_eeprom_map;
+
 	index = map[word];
 
 	if (WARN_ON(word != EEPROM_CHIP_ID && index == 0)) {
-- 
1.7.10


^ permalink raw reply related

* [PATCH 2/5] rt2x00: rt2800lib: introduce local EEPROM access functions
From: Gabor Juhos @ 2013-06-26 17:55 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1372269318-30233-1-git-send-email-juhosg@openwrt.org>

The patch adds rt2800 specific functions for
EEPROM data access and changes the code to use
these instead of the generic rt2x00_eeprom_*
variants.

To avoid functional changes, the new functions
are wrappers around the corresponding generic
rt2x00_eeprom_* routines for now. Functional
changes will be implemented in additional patches.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |  165 ++++++++++++++++++-------------
 1 file changed, 95 insertions(+), 70 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 1f80ea5..522f0b1 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -221,6 +221,24 @@ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
 	mutex_unlock(&rt2x00dev->csr_mutex);
 }
 
+static void *rt2800_eeprom_addr(struct rt2x00_dev *rt2x00dev,
+				const enum rt2800_eeprom_word word)
+{
+	return rt2x00_eeprom_addr(rt2x00dev, word);
+}
+
+static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
+			       const enum rt2800_eeprom_word word, u16 *data)
+{
+	rt2x00_eeprom_read(rt2x00dev, word, data);
+}
+
+static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
+				const enum rt2800_eeprom_word word, u16 data)
+{
+	rt2x00_eeprom_write(rt2x00dev, word, data);
+}
+
 static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -609,16 +627,16 @@ static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2)
 	u8 offset2;
 
 	if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &eeprom);
 		offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET0);
 		offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG_OFFSET1);
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
 		offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_OFFSET2);
 	} else {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &eeprom);
 		offset0 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET0);
 		offset1 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A_OFFSET1);
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
 		offset2 = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_OFFSET2);
 	}
 
@@ -890,6 +908,9 @@ const struct rt2x00debug rt2800_rt2x00debug = {
 		.word_count	= CSR_REG_SIZE / sizeof(u32),
 	},
 	.eeprom	= {
+		/* NOTE: The local EEPROM access functions can't
+		 * be used here, use the generic versions instead.
+		 */
 		.read		= rt2x00_eeprom_read,
 		.write		= rt2x00_eeprom_write,
 		.word_base	= EEPROM_BASE,
@@ -1547,7 +1568,7 @@ static void rt2800_config_3572bt_ant(struct rt2x00_dev *rt2x00dev)
 	led_r_mode = rt2x00_get_field32(reg, LED_CFG_LED_POLAR) ? 0 : 3;
 	if (led_g_mode != rt2x00_get_field32(reg, LED_CFG_G_LED_MODE) ||
 	    led_r_mode != rt2x00_get_field32(reg, LED_CFG_R_LED_MODE)) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
 		led_ctrl = rt2x00_get_field16(eeprom, EEPROM_FREQ_LED_MODE);
 		if (led_ctrl == 0 || led_ctrl > 0x40) {
 			rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE, led_g_mode);
@@ -1622,7 +1643,7 @@ void rt2800_config_ant(struct rt2x00_dev *rt2x00dev, struct antenna_setup *ant)
 		    rt2x00_rt(rt2x00dev, RT3090) ||
 		    rt2x00_rt(rt2x00dev, RT3352) ||
 		    rt2x00_rt(rt2x00dev, RT3390)) {
-			rt2x00_eeprom_read(rt2x00dev,
+			rt2800_eeprom_read(rt2x00dev,
 					   EEPROM_NIC_CONF1, &eeprom);
 			if (rt2x00_get_field16(eeprom,
 						EEPROM_NIC_CONF1_ANT_DIVERSITY))
@@ -1659,16 +1680,16 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,
 	short lna_gain;
 
 	if (libconf->rf.channel <= 14) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG);
 	} else if (libconf->rf.channel <= 64) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
 	} else if (libconf->rf.channel <= 128) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
 	} else {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
 		lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
 	}
 
@@ -2798,62 +2819,62 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev)
 	 * Example TSSI bounds  0xF0 0xD0 0xB5 0xA0 0x88 0x45 0x25 0x15 0x00
 	 */
 	if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
 		tssi_bounds[0] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG1_MINUS4);
 		tssi_bounds[1] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG1_MINUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
 		tssi_bounds[2] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG2_MINUS2);
 		tssi_bounds[3] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG2_MINUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
 		tssi_bounds[4] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG3_REF);
 		tssi_bounds[5] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG3_PLUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
 		tssi_bounds[6] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG4_PLUS2);
 		tssi_bounds[7] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG4_PLUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
 		tssi_bounds[8] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_BG5_PLUS4);
 
 		step = rt2x00_get_field16(eeprom,
 					  EEPROM_TSSI_BOUND_BG5_AGC_STEP);
 	} else {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
 		tssi_bounds[0] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A1_MINUS4);
 		tssi_bounds[1] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A1_MINUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
 		tssi_bounds[2] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A2_MINUS2);
 		tssi_bounds[3] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A2_MINUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
 		tssi_bounds[4] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A3_REF);
 		tssi_bounds[5] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A3_PLUS1);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
 		tssi_bounds[6] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A4_PLUS2);
 		tssi_bounds[7] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A4_PLUS3);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
 		tssi_bounds[8] = rt2x00_get_field16(eeprom,
 					EEPROM_TSSI_BOUND_A5_PLUS4);
 
@@ -2899,7 +2920,7 @@ static int rt2800_get_txpower_bw_comp(struct rt2x00_dev *rt2x00dev,
 	u8 comp_type;
 	int comp_value = 0;
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
 
 	/*
 	 * HT40 compensation not required.
@@ -2974,12 +2995,12 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
 		 * .11b data rate need add additional 4dbm
 		 * when calculating eirp txpower.
 		 */
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
 				   &eeprom);
 		criterion = rt2x00_get_field16(eeprom,
 					       EEPROM_TXPOWER_BYRATE_RATE0);
 
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER,
 				   &eeprom);
 
 		if (band == IEEE80211_BAND_2GHZ)
@@ -3080,7 +3101,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2800_register_read(rt2x00dev, offset, &reg);
 
 		/* read the next four txpower values */
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
 				   &eeprom);
 
 		is_rate_b = i ? 0 : 1;
@@ -3129,7 +3150,7 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
 
 		/* read the next four txpower values */
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
+		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
 				   &eeprom);
 
 		is_rate_b = 0;
@@ -3528,7 +3549,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
 		if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
 		    rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
 		    rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
-			rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+			rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1,
+					   &eeprom);
 			if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
 				rt2800_register_write(rt2x00dev, TX_SW_CFG2,
 						      0x0000002c);
@@ -3989,7 +4011,7 @@ static void rt2800_disable_unused_dac_adc(struct rt2x00_dev *rt2x00dev)
 	u8 value;
 
 	rt2800_bbp_read(rt2x00dev, 138, &value);
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
 		value |= 0x20;
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
@@ -4402,7 +4424,7 @@ static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev)
 
 	rt2800_disable_unused_dac_adc(rt2x00dev);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
 	div_mode = rt2x00_get_field16(eeprom,
 				      EEPROM_NIC_CONF1_ANT_DIVERSITY);
 	ant = (div_mode == 3) ? 1 : 0;
@@ -4488,7 +4510,7 @@ static void rt2800_init_bbp_5592(struct rt2x00_dev *rt2x00dev)
 
 	rt2800_bbp4_mac_if_ctrl(rt2x00dev);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
 	div_mode = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_ANT_DIVERSITY);
 	ant = (div_mode == 3) ? 1 : 0;
 	rt2800_bbp_read(rt2x00dev, 152, &value);
@@ -4557,7 +4579,7 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
 	}
 
 	for (i = 0; i < EEPROM_BBP_SIZE; i++) {
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
 
 		if (eeprom != 0xffff && eeprom != 0x0000) {
 			reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
@@ -4728,7 +4750,7 @@ static void rt2800_normal_mode_setup_3xxx(struct rt2x00_dev *rt2x00dev)
 	if (rt2x00_rt(rt2x00dev, RT3090)) {
 		/*  Turn off unused DAC1 and ADC1 to reduce power consumption */
 		rt2800_bbp_read(rt2x00dev, 138, &bbp);
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 		if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
 			rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0);
 		if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
@@ -4778,7 +4800,7 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
 
 	/*  Turn off unused DAC1 and ADC1 to reduce power consumption */
 	rt2800_bbp_read(rt2x00dev, 138, &reg);
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
 		rt2x00_set_field8(&reg, BBP138_RX_ADC1, 0);
 	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
@@ -4884,7 +4906,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
 		rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
 		if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
 		    rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) {
-			rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+			rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1,
+					   &eeprom);
 			if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
 				rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
 			else
@@ -5456,15 +5479,15 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Initialize LED control
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
 	rt2800_mcu_request(rt2x00dev, MCU_LED_AG_CONF, 0xff,
 			   word & 0xff, (word >> 8) & 0xff);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
 	rt2800_mcu_request(rt2x00dev, MCU_LED_ACT_CONF, 0xff,
 			   word & 0xff, (word >> 8) & 0xff);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
 	rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff,
 			   word & 0xff, (word >> 8) & 0xff);
 
@@ -5578,18 +5601,18 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Start validation of the data that has been read.
 	 */
-	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+	mac = rt2800_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
 	if (!is_valid_ether_addr(mac)) {
 		eth_random_addr(mac);
 		rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", mac);
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
 	if (word == 0xffff) {
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_TXPATH, 1);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
 		rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word);
 	} else if (rt2x00_rt(rt2x00dev, RT2860) ||
 		   rt2x00_rt(rt2x00dev, RT2872)) {
@@ -5598,10 +5621,10 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		 */
 		if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2)
 			rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
 	if (word == 0xffff) {
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0);
@@ -5618,24 +5641,24 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0);
 		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
 		rt2x00_eeprom_dbg(rt2x00dev, "NIC: 0x%04x\n", word);
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
 	if ((word & 0x00ff) == 0x00ff) {
 		rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
 		rt2x00_eeprom_dbg(rt2x00dev, "Freq: 0x%04x\n", word);
 	}
 	if ((word & 0xff00) == 0xff00) {
 		rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE,
 				   LED_MODE_TXRX_ACTIVITY);
 		rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
+		rt2800_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
 		rt2x00_eeprom_dbg(rt2x00dev, "Led Mode: 0x%04x\n", word);
 	}
 
@@ -5644,17 +5667,17 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	 * lna0 as correct value. Note that EEPROM_LNA
 	 * is never validated.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
 	default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
 	if ((word & 0x00ff) != 0x00ff) {
 		drv_data->txmixer_gain_24g =
 			rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL);
@@ -5662,16 +5685,16 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		drv_data->txmixer_gain_24g = 0;
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
 	if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
 	    rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
 		rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
 				   default_lna_gain);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
 	if ((word & 0x00ff) != 0x00ff) {
 		drv_data->txmixer_gain_5g =
 			rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL);
@@ -5679,21 +5702,21 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		drv_data->txmixer_gain_5g = 0;
 	}
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
 	if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
 	if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
 	    rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
 		rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
 				   default_lna_gain);
-	rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
+	rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
 
 	return 0;
 }
@@ -5707,7 +5730,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Read EEPROM word for configuration.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 
 	/*
 	 * Identify RF chipset by EEPROM value
@@ -5717,7 +5740,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	if (rt2x00_rt(rt2x00dev, RT3290) ||
 	    rt2x00_rt(rt2x00dev, RT5390) ||
 	    rt2x00_rt(rt2x00dev, RT5392))
-		rt2x00_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
+		rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
 	else
 		rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
 
@@ -5757,7 +5780,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->default_ant.rx_chain_num =
 	    rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH);
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
 
 	if (rt2x00_rt(rt2x00dev, RT3070) ||
 	    rt2x00_rt(rt2x00dev, RT3090) ||
@@ -5810,7 +5833,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Read frequency offset and RF programming sequence.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
 	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
 
 	/*
@@ -5827,7 +5850,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Check if support EIRP tx power limit feature.
 	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_EIRP_MAX_TX_POWER, &eeprom);
 
 	if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) <
 					EIRP_MAX_TX_POWER_LIMIT)
@@ -6148,7 +6171,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
-				rt2x00_eeprom_addr(rt2x00dev,
+				rt2800_eeprom_addr(rt2x00dev,
 						   EEPROM_MAC_ADDR_0));
 
 	/*
@@ -6164,7 +6187,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->hw->max_report_rates = 7;
 	rt2x00dev->hw->max_rate_tries = 1;
 
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
+	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
 
 	/*
 	 * Initialize hw_mode information.
@@ -6264,8 +6287,8 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 
 	spec->channels_info = info;
 
-	default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
-	default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
+	default_power1 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
+	default_power2 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
 
 	for (i = 0; i < 14; i++) {
 		info[i].default_power1 = default_power1[i];
@@ -6273,8 +6296,10 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 	}
 
 	if (spec->num_channels > 14) {
-		default_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
-		default_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
+		default_power1 = rt2800_eeprom_addr(rt2x00dev,
+						    EEPROM_TXPOWER_A1);
+		default_power2 = rt2800_eeprom_addr(rt2x00dev,
+						    EEPROM_TXPOWER_A2);
 
 		for (i = 14; i < spec->num_channels; i++) {
 			info[i].default_power1 = default_power1[i - 14];
-- 
1.7.10


^ permalink raw reply related

* [PATCH 1/5] rt2x00: rt2800lib: introduce rt2800_eeprom_word enum
From: Gabor Juhos @ 2013-06-26 17:55 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1372269318-30233-1-git-send-email-juhosg@openwrt.org>

The patch converts the EEPROM_* word address defines
into new enum values. The new enum type will be used
by new functions which will be introduced in subsequent
changes.

The patch contains no functional changes.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800.h |   79 +++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 40 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index d78c495..0647039 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2206,28 +2206,59 @@ struct mac_iveiv_entry {
  * The wordsize of the EEPROM is 16 bits.
  */
 
-/*
- * Chip ID
- */
-#define EEPROM_CHIP_ID			0x0000
+enum rt2800_eeprom_word {
+	EEPROM_CHIP_ID		= 0x0000,
+	EEPROM_VERSION		= 0x0001,
+	EEPROM_MAC_ADDR_0	= 0x0002,
+	EEPROM_MAC_ADDR_1	= 0x0003,
+	EEPROM_MAC_ADDR_2	= 0x0004,
+	EEPROM_NIC_CONF0	= 0x001a,
+	EEPROM_NIC_CONF1	= 0x001b,
+	EEPROM_FREQ		= 0x001d,
+	EEPROM_LED_AG_CONF	= 0x001e,
+	EEPROM_LED_ACT_CONF	= 0x001f,
+	EEPROM_LED_POLARITY	= 0x0020,
+	EEPROM_NIC_CONF2	= 0x0021,
+	EEPROM_LNA		= 0x0022,
+	EEPROM_RSSI_BG		= 0x0023,
+	EEPROM_RSSI_BG2		= 0x0024,
+	EEPROM_TXMIXER_GAIN_BG	= 0x0024, /* overlaps with RSSI_BG2 */
+	EEPROM_RSSI_A		= 0x0025,
+	EEPROM_RSSI_A2		= 0x0026,
+	EEPROM_TXMIXER_GAIN_A	= 0x0026, /* overlaps with RSSI_A2 */
+	EEPROM_EIRP_MAX_TX_POWER = 0x0027,
+	EEPROM_TXPOWER_DELTA	= 0x0028,
+	EEPROM_TXPOWER_BG1	= 0x0029,
+	EEPROM_TXPOWER_BG2	= 0x0030,
+	EEPROM_TSSI_BOUND_BG1	= 0x0037,
+	EEPROM_TSSI_BOUND_BG2	= 0x0038,
+	EEPROM_TSSI_BOUND_BG3	= 0x0039,
+	EEPROM_TSSI_BOUND_BG4	= 0x003a,
+	EEPROM_TSSI_BOUND_BG5	= 0x003b,
+	EEPROM_TXPOWER_A1	= 0x003c,
+	EEPROM_TXPOWER_A2	= 0x0053,
+	EEPROM_TSSI_BOUND_A1	= 0x006a,
+	EEPROM_TSSI_BOUND_A2	= 0x006b,
+	EEPROM_TSSI_BOUND_A3	= 0x006c,
+	EEPROM_TSSI_BOUND_A4	= 0x006d,
+	EEPROM_TSSI_BOUND_A5	= 0x006e,
+	EEPROM_TXPOWER_BYRATE	= 0x006f,
+	EEPROM_BBP_START	= 0x0078,
+};
 
 /*
  * EEPROM Version
  */
-#define EEPROM_VERSION			0x0001
 #define EEPROM_VERSION_FAE		FIELD16(0x00ff)
 #define EEPROM_VERSION_VERSION		FIELD16(0xff00)
 
 /*
  * HW MAC address.
  */
-#define EEPROM_MAC_ADDR_0		0x0002
 #define EEPROM_MAC_ADDR_BYTE0		FIELD16(0x00ff)
 #define EEPROM_MAC_ADDR_BYTE1		FIELD16(0xff00)
-#define EEPROM_MAC_ADDR_1		0x0003
 #define EEPROM_MAC_ADDR_BYTE2		FIELD16(0x00ff)
 #define EEPROM_MAC_ADDR_BYTE3		FIELD16(0xff00)
-#define EEPROM_MAC_ADDR_2		0x0004
 #define EEPROM_MAC_ADDR_BYTE4		FIELD16(0x00ff)
 #define EEPROM_MAC_ADDR_BYTE5		FIELD16(0xff00)
 
@@ -2237,7 +2268,6 @@ struct mac_iveiv_entry {
  * TXPATH: 1: 1T, 2: 2T, 3: 3T
  * RF_TYPE: RFIC type
  */
-#define	EEPROM_NIC_CONF0		0x001a
 #define EEPROM_NIC_CONF0_RXPATH		FIELD16(0x000f)
 #define EEPROM_NIC_CONF0_TXPATH		FIELD16(0x00f0)
 #define EEPROM_NIC_CONF0_RF_TYPE		FIELD16(0x0f00)
@@ -2261,7 +2291,6 @@ struct mac_iveiv_entry {
  * BT_COEXIST: 0: disable, 1: enable
  * DAC_TEST: 0: disable, 1: enable
  */
-#define	EEPROM_NIC_CONF1		0x001b
 #define EEPROM_NIC_CONF1_HW_RADIO		FIELD16(0x0001)
 #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC		FIELD16(0x0002)
 #define EEPROM_NIC_CONF1_EXTERNAL_LNA_2G		FIELD16(0x0004)
@@ -2281,7 +2310,6 @@ struct mac_iveiv_entry {
 /*
  * EEPROM frequency
  */
-#define	EEPROM_FREQ			0x001d
 #define EEPROM_FREQ_OFFSET		FIELD16(0x00ff)
 #define EEPROM_FREQ_LED_MODE		FIELD16(0x7f00)
 #define EEPROM_FREQ_LED_POLARITY	FIELD16(0x1000)
@@ -2298,9 +2326,6 @@ struct mac_iveiv_entry {
  * POLARITY_GPIO_4: Polarity GPIO4 setting.
  * LED_MODE: Led mode.
  */
-#define EEPROM_LED_AG_CONF		0x001e
-#define EEPROM_LED_ACT_CONF		0x001f
-#define EEPROM_LED_POLARITY		0x0020
 #define EEPROM_LED_POLARITY_RDY_BG	FIELD16(0x0001)
 #define EEPROM_LED_POLARITY_RDY_A	FIELD16(0x0002)
 #define EEPROM_LED_POLARITY_ACT		FIELD16(0x0004)
@@ -2317,7 +2342,6 @@ struct mac_iveiv_entry {
  * TX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream
  * CRYSTAL: 00: Reserved, 01: One crystal, 10: Two crystal, 11: Reserved
  */
-#define EEPROM_NIC_CONF2		0x0021
 #define EEPROM_NIC_CONF2_RX_STREAM		FIELD16(0x000f)
 #define EEPROM_NIC_CONF2_TX_STREAM		FIELD16(0x00f0)
 #define EEPROM_NIC_CONF2_CRYSTAL		FIELD16(0x0600)
@@ -2325,54 +2349,46 @@ struct mac_iveiv_entry {
 /*
  * EEPROM LNA
  */
-#define EEPROM_LNA			0x0022
 #define EEPROM_LNA_BG			FIELD16(0x00ff)
 #define EEPROM_LNA_A0			FIELD16(0xff00)
 
 /*
  * EEPROM RSSI BG offset
  */
-#define EEPROM_RSSI_BG			0x0023
 #define EEPROM_RSSI_BG_OFFSET0		FIELD16(0x00ff)
 #define EEPROM_RSSI_BG_OFFSET1		FIELD16(0xff00)
 
 /*
  * EEPROM RSSI BG2 offset
  */
-#define EEPROM_RSSI_BG2			0x0024
 #define EEPROM_RSSI_BG2_OFFSET2		FIELD16(0x00ff)
 #define EEPROM_RSSI_BG2_LNA_A1		FIELD16(0xff00)
 
 /*
  * EEPROM TXMIXER GAIN BG offset (note overlaps with EEPROM RSSI BG2).
  */
-#define EEPROM_TXMIXER_GAIN_BG		0x0024
 #define EEPROM_TXMIXER_GAIN_BG_VAL	FIELD16(0x0007)
 
 /*
  * EEPROM RSSI A offset
  */
-#define EEPROM_RSSI_A			0x0025
 #define EEPROM_RSSI_A_OFFSET0		FIELD16(0x00ff)
 #define EEPROM_RSSI_A_OFFSET1		FIELD16(0xff00)
 
 /*
  * EEPROM RSSI A2 offset
  */
-#define EEPROM_RSSI_A2			0x0026
 #define EEPROM_RSSI_A2_OFFSET2		FIELD16(0x00ff)
 #define EEPROM_RSSI_A2_LNA_A2		FIELD16(0xff00)
 
 /*
  * EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2).
  */
-#define EEPROM_TXMIXER_GAIN_A		0x0026
 #define EEPROM_TXMIXER_GAIN_A_VAL	FIELD16(0x0007)
 
 /*
  * EEPROM EIRP Maximum TX power values(unit: dbm)
  */
-#define EEPROM_EIRP_MAX_TX_POWER	0x0027
 #define EEPROM_EIRP_MAX_TX_POWER_2GHZ	FIELD16(0x00ff)
 #define EEPROM_EIRP_MAX_TX_POWER_5GHZ	FIELD16(0xff00)
 
@@ -2383,7 +2399,6 @@ struct mac_iveiv_entry {
  * TYPE: 1: Plus the delta value, 0: minus the delta value
  * ENABLE: enable tx power compensation for 40BW
  */
-#define EEPROM_TXPOWER_DELTA		0x0028
 #define EEPROM_TXPOWER_DELTA_VALUE_2G	FIELD16(0x003f)
 #define EEPROM_TXPOWER_DELTA_TYPE_2G	FIELD16(0x0040)
 #define EEPROM_TXPOWER_DELTA_ENABLE_2G	FIELD16(0x0080)
@@ -2394,8 +2409,6 @@ struct mac_iveiv_entry {
 /*
  * EEPROM TXPOWER 802.11BG
  */
-#define	EEPROM_TXPOWER_BG1		0x0029
-#define	EEPROM_TXPOWER_BG2		0x0030
 #define EEPROM_TXPOWER_BG_SIZE		7
 #define EEPROM_TXPOWER_BG_1		FIELD16(0x00ff)
 #define EEPROM_TXPOWER_BG_2		FIELD16(0xff00)
@@ -2407,7 +2420,6 @@ struct mac_iveiv_entry {
  * MINUS3: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -3)
  */
-#define EEPROM_TSSI_BOUND_BG1		0x0037
 #define EEPROM_TSSI_BOUND_BG1_MINUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG1_MINUS3	FIELD16(0xff00)
 
@@ -2418,7 +2430,6 @@ struct mac_iveiv_entry {
  * MINUS1: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -1)
  */
-#define EEPROM_TSSI_BOUND_BG2		0x0038
 #define EEPROM_TSSI_BOUND_BG2_MINUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG2_MINUS1	FIELD16(0xff00)
 
@@ -2428,7 +2439,6 @@ struct mac_iveiv_entry {
  * PLUS1: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 1)
  */
-#define EEPROM_TSSI_BOUND_BG3		0x0039
 #define EEPROM_TSSI_BOUND_BG3_REF	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG3_PLUS1	FIELD16(0xff00)
 
@@ -2439,7 +2449,6 @@ struct mac_iveiv_entry {
  * PLUS3: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 3)
  */
-#define EEPROM_TSSI_BOUND_BG4		0x003a
 #define EEPROM_TSSI_BOUND_BG4_PLUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG4_PLUS3	FIELD16(0xff00)
 
@@ -2449,15 +2458,12 @@ struct mac_iveiv_entry {
  *        increased by (agc_step * 4)
  * AGC_STEP: Temperature compensation step.
  */
-#define EEPROM_TSSI_BOUND_BG5		0x003b
 #define EEPROM_TSSI_BOUND_BG5_PLUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_BG5_AGC_STEP	FIELD16(0xff00)
 
 /*
  * EEPROM TXPOWER 802.11A
  */
-#define EEPROM_TXPOWER_A1		0x003c
-#define EEPROM_TXPOWER_A2		0x0053
 #define EEPROM_TXPOWER_A_SIZE		6
 #define EEPROM_TXPOWER_A_1		FIELD16(0x00ff)
 #define EEPROM_TXPOWER_A_2		FIELD16(0xff00)
@@ -2469,7 +2475,6 @@ struct mac_iveiv_entry {
  * MINUS3: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -3)
  */
-#define EEPROM_TSSI_BOUND_A1		0x006a
 #define EEPROM_TSSI_BOUND_A1_MINUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A1_MINUS3	FIELD16(0xff00)
 
@@ -2480,7 +2485,6 @@ struct mac_iveiv_entry {
  * MINUS1: If the actual TSSI is below this boundary, tx power needs to be
  *         reduced by (agc_step * -1)
  */
-#define EEPROM_TSSI_BOUND_A2		0x006b
 #define EEPROM_TSSI_BOUND_A2_MINUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A2_MINUS1	FIELD16(0xff00)
 
@@ -2490,7 +2494,6 @@ struct mac_iveiv_entry {
  * PLUS1: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 1)
  */
-#define EEPROM_TSSI_BOUND_A3		0x006c
 #define EEPROM_TSSI_BOUND_A3_REF	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A3_PLUS1	FIELD16(0xff00)
 
@@ -2501,7 +2504,6 @@ struct mac_iveiv_entry {
  * PLUS3: If the actual TSSI is above this boundary, tx power needs to be
  *        increased by (agc_step * 3)
  */
-#define EEPROM_TSSI_BOUND_A4		0x006d
 #define EEPROM_TSSI_BOUND_A4_PLUS2	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A4_PLUS3	FIELD16(0xff00)
 
@@ -2511,14 +2513,12 @@ struct mac_iveiv_entry {
  *        increased by (agc_step * 4)
  * AGC_STEP: Temperature compensation step.
  */
-#define EEPROM_TSSI_BOUND_A5		0x006e
 #define EEPROM_TSSI_BOUND_A5_PLUS4	FIELD16(0x00ff)
 #define EEPROM_TSSI_BOUND_A5_AGC_STEP	FIELD16(0xff00)
 
 /*
  * EEPROM TXPOWER by rate: tx power per tx rate for HT20 mode
  */
-#define EEPROM_TXPOWER_BYRATE		0x006f
 #define EEPROM_TXPOWER_BYRATE_SIZE	9
 
 #define EEPROM_TXPOWER_BYRATE_RATE0	FIELD16(0x000f)
@@ -2529,7 +2529,6 @@ struct mac_iveiv_entry {
 /*
  * EEPROM BBP.
  */
-#define	EEPROM_BBP_START		0x0078
 #define EEPROM_BBP_SIZE			16
 #define EEPROM_BBP_VALUE		FIELD16(0x00ff)
 #define EEPROM_BBP_REG_ID		FIELD16(0xff00)
-- 
1.7.10


^ permalink raw reply related

* [PATCH 3/5] rt2x00: rt2800lib: introduce rt2800_eeprom_read_from_array helper
From: Gabor Juhos @ 2013-06-26 17:55 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos
In-Reply-To: <1372269318-30233-1-git-send-email-juhosg@openwrt.org>

Add a new helper function and use that for reading
single elements of various arrays in the EEPROM.

The patch does not change the current behaviour,
but it allows to use sequential values for the
rt2800_eeprom_word enums. The conversion will be
implemented in a subsequent change.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 522f0b1..b59772a 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -239,6 +239,14 @@ static void rt2800_eeprom_write(struct rt2x00_dev *rt2x00dev,
 	rt2x00_eeprom_write(rt2x00dev, word, data);
 }
 
+static void rt2800_eeprom_read_from_array(struct rt2x00_dev *rt2x00dev,
+					  const enum rt2800_eeprom_word array,
+					  unsigned int offset,
+					  u16 *data)
+{
+	rt2x00_eeprom_read(rt2x00dev, array + offset, data);
+}
+
 static int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -2995,8 +3003,8 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
 		 * .11b data rate need add additional 4dbm
 		 * when calculating eirp txpower.
 		 */
-		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + 1,
-				   &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
+					      1, &eeprom);
 		criterion = rt2x00_get_field16(eeprom,
 					       EEPROM_TXPOWER_BYRATE_RATE0);
 
@@ -3101,8 +3109,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2800_register_read(rt2x00dev, offset, &reg);
 
 		/* read the next four txpower values */
-		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
-				   &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
+					      i, &eeprom);
 
 		is_rate_b = i ? 0 : 1;
 		/*
@@ -3150,8 +3158,8 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 		rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower);
 
 		/* read the next four txpower values */
-		rt2800_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
-				   &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_TXPOWER_BYRATE,
+					      i + 1, &eeprom);
 
 		is_rate_b = 0;
 		/*
@@ -4579,7 +4587,8 @@ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
 	}
 
 	for (i = 0; i < EEPROM_BBP_SIZE; i++) {
-		rt2800_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
+		rt2800_eeprom_read_from_array(rt2x00dev, EEPROM_BBP_START, i,
+					      &eeprom);
 
 		if (eeprom != 0xffff && eeprom != 0x0000) {
 			reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
-- 
1.7.10


^ permalink raw reply related

* [PATCH 0/5] rt2x00: rt2800lib: add support for extended EEPROM of three-cain devices
From: Gabor Juhos @ 2013-06-26 17:55 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos

Gabor Juhos (5):
  rt2x00: rt2800lib: introduce rt2800_eeprom_word enum
  rt2x00: rt2800lib: introduce local EEPROM access functions
  rt2x00: rt2800lib: introduce rt2800_eeprom_read_from_array helper
  rt2x00: rt2800lib: introduce rt2800_eeprom_word_index helper
  rt2x00: rt2800lib: add EEPROM map for the RT3593 chipset

 drivers/net/wireless/rt2x00/rt2800.h    |   87 +++++----
 drivers/net/wireless/rt2x00/rt2800lib.c |  306 +++++++++++++++++++++++--------
 2 files changed, 280 insertions(+), 113 deletions(-)

--
1.7.10


^ permalink raw reply

* Re: Fwd: Re: TP-Link 8200ND - rtl8192cu module not loading / working
From: shiki.biomernok @ 2013-06-26 17:29 UTC (permalink / raw)
  To: Larry Finger, linux-wireless
In-Reply-To: <51CB1356.80306@lwfinger.net>

Hello Larry/Mailing list!

I have compiled and installed the new wireless-testing kernel from git.
I'm sure I used the new kernel, as the device lighted up as soon as I 
plugged in. (And I got some new atheros ac module at "make oldconfig".)
There was no need for manual echo or modprobe.

Yet, the device is not working. It dies at the very same step.
Here is the dmesg: http://pastebin.com/C1MNdFiw

Please, let me know if I can help with anything.
Any debug option, patch or things like that.

My offer is still there Larry, I'm willing to give you a full SSH access 
to the machine with this stuff plugged in.
Besides that, I have no other idea.


! My router runs OpenWRT (latest stable), so I could also gather info 
from there. If it's possible.
(I checked dmesg but there is nothing. Only some non-crucial info about 
the generic eth ports and such.)

Thank you for the help.

(By the way if the chip is rare (no other people will benefit), then I 
can just get it back and ask for a refund. But if others use it as well, 
then it's not a waste of time... I guess.)

On 2013-06-26 18:14, Larry Finger wrote:
> On 06/26/2013 06:30 AM, shiki.biomernok wrote:
>> Hello everyone!
>>
>> CC'ing my original message that I sent to Larry.
>> It's been a while, but I've been busy and I couldn't fiddle with the 
>> wireless
>> device.
>>
>> Basically it's a 8192cu device. Larry suspected it's not, but I think 
>> he saw the
>> advertisement displayed on top of the TP-Link page.
>> I even mailed TP-Link, and here is the reply:
>>
>>     The chipset is Realtek RTL8192CU and you can download the driver
>>     from
>>
>> http://www.realtek.com/downloads/downloadsView.aspx?Langid=1&PNid=21&PFid=48&Level=5&Conn=4&DownTypeID=3&GetDown=false&Downloads=true. 
>>
>>
>>     Thank you.
>>
>> Tested with many kernels, but none of them worked.
>> Ubuntu 13.04 (both stock + updated), Fedora (Schrodinger-1), Fedora Beta
>> (Schrodinger), openSUSE (normal+tumbleweed).
>> I even tried the latest kernels since 3.10-rc4. (latest I tried is -rc7)
>>
>> Basically this device *should* work with the 8192cu driver, but it 
>> just won't.
>> If you just plug it in, nothing happens.
>> You have to first:
>> $ modprobe 8192cu
>> $ echo 2357 0100 > /sys/bus/usb/drivers/rtl8192cu/new_id
>>
>> Then it lights up, it shows up in NM-Applet. But it won't work.
>> I tried enabling the realtek debug option at the kernel driver, but 
>> it didn't help.
>> Even with that, I only see the authentication failed messages.
>>
>> Dmesg shows the errors: http://pastebin.com/QCfXYCZ1
>>
>>
>> Hope you guys can come up with some tips/ideas.
>> Ps.: I hope you don't mind the CC Larry.
>
> No, that is what I told you to do.
>
> A patch has been submitted to add that device to the USB_DEVICE table. 
> It is included in the wireless-testing git tree, but it is not in the 
> mainline code (yet). After that patch was applied, the device worked 
> for that reported.
>
> I noticed that you are getting an oops from iwlwifi, and an ehci-hcd 
> error. Are you also exploring these problems?
>
> If possible, could you use the wireless-testing repo? That will get 
> you the latest code for all wireless drivers, and the USB code will 
> match mainline.
>
> Larry
>
>


^ permalink raw reply

* [RFC] mac80211: Use libnl-configurable values for retry counts
From: Jean-Pierre Tosoni @ 2013-06-26 17:28 UTC (permalink / raw)
  To: linux-wireless; +Cc: J.P. Tosoni

From: J.P. Tosoni <jp.tosoni@acksys.fr>

In the rate control algorithms, the maximum retry count is limited by
a) a constant value obtained from the hardware driver
b) a constant limit (6ms) on the time allowed for all
   retries of each frame.

Replace the retry count by existing configurable values from nl80211.
Use wiphy->retry_short for management frames.
Use wiphy->retry_long for other frames.
Check that the configured value does not exceed driver capabilities.

Caveat: in minstrel rate control, the retry count is reused for each
rate of the rate table, potentially resulting in 4*max_retry retries.
---
Please comment on the patch and the caveat above, then I'll proceed
to update iw and to change the hard limit of 30 retries in ath9k.

 net/mac80211/cfg.c              |    4 ++++
 net/mac80211/rate.c             |    2 +-
 net/mac80211/rc80211_minstrel.c |    6 +-----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 082f270..4d3eb56 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2203,11 +2203,15 @@ static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
 	if (changed & WIPHY_PARAM_RETRY_SHORT) {
 		if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
 			return -EINVAL;
+		if (wiphy->retry_short > local->hw.max_rate_tries)
+			return -EINVAL;
 		local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
 	}
 	if (changed & WIPHY_PARAM_RETRY_LONG) {
 		if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
 			return -EINVAL;
+		if (wiphy->retry_long > local->hw.max_rate_tries)
+			return -EINVAL;
 		local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
 	}
 	if (changed &
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index a02bef3..9be3006 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -266,7 +266,7 @@ static void __rate_control_send_low(struct ieee80211_hw *hw,
 
 	info->control.rates[0].count =
 		(info->flags & IEEE80211_TX_CTL_NO_ACK) ?
-		1 : hw->max_rate_tries;
+		1 : hw->conf.short_frame_max_tx_count;
 
 	info->control.skip_table = 1;
 }
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index ac7ef54..502d0c9 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -592,11 +592,7 @@ minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
 	/* maximum time that the hw is allowed to stay in one MRR segment */
 	mp->segment_size = 6000;
 
-	if (hw->max_rate_tries > 0)
-		mp->max_retry = hw->max_rate_tries;
-	else
-		/* safe default, does not necessarily have to match hw properties */
-		mp->max_retry = 7;
+	mp->max_retry = hw->conf.long_frame_max_tx_count;
 
 	if (hw->max_rates >= 4)
 		mp->has_mrr = true;
-- 
1.7.2.5


^ permalink raw reply related

* Re: [v3.10-rc2] iwlwifi regression
From: Sedat Dilek @ 2013-06-26 16:37 UTC (permalink / raw)
  To: Jörg Otte
  Cc: linux-wireless, Linux Kernel Mailing List, Johannes Berg,
	Linus Torvalds
In-Reply-To: <CADDKRnCP_s2hL2wr8TsKeToNRt5nXF3NBYAqkmCCUPX8HbY_yQ@mail.gmail.com>

On Wed, Jun 26, 2013 at 6:16 PM, Jörg Otte <jrg.otte@gmail.com> wrote:
> 2013/5/25 Jörg Otte <jrg.otte@gmail.com>:
>> If iwlwifi/iwldvm are built into the kernel (no loadable modules)
>> following error is written to console and syslog since v3.10-rc:
>>
>> iwlwifi 0000:08:00.0: failed to load module iwldvm (error -38), is
>> dynamic loading enabled?
>>
>> reverting
>> commit 1618b2b02a3a0ee7a6863fed4b0d22e697e7e97c
>> Author: Johannes Berg <johannes.berg@intel.com>
>> Date:   Thu Apr 4 10:35:23 2013 +0200
>>     iwlwifi: print warning on request_module failure
>>
>> fixes the problem for me.
>>
>> Jörg
>>
>> I'm not subscribed,please CC me in answeres
>
> We have rc-7 now and it's still not fixed. What is the problem?
>

The patch is pending in wireless.git and is not in mainline, right.
AFAICS there was a recent pull request... so should be in rc8.

commit 8edf3fd6eb0649b0f19363baf23bca39c6fbdba4
"iwlwifi: don't print module loading error if not modular"

- Sedat -

http://git.kernel.org/cgit/linux/kernel/git/linville/wireless.git/commit/?id=8edf3fd6eb0649b0f19363baf23bca39c6fbdba4

> Thanks, Jörg
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [v3.10-rc2] iwlwifi regression
From: Jörg Otte @ 2013-06-26 16:16 UTC (permalink / raw)
  To: linux-wireless; +Cc: Linux Kernel Mailing List, Johannes Berg, Linus Torvalds
In-Reply-To: <CADDKRnBf4i8ZQ4EXC15Sa6z9CZ55w0vBDnXG26sjWgdO9zH45w@mail.gmail.com>

2013/5/25 Jörg Otte <jrg.otte@gmail.com>:
> If iwlwifi/iwldvm are built into the kernel (no loadable modules)
> following error is written to console and syslog since v3.10-rc:
>
> iwlwifi 0000:08:00.0: failed to load module iwldvm (error -38), is
> dynamic loading enabled?
>
> reverting
> commit 1618b2b02a3a0ee7a6863fed4b0d22e697e7e97c
> Author: Johannes Berg <johannes.berg@intel.com>
> Date:   Thu Apr 4 10:35:23 2013 +0200
>     iwlwifi: print warning on request_module failure
>
> fixes the problem for me.
>
> Jörg
>
> I'm not subscribed,please CC me in answeres

We have rc-7 now and it's still not fixed. What is the problem?

Thanks, Jörg

^ permalink raw reply

* Re: Fwd: Re: TP-Link 8200ND - rtl8192cu module not loading / working
From: Larry Finger @ 2013-06-26 16:14 UTC (permalink / raw)
  To: shiki.biomernok; +Cc: linux-wireless
In-Reply-To: <51CAD0B8.3010303@gmail.com>

On 06/26/2013 06:30 AM, shiki.biomernok wrote:
> Hello everyone!
>
> CC'ing my original message that I sent to Larry.
> It's been a while, but I've been busy and I couldn't fiddle with the wireless
> device.
>
> Basically it's a 8192cu device. Larry suspected it's not, but I think he saw the
> advertisement displayed on top of the TP-Link page.
> I even mailed TP-Link, and here is the reply:
>
>     The chipset is Realtek RTL8192CU and you can download the driver
>     from
>
> http://www.realtek.com/downloads/downloadsView.aspx?Langid=1&PNid=21&PFid=48&Level=5&Conn=4&DownTypeID=3&GetDown=false&Downloads=true.
>
>     Thank you.
>
> Tested with many kernels, but none of them worked.
> Ubuntu 13.04 (both stock + updated), Fedora (Schrodinger-1), Fedora Beta
> (Schrodinger), openSUSE (normal+tumbleweed).
> I even tried the latest kernels since 3.10-rc4. (latest I tried is -rc7)
>
> Basically this device *should* work with the 8192cu driver, but it just won't.
> If you just plug it in, nothing happens.
> You have to first:
> $ modprobe 8192cu
> $ echo 2357 0100 > /sys/bus/usb/drivers/rtl8192cu/new_id
>
> Then it lights up, it shows up in NM-Applet. But it won't work.
> I tried enabling the realtek debug option at the kernel driver, but it didn't help.
> Even with that, I only see the authentication failed messages.
>
> Dmesg shows the errors: http://pastebin.com/QCfXYCZ1
>
>
> Hope you guys can come up with some tips/ideas.
> Ps.: I hope you don't mind the CC Larry.

No, that is what I told you to do.

A patch has been submitted to add that device to the USB_DEVICE table. It is 
included in the wireless-testing git tree, but it is not in the mainline code 
(yet). After that patch was applied, the device worked for that reported.

I noticed that you are getting an oops from iwlwifi, and an ehci-hcd error. Are 
you also exploring these problems?

If possible, could you use the wireless-testing repo? That will get you the 
latest code for all wireless drivers, and the USB code will match mainline.

Larry



^ permalink raw reply

* Re: rtl8192cu: slow path warning
From: Larry Finger @ 2013-06-26 15:54 UTC (permalink / raw)
  To: Richard GENOUD
  Cc: Chaoming Li, John W. Linville, linux-wireless, linux-kernel
In-Reply-To: <20130626142241.GA13107@lnx-rg>

[-- Attachment #1: Type: text/plain, Size: 3743 bytes --]

On 06/26/2013 09:22 AM, Richard GENOUD wrote:
> Using 3.10-rc7, I'm still seeing the warning, BUT ONLY on the first
> connection.
>
> [   40.312500] usb 2-2: default language 0x0409
> [   40.312500] usb 2-2: udev 2, busnum 2, minor = 129
> [   40.320312] usb 2-2: New USB device found, idVendor=0bda, idProduct=8176
> [   40.328125] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [   40.328125] usb 2-2: Product: 802.11n WLAN Adapter
> [   40.335937] usb 2-2: Manufacturer: Realtek
> [   40.343750] usb 2-2: SerialNumber: 00e04c000001
> [   40.343750] usb 2-2: usb_probe_device
> [   40.351562] usb 2-2: configuration #1 chosen from 1 choice
> [   40.351562] usb 2-2: adding 2-2:1.0 (config #1, interface 0)
> [   40.500000] cfg80211: Calling CRDA to update world regulatory domain
> [   40.648437] rtl8192cu 2-2:1.0: usb_probe_interface
> [   40.656250] rtl8192cu 2-2:1.0: usb_probe_interface - got id
> [   40.664062] rtl8192cu: Chip version 0x10
> [   40.757812] rtl8192cu: MAC address: a0:f3:c1:1e:02:a0
> [   40.765625] rtl8192cu: Board Type 0
> [   40.773437] rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1
> [   40.773437] rtl8192cu: Loading firmware rtlwifi/rtl8192cufw.bin
> [   40.781250] usbcore: registered new interface driver rtl8192cu
> [   40.835937] ieee80211 phy0: Selected rate control algorithm 'rtl_rc'
> [   40.843750] rtlwifi: wireless switch is on
> # ip link set wlan0 up
> [   59.921875] rtl8192cu: MAC auto ON okay!
> [   59.960937] rtl8192cu: Tx queue select: 0x05
> # iw wlan0 connect test
> [   75.390625] wlan0: authenticate with f8:1a:67:1a:df:88
> [   75.421875] wlan0: send auth to f8:1a:67:1a:df:88 (try 1/3)
> [   75.437500] wlan0: authenticated
> [   75.453125] wlan0: associate with f8:1a:67:1a:df:88 (try 1/3)
> [   75.460937] wlan0: RX AssocResp from f8:1a:67:1a:df:88 (capab=0x401 status=0 aid=2)
> [   75.468750] wlan0: associated
> [   76.375000] ------------[ cut here ]------------
> [   76.375000] WARNING: at kernel/workqueue.c:1365 __queue_work+0x168/0x200()
> [   76.375000] Modules linked in: rtl8192cu rtl8192c_common rtlwifi mac80211 cfg80211 rfkill ehci_atmel ehci_hcd atmel_usba_udc udc_core ohci_hcd
> [   76.375000] CPU: 0 PID: 308 Comm: kworker/0:1 Not tainted 3.10.0-rc7 #36
> [   76.375000] Workqueue: rtl92c_usb rtl_watchdog_wq_callback [rtlwifi]
> [   76.375000] [<c000d9bc>] (unwind_backtrace+0x0/0xf0) from [<c000b9ec>] (show_stack+0x10/0x14)
> [   76.375000] [<c000b9ec>] (show_stack+0x10/0x14) from [<c0015c00>] (warn_slowpath_common+0x4c/0x68)
> [   76.375000] [<c0015c00>] (warn_slowpath_common+0x4c/0x68) from [<c0015c38>] (warn_slowpath_null+0x1c/0x24)
> [   76.375000] [<c0015c38>] (warn_slowpath_null+0x1c/0x24) from [<c0029e40>] (__queue_work+0x168/0x200)
> [   76.375000] [<c0029e40>] (__queue_work+0x168/0x200) from [<c0029f2c>] (queue_work_on+0x44/0x50)
> [   76.375000] [<c0029f2c>] (queue_work_on+0x44/0x50) from [<bf09bb54>] (rtl_watchdog_wq_callback+0x320/0x404 [rtlwifi])
> [   76.375000] [<bf09bb54>] (rtl_watchdog_wq_callback+0x320/0x404 [rtlwifi]) from [<c002b168>] (process_one_work+0x10c/0x354)
> [   76.375000] [<c002b168>] (process_one_work+0x10c/0x354) from [<c002b784>] (worker_thread+0x130/0x380)
> [   76.375000] [<c002b784>] (worker_thread+0x130/0x380) from [<c0030330>] (kthread+0xa4/0xb0)
> [   76.375000] [<c0030330>] (kthread+0xa4/0xb0) from [<c00092f0>] (ret_from_fork+0x14/0x24)
> [   76.375000] ---[ end trace e116b4b3d671f3d2 ]---

The WARNING is the result of a workqueue not being initialized for the USB driver.

Please try the attached patch. As you have posted on a public mailing list, May 
I assume that it will be OK to use your address in Reported-by/Tested-by lines 
in the patch submission?

Thanks,

Larry


[-- Attachment #2: rtl8192cu_init_work --]
[-- Type: text/plain, Size: 1754 bytes --]

Index: wireless-testing-save/drivers/net/wireless/rtlwifi/pci.c
===================================================================
--- wireless-testing-save.orig/drivers/net/wireless/rtlwifi/pci.c
+++ wireless-testing-save/drivers/net/wireless/rtlwifi/pci.c
@@ -1008,7 +1008,7 @@ static void _rtl_pci_prepare_bcn_tasklet
 	return;
 }
 
-static void rtl_lps_change_work_callback(struct work_struct *work)
+void rtl_lps_change_work_callback(struct work_struct *work)
 {
 	struct rtl_works *rtlworks =
 	    container_of(work, struct rtl_works, lps_change_work);
Index: wireless-testing-save/drivers/net/wireless/rtlwifi/ps.h
===================================================================
--- wireless-testing-save.orig/drivers/net/wireless/rtlwifi/ps.h
+++ wireless-testing-save/drivers/net/wireless/rtlwifi/ps.h
@@ -49,5 +49,6 @@ void rtl_swlps_rf_awake(struct ieee80211
 void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
 void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
 void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len);
+void rtl_lps_change_work_callback(struct work_struct *work);
 
 #endif
Index: wireless-testing-save/drivers/net/wireless/rtlwifi/usb.c
===================================================================
--- wireless-testing-save.orig/drivers/net/wireless/rtlwifi/usb.c
+++ wireless-testing-save/drivers/net/wireless/rtlwifi/usb.c
@@ -1070,6 +1070,8 @@ int rtl_usb_probe(struct usb_interface *
 	spin_lock_init(&rtlpriv->locks.usb_lock);
 	INIT_WORK(&rtlpriv->works.fill_h2c_cmd,
 		  rtl_fill_h2c_cmd_work_callback);
+	INIT_WORK(&rtlpriv->works.lps_change_work,
+		  rtl_lps_change_work_callback);
 
 	rtlpriv->usb_data_index = 0;
 	init_completion(&rtlpriv->firmware_loading_complete);

^ permalink raw reply

* Re: [PATCH v12 2/2] cfg80211: P2P find phase offload
From: Johannes Berg @ 2013-06-26 15:31 UTC (permalink / raw)
  To: Vladimir Kondratiev
  Cc: linux-wireless, Luis R . Rodriguez, John W . Linville,
	Jouni Malinen, Arend van Spriel, Ilan Peer
In-Reply-To: <1372167756-17928-3-git-send-email-qca_vkondrat@qca.qualcomm.com>

Looking good ... :)

On Tue, 2013-06-25 at 16:42 +0300, Vladimir Kondratiev wrote:

> + * @channels: channels to operate on
> + *     may be NULL, in this case driver suppose to scan for all
> social
> + *     channels; or channel set should be non-empty (n_channels > 0)

Does that make sense, or should cfg80211 just build the channel list in
the case the user didn't specify anything, rather than leave it NULL? It
seems that every driver implementing it really needs the list, and
having multiple drivers create it seems wasteful?

> +static int nl80211_stop_p2p_find(struct sk_buff *skb, struct genl_info *info)
> +{
> +	struct cfg80211_registered_device *rdev = info->user_ptr[0];
> +	struct wireless_dev *wdev = info->user_ptr[1];
> +
> +	if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)
> +		return -EOPNOTSUPP;
> +
> +	if (!rdev->ops->start_p2p_find || !rdev->ops->stop_p2p_find)
> +		return -EOPNOTSUPP;
> +
> +	rdev_stop_p2p_find(rdev, wdev);

You don't track whether this p2p find is ongoing, so userspace can abort
it many times. I think it would be worth documenting that, and also that
in that case cfg80211_p2p_find_notify_end() probably shouldn't be
called?

johannes


^ permalink raw reply

* Re: [PATCH] iw: fix incorrect bit shifting in print_ht_mcs
From: Johannes Berg @ 2013-06-26 15:24 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless
In-Reply-To: <1372259260-7061-1-git-send-email-linville@tuxdriver.com>

On Wed, 2013-06-26 at 11:07 -0400, John W. Linville wrote:
> From: "John W. Linville" <linville@tuxdriver.com>
> 
> From a Coverity run on version 3.10:
> 
> iw-3.10/util.c:569:result_independent_of_operands –
> 	"mcs[10] >> 8" is 0 regardless of the values of its operands. This occurs as the bitwise first operand of '&'.
> 
> This seems more like what was intended...

Applied both, thanks.

johannes


^ permalink raw reply

* Re: [PATCH v12 1/2] cfg80211: add 'flags' to cfg80211_rx_mgmt()
From: Johannes Berg @ 2013-06-26 15:17 UTC (permalink / raw)
  To: Vladimir Kondratiev
  Cc: linux-wireless, Luis R . Rodriguez, John W . Linville,
	Jouni Malinen, Arend van Spriel, Ilan Peer
In-Reply-To: <1372167756-17928-2-git-send-email-qca_vkondrat@qca.qualcomm.com>

On Tue, 2013-06-25 at 16:42 +0300, Vladimir Kondratiev wrote:

> +++ b/include/uapi/linux/nl80211.h
> @@ -1436,6 +1436,8 @@ enum nl80211_commands {
>   *	allowed to be used with the first @NL80211_CMD_SET_STATION command to
>   *	update a TDLS peer STA entry.
>   *
> + * @NL80211_ATTR_RXMGMT_FLAGS: flags for cfg80211_rx_mgmt, u32

That's a little insufficient, don't you think? cfg80211_rx_mgmt()
doesn't even really make sense to userspace, you should point to the
nl80211 event and maybe even reference this new attribute in the command
description.

> +/**
> + * enum nl80211_rxmgmt_flags - flags for cfg80211_rx_mgmt
> + *
> + * @NL80211_RXMGMT_FLAG_REPLIED: frame was replied by device/driver.
> + */
> +enum nl80211_rxmgmt_flags {
> +	NL80211_RXMGMT_FLAG_REPLIED = (1 << 0),

No need for parentheses.

>  bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
> -		      const u8 *buf, size_t len, gfp_t gfp)
> +		      const u8 *buf, size_t len, u32 flags, gfp_t gfp)

I'm starting to wonder if this function has too many arguments?
Thoughts? Maybe it should get a struct or so? Not really sure ... could
just be a worthwhile cleanup afterwards?

johannes


^ permalink raw reply

* [PATCH] iw: fix incorrect bit shifting in print_ht_mcs
From: John W. Linville @ 2013-06-26 15:07 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, John W. Linville

From: "John W. Linville" <linville@tuxdriver.com>

>From a Coverity run on version 3.10:

iw-3.10/util.c:569:result_independent_of_operands –
	"mcs[10] >> 8" is 0 regardless of the values of its operands. This occurs as the bitwise first operand of '&'.

This seems more like what was intended...

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util.c b/util.c
index d8b76ee..e3d0c27 100644
--- a/util.c
+++ b/util.c
@@ -574,7 +574,7 @@ void print_ht_mcs(const __u8 *mcs)
 	unsigned int tx_max_num_spatial_streams, max_rx_supp_data_rate;
 	bool tx_mcs_set_defined, tx_mcs_set_equal, tx_unequal_modulation;
 
-	max_rx_supp_data_rate = ((mcs[10] >> 8) & ((mcs[11] & 0x3) << 8));
+	max_rx_supp_data_rate = (mcs[10] & ((mcs[11] & 0x3) << 8));
 	tx_mcs_set_defined = !!(mcs[12] & (1 << 0));
 	tx_mcs_set_equal = !(mcs[12] & (1 << 1));
 	tx_max_num_spatial_streams = ((mcs[12] >> 2) & 3) + 1;
-- 
1.8.1.4


^ permalink raw reply related

* [PATCH] iw: reorder some code in iw_connect to avoid a potential memory leak
From: John W. Linville @ 2013-06-26 15:07 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, John W. Linville

From: "John W. Linville" <linville@tuxdriver.com>

>From Coverity run on version 3.10:

iw-3.10/connect.c:104:leaked_storage –
	Variable "conn_argv" going out of scope leaks the storage it points to.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 connect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/connect.c b/connect.c
index 74e4578..fb3b2fe 100644
--- a/connect.c
+++ b/connect.c
@@ -94,15 +94,15 @@ static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
 		argv++;
 	}
 
+	err = __prepare_listen_events(state);
+	if (err)
+		return err;
+
 	conn_argc = 3 + argc;
 	conn_argv = calloc(conn_argc, sizeof(*conn_argv));
 	if (!conn_argv)
 		return -ENOMEM;
 
-	err = __prepare_listen_events(state);
-	if (err)
-		return err;
-
 	conn_argv[0] = dev;
 	conn_argv[1] = "connect";
 	conn_argv[2] = "establish";
-- 
1.8.1.4


^ permalink raw reply related

* Re: [PATCH v4 2/2] cfg80211/nl80211: Add packet coalesce support
From: Johannes Berg @ 2013-06-26 15:13 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, Luis R. Rodriguez, Jouni Malinen,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	Luciano Coelho, Amitkumar Karwar
In-Reply-To: <1372212237-5687-2-git-send-email-bzhao@marvell.com>

On Tue, 2013-06-25 at 19:03 -0700, Bing Zhao wrote:

> +/**
> + * struct cfg80211_coalesce - Packet coalescing settings
> + *
> + * This structure defines coalescing settings.
> + * @rules: array of coalesce rules
> + * @n_rules: number of rules
> + */
> +struct cfg80211_coalesce {
> +	struct cfg80211_coalesce_rules **rules;

I don't really see why this should be a double pointer? The
coalesce_rules struct is small enough that you could just allocate an
array of that, no?

>  /**
> + * struct wiphy_coalesce_support - coalesce support data
> + * @n_rules: maximum number of coalesce rules
> + * @n_patterns: number of supported patterns
> + *	(see nl80211.h for the pattern definition)
> + * @pattern_max_len: maximum length of each pattern
> + * @pattern_min_len: minimum length of each pattern
> + * @max_pkt_offset: maximum Rx packet offset

Should there be any limits on the timer? Will the firmware actually work
if I set it to (useless) values like 2^32-1 msecs?

Also -- is n_patterns per rule, or global? It seems global, but in the
rules you can have multiple patterns per rule?

> +/**
>   * enum nl80211_commands - supported nl80211 commands
>   *
>   * @NL80211_CMD_UNSPEC: unspecified command to catch errors
> @@ -648,6 +673,10 @@
>   * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
>   *	return back to normal.
>   *
> + * @NL80211_CMD_GET_COALESCE: Get currently supported coalesce rules.
> + *
> + * @NL80211_CMD_SET_COALESCE: Configure coalesce rules or clear existing rules.

I'd prefer no space between the two :)

> +struct nl80211_coalesce_rule_support {
> +	__u32 max_rules;
> +	struct nl80211_pattern_support pat;

(timing stuff would also go here, I suppose)

> +static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
> +				       struct nlattr *rule,
> +				       struct cfg80211_coalesce_rules *new_rule)
> +{
> +	int err, i;
> +	const struct wiphy_coalesce_support *coalesce = rdev->wiphy.coalesce;
> +	struct nlattr *tb[NUM_NL80211_ATTR_COALESCE_RULE], *pat;
> +	int rem, pat_len, mask_len, pkt_offset, n_patterns = 0;
> +	struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
> +
> +	err = nla_parse(tb, NL80211_ATTR_COALESCE_RULE_MAX, nla_data(rule),
> +			nla_len(rule), nl80211_coalesce_policy);
> +	if (err)
> +		return err;
> +
> +	memset(new_rule, 0, sizeof(*new_rule));
> +	new_rule->delay = nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_DELAY]);

no check that it actually exists?

> +	new_rule->condition =
> +		nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_CONDITION]);

ditto. easy to crash, no?

> +static int nl80211_set_coalesce(struct sk_buff *skb, struct genl_info *info)
> +{
> +	struct cfg80211_registered_device *rdev = info->user_ptr[0];
> +	const struct wiphy_coalesce_support *coalesce = rdev->wiphy.coalesce;
> +	struct cfg80211_coalesce_rules new_rule = {};
> +	struct cfg80211_coalesce_rules *nrule;
> +	struct cfg80211_coalesce *new_coalesce;
> +	int err, rem_rule;
> +	struct nlattr *rule;
> +
> +	if (!rdev->wiphy.coalesce)
> +		return -EOPNOTSUPP;
> +	if (!rdev->ops->set_coalesce)
> +		return -EOPNOTSUPP;

could combine the conditions :)

> +	new_coalesce = kzalloc(sizeof(*new_coalesce), GFP_KERNEL);
> +	new_coalesce->rules = kcalloc(coalesce->n_rules,
> +					sizeof(void *), GFP_KERNEL);

*kaboom*

> +	cfg80211_rdev_free_coalesce(rdev->coalesce);
> +	rdev->coalesce = new_coalesce;
> +
> +	err = rdev->ops->set_coalesce(&rdev->wiphy, rdev->coalesce);
> +	if (err)
> +		goto error;
> +
> +	return 0;
> +error:
> +	cfg80211_rdev_free_coalesce(new_coalesce);

*kaboom* if it ever fails, and you then do get_coalesce -- should
probably assign only after setting the new value successfully?

johannes


^ permalink raw reply

* Re: [PATCH v4 1/2] cfg80211/nl80211: rename packet pattern related structures and enums
From: Johannes Berg @ 2013-06-26 15:04 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, Luis R. Rodriguez, Jouni Malinen,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	Luciano Coelho, Amitkumar Karwar
In-Reply-To: <1372212237-5687-1-git-send-email-bzhao@marvell.com>

On Tue, 2013-06-25 at 19:03 -0700, Bing Zhao wrote:
> From: Amitkumar Karwar <akarwar@marvell.com>
> 
> Currently packet patterns and it's enum/structures are used only
> for WoWLAN feature. As we intend to reuse them for new feature
> packet coalesce, they are renamed in this patch.

This looks good, applied.

johannes


^ permalink raw reply

* rtl8192cu: slow path warning
From: Richard GENOUD @ 2013-06-26 14:22 UTC (permalink / raw)
  To: Larry Finger; +Cc: Chaoming Li, John W. Linville, linux-wireless, linux-kernel
In-Reply-To: <20130611123814.GA9854@lnx-rg>

On [mar., 11.06.2013 14:38:15], Richard GENOUD wrote:
> Hi,
> 
> I've got an usb wireless adapter TP-Link TL-WN725N
> http://www.tp-link.com/ca/products/details/?categoryid=241&model=TL-WN725N
> It is based on the rtl8192cu chip.
> I'm running a recent kernel (3.10-rc5) on a arm-based board (at91sam9g35-ek).
> and last linux-firmwares (2892af0)
> 
> Here is the log:
> ***Insert the TP-Link key
> [   22.710937] usb 1-2.3: new high-speed USB device number 3 using atmel-ehci
> [   22.828125] rtl8192cu: Chip version 0x10
> [   22.921875] rtl8192cu: MAC address: a0:f3:c1:1a:28:5f
> [   22.929687] rtl8192cu: Board Type 0
> [   22.929687] rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1
> [   22.937500] rtl8192cu: Loading firmware rtlwifi/rtl8192cufw.bin
> [   22.953125] ieee80211 phy0: Selected rate control algorithm 'rtl_rc'
> [   22.968750] rtlwifi: wireless switch is on
> 
> # ip link set wlan0 up
> [   34.656250] rtl8192cu: MAC auto ON okay!
> [   34.695312] rtl8192cu: Tx queue select: 0x05
> # iw dev wlan0 scan
> BSS 00:1c:10:69:90:fe (on wlan0)
> 	TSF: 1046528539 usec (0d, 00:17:26)
> 	freq: 2412
> 	beacon interval: 100
> 	capability: ESS ShortSlotTime (0x0401)
> 	signal: -58.00 dBm
> 	last seen: 500 ms ago
> 	Information elements from Probe Response frame:
> 	SSID: test
> 	Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 
> 	DS Parameter set: channel 1
> 	TIM: DTIM Count 1 DTIM Period 2 Bitmap Control 0x0 Bitmap[0] 0x0
> 	ERP: Barker_Preamble_Mode
> 	Extended supported rates: 24.0 36.0 48.0 54.0 
> # iw wlan0 connect test
> [   51.851562] wlan0: authenticate with 00:1c:10:69:90:fe
> [   51.859375] wlan0: Allocated STA 00:1c:10:69:90:fe
> [   51.867187] wlan0: Inserted STA 00:1c:10:69:90:fe
> [   51.875000] wlan0: direct probe to 00:1c:10:69:90:fe (try 1/3)
> # [   52.078125] wlan0: direct probe to 00:1c:10:69:90:fe (try 2/3)
> [   52.281250] wlan0: direct probe to 00:1c:10:69:90:fe (try 3/3)
> [   52.484375] wlan0: authentication with 00:1c:10:69:90:fe timed out
> [   52.484375] wlan0: Removed STA 00:1c:10:69:90:fe
> [   52.492187] wlan0: Destroyed STA 00:1c:10:69:90:fe
> 
> # iw wlan0 connect test
> # [   70.718750] wlan0: authenticate with 00:1c:10:69:90:fe
> [   70.718750] wlan0: Allocated STA 00:1c:10:69:90:fe
> [   70.742187] wlan0: Inserted STA 00:1c:10:69:90:fe
> [   70.742187] wlan0: send auth to 00:1c:10:69:90:fe (try 1/3)
> [   70.757812] wlan0: authenticated
> [   70.757812] wlan0: moving STA 00:1c:10:69:90:fe to state 2
> [   70.765625] rtl8192cu 1-2.3:1.0 wlan0: disabling HT as WMM/QoS is not supported by the AP
> [   70.773437] rtl8192cu 1-2.3:1.0 wlan0: disabling VHT as WMM/QoS is not supported by the AP
> [   70.789062] wlan0: associate with 00:1c:10:69:90:fe (try 1/3)
> [   70.804687] wlan0: RX AssocResp from 00:1c:10:69:90:fe (capab=0x401 status=0 aid=1)
> [   70.812500] wlan0: moving STA 00:1c:10:69:90:fe to state 3
> [   70.820312] wlan0: moving STA 00:1c:10:69:90:fe to state 4
> [   70.828125] wlan0: associated
> [   71.187500] ------------[ cut here ]------------
> [   71.187500] WARNING: at kernel/workqueue.c:1365 __queue_work+0x180/0x1f8()
> [   71.187500] CPU: 0 PID: 593 Comm: kworker/0:2 Not tainted 3.10.0-rc5-00133-g691a986 #6
> [   71.187500] Workqueue: rtl92c_usb rtl_watchdog_wq_callback
> [   71.187500] [<c000d2a0>] (unwind_backtrace+0x0/0xf0) from [<c000ba34>] (show_stack+0x10/0x14)
> [   71.187500] [<c000ba34>] (show_stack+0x10/0x14) from [<c00150fc>] (warn_slowpath_common+0x48/0x64)
> [   71.187500] [<c00150fc>] (warn_slowpath_common+0x48/0x64) from [<c00151e0>] (warn_slowpath_null+0x1c/0x24)
> [   71.187500] [<c00151e0>] (warn_slowpath_null+0x1c/0x24) from [<c0029878>] (__queue_work+0x180/0x1f8)
> [   71.187500] [<c0029878>] (__queue_work+0x180/0x1f8) from [<c0029ee8>] (queue_work_on+0x44/0x50)
> [   71.187500] [<c0029ee8>] (queue_work_on+0x44/0x50) from [<c01fd850>] (rtl_watchdog_wq_callback+0x290/0x4e0)
> [   71.187500] [<c01fd850>] (rtl_watchdog_wq_callback+0x290/0x4e0) from [<c002a138>] (process_one_work+0x110/0x358)
> [   71.187500] [<c002a138>] (process_one_work+0x110/0x358) from [<c002a728>] (worker_thread+0xf4/0x308)
> [   71.187500] [<c002a728>] (worker_thread+0xf4/0x308) from [<c002f8b4>] (kthread+0xa4/0xb0)
> [   71.187500] [<c002f8b4>] (kthread+0xa4/0xb0) from [<c00091b0>] (ret_from_fork+0x14/0x24)
> [   71.187500] ---[ end trace 5f274d456b3a4c7f ]---
Hi,

Using 3.10-rc7, I'm still seeing the warning, BUT ONLY on the first
connection.

[   40.312500] usb 2-2: default language 0x0409
[   40.312500] usb 2-2: udev 2, busnum 2, minor = 129
[   40.320312] usb 2-2: New USB device found, idVendor=0bda, idProduct=8176
[   40.328125] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   40.328125] usb 2-2: Product: 802.11n WLAN Adapter
[   40.335937] usb 2-2: Manufacturer: Realtek
[   40.343750] usb 2-2: SerialNumber: 00e04c000001
[   40.343750] usb 2-2: usb_probe_device
[   40.351562] usb 2-2: configuration #1 chosen from 1 choice
[   40.351562] usb 2-2: adding 2-2:1.0 (config #1, interface 0)
[   40.500000] cfg80211: Calling CRDA to update world regulatory domain
[   40.648437] rtl8192cu 2-2:1.0: usb_probe_interface
[   40.656250] rtl8192cu 2-2:1.0: usb_probe_interface - got id
[   40.664062] rtl8192cu: Chip version 0x10
[   40.757812] rtl8192cu: MAC address: a0:f3:c1:1e:02:a0
[   40.765625] rtl8192cu: Board Type 0
[   40.773437] rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1
[   40.773437] rtl8192cu: Loading firmware rtlwifi/rtl8192cufw.bin
[   40.781250] usbcore: registered new interface driver rtl8192cu
[   40.835937] ieee80211 phy0: Selected rate control algorithm 'rtl_rc'
[   40.843750] rtlwifi: wireless switch is on
# ip link set wlan0 up
[   59.921875] rtl8192cu: MAC auto ON okay!
[   59.960937] rtl8192cu: Tx queue select: 0x05
# iw wlan0 connect test
[   75.390625] wlan0: authenticate with f8:1a:67:1a:df:88
[   75.421875] wlan0: send auth to f8:1a:67:1a:df:88 (try 1/3)
[   75.437500] wlan0: authenticated
[   75.453125] wlan0: associate with f8:1a:67:1a:df:88 (try 1/3)
[   75.460937] wlan0: RX AssocResp from f8:1a:67:1a:df:88 (capab=0x401 status=0 aid=2)
[   75.468750] wlan0: associated
[   76.375000] ------------[ cut here ]------------
[   76.375000] WARNING: at kernel/workqueue.c:1365 __queue_work+0x168/0x200()
[   76.375000] Modules linked in: rtl8192cu rtl8192c_common rtlwifi mac80211 cfg80211 rfkill ehci_atmel ehci_hcd atmel_usba_udc udc_core ohci_hcd
[   76.375000] CPU: 0 PID: 308 Comm: kworker/0:1 Not tainted 3.10.0-rc7 #36
[   76.375000] Workqueue: rtl92c_usb rtl_watchdog_wq_callback [rtlwifi]
[   76.375000] [<c000d9bc>] (unwind_backtrace+0x0/0xf0) from [<c000b9ec>] (show_stack+0x10/0x14)
[   76.375000] [<c000b9ec>] (show_stack+0x10/0x14) from [<c0015c00>] (warn_slowpath_common+0x4c/0x68)
[   76.375000] [<c0015c00>] (warn_slowpath_common+0x4c/0x68) from [<c0015c38>] (warn_slowpath_null+0x1c/0x24)
[   76.375000] [<c0015c38>] (warn_slowpath_null+0x1c/0x24) from [<c0029e40>] (__queue_work+0x168/0x200)
[   76.375000] [<c0029e40>] (__queue_work+0x168/0x200) from [<c0029f2c>] (queue_work_on+0x44/0x50)
[   76.375000] [<c0029f2c>] (queue_work_on+0x44/0x50) from [<bf09bb54>] (rtl_watchdog_wq_callback+0x320/0x404 [rtlwifi])
[   76.375000] [<bf09bb54>] (rtl_watchdog_wq_callback+0x320/0x404 [rtlwifi]) from [<c002b168>] (process_one_work+0x10c/0x354)
[   76.375000] [<c002b168>] (process_one_work+0x10c/0x354) from [<c002b784>] (worker_thread+0x130/0x380)
[   76.375000] [<c002b784>] (worker_thread+0x130/0x380) from [<c0030330>] (kthread+0xa4/0xb0)
[   76.375000] [<c0030330>] (kthread+0xa4/0xb0) from [<c00092f0>] (ret_from_fork+0x14/0x24)
[   76.375000] ---[ end trace e116b4b3d671f3d2 ]---

# iw wlan0 disconnect 
[   86.289062] wlan0: deauthenticating from f8:1a:67:1a:df:88 by local choice (reason=3)
[   86.312500] cfg80211: Calling CRDA to update world regulatory domain
# iw wlan0 connect test
[   91.671875] wlan0: authenticate with f8:1a:67:1a:df:88
[   91.687500] wlan0: send auth to f8:1a:67:1a:df:88 (try 1/3)
[   91.695312] wlan0: authenticated
[   91.710937] wlan0: associate with f8:1a:67:1a:df:88 (try 1/3)
[   91.718750] wlan0: RX AssocResp from f8:1a:67:1a:df:88 (capab=0x401 status=0 aid=1)
[   91.726562] wlan0: associated

# iw wlan0 disconnect 
[   98.929687] wlan0: deauthenticating from f8:1a:67:1a:df:88 by local choice (reason=3)
[   98.953125] cfg80211: Calling CRDA to update world regulatory domain
# iw wlan0 connect test
[  101.554687] wlan0: authenticate with f8:1a:67:1a:df:88
[  101.578125] wlan0: send auth to f8:1a:67:1a:df:88 (try 1/3)
[  101.585937] wlan0: authenticated
[  101.593750] wlan0: associate with f8:1a:67:1a:df:88 (try 1/3)
[  101.625000] wlan0: RX AssocResp from f8:1a:67:1a:df:88 (capab=0x401 status=0 aid=1)
[  101.632812] wlan0: associated
[  114.523437] wlan0: Connection to AP f8:1a:67:1a:df:88 lost
[  114.546875] cfg80211: Calling CRDA to update world regulatory domain


Best regards,
Richard.

^ permalink raw reply

* Re: pull request: bluetooth 2013-06-23
From: Gustavo Padovan @ 2013-06-26 12:47 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Marcel Holtmann, linville, linux-wireless, linux-bluetooth,
	linux-kernel, Rafael J. Wysocki
In-Reply-To: <20130626115255.GA7940@amd.pavel.ucw.cz>

* Pavel Machek <pavel@ucw.cz> [2013-06-26 13:52:55 +0200]:

> On Tue 2013-06-25 22:00:39, Gustavo Padovan wrote:
> > Hi Marcel,
> > 
> > * Marcel Holtmann <marcel@holtmann.org> [2013-06-25 13:49:19 -0700]:
> > 
> > > Hi Pavel,
> > > 
> > > >> Jaganath Kanakkassery (1):
> > > >>      Bluetooth: Fix invalid length check in l2cap_information_rsp()
> > > > 
> > > > Could we add the "3.10 vs. thinkpad x60" patch that fixes regression?
> > > > It is from Johan Hedberg…
> > > 
> > > that one went into net-next tree. It is scheduled for 3.11 right now.
> > > 
> > > After 3.10 is out, maybe it can go into -stable, but otherwise I think it is bit late now. Unless someone wants to cherry-pick it.
> > 
> > That patch is actually in 3.10 already, it was included in the last pull
> > request and John took it to wireless.git.
> 
> Is it? I tried pulling yesterday (some updates) and today (no
> changes), am on:

Dave already pulled it so it should land in mainline anytime soon.

	Gustavo

^ permalink raw reply

* [PATCH V2 6/9] brcmfmac: tag packet in the netdev transmit callback
From: Arend van Spriel @ 2013-06-26 12:35 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, Arend van Spriel
In-Reply-To: <1372249222-4858-7-git-send-email-arend@broadcom.com>

Transmit packets needs to be tagged in order to receive a tx status
feedback from the firmware. Determine the tag in the netdev transmit
callback instead of determining the tag just before transfer to the
device. This reduces the number of exception flows and hence makes
the driver code simpler.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
Found a checkpatch warning after sending the patch. This patch
replaces the previous patch with message ID:

Message-ID: <1372249222-4858-7-git-send-email-arend@broadcom.com>

---
 drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c |  130 ++++++++------------
 1 file changed, 48 insertions(+), 82 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
index e4fd13a..44b3192 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
@@ -1575,21 +1575,14 @@ int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len,
 	return 0;
 }
 
-static int brcmf_fws_precommit_skb(struct brcmf_fws_info *fws, int fifo,
+static void brcmf_fws_precommit_skb(struct brcmf_fws_info *fws, int fifo,
 				   struct sk_buff *p)
 {
 	struct brcmf_skbuff_cb *skcb = brcmf_skbcb(p);
 	struct brcmf_fws_mac_descriptor *entry = skcb->mac;
-	int rc = 0;
-	bool first_time;
-	int hslot = BRCMF_FWS_HANGER_MAXITEMS;
-	u8 free_ctr;
 	u8 flags;
 
-	first_time = skcb->state != BRCMF_FWS_SKBSTATE_SUPPRESSED;
-
 	brcmf_skb_if_flags_set_field(p, TRANSMIT, 1);
-	brcmf_skb_htod_tag_set_field(p, FIFO, fifo);
 	brcmf_skb_htod_tag_set_field(p, GENERATION, entry->generation);
 	flags = BRCMF_FWS_HTOD_FLAG_PKTFROMHOST;
 	if (brcmf_skb_if_flags_get_field(p, REQUESTED)) {
@@ -1600,80 +1593,36 @@ static int brcmf_fws_precommit_skb(struct brcmf_fws_info *fws, int fifo,
 		flags |= BRCMF_FWS_HTOD_FLAG_PKT_REQUESTED;
 	}
 	brcmf_skb_htod_tag_set_field(p, FLAGS, flags);
-	if (first_time) {
-		/* obtaining free slot may fail, but that will be caught
-		 * by the hanger push. This assures the packet has a BDC
-		 * header upon return.
-		 */
-		hslot = brcmf_fws_hanger_get_free_slot(&fws->hanger);
-		free_ctr = entry->seq[fifo];
-		brcmf_skb_htod_tag_set_field(p, HSLOT, hslot);
-		brcmf_skb_htod_tag_set_field(p, FREERUN, free_ctr);
-		rc = brcmf_fws_hanger_pushpkt(&fws->hanger, p, hslot);
-		if (rc)
-			brcmf_err("hanger push failed: rc=%d\n", rc);
-	}
-
-	if (rc == 0)
-		brcmf_fws_hdrpush(fws, p);
-
-	return rc;
+	brcmf_fws_hdrpush(fws, p);
 }
 
-static void
-brcmf_fws_rollback_toq(struct brcmf_fws_info *fws,
-		       struct sk_buff *skb, int fifo)
+static void brcmf_fws_rollback_toq(struct brcmf_fws_info *fws,
+				   struct sk_buff *skb, int fifo)
 {
-	/*
-	put the packet back to the head of queue
-
-	- suppressed packet goes back to suppress sub-queue
-	- pull out the header, if new or delayed packet
-
-	Note: hslot is used only when header removal is done.
-	*/
 	struct brcmf_fws_mac_descriptor *entry;
-	enum brcmf_fws_skb_state state;
 	struct sk_buff *pktout;
+	int qidx, hslot;
 	int rc = 0;
-	int hslot;
 
-	state = brcmf_skbcb(skb)->state;
 	entry = brcmf_skbcb(skb)->mac;
-	hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
-
-	if (entry != NULL) {
-		if (state == BRCMF_FWS_SKBSTATE_SUPPRESSED) {
-			/* wl-header is saved for suppressed packets */
-			pktout = brcmu_pktq_penq_head(&entry->psq, 2 * fifo + 1,
-						      skb);
-			if (pktout == NULL) {
-				brcmf_err("suppress queue full\n");
-				rc = -ENOSPC;
-			}
-		} else {
-			/* delay-q packets are going to delay-q */
-			pktout = brcmu_pktq_penq_head(&entry->psq,
-						      2 * fifo, skb);
-			if (pktout == NULL) {
-				brcmf_err("delay queue full\n");
-				rc = -ENOSPC;
-			}
-
-			/* free the hanger slot */
-			brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &pktout,
-						true);
-
-			/* decrement sequence count */
-			entry->seq[fifo]--;
+	if (entry->occupied) {
+		qidx = 2 * fifo;
+		if (brcmf_skbcb(skb)->state == BRCMF_FWS_SKBSTATE_SUPPRESSED)
+			qidx++;
+
+		pktout = brcmu_pktq_penq_head(&entry->psq, qidx, skb);
+		if (pktout == NULL) {
+			brcmf_err("%s queue %d full\n", entry->name, qidx);
+			rc = -ENOSPC;
 		}
 	} else {
-		brcmf_err("no mac entry linked\n");
+		brcmf_err("%s entry removed\n", entry->name);
 		rc = -ENOENT;
 	}
 
 	if (rc) {
 		fws->stats.rollback_failed++;
+		hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
 		brcmf_fws_txs_process(fws, BRCMF_FWS_TXSTATUS_HOST_TOSSED,
 				      hslot, 0);
 	} else {
@@ -1720,15 +1669,10 @@ static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo,
 	if (IS_ERR(entry))
 		return PTR_ERR(entry);
 
-	rc = brcmf_fws_precommit_skb(fws, fifo, skb);
-	if (rc < 0) {
-		fws->stats.generic_error++;
-		goto rollback;
-	}
-
-	brcmf_dbg(DATA, "%s flags %X htod %X\n", entry->name, skcb->if_flags,
-		  skcb->htod);
+	brcmf_fws_precommit_skb(fws, fifo, skb);
 	rc = brcmf_bus_txdata(bus, skb);
+	brcmf_dbg(DATA, "%s flags %X htod %X bus_tx %d\n", entry->name,
+		  skcb->if_flags, skcb->htod, rc);
 	if (rc < 0) {
 		brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb);
 		goto rollback;
@@ -1737,7 +1681,6 @@ static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo,
 	entry->transit_count++;
 	if (entry->suppressed)
 		entry->suppr_transit_count++;
-	entry->seq[fifo]++;
 	fws->stats.pkt2bus++;
 	fws->stats.send_pkts[fifo]++;
 	if (brcmf_skb_if_flags_get_field(skb, REQUESTED))
@@ -1750,6 +1693,24 @@ rollback:
 	return rc;
 }
 
+static int brcmf_fws_assign_htod(struct brcmf_fws_info *fws, struct sk_buff *p,
+				  int fifo)
+{
+	struct brcmf_skbuff_cb *skcb = brcmf_skbcb(p);
+	int rc, hslot;
+
+	hslot = brcmf_fws_hanger_get_free_slot(&fws->hanger);
+	brcmf_skb_htod_tag_set_field(p, HSLOT, hslot);
+	brcmf_skb_htod_tag_set_field(p, FREERUN, skcb->mac->seq[fifo]);
+	brcmf_skb_htod_tag_set_field(p, FIFO, fifo);
+	rc = brcmf_fws_hanger_pushpkt(&fws->hanger, p, hslot);
+	if (!rc)
+		skcb->mac->seq[fifo]++;
+	else
+		fws->stats.generic_error++;
+	return rc;
+}
+
 int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
 {
 	struct brcmf_pub *drvr = ifp->drvr;
@@ -1778,22 +1739,27 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
 
 	/* set control buffer information */
 	skcb->if_flags = 0;
-	skcb->mac = brcmf_fws_macdesc_find(fws, ifp, eh->h_dest);
 	skcb->state = BRCMF_FWS_SKBSTATE_NEW;
 	brcmf_skb_if_flags_set_field(skb, INDEX, ifp->ifidx);
 	if (!multicast)
 		fifo = brcmf_fws_prio2fifo[skb->priority];
 
-	brcmf_dbg(DATA, "%s mac %pM multi %d fifo %d\n", skcb->mac->name,
-		  eh->h_dest, multicast, fifo);
-
 	brcmf_fws_lock(drvr, flags);
-	brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
 	if (fifo != BRCMF_FWS_FIFO_AC_BE && fifo < BRCMF_FWS_FIFO_BCMC)
 		fws->borrow_defer_timestamp = jiffies +
 					      BRCMF_FWS_BORROW_DEFER_PERIOD;
+
+	skcb->mac = brcmf_fws_macdesc_find(fws, ifp, eh->h_dest);
+	brcmf_dbg(DATA, "%s mac %pM multi %d fifo %d\n", skcb->mac->name,
+		  eh->h_dest, multicast, fifo);
+	if (!brcmf_fws_assign_htod(fws, skb, fifo)) {
+		brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
+		brcmf_fws_schedule_deq(fws);
+	} else {
+		brcmf_err("drop skb: no hanger slot\n");
+		brcmu_pkt_buf_free_skb(skb);
+	}
 	brcmf_fws_unlock(drvr, flags);
-	brcmf_fws_schedule_deq(fws);
 	return 0;
 }
 
-- 
1.7.10.4



^ permalink raw reply related

* Re: [PATCH] cfg80211/mac80211: fix doc compilation warnings
From: Michael Opdenacker @ 2013-06-26 12:23 UTC (permalink / raw)
  To: Johannes Berg; +Cc: davem, linux-wireless, linux-kernel
In-Reply-To: <1372232238.8157.2.camel@jlt4.sipsolutions.net>

Hi Johannes,

Thank you for your review!

On 06/26/2013 09:37 AM, Johannes Berg wrote:
> On Tue, 2013-06-25 at 21:48 +0200, Michael Opdenacker wrote:
>> This patch fixes countless "No description found for parameter"
>> warnings generating documentation (running "make htmldocs"),
>> because the comments do not match the actual prototypes in the code.
>>
>> This issue didn't exist in 3.9. It may we worth fixing in 3.10
>> (if it's not too late).
> I think it's way late. Besides, all of this is already fixed in -next
> trees.
Cool! That's good news :)
>
>
>> @@ -4153,6 +4153,7 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
>>   * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
>>   *
>>   * @wdev: the wireless device for which critical protocol is stopped.
>> + * @gfp: the type of memory to allocate (see kmalloc).
> This is also wrong, the allocation flags don't really change the *type*
> of memory, but only *how* it is allocated.
I agree, but I chose to stick to the description I found 5 times in
include/linux/slab.h. I shouldn't have followed bad examples...

I'll submit another patch ;)

Thanks again,

Michael.

-- 
Michael Opdenacker, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
+33 484 258 098


^ permalink raw reply

* [PATCH 1/9] brcmfmac: simplify transmit path
From: Arend van Spriel @ 2013-06-26 12:20 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, Arend van Spriel
In-Reply-To: <1372249222-4858-1-git-send-email-arend@broadcom.com>

When getting a transmit packet from the networking layer simply
enqueue the packet unconditional and have it handled by the dequeue
worker. The transfer of the packet to the bus-specific driver part
is now done from one context.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c |   54 ++------------------
 1 file changed, 5 insertions(+), 49 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
index 13e75c4..41f902d 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
@@ -1707,37 +1707,6 @@ static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws)
 	return -ENAVAIL;
 }
 
-static int brcmf_fws_consume_credit(struct brcmf_fws_info *fws, int fifo,
-				    struct sk_buff *skb)
-{
-	struct brcmf_fws_mac_descriptor *entry = brcmf_skbcb(skb)->mac;
-	int *credit = &fws->fifo_credit[fifo];
-
-	if (fifo != BRCMF_FWS_FIFO_AC_BE)
-		fws->borrow_defer_timestamp = jiffies +
-					      BRCMF_FWS_BORROW_DEFER_PERIOD;
-
-	if (!(*credit)) {
-		/* Try to borrow a credit from other queue */
-		if (fifo != BRCMF_FWS_FIFO_AC_BE ||
-		    (brcmf_fws_borrow_credit(fws) != 0)) {
-			brcmf_dbg(DATA, "ac=%d, credits depleted\n", fifo);
-			return -ENAVAIL;
-		}
-	} else {
-		(*credit)--;
-		if (!(*credit))
-			fws->fifo_credit_map &= ~(1 << fifo);
-	}
-
-	brcmf_fws_macdesc_use_req_credit(entry, skb);
-
-	brcmf_dbg(DATA, "ac=%d, credits=%02d:%02d:%02d:%02d\n", fifo,
-		  fws->fifo_credit[0], fws->fifo_credit[1],
-		  fws->fifo_credit[2], fws->fifo_credit[3]);
-	return 0;
-}
-
 static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo,
 				struct sk_buff *skb)
 {
@@ -1819,25 +1788,12 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
 		  eh->h_dest, multicast, fifo);
 
 	brcmf_fws_lock(drvr, flags);
-	/* multicast credit support is conditional, setting
-	 * flag to false to assure credit is consumed below.
-	 */
-	if (fws->bcmc_credit_check)
-		multicast = false;
-
-	if (skcb->mac->suppressed ||
-	    fws->bus_flow_blocked ||
-	    brcmf_fws_macdesc_closed(fws, skcb->mac, fifo) ||
-	    brcmu_pktq_mlen(&skcb->mac->psq, 3 << (fifo * 2)) ||
-	    (!multicast &&
-	     brcmf_fws_consume_credit(fws, fifo, skb) < 0)) {
-		/* enqueue the packet in delayQ */
-		drvr->fws->fifo_delay_map |= 1 << fifo;
-		brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
-	} else {
-		brcmf_fws_commit_skb(fws, fifo, skb);
-	}
+	brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
+	if (fifo != BRCMF_FWS_FIFO_AC_BE && fifo < BRCMF_FWS_FIFO_BCMC)
+		fws->borrow_defer_timestamp = jiffies +
+					      BRCMF_FWS_BORROW_DEFER_PERIOD;
 	brcmf_fws_unlock(drvr, flags);
+	brcmf_fws_schedule_deq(fws);
 	return 0;
 }
 
-- 
1.7.10.4



^ permalink raw reply related

* [PATCH 4/9] brcmfmac: use unified dongle address preparation function
From: Arend van Spriel @ 2013-06-26 12:20 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, Franky Lin, Arend van Spriel
In-Reply-To: <1372249222-4858-1-git-send-email-arend@broadcom.com>

From: Franky Lin <frankyl@broadcom.com>

Introduce a unified dongle backplane address preparation function
brcmf_sdio_addrprep to replace duplicate address prep code.

Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c   |   79 +++++++-------------
 .../net/wireless/brcm80211/brcmfmac/sdio_host.h    |    3 -
 2 files changed, 27 insertions(+), 55 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index c9c5ad2..70cd0e9 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -162,7 +162,7 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev)
 	return 0;
 }
 
-int
+static int
 brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address)
 {
 	int err = 0, i;
@@ -193,12 +193,33 @@ brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address)
 	return err;
 }
 
+static int
+brcmf_sdio_addrprep(struct brcmf_sdio_dev *sdiodev, uint width, u32 *addr)
+{
+	uint bar0 = *addr & ~SBSDIO_SB_OFT_ADDR_MASK;
+	int err = 0;
+
+	if (bar0 != sdiodev->sbwad) {
+		err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0);
+		if (err)
+			return err;
+
+		sdiodev->sbwad = bar0;
+	}
+
+	*addr &= SBSDIO_SB_OFT_ADDR_MASK;
+
+	if (width == 4)
+		*addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
+
+	return 0;
+}
+
 int
 brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
 			void *data, bool write)
 {
 	u8 func_num, reg_size;
-	u32 bar;
 	s32 retry = 0;
 	int ret;
 
@@ -218,18 +239,7 @@ brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
 		func_num = SDIO_FUNC_1;
 		reg_size = 4;
 
-		/* Set the window for SB core register */
-		bar = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
-		if (bar != sdiodev->sbwad) {
-			ret = brcmf_sdcard_set_sbaddr_window(sdiodev, bar);
-			if (ret != 0) {
-				memset(data, 0xFF, reg_size);
-				return ret;
-			}
-			sdiodev->sbwad = bar;
-		}
-		addr &= SBSDIO_SB_OFT_ADDR_MASK;
-		addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
+		brcmf_sdio_addrprep(sdiodev, reg_size, &addr);
 	}
 
 	do {
@@ -452,28 +462,6 @@ static int brcmf_sdio_buffrw(struct brcmf_sdio_dev *sdiodev, uint fn,
 	return ret;
 }
 
-static int brcmf_sdcard_recv_prepare(struct brcmf_sdio_dev *sdiodev, uint fn,
-				     uint width, u32 *addr)
-{
-	uint bar0 = *addr & ~SBSDIO_SB_OFT_ADDR_MASK;
-	int err = 0;
-
-	if (bar0 != sdiodev->sbwad) {
-		err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0);
-		if (err)
-			return err;
-
-		sdiodev->sbwad = bar0;
-	}
-
-	*addr &= SBSDIO_SB_OFT_ADDR_MASK;
-
-	if (width == 4)
-		*addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
-
-	return 0;
-}
-
 int
 brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
 		      uint flags, u8 *buf, uint nbytes)
@@ -508,7 +496,7 @@ brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
 		  fn, addr, pkt->len);
 
 	width = (flags & SDIO_REQ_4BYTE) ? 4 : 2;
-	err = brcmf_sdcard_recv_prepare(sdiodev, fn, width, &addr);
+	err = brcmf_sdio_addrprep(sdiodev, width, &addr);
 	if (err)
 		goto done;
 
@@ -532,7 +520,7 @@ int brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
 		  fn, addr, pktq->qlen);
 
 	width = (flags & SDIO_REQ_4BYTE) ? 4 : 2;
-	err = brcmf_sdcard_recv_prepare(sdiodev, fn, width, &addr);
+	err = brcmf_sdio_addrprep(sdiodev, width, &addr);
 	if (err)
 		goto done;
 
@@ -570,33 +558,20 @@ brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
 		      uint flags, struct sk_buff *pkt)
 {
 	uint width;
-	uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
 	int err = 0;
 	struct sk_buff_head pkt_list;
 
 	brcmf_dbg(SDIO, "fun = %d, addr = 0x%x, size = %d\n",
 		  fn, addr, pkt->len);
 
-	if (bar0 != sdiodev->sbwad) {
-		err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0);
-		if (err)
-			goto done;
-
-		sdiodev->sbwad = bar0;
-	}
-
-	addr &= SBSDIO_SB_OFT_ADDR_MASK;
-
 	width = (flags & SDIO_REQ_4BYTE) ? 4 : 2;
-	if (width == 4)
-		addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
+	brcmf_sdio_addrprep(sdiodev, width, &addr);
 
 	skb_queue_head_init(&pkt_list);
 	skb_queue_tail(&pkt_list, pkt);
 	err = brcmf_sdio_buffrw(sdiodev, fn, true, addr, &pkt_list);
 	skb_dequeue_tail(&pkt_list);
 
-done:
 	return err;
 }
 
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
index 69c03fe..09786a5 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
@@ -249,9 +249,6 @@ extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn);
 extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
 extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev);
 
-extern int brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev,
-					  u32 address);
-
 /* attach, return handler on success, NULL if failed.
  *  The handler shall be provided by all subsequent calls. No local cache
  *  cfghdl points to the starting address of pci device mapped memory
-- 
1.7.10.4



^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox