Skip to contentSkip to conversation

rt2800: prepare for unification of EEPROM support code

PATCH In review Bartlomiej Zolnierkiewicz 4 participants 44 messages Nov 8, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/9 rt2800: prepare for unification of EEPROM support code

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for unification of EEPROM support code

* Factor out common code from rt2800[pci,usb]_validate_eeprom() to rt2800_validate_eeprom().

* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().

* Enclose interface specific code in rt2800[pci,usb]_init_eeprom() with rt2x00_intf_is_[pci,usb]() checks.

---
on top of "rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci." patch from Gertjan

 drivers/net/wireless/rt2x00/rt2800pci.c |   51 ++++++++++++++++++--------------
 drivers/net/wireless/rt2x00/rt2800usb.c |   40 +++++++++++++++----------
 2 files changed, 55 insertions(+), 36 deletions(-)
drivers/net/wireless/rt2x00/rt2800pci.c +30 -21
Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================
@@ -1091,29 +1091,13 @@ static irqreturn_t rt2800pci_interrupt(i
 /*
  * Device probe functions.
  */
-static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 word;
 	u8 *mac;
 	u8 default_lna_gain;
 
 	/*
-	 * Read EEPROM into buffer
-	 */
-	switch(rt2x00dev->chip.rt) {
-	case RT2880:
-	case RT3052:
-		rt2800pci_read_eeprom_soc(rt2x00dev);
-		break;
-	default:
-		if (rt2800pci_efuse_detect(rt2x00dev))
-			rt2800pci_read_eeprom_efuse(rt2x00dev);
-		else
-			rt2800pci_read_eeprom_pci(rt2x00dev);
-		break;
-	}
-
-	/*
 	 * Start validation of the data that has been read.
 	 */
 	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
@@ -1131,7 +1115,7 @@ static int rt2800pci_validate_eeprom(str
 		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
 	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
 		/*
-		 * There is a max of 2 RX streams for RT2860 series
+		 * There is a max of 2 RX streams for RT28x0 series
 		 */
 		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
 			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
@@ -1210,6 +1194,27 @@ static int rt2800pci_validate_eeprom(str
 	return 0;
 }
 
+static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	/*
+	 * Read EEPROM into buffer
+	 */
+	switch (rt2x00dev->chip.rt) {
+	case RT2880:
+	case RT3052:
+		rt2800pci_read_eeprom_soc(rt2x00dev);
+		break;
+	default:
+		if (rt2800pci_efuse_detect(rt2x00dev))
+			rt2800pci_read_eeprom_efuse(rt2x00dev);
+		else
+			rt2800pci_read_eeprom_pci(rt2x00dev);
+		break;
+	}
+
+	return rt2800_validate_eeprom(rt2x00dev);
+}
+
 static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -1226,7 +1231,9 @@ static int rt2800pci_init_eeprom(struct 
 	 */
 	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
 	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-	rt2x00_set_chip_rf(rt2x00dev, value, reg);
+
+	if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00_set_chip_rf(rt2x00dev, value, reg);
 
 	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct 
 	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3022)) {
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
 		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
 		return -ENODEV;
 	}
drivers/net/wireless/rt2x00/rt2800usb.c +25 -15
Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================
@@ -665,14 +665,12 @@ static void rt2800usb_fill_rxdone(struct
 /*
  * Device probe functions.
  */
-static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 word;
 	u8 *mac;
 	u8 default_lna_gain;
 
-	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
-
 	/*
 	 * Start validation of the data that has been read.
 	 */
@@ -691,7 +689,7 @@ static int rt2800usb_validate_eeprom(str
 		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
 	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
 		/*
-		 * There is a max of 2 RX streams for RT2870 series
+		 * There is a max of 2 RX streams for RT28x0 series
 		 */
 		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
 			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
@@ -770,6 +768,13 @@ static int rt2800usb_validate_eeprom(str
 	return 0;
 }
 
+static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+
+	return rt2800_validate_eeprom(rt2x00dev);
+}
+
 static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -786,18 +791,23 @@ static int rt2800usb_init_eeprom(struct 
 	 */
 	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
 	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-	rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
 
-	/*
-	 * The check for rt2860 is not a typo, some rt2870 hardware
-	 * identifies itself as rt2860 in the CSR register.
-	 */
-	if (!rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28600000) &&
-	    !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28700000) &&
-	    !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28800000) &&
-	    !rt2x00_check_rev(&rt2x00dev->chip, 0xffff0000, 0x30700000)) {
-		ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
-		return -ENODEV;
+	if (rt2x00_intf_is_usb(rt2x00dev)) {
+		struct rt2x00_chip *chip = &rt2x00dev->chip;
+
+		rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
+
+		/*
+		 * The check for rt2860 is not a typo, some rt2870 hardware
+		 * identifies itself as rt2860 in the CSR register.
+		 */
+		if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) &&
+		    !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) {
+			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
+			return -ENODEV;
+		}
 	}
 
 	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
#1 lore raw

PATCH 2/9 rt2800: unify EEPROM support code

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: unify EEPROM support code

Add rt2800_validate_eeprom() and rt2800_init_eeprom() to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800lib.c |  199 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    3 
 drivers/net/wireless/rt2x00/rt2800pci.c |  183 -----------------------------
 drivers/net/wireless/rt2x00/rt2800usb.c |  195 -------------------------------
 4 files changed, 204 insertions(+), 376 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +199 -0
Index: b/drivers/net/wireless/rt2x00/rt2800lib.c
===================================================================
@@ -1659,6 +1659,205 @@ int rt2800_init_rfcsr(struct rt2x00_dev 
 }
 EXPORT_SYMBOL_GPL(rt2800_init_rfcsr);
 
+int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	u16 word;
+	u8 *mac;
+	u8 default_lna_gain;
+
+	/*
+	 * Start validation of the data that has been read.
+	 */
+	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+	if (!is_valid_ether_addr(mac)) {
+		random_ether_addr(mac);
+		EEPROM(rt2x00dev, "MAC: %pM\n", mac);
+	}
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
+	if (word == 0xffff) {
+		rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
+		rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
+		rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
+		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
+	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
+		/*
+		 * There is a max of 2 RX streams for RT28x0 series
+		 */
+		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
+			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
+	}
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
+	if (word == 0xffff) {
+		rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
+		EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
+	}
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
+	if ((word & 0x00ff) == 0x00ff) {
+		rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
+		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_LED1, 0x5555);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
+		EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
+	}
+
+	/*
+	 * During the LNA validation we are going to use
+	 * lna0 as correct value. Note that EEPROM_LNA
+	 * is never validated.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
+	default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
+
+	rt2x00_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);
+
+	rt2x00_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);
+
+	rt2x00_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);
+
+	rt2x00_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);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_validate_eeprom);
+
+int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	u32 reg;
+	u16 value;
+	u16 eeprom;
+
+	/*
+	 * Read EEPROM word for configuration.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+	/*
+	 * Identify RF chipset.
+	 */
+	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
+	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
+
+	if (rt2x00_intf_is_usb(rt2x00dev)) {
+		struct rt2x00_chip *chip = &rt2x00dev->chip;
+
+		rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
+
+		/*
+		 * The check for rt2860 is not a typo, some rt2870 hardware
+		 * identifies itself as rt2860 in the CSR register.
+		 */
+		if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) &&
+		    !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) {
+			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
+			return -ENODEV;
+		}
+	} else if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00_set_chip_rf(rt2x00dev, value, reg);
+
+	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
+		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
+		return -ENODEV;
+	}
+
+	/*
+	 * Identify default antenna configuration.
+	 */
+	rt2x00dev->default_ant.tx =
+	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH);
+	rt2x00dev->default_ant.rx =
+	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH);
+
+	/*
+	 * Read frequency offset and RF programming sequence.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
+
+	/*
+	 * Read external LNA informations.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
+
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
+		__set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
+		__set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
+
+	/*
+	 * Detect if this device has an hardware controlled radio.
+	 */
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
+		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+
+	/*
+	 * Store led settings, for correct led behaviour.
+	 */
+#ifdef CONFIG_RT2X00_LIB_LEDS
+	rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
+	rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
+	rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &rt2x00dev->led_mcu_reg);
+#endif /* CONFIG_RT2X00_LIB_LEDS */
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_init_eeprom);
+
 /*
  * IEEE80211 stack callback functions.
  */
drivers/net/wireless/rt2x00/rt2800lib.h +3 -0
Index: b/drivers/net/wireless/rt2x00/rt2800lib.h
===================================================================
@@ -129,6 +129,9 @@ int rt2800_init_registers(struct rt2x00_
 int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
 
+int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
+int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
+
 extern const struct ieee80211_ops rt2800_mac80211_ops;
 
 #endif /* RT2800LIB_H */
drivers/net/wireless/rt2x00/rt2800pci.c +1 -182

201 lines not on this page · raw message

drivers/net/wireless/rt2x00/rt2800usb.c +1 -194

213 lines not on this page · raw message

Acked-by on v1 2/9
#2 lore raw

Re: [PATCH 2/9] rt2800: unify EEPROM support code

Quoted 6 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: unify EEPROM support code

Add rt2800_validate_eeprom() and rt2800_init_eeprom() to rt2800lib.

Quoted 660 lines
---
 drivers/net/wireless/rt2x00/rt2800lib.c |  199 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    3 
 drivers/net/wireless/rt2x00/rt2800pci.c |  183 -----------------------------
 drivers/net/wireless/rt2x00/rt2800usb.c |  195 -------------------------------
 4 files changed, 204 insertions(+), 376 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800lib.c
===================================================================

drivers/net/wireless/rt2x00/rt2800lib.c +199 -0
@@ -1659,6 +1659,205 @@ int rt2800_init_rfcsr(struct rt2x00_dev 
 }
 EXPORT_SYMBOL_GPL(rt2800_init_rfcsr);
 
+int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	u16 word;
+	u8 *mac;
+	u8 default_lna_gain;
+
+	/*
+	 * Start validation of the data that has been read.
+	 */
+	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+	if (!is_valid_ether_addr(mac)) {
+		random_ether_addr(mac);
+		EEPROM(rt2x00dev, "MAC: %pM\n", mac);
+	}
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
+	if (word == 0xffff) {
+		rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
+		rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
+		rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
+		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
+	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
+		/*
+		 * There is a max of 2 RX streams for RT28x0 series
+		 */
+		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
+			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
+	}
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
+	if (word == 0xffff) {
+		rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0);
+		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
+		EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
+	}
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
+	if ((word & 0x00ff) == 0x00ff) {
+		rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
+		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_LED1, 0x5555);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
+		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
+		EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
+	}
+
+	/*
+	 * During the LNA validation we are going to use
+	 * lna0 as correct value. Note that EEPROM_LNA
+	 * is never validated.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
+	default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
+
+	rt2x00_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);
+
+	rt2x00_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);
+
+	rt2x00_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);
+
+	rt2x00_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);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_validate_eeprom);
+
+int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	u32 reg;
+	u16 value;
+	u16 eeprom;
+
+	/*
+	 * Read EEPROM word for configuration.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+	/*
+	 * Identify RF chipset.
+	 */
+	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
+	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
+
+	if (rt2x00_intf_is_usb(rt2x00dev)) {
+		struct rt2x00_chip *chip = &rt2x00dev->chip;
+
+		rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
+
+		/*
+		 * The check for rt2860 is not a typo, some rt2870 hardware
+		 * identifies itself as rt2860 in the CSR register.
+		 */
+		if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) &&
+		    !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) {
+			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
+			return -ENODEV;
+		}
+	} else if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00_set_chip_rf(rt2x00dev, value, reg);
+
+	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
+	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
+		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
+		return -ENODEV;
+	}
+
+	/*
+	 * Identify default antenna configuration.
+	 */
+	rt2x00dev->default_ant.tx =
+	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH);
+	rt2x00dev->default_ant.rx =
+	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH);
+
+	/*
+	 * Read frequency offset and RF programming sequence.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
+	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
+
+	/*
+	 * Read external LNA informations.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
+
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
+		__set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
+		__set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
+
+	/*
+	 * Detect if this device has an hardware controlled radio.
+	 */
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
+		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+
+	/*
+	 * Store led settings, for correct led behaviour.
+	 */
+#ifdef CONFIG_RT2X00_LIB_LEDS
+	rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
+	rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
+	rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &rt2x00dev->led_mcu_reg);
+#endif /* CONFIG_RT2X00_LIB_LEDS */
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_init_eeprom);
+
 /*
  * IEEE80211 stack callback functions.
  */

Index: b/drivers/net/wireless/rt2x00/rt2800lib.h
===================================================================

drivers/net/wireless/rt2x00/rt2800lib.h +3 -0
@@ -129,6 +129,9 @@ int rt2800_init_registers(struct rt2x00_
 int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
 
+int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
+int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
+
 extern const struct ieee80211_ops rt2800_mac80211_ops;
 
 #endif /* RT2800LIB_H */

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +1 -182
@@ -1077,109 +1077,6 @@ static irqreturn_t rt2800pci_interrupt(i
 /*
  * Device probe functions.
  */
-static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
-{
-	u16 word;
-	u8 *mac;
-	u8 default_lna_gain;
-
-	/*
-	 * Start validation of the data that has been read.
-	 */
-	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
-	if (!is_valid_ether_addr(mac)) {
-		random_ether_addr(mac);
-		EEPROM(rt2x00dev, "MAC: %pM\n", mac);
-	}
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
-	if (word == 0xffff) {
-		rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
-		rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
-		rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
-		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
-	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
-		/*
-		 * There is a max of 2 RX streams for RT28x0 series
-		 */
-		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
-			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
-	}
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
-	if (word == 0xffff) {
-		rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
-		EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
-	}
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
-	if ((word & 0x00ff) == 0x00ff) {
-		rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
-		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_LED1, 0x5555);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
-		EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
-	}
-
-	/*
-	 * During the LNA validation we are going to use
-	 * lna0 as correct value. Note that EEPROM_LNA
-	 * is never validated.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
-	default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
-
-	rt2x00_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);
-
-	rt2x00_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);
-
-	rt2x00_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);
-
-	rt2x00_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);
-
-	return 0;
-}
-
 static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	/*
@@ -1201,84 +1098,6 @@ static int rt2800pci_validate_eeprom(str
 	return rt2800_validate_eeprom(rt2x00dev);
 }
 
-static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
-{
-	u32 reg;
-	u16 value;
-	u16 eeprom;
-
-	/*
-	 * Read EEPROM word for configuration.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
-
-	/*
-	 * Identify RF chipset.
-	 */
-	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
-	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-
-	if (rt2x00_intf_is_pci(rt2x00dev))
-		rt2x00_set_chip_rf(rt2x00dev, value, reg);
-
-	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
-	    (rt2x00_intf_is_usb(rt2x00dev) ||
-	     (rt2x00_intf_is_pci(rt2x00dev) &&
-	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
-	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
-		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
-		return -ENODEV;
-	}
-
-	/*
-	 * Identify default antenna configuration.
-	 */
-	rt2x00dev->default_ant.tx =
-	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH);
-	rt2x00dev->default_ant.rx =
-	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH);
-
-	/*
-	 * Read frequency offset and RF programming sequence.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
-	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
-
-	/*
-	 * Read external LNA informations.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
-
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
-		__set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
-		__set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
-
-	/*
-	 * Detect if this device has an hardware controlled radio.
-	 */
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
-		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
-
-	/*
-	 * Store led settings, for correct led behaviour.
-	 */
-#ifdef CONFIG_RT2X00_LIB_LEDS
-	rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
-	rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
-	rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &rt2x00dev->led_mcu_reg);
-#endif /* CONFIG_RT2X00_LIB_LEDS */
-
-	return 0;
-}
-
 /*
  * RF value list for rt2860
  * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
@@ -1485,7 +1304,7 @@ static int rt2800pci_probe_hw(struct rt2
 	if (retval)
 		return retval;
 
-	retval = rt2800pci_init_eeprom(rt2x00dev);
+	retval = rt2800_init_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +1 -194
@@ -665,109 +665,6 @@ static void rt2800usb_fill_rxdone(struct
 /*
  * Device probe functions.
  */
-static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
-{
-	u16 word;
-	u8 *mac;
-	u8 default_lna_gain;
-
-	/*
-	 * Start validation of the data that has been read.
-	 */
-	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
-	if (!is_valid_ether_addr(mac)) {
-		random_ether_addr(mac);
-		EEPROM(rt2x00dev, "MAC: %pM\n", mac);
-	}
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
-	if (word == 0xffff) {
-		rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
-		rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
-		rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
-		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
-	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
-		/*
-		 * There is a max of 2 RX streams for RT28x0 series
-		 */
-		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
-			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
-	}
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
-	if (word == 0xffff) {
-		rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0);
-		rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
-		EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
-	}
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
-	if ((word & 0x00ff) == 0x00ff) {
-		rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
-		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_LED1, 0x5555);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
-		rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
-		EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
-	}
-
-	/*
-	 * During the LNA validation we are going to use
-	 * lna0 as correct value. Note that EEPROM_LNA
-	 * is never validated.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
-	default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
-
-	rt2x00_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);
-
-	rt2x00_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);
-
-	rt2x00_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);
-
-	rt2x00_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);
-
-	return 0;
-}
-
 static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
@@ -775,96 +672,6 @@ static int rt2800usb_validate_eeprom(str
 	return rt2800_validate_eeprom(rt2x00dev);
 }
 
-static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
-{
-	u32 reg;
-	u16 value;
-	u16 eeprom;
-
-	/*
-	 * Read EEPROM word for configuration.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
-
-	/*
-	 * Identify RF chipset.
-	 */
-	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
-	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-
-	if (rt2x00_intf_is_usb(rt2x00dev)) {
-		struct rt2x00_chip *chip = &rt2x00dev->chip;
-
-		rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
-
-		/*
-		 * The check for rt2860 is not a typo, some rt2870 hardware
-		 * identifies itself as rt2860 in the CSR register.
-		 */
-		if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) &&
-		    !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) &&
-		    !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) &&
-		    !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) {
-			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
-			return -ENODEV;
-		}
-	}
-
-	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF2020)) {
-		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
-		return -ENODEV;
-	}
-
-	/*
-	 * Identify default antenna configuration.
-	 */
-	rt2x00dev->default_ant.tx =
-	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH);
-	rt2x00dev->default_ant.rx =
-	    rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH);
-
-	/*
-	 * Read frequency offset and RF programming sequence.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
-	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
-
-	/*
-	 * Read external LNA informations.
-	 */
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
-
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
-		__set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
-		__set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
-
-	/*
-	 * Detect if this device has an hardware controlled radio.
-	 */
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
-		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
-
-	/*
-	 * Store led settings, for correct led behaviour.
-	 */
-#ifdef CONFIG_RT2X00_LIB_LEDS
-	rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
-	rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
-	rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ,
-			   &rt2x00dev->led_mcu_reg);
-#endif /* CONFIG_RT2X00_LIB_LEDS */
-
-	return 0;
-}
-
 /*
  * RF value list for rt2870
  * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
@@ -1095,7 +902,7 @@ static int rt2800usb_probe_hw(struct rt2
 	if (retval)
 		return retval;
 
-	retval = rt2800usb_init_eeprom(rt2x00dev);
+	retval = rt2800_init_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 
Acked-by on v1 2/9
#3 lore raw

Re: [PATCH 2/9] rt2800: unify EEPROM support code

In reply to Bartlomiej Zolnierkiewicz
Quoted 7 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: unify EEPROM support code

Add rt2800_validate_eeprom() and rt2800_init_eeprom() to rt2800lib.

---

If comments to [PATCH 1/9] have been taken into account.

#4 lore raw

PATCH 3/9 rt2800pci: add missing RF values to rf_vals table

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800pci: add missing RF values to rf_vals table

rt2800pci's rf_vals[] copy was missing values for some channels.

---
 drivers/net/wireless/rt2x00/rt2800pci.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/net/wireless/rt2x00/rt2800pci.c +4 -0
Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================
@@ -1158,6 +1158,10 @@ static const struct rf_channel rf_vals[]
 	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
 	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
 	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
+	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
+	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
+	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
+	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
 
 	/* 802.11 Japan */
 	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
Acked-by on v1 3/9
#5 lore raw

Re: [PATCH 3/9] rt2800pci: add missing RF values to rf_vals table

Quoted 6 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800pci: add missing RF values to rf_vals table

rt2800pci's rf_vals[] copy was missing values for some channels.

Quoted 20 lines
---
 drivers/net/wireless/rt2x00/rt2800pci.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +4 -0
@@ -1158,6 +1158,10 @@ static const struct rf_channel rf_vals[]
 	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
 	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
 	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
+	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
+	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
+	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
+	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
 
 	/* 802.11 Japan */
 	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
Acked-by on v1 3/9
#6 lore raw

Re: [PATCH 3/9] rt2800pci: add missing RF values to rf_vals table

In reply to Bartlomiej Zolnierkiewicz
Quoted 7 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800pci: add missing RF values to rf_vals table

rt2800pci's rf_vals[] copy was missing values for some channels.

---

#7 lore raw

PATCH 4/9 rt2800usb: reorganize code in rt2800usb_probe_hw_mode()

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: reorganize code in rt2800usb_probe_hw_mode()

Move hw_mode information initialization code block before HT information initialization one to match the ordering used by rt2800pci's rt2800pci_probe_hw_mode().

---
 drivers/net/wireless/rt2x00/rt2800usb.c |   42 ++++++++++++++++----------------
 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +21 -21
Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================
@@ -795,6 +795,27 @@ static int rt2800usb_probe_hw_mode(struc
 	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
 
 	/*
+	 * Initialize hw_mode information.
+	 */
+	spec->supported_bands = SUPPORT_BAND_2GHZ;
+	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
+
+	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
+	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+		spec->num_channels = 14;
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
+		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+		spec->supported_bands |= SUPPORT_BAND_5GHZ;
+		spec->num_channels = ARRAY_SIZE(rf_vals);
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
+		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
+		spec->channels = rf_vals_3070;
+	}
+
+	/*
 	 * Initialize HT information.
 	 */
 	spec->ht.ht_supported = true;
@@ -826,27 +847,6 @@ static int rt2800usb_probe_hw_mode(struc
 	}
 
 	/*
-	 * Initialize hw_mode information.
-	 */
-	spec->supported_bands = SUPPORT_BAND_2GHZ;
-	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
-
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
-		spec->num_channels = 14;
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
-		spec->supported_bands |= SUPPORT_BAND_5GHZ;
-		spec->num_channels = ARRAY_SIZE(rf_vals);
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
-		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
-		spec->channels = rf_vals_3070;
-	}
-
-	/*
 	 * Create channel information array
 	 */
 	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
Acked-by on v1 4/9
#8 lore raw

Re: [PATCH 4/9] rt2800usb: reorganize code in rt2800usb_probe_hw_mode()

Quoted 8 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: reorganize code in rt2800usb_probe_hw_mode()

Move hw_mode information initialization code block before HT information initialization one to match the ordering used by rt2800pci's rt2800pci_probe_hw_mode().

Quoted 65 lines
---
 drivers/net/wireless/rt2x00/rt2800usb.c |   42 ++++++++++++++++----------------
 1 file changed, 21 insertions(+), 21 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +21 -21
@@ -795,6 +795,27 @@ static int rt2800usb_probe_hw_mode(struc
 	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
 
 	/*
+	 * Initialize hw_mode information.
+	 */
+	spec->supported_bands = SUPPORT_BAND_2GHZ;
+	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
+
+	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
+	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+		spec->num_channels = 14;
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
+		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+		spec->supported_bands |= SUPPORT_BAND_5GHZ;
+		spec->num_channels = ARRAY_SIZE(rf_vals);
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
+		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
+		spec->channels = rf_vals_3070;
+	}
+
+	/*
 	 * Initialize HT information.
 	 */
 	spec->ht.ht_supported = true;
@@ -826,27 +847,6 @@ static int rt2800usb_probe_hw_mode(struc
 	}
 
 	/*
-	 * Initialize hw_mode information.
-	 */
-	spec->supported_bands = SUPPORT_BAND_2GHZ;
-	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
-
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
-		spec->num_channels = 14;
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
-		spec->supported_bands |= SUPPORT_BAND_5GHZ;
-		spec->num_channels = ARRAY_SIZE(rf_vals);
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
-		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
-		spec->channels = rf_vals_3070;
-	}
-
-	/*
 	 * Create channel information array
 	 */
 	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
Acked-by on v1 4/9
#9 lore raw

Re: [PATCH 4/9] rt2800usb: reorganize code in rt2800usb_probe_hw_mode()

In reply to Bartlomiej Zolnierkiewicz
Quoted 9 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: reorganize code in rt2800usb_probe_hw_mode()

Move hw_mode information initialization code block before HT information initialization one to match the ordering used by rt2800pci's rt2800pci_probe_hw_mode().

---

#10 lore raw

PATCH 5/9 rt2800: prepare for rt2800*_probe_hw_mode() unification

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for rt2800*_probe_hw_mode() unification

Enclose interface specific code in rt2800[pci,usb]_probe_hw_mode() with rt2x00_intf_is_[pci,usb]() checks.

---
 drivers/net/wireless/rt2x00/rt2800pci.c |   24 ++++++++++++++----------
 drivers/net/wireless/rt2x00/rt2800usb.c |   19 ++++++++++++-------
 2 files changed, 26 insertions(+), 17 deletions(-)
drivers/net/wireless/rt2x00/rt2800pci.c +14 -10
Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================
@@ -1175,6 +1175,7 @@ static const struct rf_channel rf_vals[]
 
 static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
 	struct hw_mode_spec *spec = &rt2x00dev->spec;
 	struct channel_info *info;
 	char *tx_power1;
@@ -1190,7 +1191,9 @@ static int rt2800pci_probe_hw_mode(struc
 	    IEEE80211_HW_SIGNAL_DBM |
 	    IEEE80211_HW_SUPPORTS_PS |
 	    IEEE80211_HW_PS_NULLFUNC_STACK;
-	rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
+
+	if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -1205,17 +1208,18 @@ static int rt2800pci_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3021) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3022) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2020) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3052)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720) ||
+	    (rt2x00_intf_is_pci(rt2x00dev) &&
+	     (rt2x00_rf(chip, RF3020) ||
+	      rt2x00_rf(chip, RF3021) ||
+	      rt2x00_rf(chip, RF3022) ||
+	      rt2x00_rf(chip, RF2020) ||
+	      rt2x00_rf(chip, RF3052)))) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;
drivers/net/wireless/rt2x00/rt2800usb.c +12 -7
Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================
@@ -770,6 +770,7 @@ static const struct rf_channel rf_vals_3
 
 static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
 	struct hw_mode_spec *spec = &rt2x00dev->spec;
 	struct channel_info *info;
 	char *tx_power1;
@@ -785,7 +786,10 @@ static int rt2800usb_probe_hw_mode(struc
 	    IEEE80211_HW_SIGNAL_DBM |
 	    IEEE80211_HW_SUPPORTS_PS |
 	    IEEE80211_HW_PS_NULLFUNC_STACK;
-	rt2x00dev->hw->extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+
+	if (rt2x00_intf_is_usb(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom =
+			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -800,17 +804,18 @@ static int rt2800usb_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720)) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
 		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
 		spec->channels = rf_vals_3070;
 	}
Acked-by on v1 5/9
#11 lore raw

Re: [PATCH 5/9] rt2800: prepare for rt2800*_probe_hw_mode() unification

Quoted 7 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for rt2800*_probe_hw_mode() unification

Enclose interface specific code in rt2800[pci,usb]_probe_hw_mode() with rt2x00_intf_is_[pci,usb]() checks.

Quoted 106 lines
---
 drivers/net/wireless/rt2x00/rt2800pci.c |   24 ++++++++++++++----------
 drivers/net/wireless/rt2x00/rt2800usb.c |   19 ++++++++++++-------
 2 files changed, 26 insertions(+), 17 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +14 -10
@@ -1175,6 +1175,7 @@ static const struct rf_channel rf_vals[]
 
 static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
 	struct hw_mode_spec *spec = &rt2x00dev->spec;
 	struct channel_info *info;
 	char *tx_power1;
@@ -1190,7 +1191,9 @@ static int rt2800pci_probe_hw_mode(struc
 	    IEEE80211_HW_SIGNAL_DBM |
 	    IEEE80211_HW_SUPPORTS_PS |
 	    IEEE80211_HW_PS_NULLFUNC_STACK;
-	rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
+
+	if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -1205,17 +1208,18 @@ static int rt2800pci_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3021) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3022) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2020) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3052)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720) ||
+	    (rt2x00_intf_is_pci(rt2x00dev) &&
+	     (rt2x00_rf(chip, RF3020) ||
+	      rt2x00_rf(chip, RF3021) ||
+	      rt2x00_rf(chip, RF3022) ||
+	      rt2x00_rf(chip, RF2020) ||
+	      rt2x00_rf(chip, RF3052)))) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +12 -7
@@ -770,6 +770,7 @@ static const struct rf_channel rf_vals_3
 
 static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
 	struct hw_mode_spec *spec = &rt2x00dev->spec;
 	struct channel_info *info;
 	char *tx_power1;
@@ -785,7 +786,10 @@ static int rt2800usb_probe_hw_mode(struc
 	    IEEE80211_HW_SIGNAL_DBM |
 	    IEEE80211_HW_SUPPORTS_PS |
 	    IEEE80211_HW_PS_NULLFUNC_STACK;
-	rt2x00dev->hw->extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+
+	if (rt2x00_intf_is_usb(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom =
+			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -800,17 +804,18 @@ static int rt2800usb_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720)) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
 		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
 		spec->channels = rf_vals_3070;
 	}
#12 lore raw

Re: [PATCH 5/9] rt2800: prepare for rt2800*_probe_hw_mode() unification

In reply to Bartlomiej Zolnierkiewicz
Quoted 103 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for rt2800*_probe_hw_mode() unification

Enclose interface specific code in rt2800[pci,usb]_probe_hw_mode() with rt2x00_intf_is_[pci,usb]() checks.

---
 drivers/net/wireless/rt2x00/rt2800pci.c |   24 ++++++++++++++----------
 drivers/net/wireless/rt2x00/rt2800usb.c |   19 ++++++++++++-------
 2 files changed, 26 insertions(+), 17 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +14 -10
@@ -1175,6 +1175,7 @@ static const struct rf_channel rf_vals[]
 
 static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
 	struct hw_mode_spec *spec = &rt2x00dev->spec;
 	struct channel_info *info;
 	char *tx_power1;
@@ -1190,7 +1191,9 @@ static int rt2800pci_probe_hw_mode(struc
 	    IEEE80211_HW_SIGNAL_DBM |
 	    IEEE80211_HW_SUPPORTS_PS |
 	    IEEE80211_HW_PS_NULLFUNC_STACK;
-	rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
+
+	if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -1205,17 +1208,18 @@ static int rt2800pci_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3021) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3022) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2020) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF3052)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720) ||
+	    (rt2x00_intf_is_pci(rt2x00dev) &&
+	     (rt2x00_rf(chip, RF3020) ||
+	      rt2x00_rf(chip, RF3021) ||
+	      rt2x00_rf(chip, RF3022) ||
+	      rt2x00_rf(chip, RF2020) ||
+	      rt2x00_rf(chip, RF3052)))) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +9 -5
@@ -770,6 +770,7 @@ static const struct rf_channel rf_vals_3
 
 static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
 	struct hw_mode_spec *spec = &rt2x00dev->spec;
 	struct channel_info *info;
 	char *tx_power1;
@@ -785,7 +786,10 @@ static int rt2800usb_probe_hw_mode(struc
 	    IEEE80211_HW_SIGNAL_DBM |
 	    IEEE80211_HW_SUPPORTS_PS |
 	    IEEE80211_HW_PS_NULLFUNC_STACK;
-	rt2x00dev->hw->extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+
+	if (rt2x00_intf_is_usb(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom =
+			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
 
 	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
 	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -800,17 +804,18 @@ static int rt2800usb_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720)) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;

drivers/net/wireless/rt2x00/rt2800usb.c static int rt2800usb_probe_hw_mode(struc · line 821

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800usb.c +3 -2
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
 		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
 		spec->channels = rf_vals_3070;
 	}

Hmm, another one where we can benefit from decoupling RF chipset code from the actual interface (USB or PCI) used. I do not see the need to check for USB or PCI support, we just need to unify on the RF chipset level.

BTW this rf_vals_3070 initialization looks weird. It doesn't resemble any other rf_channel initializations we have. I'd say we can go with the rt2800pci variant of the initialization here.

---
Gertjan.

#13 lore raw

Re: [PATCH 5/9] rt2800: prepare for rt2800*_probe_hw_mode() unification

Quoted 8 lines · On Sunday 08 November 2009 15:35:19 Gertjan van Wingerde wrote:
Quoted 7 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for rt2800*_probe_hw_mode() unification

Enclose interface specific code in rt2800[pci,usb]_probe_hw_mode() with rt2x00_intf_is_[pci,usb]() checks.

[ please remove needles parts of mails, thanks! ]

Quoted 30 lines
Quoted 16 lines
drivers/net/wireless/rt2x00/rt2800usb.c +4 -4
@@ -800,17 +804,18 @@ static int rt2800usb_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720)) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;

drivers/net/wireless/rt2x00/rt2800usb.c static int rt2800usb_probe_hw_mode(struc · line 821

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800usb.c +3 -2
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
 		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
 		spec->channels = rf_vals_3070;
 	}

Hmm, another one where we can benefit from decoupling RF chipset code from the actual interface (USB or PCI) used. I do not see the need to check for USB or PCI support, we just need to unify on the RF chipset level.

Quoted 1 line

BTW this rf_vals_3070 initialization looks weird. It doesn't resemble any other rf_channel initializations we have. I'd say we can go with the rt2800pci variant of the initialization here.

IIRC from the vendor driver rf_vals_3070 is needed so by working in the incremental way I prefer to leave it as it is before somebody verifies this with the vendor driver, also it should be a separate patch for better bisectability anyway.

Signature · 1 line
Bartlomiej Zolnierkiewicz
#14 lore raw

Re: [PATCH 5/9] rt2800: prepare for rt2800*_probe_hw_mode() unification

Quoted 42 lines · Bartlomiej Zolnierkiewicz
Quoted 8 lines · On Sunday 08 November 2009 15:35:19 Gertjan van Wingerde wrote:
Quoted 7 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for rt2800*_probe_hw_mode() unification

Enclose interface specific code in rt2800[pci,usb]_probe_hw_mode() with rt2x00_intf_is_[pci,usb]() checks.

[ please remove needles parts of mails, thanks! ]

Quoted 30 lines
Quoted 16 lines
drivers/net/wireless/rt2x00/rt2800usb.c +4 -4
@@ -800,17 +804,18 @@ static int rt2800usb_probe_hw_mode(struc
 	spec->supported_bands = SUPPORT_BAND_2GHZ;
 	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2720)) {
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720)) {
 		spec->num_channels = 14;
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2750)) {
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
 		spec->supported_bands |= SUPPORT_BAND_5GHZ;

drivers/net/wireless/rt2x00/rt2800usb.c static int rt2800usb_probe_hw_mode(struc · line 821

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800usb.c +3 -2
 		spec->num_channels = ARRAY_SIZE(rf_vals);
 		spec->channels = rf_vals;
-	} else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
-		   rt2x00_rf(&rt2x00dev->chip, RF2020)) {
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
 		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
 		spec->channels = rf_vals_3070;
 	}

Hmm, another one where we can benefit from decoupling RF chipset code from the actual interface (USB or PCI) used. I do not see the need to check for USB or PCI support, we just need to unify on the RF chipset level.

Quoted 7 lines
Quoted 1 line

BTW this rf_vals_3070 initialization looks weird. It doesn't resemble any other rf_channel initializations we have. I'd say we can go with the rt2800pci variant of the initialization here.

IIRC from the vendor driver rf_vals_3070 is needed so by working in the incremental way I prefer to leave it as it is before somebody verifies this with the vendor driver, also it should be a separate patch for better bisectability anyway.

The vendor driver does this in a slightly different way. I was caught off-guard on the complexity of this code. I'll look at that myself. So, on second thought,

---
Gertjan.

#15 lore raw

PATCH 6/9 rt2800: unify rt2800*_probe_hw_mode()

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: unify rt2800*_probe_hw_mode()

Add rf_vals tables and rt2800_probe_hw_mode() to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800lib.c |  218 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    1 
 drivers/net/wireless/rt2x00/rt2800pci.c |  190 ---------------------------
 drivers/net/wireless/rt2x00/rt2800usb.c |  211 ------------------------------
 4 files changed, 221 insertions(+), 399 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +218 -0
Index: b/drivers/net/wireless/rt2x00/rt2800lib.c
===================================================================
@@ -1859,6 +1859,224 @@ int rt2800_init_eeprom(struct rt2x00_dev
 EXPORT_SYMBOL_GPL(rt2800_init_eeprom);
 
 /*
+ * RF value list for rt28x0
+ * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
+ */
+static const struct rf_channel rf_vals[] = {
+	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
+	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
+	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
+	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
+	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
+	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
+	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
+	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
+	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
+	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
+	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
+	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
+	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
+	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
+
+	/* 802.11 UNI / HyperLan 2 */
+	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
+	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
+	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
+	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
+	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
+	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
+	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
+	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
+	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
+	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
+	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
+	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
+
+	/* 802.11 HyperLan 2 */
+	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
+	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
+	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
+	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
+	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
+	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
+	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
+	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
+	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
+	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
+	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
+	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
+	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
+	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
+	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
+	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
+
+	/* 802.11 UNII */
+	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
+	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
+	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
+	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
+	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
+	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
+	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
+	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
+	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
+	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
+	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
+
+	/* 802.11 Japan */
+	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
+	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
+	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
+	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
+	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
+	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
+	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
+};
+
+/*
+ * RF value list for rt3070
+ * Supports: 2.4 GHz
+ */
+static const struct rf_channel rf_vals_3070[] = {
+	{1,  241, 2, 2 },
+	{2,  241, 2, 7 },
+	{3,  242, 2, 2 },
+	{4,  242, 2, 7 },
+	{5,  243, 2, 2 },
+	{6,  243, 2, 7 },
+	{7,  244, 2, 2 },
+	{8,  244, 2, 7 },
+	{9,  245, 2, 2 },
+	{10, 245, 2, 7 },
+	{11, 246, 2, 2 },
+	{12, 246, 2, 7 },
+	{13, 247, 2, 2 },
+	{14, 248, 2, 4 },
+};
+
+int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+{
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
+	struct hw_mode_spec *spec = &rt2x00dev->spec;
+	struct channel_info *info;
+	char *tx_power1;
+	char *tx_power2;
+	unsigned int i;
+	u16 eeprom;
+
+	/*
+	 * Initialize all hw fields.
+	 */
+	rt2x00dev->hw->flags =
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
+	    IEEE80211_HW_SIGNAL_DBM |
+	    IEEE80211_HW_SUPPORTS_PS |
+	    IEEE80211_HW_PS_NULLFUNC_STACK;
+
+	if (rt2x00_intf_is_usb(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom =
+			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+	else if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
+
+	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
+	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
+				rt2x00_eeprom_addr(rt2x00dev,
+						   EEPROM_MAC_ADDR_0));
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+	/*
+	 * Initialize hw_mode information.
+	 */
+	spec->supported_bands = SUPPORT_BAND_2GHZ;
+	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
+
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720) ||
+	    (rt2x00_intf_is_pci(rt2x00dev) &&
+	     (rt2x00_rf(chip, RF3020) ||
+	      rt2x00_rf(chip, RF3021) ||
+	      rt2x00_rf(chip, RF3022) ||
+	      rt2x00_rf(chip, RF2020) ||
+	      rt2x00_rf(chip, RF3052)))) {
+		spec->num_channels = 14;
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
+		spec->supported_bands |= SUPPORT_BAND_5GHZ;
+		spec->num_channels = ARRAY_SIZE(rf_vals);
+		spec->channels = rf_vals;
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
+		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
+		spec->channels = rf_vals_3070;
+	}
+
+	/*
+	 * Initialize HT information.
+	 */
+	spec->ht.ht_supported = true;
+	spec->ht.cap =
+	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+	    IEEE80211_HT_CAP_GRN_FLD |
+	    IEEE80211_HT_CAP_SGI_20 |
+	    IEEE80211_HT_CAP_SGI_40 |
+	    IEEE80211_HT_CAP_TX_STBC |
+	    IEEE80211_HT_CAP_RX_STBC |
+	    IEEE80211_HT_CAP_PSMP_SUPPORT;
+	spec->ht.ampdu_factor = 3;
+	spec->ht.ampdu_density = 4;
+	spec->ht.mcs.tx_params =
+	    IEEE80211_HT_MCS_TX_DEFINED |
+	    IEEE80211_HT_MCS_TX_RX_DIFF |
+	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
+		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
+
+	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
+	case 3:
+		spec->ht.mcs.rx_mask[2] = 0xff;
+	case 2:
+		spec->ht.mcs.rx_mask[1] = 0xff;
+	case 1:
+		spec->ht.mcs.rx_mask[0] = 0xff;
+		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
+		break;
+	}
+
+	/*
+	 * Create channel information array
+	 */
+	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	spec->channels_info = info;
+
+	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
+	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
+
+	for (i = 0; i < 14; i++) {
+		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
+		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
+	}
+
+	if (spec->num_channels > 14) {
+		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
+		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
+
+		for (i = 14; i < spec->num_channels; i++) {
+			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
+			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_probe_hw_mode);
+
+/*
  * IEEE80211 stack callback functions.
  */
 static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
drivers/net/wireless/rt2x00/rt2800lib.h +1 -0
Index: b/drivers/net/wireless/rt2x00/rt2800lib.h
===================================================================
@@ -131,6 +131,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev 
 
 int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
+int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
 
 extern const struct ieee80211_ops rt2800_mac80211_ops;
 
drivers/net/wireless/rt2x00/rt2800pci.c +1 -189

202 lines not on this page · raw message

drivers/net/wireless/rt2x00/rt2800usb.c +1 -210

223 lines not on this page · raw message

Acked-by on v1 6/9
#16 lore raw

Re: [PATCH 6/9] rt2800: unify rt2800*_probe_hw_mode()

Quoted 6 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: unify rt2800*_probe_hw_mode()

Add rf_vals tables and rt2800_probe_hw_mode() to rt2800lib.

Quoted 686 lines
---
 drivers/net/wireless/rt2x00/rt2800lib.c |  218 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    1 
 drivers/net/wireless/rt2x00/rt2800pci.c |  190 ---------------------------
 drivers/net/wireless/rt2x00/rt2800usb.c |  211 ------------------------------
 4 files changed, 221 insertions(+), 399 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800lib.c
===================================================================

drivers/net/wireless/rt2x00/rt2800lib.c +218 -0
@@ -1859,6 +1859,224 @@ int rt2800_init_eeprom(struct rt2x00_dev
 EXPORT_SYMBOL_GPL(rt2800_init_eeprom);
 
 /*
+ * RF value list for rt28x0
+ * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
+ */
+static const struct rf_channel rf_vals[] = {
+	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
+	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
+	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
+	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
+	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
+	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
+	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
+	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
+	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
+	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
+	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
+	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
+	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
+	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
+
+	/* 802.11 UNI / HyperLan 2 */
+	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
+	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
+	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
+	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
+	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
+	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
+	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
+	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
+	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
+	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
+	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
+	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
+
+	/* 802.11 HyperLan 2 */
+	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
+	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
+	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
+	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
+	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
+	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
+	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
+	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
+	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
+	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
+	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
+	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
+	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
+	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
+	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
+	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
+
+	/* 802.11 UNII */
+	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
+	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
+	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
+	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
+	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
+	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
+	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
+	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
+	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
+	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
+	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
+
+	/* 802.11 Japan */
+	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
+	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
+	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
+	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
+	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
+	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
+	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
+};
+
+/*
+ * RF value list for rt3070
+ * Supports: 2.4 GHz
+ */
+static const struct rf_channel rf_vals_3070[] = {
+	{1,  241, 2, 2 },
+	{2,  241, 2, 7 },
+	{3,  242, 2, 2 },
+	{4,  242, 2, 7 },
+	{5,  243, 2, 2 },
+	{6,  243, 2, 7 },
+	{7,  244, 2, 2 },
+	{8,  244, 2, 7 },
+	{9,  245, 2, 2 },
+	{10, 245, 2, 7 },
+	{11, 246, 2, 2 },
+	{12, 246, 2, 7 },
+	{13, 247, 2, 2 },
+	{14, 248, 2, 4 },
+};
+
+int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+{
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
+	struct hw_mode_spec *spec = &rt2x00dev->spec;
+	struct channel_info *info;
+	char *tx_power1;
+	char *tx_power2;
+	unsigned int i;
+	u16 eeprom;
+
+	/*
+	 * Initialize all hw fields.
+	 */
+	rt2x00dev->hw->flags =
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
+	    IEEE80211_HW_SIGNAL_DBM |
+	    IEEE80211_HW_SUPPORTS_PS |
+	    IEEE80211_HW_PS_NULLFUNC_STACK;
+
+	if (rt2x00_intf_is_usb(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom =
+			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+	else if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
+
+	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
+	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
+				rt2x00_eeprom_addr(rt2x00dev,
+						   EEPROM_MAC_ADDR_0));
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+	/*
+	 * Initialize hw_mode information.
+	 */
+	spec->supported_bands = SUPPORT_BAND_2GHZ;
+	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
+
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720) ||
+	    (rt2x00_intf_is_pci(rt2x00dev) &&
+	     (rt2x00_rf(chip, RF3020) ||
+	      rt2x00_rf(chip, RF3021) ||
+	      rt2x00_rf(chip, RF3022) ||
+	      rt2x00_rf(chip, RF2020) ||
+	      rt2x00_rf(chip, RF3052)))) {
+		spec->num_channels = 14;
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
+		spec->supported_bands |= SUPPORT_BAND_5GHZ;
+		spec->num_channels = ARRAY_SIZE(rf_vals);
+		spec->channels = rf_vals;
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
+		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
+		spec->channels = rf_vals_3070;
+	}
+
+	/*
+	 * Initialize HT information.
+	 */
+	spec->ht.ht_supported = true;
+	spec->ht.cap =
+	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+	    IEEE80211_HT_CAP_GRN_FLD |
+	    IEEE80211_HT_CAP_SGI_20 |
+	    IEEE80211_HT_CAP_SGI_40 |
+	    IEEE80211_HT_CAP_TX_STBC |
+	    IEEE80211_HT_CAP_RX_STBC |
+	    IEEE80211_HT_CAP_PSMP_SUPPORT;
+	spec->ht.ampdu_factor = 3;
+	spec->ht.ampdu_density = 4;
+	spec->ht.mcs.tx_params =
+	    IEEE80211_HT_MCS_TX_DEFINED |
+	    IEEE80211_HT_MCS_TX_RX_DIFF |
+	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
+		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
+
+	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
+	case 3:
+		spec->ht.mcs.rx_mask[2] = 0xff;
+	case 2:
+		spec->ht.mcs.rx_mask[1] = 0xff;
+	case 1:
+		spec->ht.mcs.rx_mask[0] = 0xff;
+		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
+		break;
+	}
+
+	/*
+	 * Create channel information array
+	 */
+	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	spec->channels_info = info;
+
+	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
+	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
+
+	for (i = 0; i < 14; i++) {
+		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
+		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
+	}
+
+	if (spec->num_channels > 14) {
+		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
+		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
+
+		for (i = 14; i < spec->num_channels; i++) {
+			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
+			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_probe_hw_mode);
+
+/*
  * IEEE80211 stack callback functions.
  */
 static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,

Index: b/drivers/net/wireless/rt2x00/rt2800lib.h
===================================================================

drivers/net/wireless/rt2x00/rt2800lib.h +1 -0
@@ -131,6 +131,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev 
 
 int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
+int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
 
 extern const struct ieee80211_ops rt2800_mac80211_ops;
 

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +1 -189
@@ -1098,194 +1098,6 @@ static int rt2800pci_validate_eeprom(str
 	return rt2800_validate_eeprom(rt2x00dev);
 }
 
-/*
- * RF value list for rt2860
- * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
- */
-static const struct rf_channel rf_vals[] = {
-	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
-	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
-	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
-	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
-	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
-	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
-	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
-	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
-	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
-	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
-	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
-	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
-	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
-	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
-
-	/* 802.11 UNI / HyperLan 2 */
-	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
-	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
-	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
-	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
-	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
-	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
-	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
-	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
-	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
-	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
-	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
-	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
-
-	/* 802.11 HyperLan 2 */
-	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
-	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
-	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
-	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
-	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
-	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
-	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
-	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
-	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
-	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
-	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
-	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
-	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
-	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
-	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
-	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
-
-	/* 802.11 UNII */
-	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
-	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
-	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
-	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
-	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
-	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
-	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
-	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
-	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
-	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
-	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
-
-	/* 802.11 Japan */
-	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
-	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
-	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
-	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
-	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
-	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
-	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
-};
-
-static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
-{
-	struct rt2x00_chip *chip = &rt2x00dev->chip;
-	struct hw_mode_spec *spec = &rt2x00dev->spec;
-	struct channel_info *info;
-	char *tx_power1;
-	char *tx_power2;
-	unsigned int i;
-	u16 eeprom;
-
-	/*
-	 * Initialize all hw fields.
-	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_SIGNAL_DBM |
-	    IEEE80211_HW_SUPPORTS_PS |
-	    IEEE80211_HW_PS_NULLFUNC_STACK;
-
-	if (rt2x00_intf_is_pci(rt2x00dev))
-		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
-
-	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
-	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
-				rt2x00_eeprom_addr(rt2x00dev,
-						   EEPROM_MAC_ADDR_0));
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
-
-	/*
-	 * Initialize hw_mode information.
-	 */
-	spec->supported_bands = SUPPORT_BAND_2GHZ;
-	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
-
-	if (rt2x00_rf(chip, RF2820) ||
-	    rt2x00_rf(chip, RF2720) ||
-	    (rt2x00_intf_is_pci(rt2x00dev) &&
-	     (rt2x00_rf(chip, RF3020) ||
-	      rt2x00_rf(chip, RF3021) ||
-	      rt2x00_rf(chip, RF3022) ||
-	      rt2x00_rf(chip, RF2020) ||
-	      rt2x00_rf(chip, RF3052)))) {
-		spec->num_channels = 14;
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(chip, RF2850) ||
-		   rt2x00_rf(chip, RF2750)) {
-		spec->supported_bands |= SUPPORT_BAND_5GHZ;
-		spec->num_channels = ARRAY_SIZE(rf_vals);
-		spec->channels = rf_vals;
-	}
-
-	/*
-	 * Initialize HT information.
-	 */
-	spec->ht.ht_supported = true;
-	spec->ht.cap =
-	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-	    IEEE80211_HT_CAP_GRN_FLD |
-	    IEEE80211_HT_CAP_SGI_20 |
-	    IEEE80211_HT_CAP_SGI_40 |
-	    IEEE80211_HT_CAP_TX_STBC |
-	    IEEE80211_HT_CAP_RX_STBC |
-	    IEEE80211_HT_CAP_PSMP_SUPPORT;
-	spec->ht.ampdu_factor = 3;
-	spec->ht.ampdu_density = 4;
-	spec->ht.mcs.tx_params =
-	    IEEE80211_HT_MCS_TX_DEFINED |
-	    IEEE80211_HT_MCS_TX_RX_DIFF |
-	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
-		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
-
-	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
-	case 3:
-		spec->ht.mcs.rx_mask[2] = 0xff;
-	case 2:
-		spec->ht.mcs.rx_mask[1] = 0xff;
-	case 1:
-		spec->ht.mcs.rx_mask[0] = 0xff;
-		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
-		break;
-	}
-
-	/*
-	 * Create channel information array
-	 */
-	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
-	if (!info)
-		return -ENOMEM;
-
-	spec->channels_info = info;
-
-	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
-	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
-
-	for (i = 0; i < 14; i++) {
-		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
-		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
-	}
-
-	if (spec->num_channels > 14) {
-		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
-		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
-
-		for (i = 14; i < spec->num_channels; i++) {
-			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
-			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
-		}
-	}
-
-	return 0;
-}
-
 static const struct rt2800_ops rt2800pci_rt2800_ops = {
 	.register_read		= rt2x00pci_register_read,
 	.register_write		= rt2x00pci_register_write,
@@ -1319,7 +1131,7 @@ static int rt2800pci_probe_hw(struct rt2
 	/*
 	 * Initialize hw specifications.
 	 */
-	retval = rt2800pci_probe_hw_mode(rt2x00dev);
+	retval = rt2800_probe_hw_mode(rt2x00dev);
 	if (retval)
 		return retval;
 

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +1 -210
@@ -672,215 +672,6 @@ static int rt2800usb_validate_eeprom(str
 	return rt2800_validate_eeprom(rt2x00dev);
 }
 
-/*
- * RF value list for rt2870
- * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
- */
-static const struct rf_channel rf_vals[] = {
-	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
-	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
-	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
-	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
-	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
-	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
-	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
-	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
-	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
-	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
-	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
-	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
-	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
-	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
-
-	/* 802.11 UNI / HyperLan 2 */
-	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
-	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
-	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
-	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
-	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
-	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
-	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
-	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
-	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
-	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
-	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
-	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
-
-	/* 802.11 HyperLan 2 */
-	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
-	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
-	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
-	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
-	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
-	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
-	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
-	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
-	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
-	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
-	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
-	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
-	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
-	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
-	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
-	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
-
-	/* 802.11 UNII */
-	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
-	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
-	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
-	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
-	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
-	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
-	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
-	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
-	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
-	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
-	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
-
-	/* 802.11 Japan */
-	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
-	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
-	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
-	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
-	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
-	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
-	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
-};
-
-/*
- * RF value list for rt3070
- * Supports: 2.4 GHz
- */
-static const struct rf_channel rf_vals_3070[] = {
-	{1,  241, 2, 2 },
-	{2,  241, 2, 7 },
-	{3,  242, 2, 2 },
-	{4,  242, 2, 7 },
-	{5,  243, 2, 2 },
-	{6,  243, 2, 7 },
-	{7,  244, 2, 2 },
-	{8,  244, 2, 7 },
-	{9,  245, 2, 2 },
-	{10, 245, 2, 7 },
-	{11, 246, 2, 2 },
-	{12, 246, 2, 7 },
-	{13, 247, 2, 2 },
-	{14, 248, 2, 4 },
-};
-
-static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
-{
-	struct rt2x00_chip *chip = &rt2x00dev->chip;
-	struct hw_mode_spec *spec = &rt2x00dev->spec;
-	struct channel_info *info;
-	char *tx_power1;
-	char *tx_power2;
-	unsigned int i;
-	u16 eeprom;
-
-	/*
-	 * Initialize all hw fields.
-	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_SIGNAL_DBM |
-	    IEEE80211_HW_SUPPORTS_PS |
-	    IEEE80211_HW_PS_NULLFUNC_STACK;
-
-	if (rt2x00_intf_is_usb(rt2x00dev))
-		rt2x00dev->hw->extra_tx_headroom =
-			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
-
-	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
-	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
-				rt2x00_eeprom_addr(rt2x00dev,
-						   EEPROM_MAC_ADDR_0));
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
-
-	/*
-	 * Initialize hw_mode information.
-	 */
-	spec->supported_bands = SUPPORT_BAND_2GHZ;
-	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
-
-	if (rt2x00_rf(chip, RF2820) ||
-	    rt2x00_rf(chip, RF2720)) {
-		spec->num_channels = 14;
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(chip, RF2850) ||
-		   rt2x00_rf(chip, RF2750)) {
-		spec->supported_bands |= SUPPORT_BAND_5GHZ;
-		spec->num_channels = ARRAY_SIZE(rf_vals);
-		spec->channels = rf_vals;
-	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
-		    (rt2x00_rf(chip, RF3020) ||
-		     rt2x00_rf(chip, RF2020))) {
-		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
-		spec->channels = rf_vals_3070;
-	}
-
-	/*
-	 * Initialize HT information.
-	 */
-	spec->ht.ht_supported = true;
-	spec->ht.cap =
-	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-	    IEEE80211_HT_CAP_GRN_FLD |
-	    IEEE80211_HT_CAP_SGI_20 |
-	    IEEE80211_HT_CAP_SGI_40 |
-	    IEEE80211_HT_CAP_TX_STBC |
-	    IEEE80211_HT_CAP_RX_STBC |
-	    IEEE80211_HT_CAP_PSMP_SUPPORT;
-	spec->ht.ampdu_factor = 3;
-	spec->ht.ampdu_density = 4;
-	spec->ht.mcs.tx_params =
-	    IEEE80211_HT_MCS_TX_DEFINED |
-	    IEEE80211_HT_MCS_TX_RX_DIFF |
-	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
-		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
-
-	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
-	case 3:
-		spec->ht.mcs.rx_mask[2] = 0xff;
-	case 2:
-		spec->ht.mcs.rx_mask[1] = 0xff;
-	case 1:
-		spec->ht.mcs.rx_mask[0] = 0xff;
-		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
-		break;
-	}
-
-	/*
-	 * Create channel information array
-	 */
-	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
-	if (!info)
-		return -ENOMEM;
-
-	spec->channels_info = info;
-
-	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
-	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
-
-	for (i = 0; i < 14; i++) {
-		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
-		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
-	}
-
-	if (spec->num_channels > 14) {
-		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
-		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
-
-		for (i = 14; i < spec->num_channels; i++) {
-			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
-			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
-		}
-	}
-
-	return 0;
-}
-
 static const struct rt2800_ops rt2800usb_rt2800_ops = {
 	.register_read		= rt2x00usb_register_read,
 	.register_write		= rt2x00usb_register_write,
@@ -914,7 +705,7 @@ static int rt2800usb_probe_hw(struct rt2
 	/*
 	 * Initialize hw specifications.
 	 */
-	retval = rt2800usb_probe_hw_mode(rt2x00dev);
+	retval = rt2800_probe_hw_mode(rt2x00dev);
 	if (retval)
 		return retval;
 
#17 lore raw

Re: [PATCH 6/9] rt2800: unify rt2800*_probe_hw_mode()

In reply to Bartlomiej Zolnierkiewicz
Quoted 684 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: unify rt2800*_probe_hw_mode()

Add rf_vals tables and rt2800_probe_hw_mode() to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800lib.c |  218 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    1 
 drivers/net/wireless/rt2x00/rt2800pci.c |  190 ---------------------------
 drivers/net/wireless/rt2x00/rt2800usb.c |  211 ------------------------------
 4 files changed, 221 insertions(+), 399 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800lib.c
===================================================================

drivers/net/wireless/rt2x00/rt2800lib.c +218 -0
@@ -1859,6 +1859,224 @@ int rt2800_init_eeprom(struct rt2x00_dev
 EXPORT_SYMBOL_GPL(rt2800_init_eeprom);
 
 /*
+ * RF value list for rt28x0
+ * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
+ */
+static const struct rf_channel rf_vals[] = {
+	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
+	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
+	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
+	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
+	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
+	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
+	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
+	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
+	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
+	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
+	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
+	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
+	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
+	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
+
+	/* 802.11 UNI / HyperLan 2 */
+	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
+	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
+	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
+	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
+	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
+	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
+	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
+	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
+	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
+	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
+	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
+	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
+
+	/* 802.11 HyperLan 2 */
+	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
+	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
+	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
+	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
+	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
+	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
+	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
+	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
+	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
+	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
+	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
+	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
+	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
+	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
+	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
+	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
+
+	/* 802.11 UNII */
+	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
+	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
+	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
+	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
+	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
+	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
+	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
+	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
+	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
+	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
+	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
+
+	/* 802.11 Japan */
+	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
+	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
+	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
+	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
+	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
+	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
+	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
+};
+
+/*
+ * RF value list for rt3070
+ * Supports: 2.4 GHz
+ */
+static const struct rf_channel rf_vals_3070[] = {
+	{1,  241, 2, 2 },
+	{2,  241, 2, 7 },
+	{3,  242, 2, 2 },
+	{4,  242, 2, 7 },
+	{5,  243, 2, 2 },
+	{6,  243, 2, 7 },
+	{7,  244, 2, 2 },
+	{8,  244, 2, 7 },
+	{9,  245, 2, 2 },
+	{10, 245, 2, 7 },
+	{11, 246, 2, 2 },
+	{12, 246, 2, 7 },
+	{13, 247, 2, 2 },
+	{14, 248, 2, 4 },
+};
+
+int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+{
+	struct rt2x00_chip *chip = &rt2x00dev->chip;
+	struct hw_mode_spec *spec = &rt2x00dev->spec;
+	struct channel_info *info;
+	char *tx_power1;
+	char *tx_power2;
+	unsigned int i;
+	u16 eeprom;
+
+	/*
+	 * Initialize all hw fields.
+	 */
+	rt2x00dev->hw->flags =
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
+	    IEEE80211_HW_SIGNAL_DBM |
+	    IEEE80211_HW_SUPPORTS_PS |
+	    IEEE80211_HW_PS_NULLFUNC_STACK;
+
+	if (rt2x00_intf_is_usb(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom =
+			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
+	else if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
+
+	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
+	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
+				rt2x00_eeprom_addr(rt2x00dev,
+						   EEPROM_MAC_ADDR_0));
+
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
+
+	/*
+	 * Initialize hw_mode information.
+	 */
+	spec->supported_bands = SUPPORT_BAND_2GHZ;
+	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
+
+	if (rt2x00_rf(chip, RF2820) ||
+	    rt2x00_rf(chip, RF2720) ||
+	    (rt2x00_intf_is_pci(rt2x00dev) &&
+	     (rt2x00_rf(chip, RF3020) ||
+	      rt2x00_rf(chip, RF3021) ||
+	      rt2x00_rf(chip, RF3022) ||
+	      rt2x00_rf(chip, RF2020) ||
+	      rt2x00_rf(chip, RF3052)))) {
+		spec->num_channels = 14;
+		spec->channels = rf_vals;
+	} else if (rt2x00_rf(chip, RF2850) ||
+		   rt2x00_rf(chip, RF2750)) {
+		spec->supported_bands |= SUPPORT_BAND_5GHZ;
+		spec->num_channels = ARRAY_SIZE(rf_vals);
+		spec->channels = rf_vals;
+	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
+		    (rt2x00_rf(chip, RF3020) ||
+		     rt2x00_rf(chip, RF2020))) {
+		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
+		spec->channels = rf_vals_3070;
+	}
+
+	/*
+	 * Initialize HT information.
+	 */
+	spec->ht.ht_supported = true;
+	spec->ht.cap =
+	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+	    IEEE80211_HT_CAP_GRN_FLD |
+	    IEEE80211_HT_CAP_SGI_20 |
+	    IEEE80211_HT_CAP_SGI_40 |
+	    IEEE80211_HT_CAP_TX_STBC |
+	    IEEE80211_HT_CAP_RX_STBC |
+	    IEEE80211_HT_CAP_PSMP_SUPPORT;
+	spec->ht.ampdu_factor = 3;
+	spec->ht.ampdu_density = 4;
+	spec->ht.mcs.tx_params =
+	    IEEE80211_HT_MCS_TX_DEFINED |
+	    IEEE80211_HT_MCS_TX_RX_DIFF |
+	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
+		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
+
+	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
+	case 3:
+		spec->ht.mcs.rx_mask[2] = 0xff;
+	case 2:
+		spec->ht.mcs.rx_mask[1] = 0xff;
+	case 1:
+		spec->ht.mcs.rx_mask[0] = 0xff;
+		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
+		break;
+	}
+
+	/*
+	 * Create channel information array
+	 */
+	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	spec->channels_info = info;
+
+	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
+	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
+
+	for (i = 0; i < 14; i++) {
+		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
+		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
+	}
+
+	if (spec->num_channels > 14) {
+		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
+		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
+
+		for (i = 14; i < spec->num_channels; i++) {
+			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
+			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt2800_probe_hw_mode);
+
+/*
  * IEEE80211 stack callback functions.
  */
 static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,

Index: b/drivers/net/wireless/rt2x00/rt2800lib.h
===================================================================

drivers/net/wireless/rt2x00/rt2800lib.h +1 -0
@@ -131,6 +131,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev 
 
 int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
+int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
 
 extern const struct ieee80211_ops rt2800_mac80211_ops;
 

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +1 -189
@@ -1098,194 +1098,6 @@ static int rt2800pci_validate_eeprom(str
 	return rt2800_validate_eeprom(rt2x00dev);
 }
 
-/*
- * RF value list for rt2860
- * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
- */
-static const struct rf_channel rf_vals[] = {
-	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
-	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
-	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
-	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
-	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
-	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
-	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
-	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
-	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
-	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
-	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
-	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
-	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
-	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
-
-	/* 802.11 UNI / HyperLan 2 */
-	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
-	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
-	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
-	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
-	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
-	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
-	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
-	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
-	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
-	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
-	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
-	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
-
-	/* 802.11 HyperLan 2 */
-	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
-	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
-	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
-	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
-	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
-	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
-	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
-	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
-	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
-	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
-	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
-	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
-	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
-	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
-	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
-	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
-
-	/* 802.11 UNII */
-	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
-	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
-	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
-	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
-	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
-	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
-	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
-	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
-	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
-	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
-	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
-
-	/* 802.11 Japan */
-	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
-	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
-	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
-	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
-	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
-	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
-	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
-};
-
-static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
-{
-	struct rt2x00_chip *chip = &rt2x00dev->chip;
-	struct hw_mode_spec *spec = &rt2x00dev->spec;
-	struct channel_info *info;
-	char *tx_power1;
-	char *tx_power2;
-	unsigned int i;
-	u16 eeprom;
-
-	/*
-	 * Initialize all hw fields.
-	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_SIGNAL_DBM |
-	    IEEE80211_HW_SUPPORTS_PS |
-	    IEEE80211_HW_PS_NULLFUNC_STACK;
-
-	if (rt2x00_intf_is_pci(rt2x00dev))
-		rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
-
-	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
-	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
-				rt2x00_eeprom_addr(rt2x00dev,
-						   EEPROM_MAC_ADDR_0));
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
-
-	/*
-	 * Initialize hw_mode information.
-	 */
-	spec->supported_bands = SUPPORT_BAND_2GHZ;
-	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
-
-	if (rt2x00_rf(chip, RF2820) ||
-	    rt2x00_rf(chip, RF2720) ||
-	    (rt2x00_intf_is_pci(rt2x00dev) &&
-	     (rt2x00_rf(chip, RF3020) ||
-	      rt2x00_rf(chip, RF3021) ||
-	      rt2x00_rf(chip, RF3022) ||
-	      rt2x00_rf(chip, RF2020) ||
-	      rt2x00_rf(chip, RF3052)))) {
-		spec->num_channels = 14;
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(chip, RF2850) ||
-		   rt2x00_rf(chip, RF2750)) {
-		spec->supported_bands |= SUPPORT_BAND_5GHZ;
-		spec->num_channels = ARRAY_SIZE(rf_vals);
-		spec->channels = rf_vals;
-	}
-
-	/*
-	 * Initialize HT information.
-	 */
-	spec->ht.ht_supported = true;
-	spec->ht.cap =
-	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-	    IEEE80211_HT_CAP_GRN_FLD |
-	    IEEE80211_HT_CAP_SGI_20 |
-	    IEEE80211_HT_CAP_SGI_40 |
-	    IEEE80211_HT_CAP_TX_STBC |
-	    IEEE80211_HT_CAP_RX_STBC |
-	    IEEE80211_HT_CAP_PSMP_SUPPORT;
-	spec->ht.ampdu_factor = 3;
-	spec->ht.ampdu_density = 4;
-	spec->ht.mcs.tx_params =
-	    IEEE80211_HT_MCS_TX_DEFINED |
-	    IEEE80211_HT_MCS_TX_RX_DIFF |
-	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
-		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
-
-	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
-	case 3:
-		spec->ht.mcs.rx_mask[2] = 0xff;
-	case 2:
-		spec->ht.mcs.rx_mask[1] = 0xff;
-	case 1:
-		spec->ht.mcs.rx_mask[0] = 0xff;
-		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
-		break;
-	}
-
-	/*
-	 * Create channel information array
-	 */
-	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
-	if (!info)
-		return -ENOMEM;
-
-	spec->channels_info = info;
-
-	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
-	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
-
-	for (i = 0; i < 14; i++) {
-		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
-		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
-	}
-
-	if (spec->num_channels > 14) {
-		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
-		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
-
-		for (i = 14; i < spec->num_channels; i++) {
-			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
-			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
-		}
-	}
-
-	return 0;
-}
-
 static const struct rt2800_ops rt2800pci_rt2800_ops = {
 	.register_read		= rt2x00pci_register_read,
 	.register_write		= rt2x00pci_register_write,
@@ -1319,7 +1131,7 @@ static int rt2800pci_probe_hw(struct rt2
 	/*
 	 * Initialize hw specifications.
 	 */
-	retval = rt2800pci_probe_hw_mode(rt2x00dev);
+	retval = rt2800_probe_hw_mode(rt2x00dev);
 	if (retval)
 		return retval;
 

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +0 -209
@@ -672,215 +672,6 @@ static int rt2800usb_validate_eeprom(str
 	return rt2800_validate_eeprom(rt2x00dev);
 }
 
-/*
- * RF value list for rt2870
- * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
- */
-static const struct rf_channel rf_vals[] = {
-	{ 1,  0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
-	{ 2,  0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
-	{ 3,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
-	{ 4,  0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
-	{ 5,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
-	{ 6,  0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
-	{ 7,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
-	{ 8,  0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
-	{ 9,  0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
-	{ 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
-	{ 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
-	{ 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
-	{ 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
-	{ 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
-
-	/* 802.11 UNI / HyperLan 2 */
-	{ 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
-	{ 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
-	{ 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
-	{ 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
-	{ 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
-	{ 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
-	{ 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
-	{ 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
-	{ 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
-	{ 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
-	{ 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
-	{ 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
-
-	/* 802.11 HyperLan 2 */
-	{ 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
-	{ 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
-	{ 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
-	{ 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
-	{ 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
-	{ 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
-	{ 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
-	{ 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
-	{ 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
-	{ 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
-	{ 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
-	{ 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
-	{ 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
-	{ 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
-	{ 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
-	{ 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
-
-	/* 802.11 UNII */
-	{ 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
-	{ 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
-	{ 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
-	{ 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
-	{ 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
-	{ 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
-	{ 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
-	{ 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
-	{ 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
-	{ 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
-	{ 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
-
-	/* 802.11 Japan */
-	{ 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
-	{ 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
-	{ 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
-	{ 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
-	{ 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
-	{ 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
-	{ 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
-};
-
-/*
- * RF value list for rt3070
- * Supports: 2.4 GHz
- */
-static const struct rf_channel rf_vals_3070[] = {
-	{1,  241, 2, 2 },
-	{2,  241, 2, 7 },
-	{3,  242, 2, 2 },
-	{4,  242, 2, 7 },
-	{5,  243, 2, 2 },
-	{6,  243, 2, 7 },
-	{7,  244, 2, 2 },
-	{8,  244, 2, 7 },
-	{9,  245, 2, 2 },
-	{10, 245, 2, 7 },
-	{11, 246, 2, 2 },
-	{12, 246, 2, 7 },
-	{13, 247, 2, 2 },
-	{14, 248, 2, 4 },
-};
-
-static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
-{
-	struct rt2x00_chip *chip = &rt2x00dev->chip;
-	struct hw_mode_spec *spec = &rt2x00dev->spec;
-	struct channel_info *info;
-	char *tx_power1;
-	char *tx_power2;
-	unsigned int i;
-	u16 eeprom;
-
-	/*
-	 * Initialize all hw fields.
-	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_SIGNAL_DBM |
-	    IEEE80211_HW_SUPPORTS_PS |
-	    IEEE80211_HW_PS_NULLFUNC_STACK;
-
-	if (rt2x00_intf_is_usb(rt2x00dev))
-		rt2x00dev->hw->extra_tx_headroom =
-			TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
-
-	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
-	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
-				rt2x00_eeprom_addr(rt2x00dev,
-						   EEPROM_MAC_ADDR_0));
-
-	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
-
-	/*
-	 * Initialize hw_mode information.
-	 */
-	spec->supported_bands = SUPPORT_BAND_2GHZ;
-	spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
-
-	if (rt2x00_rf(chip, RF2820) ||
-	    rt2x00_rf(chip, RF2720)) {
-		spec->num_channels = 14;
-		spec->channels = rf_vals;
-	} else if (rt2x00_rf(chip, RF2850) ||
-		   rt2x00_rf(chip, RF2750)) {
-		spec->supported_bands |= SUPPORT_BAND_5GHZ;
-		spec->num_channels = ARRAY_SIZE(rf_vals);
-		spec->channels = rf_vals;
-	} else if (rt2x00_intf_is_usb(rt2x00dev) &&
-		    (rt2x00_rf(chip, RF3020) ||
-		     rt2x00_rf(chip, RF2020))) {
-		spec->num_channels = ARRAY_SIZE(rf_vals_3070);
-		spec->channels = rf_vals_3070;
-	}
-
-	/*
-	 * Initialize HT information.
-	 */
-	spec->ht.ht_supported = true;
-	spec->ht.cap =
-	    IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-	    IEEE80211_HT_CAP_GRN_FLD |
-	    IEEE80211_HT_CAP_SGI_20 |
-	    IEEE80211_HT_CAP_SGI_40 |
-	    IEEE80211_HT_CAP_TX_STBC |
-	    IEEE80211_HT_CAP_RX_STBC |
-	    IEEE80211_HT_CAP_PSMP_SUPPORT;
-	spec->ht.ampdu_factor = 3;
-	spec->ht.ampdu_density = 4;
-	spec->ht.mcs.tx_params =
-	    IEEE80211_HT_MCS_TX_DEFINED |
-	    IEEE80211_HT_MCS_TX_RX_DIFF |
-	    ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
-		IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
-
-	switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
-	case 3:
-		spec->ht.mcs.rx_mask[2] = 0xff;
-	case 2:
-		spec->ht.mcs.rx_mask[1] = 0xff;
-	case 1:
-		spec->ht.mcs.rx_mask[0] = 0xff;
-		spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
-		break;
-	}
-
-	/*
-	 * Create channel information array
-	 */
-	info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
-	if (!info)
-		return -ENOMEM;
-
-	spec->channels_info = info;
-
-	tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
-	tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
-
-	for (i = 0; i < 14; i++) {
-		info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
-		info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
-	}
-
-	if (spec->num_channels > 14) {
-		tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
-		tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
-
-		for (i = 14; i < spec->num_channels; i++) {
-			info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
-			info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
-		}
-	}
-
-	return 0;
-}
-
 static const struct rt2800_ops rt2800usb_rt2800_ops = {
 	.register_read		= rt2x00usb_register_read,
 	.register_write		= rt2x00usb_register_write,

drivers/net/wireless/rt2x00/rt2800usb.c static int rt2800usb_probe_hw(struct rt2 · line 711

Quoted 8 lines
drivers/net/wireless/rt2x00/rt2800usb.c +1 -1
@@ -914,7 +705,7 @@ static int rt2800usb_probe_hw(struct rt2
 	/*
 	 * Initialize hw specifications.
 	 */
-	retval = rt2800usb_probe_hw_mode(rt2x00dev);
+	retval = rt2800_probe_hw_mode(rt2x00dev);
 	if (retval)
 		return retval;
 

See comments to [PATCH 5/9]. Once that is fixed then this one is OK too.

---
Gertjan.

#18 lore raw

PATCH 7/9 rt2800usb: fix RX descriptor naming

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: fix RX descriptor naming

Rename RXD_W0_* defines to RXINFO_W0_* ones to match naming used for TX descriptor and by the vendor driver.

---
 drivers/net/wireless/rt2x00/rt2800usb.c |   10 ++++----
 drivers/net/wireless/rt2x00/rt2800usb.h |   40 ++++++++++++++++----------------
 2 files changed, 25 insertions(+), 25 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +5 -5
Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================
@@ -594,16 +594,16 @@ static void rt2800usb_fill_rxdone(struct
 	rt2x00_desc_read(rxwi, 2, &rxwi2);
 	rt2x00_desc_read(rxwi, 3, &rxwi3);
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR))
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_CRC_ERROR))
 		rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
 
 	if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
 		rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF);
 		rxdesc->cipher_status =
-		    rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
+		    rt2x00_get_field32(rxd0, RXINFO_W0_CIPHER_ERROR);
 	}
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) {
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_DECRYPTED)) {
 		/*
 		 * Hardware has stripped IV/EIV data from 802.11 frame during
 		 * decryption. Unfortunately the descriptor doesn't contain
@@ -618,10 +618,10 @@ static void rt2800usb_fill_rxdone(struct
 			rxdesc->flags |= RX_FLAG_MMIC_ERROR;
 	}
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_MY_BSS))
 		rxdesc->dev_flags |= RXDONE_MY_BSS;
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) {
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_L2PAD)) {
 		rxdesc->dev_flags |= RXDONE_L2PAD;
 		skbdesc->flags |= SKBDESC_L2_PADDED;
 	}
drivers/net/wireless/rt2x00/rt2800usb.h +20 -20
Index: b/drivers/net/wireless/rt2x00/rt2800usb.h
===================================================================
@@ -111,25 +111,25 @@
  * AMSDU: rx with 802.3 header, not 802.11 header.
  */
 
-#define RXD_W0_BA			FIELD32(0x00000001)
-#define RXD_W0_DATA			FIELD32(0x00000002)
-#define RXD_W0_NULLDATA			FIELD32(0x00000004)
-#define RXD_W0_FRAG			FIELD32(0x00000008)
-#define RXD_W0_UNICAST_TO_ME		FIELD32(0x00000010)
-#define RXD_W0_MULTICAST		FIELD32(0x00000020)
-#define RXD_W0_BROADCAST		FIELD32(0x00000040)
-#define RXD_W0_MY_BSS			FIELD32(0x00000080)
-#define RXD_W0_CRC_ERROR		FIELD32(0x00000100)
-#define RXD_W0_CIPHER_ERROR		FIELD32(0x00000600)
-#define RXD_W0_AMSDU			FIELD32(0x00000800)
-#define RXD_W0_HTC			FIELD32(0x00001000)
-#define RXD_W0_RSSI			FIELD32(0x00002000)
-#define RXD_W0_L2PAD			FIELD32(0x00004000)
-#define RXD_W0_AMPDU			FIELD32(0x00008000)
-#define RXD_W0_DECRYPTED		FIELD32(0x00010000)
-#define RXD_W0_PLCP_RSSI		FIELD32(0x00020000)
-#define RXD_W0_CIPHER_ALG		FIELD32(0x00040000)
-#define RXD_W0_LAST_AMSDU		FIELD32(0x00080000)
-#define RXD_W0_PLCP_SIGNAL		FIELD32(0xfff00000)
+#define RXINFO_W0_BA			FIELD32(0x00000001)
+#define RXINFO_W0_DATA			FIELD32(0x00000002)
+#define RXINFO_W0_NULLDATA		FIELD32(0x00000004)
+#define RXINFO_W0_FRAG			FIELD32(0x00000008)
+#define RXINFO_W0_UNICAST_TO_ME		FIELD32(0x00000010)
+#define RXINFO_W0_MULTICAST		FIELD32(0x00000020)
+#define RXINFO_W0_BROADCAST		FIELD32(0x00000040)
+#define RXINFO_W0_MY_BSS		FIELD32(0x00000080)
+#define RXINFO_W0_CRC_ERROR		FIELD32(0x00000100)
+#define RXINFO_W0_CIPHER_ERROR		FIELD32(0x00000600)
+#define RXINFO_W0_AMSDU			FIELD32(0x00000800)
+#define RXINFO_W0_HTC			FIELD32(0x00001000)
+#define RXINFO_W0_RSSI			FIELD32(0x00002000)
+#define RXINFO_W0_L2PAD			FIELD32(0x00004000)
+#define RXINFO_W0_AMPDU			FIELD32(0x00008000)
+#define RXINFO_W0_DECRYPTED		FIELD32(0x00010000)
+#define RXINFO_W0_PLCP_RSSI		FIELD32(0x00020000)
+#define RXINFO_W0_CIPHER_ALG		FIELD32(0x00040000)
+#define RXINFO_W0_LAST_AMSDU		FIELD32(0x00080000)
+#define RXINFO_W0_PLCP_SIGNAL		FIELD32(0xfff00000)
 
 #endif /* RT2800USB_H */
Acked-by on v1 7/9
#19 lore raw

Re: [PATCH 7/9] rt2800usb: fix RX descriptor naming

Quoted 7 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: fix RX descriptor naming

Rename RXD_W0_* defines to RXINFO_W0_* ones to match naming used for TX descriptor and by the vendor driver.

Quoted 93 lines
---
 drivers/net/wireless/rt2x00/rt2800usb.c |   10 ++++----
 drivers/net/wireless/rt2x00/rt2800usb.h |   40 ++++++++++++++++----------------
 2 files changed, 25 insertions(+), 25 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +5 -5
@@ -594,16 +594,16 @@ static void rt2800usb_fill_rxdone(struct
 	rt2x00_desc_read(rxwi, 2, &rxwi2);
 	rt2x00_desc_read(rxwi, 3, &rxwi3);
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR))
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_CRC_ERROR))
 		rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
 
 	if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
 		rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF);
 		rxdesc->cipher_status =
-		    rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
+		    rt2x00_get_field32(rxd0, RXINFO_W0_CIPHER_ERROR);
 	}
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) {
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_DECRYPTED)) {
 		/*
 		 * Hardware has stripped IV/EIV data from 802.11 frame during
 		 * decryption. Unfortunately the descriptor doesn't contain
@@ -618,10 +618,10 @@ static void rt2800usb_fill_rxdone(struct
 			rxdesc->flags |= RX_FLAG_MMIC_ERROR;
 	}
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_MY_BSS))
 		rxdesc->dev_flags |= RXDONE_MY_BSS;
 
-	if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) {
+	if (rt2x00_get_field32(rxd0, RXINFO_W0_L2PAD)) {
 		rxdesc->dev_flags |= RXDONE_L2PAD;
 		skbdesc->flags |= SKBDESC_L2_PADDED;
 	}

Index: b/drivers/net/wireless/rt2x00/rt2800usb.h
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.h +20 -20
@@ -111,25 +111,25 @@
  * AMSDU: rx with 802.3 header, not 802.11 header.
  */
 
-#define RXD_W0_BA			FIELD32(0x00000001)
-#define RXD_W0_DATA			FIELD32(0x00000002)
-#define RXD_W0_NULLDATA			FIELD32(0x00000004)
-#define RXD_W0_FRAG			FIELD32(0x00000008)
-#define RXD_W0_UNICAST_TO_ME		FIELD32(0x00000010)
-#define RXD_W0_MULTICAST		FIELD32(0x00000020)
-#define RXD_W0_BROADCAST		FIELD32(0x00000040)
-#define RXD_W0_MY_BSS			FIELD32(0x00000080)
-#define RXD_W0_CRC_ERROR		FIELD32(0x00000100)
-#define RXD_W0_CIPHER_ERROR		FIELD32(0x00000600)
-#define RXD_W0_AMSDU			FIELD32(0x00000800)
-#define RXD_W0_HTC			FIELD32(0x00001000)
-#define RXD_W0_RSSI			FIELD32(0x00002000)
-#define RXD_W0_L2PAD			FIELD32(0x00004000)
-#define RXD_W0_AMPDU			FIELD32(0x00008000)
-#define RXD_W0_DECRYPTED		FIELD32(0x00010000)
-#define RXD_W0_PLCP_RSSI		FIELD32(0x00020000)
-#define RXD_W0_CIPHER_ALG		FIELD32(0x00040000)
-#define RXD_W0_LAST_AMSDU		FIELD32(0x00080000)
-#define RXD_W0_PLCP_SIGNAL		FIELD32(0xfff00000)
+#define RXINFO_W0_BA			FIELD32(0x00000001)
+#define RXINFO_W0_DATA			FIELD32(0x00000002)
+#define RXINFO_W0_NULLDATA		FIELD32(0x00000004)
+#define RXINFO_W0_FRAG			FIELD32(0x00000008)
+#define RXINFO_W0_UNICAST_TO_ME		FIELD32(0x00000010)
+#define RXINFO_W0_MULTICAST		FIELD32(0x00000020)
+#define RXINFO_W0_BROADCAST		FIELD32(0x00000040)
+#define RXINFO_W0_MY_BSS		FIELD32(0x00000080)
+#define RXINFO_W0_CRC_ERROR		FIELD32(0x00000100)
+#define RXINFO_W0_CIPHER_ERROR		FIELD32(0x00000600)
+#define RXINFO_W0_AMSDU			FIELD32(0x00000800)
+#define RXINFO_W0_HTC			FIELD32(0x00001000)
+#define RXINFO_W0_RSSI			FIELD32(0x00002000)
+#define RXINFO_W0_L2PAD			FIELD32(0x00004000)
+#define RXINFO_W0_AMPDU			FIELD32(0x00008000)
+#define RXINFO_W0_DECRYPTED		FIELD32(0x00010000)
+#define RXINFO_W0_PLCP_RSSI		FIELD32(0x00020000)
+#define RXINFO_W0_CIPHER_ALG		FIELD32(0x00040000)
+#define RXINFO_W0_LAST_AMSDU		FIELD32(0x00080000)
+#define RXINFO_W0_PLCP_SIGNAL		FIELD32(0xfff00000)
 
 #endif /* RT2800USB_H */
Acked-by on v1 7/9
#20 lore raw

Re: [PATCH 7/9] rt2800usb: fix RX descriptor naming

In reply to Bartlomiej Zolnierkiewicz
Quoted 8 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: fix RX descriptor naming

Rename RXD_W0_* defines to RXINFO_W0_* ones to match naming used for TX descriptor and by the vendor driver.

---

#21 lore raw

PATCH 8/9 rt2800: add eFuse EEPROM support code to rt2800lib

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)
drivers/net/wireless/rt2x00/rt2800.h +29 -0
Index: b/drivers/net/wireless/rt2x00/rt2800.h
===================================================================
@@ -362,6 +362,35 @@
 #define RF_CSR_CFG_BUSY			FIELD32(0x00020000)
 
 /*
+ * EFUSE_CSR: RT30x0 EEPROM
+ */
+#define EFUSE_CTRL			0x0580
+#define EFUSE_CTRL_ADDRESS_IN		FIELD32(0x03fe0000)
+#define EFUSE_CTRL_MODE			FIELD32(0x000000c0)
+#define EFUSE_CTRL_KICK			FIELD32(0x40000000)
+#define EFUSE_CTRL_PRESENT		FIELD32(0x80000000)
+
+/*
+ * EFUSE_DATA0
+ */
+#define EFUSE_DATA0			0x0590
+
+/*
+ * EFUSE_DATA1
+ */
+#define EFUSE_DATA1			0x0594
+
+/*
+ * EFUSE_DATA2
+ */
+#define EFUSE_DATA2			0x0598
+
+/*
+ * EFUSE_DATA3
+ */
+#define EFUSE_DATA3			0x059c
+
+/*
  * MAC Control/Status Registers(CSR).
  * Some values are set in TU, whereas 1 TU == 1024 us.
  */
drivers/net/wireless/rt2x00/rt2800lib.c +43 -0

49 lines not on this page · raw message

drivers/net/wireless/rt2x00/rt2800lib.h +2 -0
Index: b/drivers/net/wireless/rt2x00/rt2800lib.h
===================================================================
@@ -129,6 +129,8 @@ int rt2800_init_registers(struct rt2x00_
 int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
 
+int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
+void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
 int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
drivers/net/wireless/rt2x00/rt2800pci.c +3 -35
Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }
 
-static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev,
-				 unsigned int i)
-{
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-	rt2x00_set_field32(&reg, EFUSE_CTRL_ADDRESS_IN, i);
-	rt2x00_set_field32(&reg, EFUSE_CTRL_MODE, 0);
-	rt2x00_set_field32(&reg, EFUSE_CTRL_KICK, 1);
-	rt2800_register_write(rt2x00dev, EFUSE_CTRL, reg);
-
-	/* Wait until the EEPROM has been loaded */
-	rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
-
-	/* Apparently the data is read from end to start */
-	rt2800_register_read(rt2x00dev, EFUSE_DATA3,
-				(u32 *)&rt2x00dev->eeprom[i]);
-	rt2800_register_read(rt2x00dev, EFUSE_DATA2,
-				(u32 *)&rt2x00dev->eeprom[i + 2]);
-	rt2800_register_read(rt2x00dev, EFUSE_DATA1,
-				(u32 *)&rt2x00dev->eeprom[i + 4]);
-	rt2800_register_read(rt2x00dev, EFUSE_DATA0,
-				(u32 *)&rt2x00dev->eeprom[i + 6]);
-}
-
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }
 #else
 static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
drivers/net/wireless/rt2x00/rt2800pci.h +0 -29
Index: b/drivers/net/wireless/rt2x00/rt2800pci.h
===================================================================
@@ -56,35 +56,6 @@
 #define TX_DTX_IDX(__x)			TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET)
 
 /*
- * EFUSE_CSR: RT3090 EEPROM
- */
-#define EFUSE_CTRL			0x0580
-#define EFUSE_CTRL_ADDRESS_IN		FIELD32(0x03fe0000)
-#define EFUSE_CTRL_MODE			FIELD32(0x000000c0)
-#define EFUSE_CTRL_KICK			FIELD32(0x40000000)
-#define EFUSE_CTRL_PRESENT		FIELD32(0x80000000)
-
-/*
- * EFUSE_DATA0
- */
-#define EFUSE_DATA0			0x0590
-
-/*
- * EFUSE_DATA1
- */
-#define EFUSE_DATA1			0x0594
-
-/*
- * EFUSE_DATA2
- */
-#define EFUSE_DATA2			0x0598
-
-/*
- * EFUSE_DATA3
- */
-#define EFUSE_DATA3			0x059c
-
-/*
  * 8051 firmware image.
  */
 #define FIRMWARE_RT2860			"rt2860.bin"
#22 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 156

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Ivo

#23 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 156

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Signature · 1 line
Bartlomiej Zolnierkiewicz
#24 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 156

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Ivo

#25 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 59 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 156

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}
Quoted 7 lines

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Please go read the original code..

#ifdef CONFIG_RT2800PCI_PCI
...
[ the code quoted in your mail ]
...
#else
static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) {
}

static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) {
}
#endif /* CONFIG_RT2800PCI_PCI */

[ #else is for CONFIG_RT2800PCI_WISOC ]

Signature · 1 line
Bartlomiej Zolnierkiewicz
#26 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 79 lines · Bartlomiej Zolnierkiewicz
Quoted 59 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 156

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}
Quoted 7 lines

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Please go read the original code..

#ifdef CONFIG_RT2800PCI_PCI
...
[ the code quoted in your mail ]
...
#else
static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) {
}

Quoted 6 lines

static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) {
}
#endif /* CONFIG_RT2800PCI_PCI */

[ #else is for CONFIG_RT2800PCI_WISOC ]

True, but rt2800pci_read_eeprom_efuse() has no WISOC counterpart, the fact that it is compiled into rt2x00lib without any restriction makes the ifdef statements in the rt2800pci obsolete.

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Ivo

#27 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 85 lines · On Sunday 08 November 2009 19:27:30 Ivo van Doorn wrote:
Quoted 84 lines · Bartlomiej Zolnierkiewicz
Quoted 59 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 156

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}
Quoted 7 lines

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Please go read the original code..

#ifdef CONFIG_RT2800PCI_PCI
...
[ the code quoted in your mail ]
...
#else
static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) {
}

static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) {
}
#endif /* CONFIG_RT2800PCI_PCI */

Quoted 5 lines
Quoted 1 line

[ #else is for CONFIG_RT2800PCI_WISOC ]

True, but rt2800pci_read_eeprom_efuse() has no WISOC counterpart, the fact that it is compiled into rt2x00lib without any restriction makes the ifdef statements in the rt2800pci obsolete.

Not really. Please note that driver's behavior WRT WISOC is preserved.

Quoted 4 lines

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Said wrappers predate all of my rt2800 patches.

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Thanks.

Signature · 1 line
Bartlomiej Zolnierkiewicz
#28 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 86 lines · Bartlomiej Zolnierkiewicz
Quoted 85 lines · On Sunday 08 November 2009 19:27:30 Ivo van Doorn wrote:
Quoted 84 lines · Bartlomiej Zolnierkiewicz
Quoted 59 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 155

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}
Quoted 7 lines

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Please go read the original code..

#ifdef CONFIG_RT2800PCI_PCI
...
[ the code quoted in your mail ]
...
#else
static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) {
}

static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) {
}
#endif /* CONFIG_RT2800PCI_PCI */

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

[ #else is for CONFIG_RT2800PCI_WISOC ]

True, but rt2800pci_read_eeprom_efuse() has no WISOC counterpart, the fact that it is compiled into rt2x00lib without any restriction makes the ifdef statements in the rt2800pci obsolete.

Not really. Please note that driver's behavior WRT WISOC is preserved.

The behavior, not the amount of code compiled into the binary. The original code had the efuse code within the ifdef, during the move to rt2800lib it was moved outside the ifdef.

Quoted 6 lines
Quoted 4 lines

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Said wrappers predate all of my rt2800 patches.

Actually the code inside the function was larger, since you removed multiple lines from the function (moved to rt2800lib). But as said above, the wrapper had the code inside the ifdef, while the this patch has the code outside the ifdef, and thus the wrapper has no need.

Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Removing the ifdefs entirely would be fine.

Ivo

#29 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 111 lines · On Sunday 08 November 2009 19:40:27 Ivo van Doorn wrote:
Quoted 86 lines · Bartlomiej Zolnierkiewicz
Quoted 85 lines · On Sunday 08 November 2009 19:27:30 Ivo van Doorn wrote:
Quoted 84 lines · Bartlomiej Zolnierkiewicz
Quoted 59 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 155

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}
Quoted 7 lines

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Please go read the original code..

#ifdef CONFIG_RT2800PCI_PCI
...
[ the code quoted in your mail ]
...
#else
static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) {
}

static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) {
}
#endif /* CONFIG_RT2800PCI_PCI */

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

[ #else is for CONFIG_RT2800PCI_WISOC ]

True, but rt2800pci_read_eeprom_efuse() has no WISOC counterpart, the fact that it is compiled into rt2x00lib without any restriction makes the ifdef statements in the rt2800pci obsolete.

Not really. Please note that driver's behavior WRT WISOC is preserved.

The behavior, not the amount of code compiled into the binary. The original code had the efuse code within the ifdef, during the move to rt2800lib it was moved outside the ifdef.

Quoted 6 lines
Quoted 4 lines

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Said wrappers predate all of my rt2800 patches.

Actually the code inside the function was larger, since you removed multiple lines from the function (moved to rt2800lib). But as said above, the wrapper had the code inside the ifdef, while the this patch has the code outside the ifdef, and thus the wrapper has no need.

Quoted 5 lines
Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Removing the ifdefs entirely would be fine.

Like I said before -- this would mean driver's behavior change. Even though WISOC code is currently dead (RALINK_RT288X and RALINK_RT305X are never set) I prefer to not "overload" patches with logically different changes.

If you feel strongly about it please fix it in rt2x00 code and rt2800 tree will deal with it, or alternatively please send me an incremental patch.

Signature · 1 line
Bartlomiej Zolnierkiewicz
#30 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 8 lines · Bartlomiej Zolnierkiewicz
Quoted 7 lines · On Sunday 08 November 2009 19:40:27 Ivo van Doorn wrote:
Quoted 6 lines · Bartlomiej Zolnierkiewicz
Quoted 5 lines · On Sunday 08 November 2009 19:27:30 Ivo van Doorn wrote:
Quoted 4 lines · Bartlomiej Zolnierkiewicz
Quoted 3 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 2 lines · Bartlomiej Zolnierkiewicz
Quoted 1 line · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:

On Sunday 08 November 2009, Bartlomiej Zolnierkiewicz wrote:

A kind request: please edit your quotations to the minimum.

Signature · 1 line
Kalle Valo
#31 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

In reply to Bartlomiej Zolnierkiewicz
Quoted 116 lines · On Sunday 08 November 2009 19:47:53 Bartlomiej Zolnierkiewicz wrote:
Quoted 115 lines · On Sunday 08 November 2009 19:40:27 Ivo van Doorn wrote:
Quoted 86 lines · Bartlomiej Zolnierkiewicz
Quoted 85 lines · On Sunday 08 November 2009 19:27:30 Ivo van Doorn wrote:
Quoted 84 lines · Bartlomiej Zolnierkiewicz
Quoted 59 lines · On Sunday 08 November 2009 19:08:23 Ivo van Doorn wrote:
Quoted 48 lines · Bartlomiej Zolnierkiewicz
Quoted 35 lines · On Sunday 08 November 2009 14:55:59 Ivo van Doorn wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---
 drivers/net/wireless/rt2x00/rt2800.h    |   29 +++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.c |   43 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/rt2x00/rt2800lib.h |    2 +
 drivers/net/wireless/rt2x00/rt2800pci.c |   38 ++--------------------------
 drivers/net/wireless/rt2x00/rt2800pci.h |   29 ---------------------
 5 files changed, 77 insertions(+), 64 deletions(-)

===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 151

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1 -5
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(st
 
 static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
 {
-	u32 reg;
-
-	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-
-	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+	return rt2800_efuse_detect(rt2x00dev);
 }

It would be better to fix all calls to rt2800pci_efuse_detect to use rt2800_efuse_detect rather then adding a special wrapper function for it.

Quoted 11 lines

drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_read_eeprom_pci(st · line 155

Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2 -5
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-	unsigned int i;
-
-	for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-		rt2800pci_efuse_read(rt2x00dev, i);
+	rt2800_read_eeprom_efuse(rt2x00dev);
 }

Same here.

Quoted 2 lines

Could you please explain some more what do you mean by that? (Please note that we have an extra SOC handling in rt2800pci.c.)

Your changes made the following 2 functions:

int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)

{
	return rt2800_efuse_detect(rt2x00dev);
}
Quoted 7 lines

void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)

{
	rt2800_read_eeprom_efuse(rt2x00dev);
}

So why do we need rt2800pci_* versions in this case? They simply wrap the rt2800 library function without providing anything extra...

Please go read the original code..

#ifdef CONFIG_RT2800PCI_PCI
...
[ the code quoted in your mail ]
...
#else
static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) {
}

static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) {
}
#endif /* CONFIG_RT2800PCI_PCI */

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

[ #else is for CONFIG_RT2800PCI_WISOC ]

True, but rt2800pci_read_eeprom_efuse() has no WISOC counterpart, the fact that it is compiled into rt2x00lib without any restriction makes the ifdef statements in the rt2800pci obsolete.

Not really. Please note that driver's behavior WRT WISOC is preserved.

The behavior, not the amount of code compiled into the binary. The original code had the efuse code within the ifdef, during the move to rt2800lib it was moved outside the ifdef.

Quoted 6 lines
Quoted 4 lines

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Said wrappers predate all of my rt2800 patches.

Actually the code inside the function was larger, since you removed multiple lines from the function (moved to rt2800lib). But as said above, the wrapper had the code inside the ifdef, while the this patch has the code outside the ifdef, and thus the wrapper has no need.

Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Quoted 8 lines
Quoted 1 line

Removing the ifdefs entirely would be fine.

Like I said before -- this would mean driver's behavior change. Even though WISOC code is currently dead (RALINK_RT288X and RALINK_RT305X are never set) I prefer to not "overload" patches with logically different changes.

If you feel strongly about it please fix it in rt2x00 code and rt2800 tree will deal with it, or alternatively please send me an incremental patch.

BTW the patch's impact is _320_ bytes increase of rt2800lib (on x86-64 so it is probably much less on the affected embedded architectures):

text data bss dec hex filename
before:
16916 0 0 16916 4214 drivers/net/wireless/rt2x00/rt2800lib.o
after:
17281 0 0 17281 4381 drivers/net/wireless/rt2x00/rt2800lib.o

for the _completely_ dead code (because embedded WISOC support is never enabled) that probably will be changed over anyway later during development.

IOW something like this is completely not worth to be worried about and I would personally just skip it during review to not waste people's time needlessly..

Signature · 1 line
Bartlomiej Zolnierkiewicz
#32 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Quoted 8 lines
Quoted 1 line

Removing the ifdefs entirely would be fine.

Like I said before -- this would mean driver's behavior change. Even though WISOC code is currently dead (RALINK_RT288X and RALINK_RT305X are never set) I prefer to not "overload" patches with logically different changes.

If you feel strongly about it please fix it in rt2x00 code and rt2800 tree will deal with it, or alternatively please send me an incremental patch.

BTW the patch's impact is _320_ bytes increase of rt2800lib (on x86-64 so it is probably much less on the affected embedded architectures):

Quoted 8 lines

text data bss dec hex filename
before:
16916 0 0 16916 4214 drivers/net/wireless/rt2x00/rt2800lib.o
after:
17281 0 0 17281 4381 drivers/net/wireless/rt2x00/rt2800lib.o

for the _completely_ dead code (because embedded WISOC support is never enabled) that probably will be changed over anyway later during development.

As mentioned: Wisoc is not dead code, it is there for the platform devices with integrated rt2800 chipsets. If you look at KConfig you can see the RALINK_RT288X RALINK_RT305X are dependencies from configuration options...

Quoted 3 lines

IOW something like this is completely not worth to be worried about and I would personally just skip it during review to not waste people's time needlessly..

Well dependencies from/on other drivers is something important...

Ivo

#33 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 22 lines · On Sunday 08 November 2009 20:35:17 Ivo van Doorn wrote:
Quoted 22 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Quoted 8 lines
Quoted 1 line

Removing the ifdefs entirely would be fine.

Like I said before -- this would mean driver's behavior change. Even though WISOC code is currently dead (RALINK_RT288X and RALINK_RT305X are never set) I prefer to not "overload" patches with logically different changes.

If you feel strongly about it please fix it in rt2x00 code and rt2800 tree will deal with it, or alternatively please send me an incremental patch.

BTW the patch's impact is _320_ bytes increase of rt2800lib (on x86-64 so it is probably much less on the affected embedded architectures):

text data bss dec hex filename
before:
16916 0 0 16916 4214 drivers/net/wireless/rt2x00/rt2800lib.o
after:
17281 0 0 17281 4381 drivers/net/wireless/rt2x00/rt2800lib.o

Quoted 4 lines
Quoted 2 lines

for the _completely_ dead code (because embedded WISOC support is never enabled) that probably will be changed over anyway later during development.

As mentioned: Wisoc is not dead code, it is there for the platform devices with

Not in upstream, not in next, not in wireless, not in rt2x00...

=> Not our problem. ;)

Signature · 1 line
Bartlomiej Zolnierkiewicz
#34 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

In reply to Bartlomiej Zolnierkiewicz
Quoted 16 lines
Quoted 16 lines
Quoted 6 lines
Quoted 4 lines

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Said wrappers predate all of my rt2800 patches.

Actually the code inside the function was larger, since you removed multiple lines from the function (moved to rt2800lib). But as said above, the wrapper had the code inside the ifdef, while the this patch has the code outside the ifdef, and thus the wrapper has no need.

Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Quoted 5 lines
Quoted 1 line

Removing the ifdefs entirely would be fine.

Like I said before -- this would mean driver's behavior change. Even though WISOC code is currently dead (RALINK_RT288X and RALINK_RT305X are never set) I prefer to not "overload" patches with logically different changes.

The code is not really dead. RALINK_RT288X and RALINK_RT305X are platforms which are currently present in another tree, it is not the job for rt2x00 to set those defines. I don't know when these platforms will be merged upstream, nor do I know the status of them.

Quoted 2 lines

If you feel strongly about it please fix it in rt2x00 code and rt2800 tree will deal with it, or alternatively please send me an incremental patch.

---

drivers/net/wireless/rt2x00/rt2800pci.c +2 -33
index 6f151d0..b33204d 100644
@@ -80,20 +80,13 @@ static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token)
 	rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
 }
 
-#ifdef CONFIG_RT2800PCI_WISOC
 static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
 {
 	u32 *base_addr = (u32 *) KSEG1ADDR(0x1F040000); /* XXX for RT3052 */
 
 	memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
 }
-#else
-static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
-{
-}
-#endif /* CONFIG_RT2800PCI_WISOC */
 
-#ifdef CONFIG_RT2800PCI_PCI
 static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
 {
 	struct rt2x00_dev *rt2x00dev = eeprom->data;
@@ -145,30 +138,6 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 			       EEPROM_SIZE / sizeof(u16));
 }
 
-static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
-{
-	return rt2800_efuse_detect(rt2x00dev);
-}
-
-static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
-{
-	rt2800_read_eeprom_efuse(rt2x00dev);
-}
-#else
-static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
-{
-}
-
-static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
-{
-	return 0;
-}
-
-static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
-{
-}
-#endif /* CONFIG_RT2800PCI_PCI */
-
 /*
  * Firmware functions
  */
@@ -1070,8 +1039,8 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 		rt2800pci_read_eeprom_soc(rt2x00dev);
 		break;
 	default:
-		if (rt2800pci_efuse_detect(rt2x00dev))
-			rt2800pci_read_eeprom_efuse(rt2x00dev);
+		if (rt2800_efuse_detect(rt2x00dev))
+			rt2800_read_eeprom_efuse(rt2x00dev);
 		else
 			rt2800pci_read_eeprom_pci(rt2x00dev);
 		break;
#35 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

Quoted 18 lines · On Sunday 08 November 2009 20:25:48 Ivo van Doorn wrote:
Quoted 18 lines
Quoted 17 lines
Quoted 6 lines
Quoted 4 lines

The purpose of the defines was to keep the EFUSE code out of the driver on embedded systems. So either rt2800lib should do the same with ifdefs in the rt2800lib.c and rt2800lib.h files, or we don't need the efuse specific wrappers in rt2800pci.c.

Said wrappers predate all of my rt2800 patches.

Actually the code inside the function was larger, since you removed multiple lines from the function (moved to rt2800lib). But as said above, the wrapper had the code inside the ifdef, while the this patch has the code outside the ifdef, and thus the wrapper has no need.

Quoted 3 lines

I think that they shouldn't have been added in the first place and I'll be happy to add patch removing them to rt2800 tree (since code savings seem to be really marginal and not worth the maintenance cost).

Removing the ifdefs entirely would be fine.

Quoted 7 lines
Quoted 3 lines

Like I said before -- this would mean driver's behavior change. Even though WISOC code is currently dead (RALINK_RT288X and RALINK_RT305X are never set) I prefer to not "overload" patches with logically different changes.

The code is not really dead. RALINK_RT288X and RALINK_RT305X are platforms which are currently present in another tree, it is not the job for rt2x00 to set those defines. I don't know when these platforms will be merged upstream, nor do I know the status of them.

They are not really our problem then and said tree should maintain RALINK_RT[288X,305X] specific changes itself. :)

Quoted 4 lines
Quoted 2 lines

If you feel strongly about it please fix it in rt2x00 code and rt2800 tree will deal with it, or alternatively please send me an incremental patch.

Thanks, I'll merge it later to rt2800.

Signature · 1 line
Bartlomiej Zolnierkiewicz
Acked-by on v1 8/9
#36 lore raw

Re: [PATCH 8/9] rt2800: add eFuse EEPROM support code to rt2800lib

In reply to Bartlomiej Zolnierkiewicz
Quoted 8 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib.

---

#37 lore raw

PATCH 9/9 rt2800usb: add eFuse EEPROM support

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: add eFuse EEPROM support

It is needed for at least RT3070 chip.

---
 drivers/net/wireless/rt2x00/rt2800usb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/rt2x00/rt2800usb.c +5 -1
Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================
@@ -667,7 +667,11 @@ static void rt2800usb_fill_rxdone(struct
  */
 static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
-	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+	if (rt2800_efuse_detect(rt2x00dev))
+		rt2800_read_eeprom_efuse(rt2x00dev);
+	else
+		rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,
+				      EEPROM_SIZE);
 
 	return rt2800_validate_eeprom(rt2x00dev);
 }
Acked-by on v1 9/9
#38 lore raw

Re: [PATCH 9/9] rt2800usb: add eFuse EEPROM support

Quoted 6 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: add eFuse EEPROM support

It is needed for at least RT3070 chip.

Quoted 22 lines
---
 drivers/net/wireless/rt2x00/rt2800usb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +5 -1
@@ -667,7 +667,11 @@ static void rt2800usb_fill_rxdone(struct
  */
 static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
-	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+	if (rt2800_efuse_detect(rt2x00dev))
+		rt2800_read_eeprom_efuse(rt2x00dev);
+	else
+		rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,
+				      EEPROM_SIZE);
 
 	return rt2800_validate_eeprom(rt2x00dev);
 }
Acked-by on v1 9/9
#39 lore raw

Re: [PATCH 9/9] rt2800usb: add eFuse EEPROM support

In reply to Bartlomiej Zolnierkiewicz
Quoted 18 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800usb: add eFuse EEPROM support

It is needed for at least RT3070 chip.

---
 drivers/net/wireless/rt2x00/rt2800usb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +0 -0
@@ -667,7 +667,11 @@ static void rt2800usb_fill_rxdone(struct
  */
 static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)

drivers/net/wireless/rt2x00/rt2800usb.c static void rt2800usb_fill_rxdone(struct · line 677

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800usb.c +5 -1
 {
-	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+	if (rt2800_efuse_detect(rt2x00dev))
+		rt2800_read_eeprom_efuse(rt2x00dev);
+	else
+		rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,
+				      EEPROM_SIZE);
 
 	return rt2800_validate_eeprom(rt2x00dev);
 }

I guess this gives further unification possibilities now. The only difference is the SOC support in the rt2800pci variant of this.

Acked-by on v1 1/9
#40 lore raw
In reply to Bartlomiej Zolnierkiewicz
Quoted 6 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for unification of EEPROM support code

* Factor out common code from rt2800[pci,usb]_validate_eeprom() to rt2800_validate_eeprom().

Quoted 6 lines

* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().

* Enclose interface specific code in rt2800[pci,usb]_init_eeprom() with rt2x00_intf_is_[pci,usb]() checks.

Quoted 183 lines

---
on top of "rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci." patch from Gertjan

 drivers/net/wireless/rt2x00/rt2800pci.c |   51 ++++++++++++++++++--------------
 drivers/net/wireless/rt2x00/rt2800usb.c |   40 +++++++++++++++----------
 2 files changed, 55 insertions(+), 36 deletions(-)

Index: b/drivers/net/wireless/rt2x00/rt2800pci.c
===================================================================

drivers/net/wireless/rt2x00/rt2800pci.c +30 -21
@@ -1091,29 +1091,13 @@ static irqreturn_t rt2800pci_interrupt(i
 /*
  * Device probe functions.
  */
-static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 word;
 	u8 *mac;
 	u8 default_lna_gain;
 
 	/*
-	 * Read EEPROM into buffer
-	 */
-	switch(rt2x00dev->chip.rt) {
-	case RT2880:
-	case RT3052:
-		rt2800pci_read_eeprom_soc(rt2x00dev);
-		break;
-	default:
-		if (rt2800pci_efuse_detect(rt2x00dev))
-			rt2800pci_read_eeprom_efuse(rt2x00dev);
-		else
-			rt2800pci_read_eeprom_pci(rt2x00dev);
-		break;
-	}
-
-	/*
 	 * Start validation of the data that has been read.
 	 */
 	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
@@ -1131,7 +1115,7 @@ static int rt2800pci_validate_eeprom(str
 		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
 	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
 		/*
-		 * There is a max of 2 RX streams for RT2860 series
+		 * There is a max of 2 RX streams for RT28x0 series
 		 */
 		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
 			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
@@ -1210,6 +1194,27 @@ static int rt2800pci_validate_eeprom(str
 	return 0;
 }
 
+static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	/*
+	 * Read EEPROM into buffer
+	 */
+	switch (rt2x00dev->chip.rt) {
+	case RT2880:
+	case RT3052:
+		rt2800pci_read_eeprom_soc(rt2x00dev);
+		break;
+	default:
+		if (rt2800pci_efuse_detect(rt2x00dev))
+			rt2800pci_read_eeprom_efuse(rt2x00dev);
+		else
+			rt2800pci_read_eeprom_pci(rt2x00dev);
+		break;
+	}
+
+	return rt2800_validate_eeprom(rt2x00dev);
+}
+
 static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -1226,7 +1231,9 @@ static int rt2800pci_init_eeprom(struct 
 	 */
 	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
 	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-	rt2x00_set_chip_rf(rt2x00dev, value, reg);
+
+	if (rt2x00_intf_is_pci(rt2x00dev))
+		rt2x00_set_chip_rf(rt2x00dev, value, reg);
 
 	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct 
 	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3022)) {
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
 		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
 		return -ENODEV;
 	}

Index: b/drivers/net/wireless/rt2x00/rt2800usb.c
===================================================================

drivers/net/wireless/rt2x00/rt2800usb.c +25 -15
@@ -665,14 +665,12 @@ static void rt2800usb_fill_rxdone(struct
 /*
  * Device probe functions.
  */
-static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 word;
 	u8 *mac;
 	u8 default_lna_gain;
 
-	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
-
 	/*
 	 * Start validation of the data that has been read.
 	 */
@@ -691,7 +689,7 @@ static int rt2800usb_validate_eeprom(str
 		EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
 	} else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
 		/*
-		 * There is a max of 2 RX streams for RT2870 series
+		 * There is a max of 2 RX streams for RT28x0 series
 		 */
 		if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
 			rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
@@ -770,6 +768,13 @@ static int rt2800usb_validate_eeprom(str
 	return 0;
 }
 
+static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
+{
+	rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
+
+	return rt2800_validate_eeprom(rt2x00dev);
+}
+
 static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -786,18 +791,23 @@ static int rt2800usb_init_eeprom(struct 
 	 */
 	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
 	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-	rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
 
-	/*
-	 * The check for rt2860 is not a typo, some rt2870 hardware
-	 * identifies itself as rt2860 in the CSR register.
-	 */
-	if (!rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28600000) &&
-	    !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28700000) &&
-	    !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28800000) &&
-	    !rt2x00_check_rev(&rt2x00dev->chip, 0xffff0000, 0x30700000)) {
-		ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
-		return -ENODEV;
+	if (rt2x00_intf_is_usb(rt2x00dev)) {
+		struct rt2x00_chip *chip = &rt2x00dev->chip;
+
+		rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
+
+		/*
+		 * The check for rt2860 is not a typo, some rt2870 hardware
+		 * identifies itself as rt2860 in the CSR register.
+		 */
+		if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) &&
+		    !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) &&
+		    !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) {
+			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
+			return -ENODEV;
+		}
 	}
 
 	if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
#41 lore raw
In reply to Bartlomiej Zolnierkiewicz
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for unification of EEPROM support code

* Factor out common code from rt2800[pci,usb]_validate_eeprom() to rt2800_validate_eeprom().

* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().

* Enclose interface specific code in rt2800[pci,usb]_init_eeprom() with rt2x00_intf_is_[pci,usb]() checks.

---
on top of "rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci." patch from Gertjan

 drivers/net/wireless/rt2x00/rt2800pci.c |   51 ++++++++++++++++++--------------
 drivers/net/wireless/rt2x00/rt2800usb.c |   40 +++++++++++++++----------
 2 files changed, 55 insertions(+), 36 deletions(-)

<snip>

drivers/net/wireless/rt2x00/rt2800pci.c static int rt2800pci_init_eeprom(struct · line 1250

Quoted 13 lines
drivers/net/wireless/rt2x00/rt2800pci.c +4 -2
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct 
 	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3022)) {
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
 		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
 		return -ENODEV;
 	}

Can we leave this as-is. There are rt2800usb devices that support these RF chipsets as well (I am now the proud owner of such a device), so there is no need to restrict the use of these RF chipsets to just PCI devices.
So, if we leave this as-is then the EEPROM unification ensures rt2800usb will "support" these RF chipsets as well.

---
Gertjan.

#42 lore raw
Quoted 24 lines · On Sunday 08 November 2009 15:16:00 Gertjan van Wingerde wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for unification of EEPROM support code

* Factor out common code from rt2800[pci,usb]_validate_eeprom() to rt2800_validate_eeprom().

* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().

* Enclose interface specific code in rt2800[pci,usb]_init_eeprom() with rt2x00_intf_is_[pci,usb]() checks.

---
on top of "rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci." patch from Gertjan

 drivers/net/wireless/rt2x00/rt2800pci.c |   51 ++++++++++++++++++--------------
 drivers/net/wireless/rt2x00/rt2800usb.c |   40 +++++++++++++++----------
 2 files changed, 55 insertions(+), 36 deletions(-)

<snip>

Quoted 16 lines

drivers/net/wireless/rt2x00/rt2800pci.c static int rt2800pci_init_eeprom(struct · line 1250

Quoted 13 lines
drivers/net/wireless/rt2x00/rt2800pci.c +4 -2
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct 
 	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3022)) {
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
 		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
 		return -ENODEV;
 	}

Can we leave this as-is. There are rt2800usb devices that support these RF chipsets as well (I am now the proud owner of such a device), so there is no need to restrict the use of these RF chipsets to just PCI devices.

Please note that the patch doesn't change the current behavior of rt2800usb and for bisectability reasons I would strongly prefer for it to stay this way.

Quoted 1 line

So, if we leave this as-is then the EEPROM unification ensures rt2800usb will "support" these RF chipsets as well.

Lets work in incremental fashion -- when there is a need to do such change lets just do it against current tree and apply it as soon as possible (this way we won't be spending time on micro-decisions).

IOW just make a post- (or pre-) patch and I'll deal with it.

Thanks.

Signature · 1 line
Bartlomiej Zolnierkiewicz
#43 lore raw
Quoted 47 lines · Bartlomiej Zolnierkiewicz
Quoted 24 lines · On Sunday 08 November 2009 15:16:00 Gertjan van Wingerde wrote:
Quoted 20 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] rt2800: prepare for unification of EEPROM support code

* Factor out common code from rt2800[pci,usb]_validate_eeprom() to rt2800_validate_eeprom().

* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().

* Enclose interface specific code in rt2800[pci,usb]_init_eeprom() with rt2x00_intf_is_[pci,usb]() checks.

---
on top of "rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci." patch from Gertjan

 drivers/net/wireless/rt2x00/rt2800pci.c |   51 ++++++++++++++++++--------------
 drivers/net/wireless/rt2x00/rt2800usb.c |   40 +++++++++++++++----------
 2 files changed, 55 insertions(+), 36 deletions(-)

<snip>

Quoted 16 lines

drivers/net/wireless/rt2x00/rt2800pci.c static int rt2800pci_init_eeprom(struct · line 1250

Quoted 13 lines
drivers/net/wireless/rt2x00/rt2800pci.c +4 -2
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct 
 	    !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
 	    !rt2x00_rf(&rt2x00dev->chip, RF2020) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
-	    !rt2x00_rf(&rt2x00dev->chip, RF3022)) {
+	    (rt2x00_intf_is_usb(rt2x00dev) ||
+	     (rt2x00_intf_is_pci(rt2x00dev) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3021) &&
+	      !rt2x00_rf(&rt2x00dev->chip, RF3022)))) {
 		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
 		return -ENODEV;
 	}

Can we leave this as-is. There are rt2800usb devices that support these RF chipsets as well (I am now the proud owner of such a device), so there is no need to restrict the use of these RF chipsets to just PCI devices.

Please note that the patch doesn't change the current behavior of rt2800usb and for bisectability reasons I would strongly prefer for it to stay this way.

Quoted 1 line

So, if we leave this as-is then the EEPROM unification ensures rt2800usb will "support" these RF chipsets as well.

Quoted 7 lines

Lets work in incremental fashion -- when there is a need to do such change lets just do it against current tree and apply it as soon as possible (this way we won't be spending time on micro-decisions).

IOW just make a post- (or pre-) patch and I'll deal with it.

Thanks.

Yeah, while spending more time on this this afternoon I found out that actually a lot more is needed, so doing this right now doesn't help at all. So, on second thought,

---
Gertjan.