Skip to contentSkip to conversation

rt2x00: Fix channel_change_time calculation

PATCH In review Ivo van Doorn 1 participant 1 message Dec 3, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 19/26 rt2x00: Fix channel_change_time calculation

Correctly initialize the channel_change_time. Make sure that channel is reset afterwards, otherwise the channel is not correctly initialized and rx/tx will fail.

Signed-off-by Ivo van Doorn <[email protected]>

---

drivers/net/wireless/d80211/rt2x00/rt2400pci.c +17 -3
diff -rU3 wireless-dev-mac/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-channel/drivers/net/wireless/d80211/rt2x00/rt2400pci.c
@@ -1124,6 +1124,19 @@
 	unsigned long jiffies_end;
 
 	/*
+	 * Only initialize the channel_change_time
+	 * if it has not been set previously.
+	 */
+	if (rt2x00dev->hw->channel_change_time)
+		return 0;
+
+	/*
+	 * Invalidate the rx_params.channel value to make sure
+	 * the config channel will be correctly executed.
+	 */
+	rt2x00dev->rx_params.channel = 0;
+
+	/*
 	 * Determine channel_change_time
 	 * by measuring the time it takes
 	 * to switch the channel.
@@ -1171,10 +1184,11 @@
 	}
 
 	/*
-	 * Determine channel change time.
+	 * Reset the channel_change_time value
+	 * to make sure it will be correctly initialized
+	 * after the radio has been enabled.
 	 */
-	if (rt2400pci_init_channel_time(rt2x00dev))
-		goto exit_fail;
+	rt2x00dev->hw->channel_change_time = 0;
 
 	/*
 	 * Register interrupt handler.
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +17 -3
diff -rU3 wireless-dev-mac/drivers/net/wireless/d80211/rt2x00/rt2500pci.c wireless-dev-channel/drivers/net/wireless/d80211/rt2x00/rt2500pci.c
@@ -1248,6 +1248,19 @@
 	unsigned long jiffies_end;
 
 	/*
+	 * Only initialize the channel_change_time
+	 * if it has not been set previously.
+	 */
+	if (rt2x00dev->hw->channel_change_time)
+		return 0;
+
+	/*
+	 * Invalidate the rx_params.channel value to make sure
+	 * the config channel will be correctly executed.
+	 */
+	rt2x00dev->rx_params.channel = 0;
+
+	/*
 	 * Determine channel_change_time
 	 * by measuring the time it takes
 	 * to switch the channel.
@@ -1296,10 +1309,11 @@
 	}
 
 	/*
-	 * Determine channel change time.
+	 * Reset the channel_change_time value
+	 * to make sure it will be correctly initialized
+	 * after the radio has been enabled.
 	 */
-	if (rt2500pci_init_channel_time(rt2x00dev))
-		goto exit_fail;
+	rt2x00dev->hw->channel_change_time = 0;
 
 	/*
 	 * Register interrupt handler.
drivers/net/wireless/d80211/rt2x00/rt2500usb.c +17 -3
diff -rU3 wireless-dev-mac/drivers/net/wireless/d80211/rt2x00/rt2500usb.c wireless-dev-channel/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
@@ -1214,6 +1214,19 @@
 	unsigned long jiffies_end;
 
 	/*
+	 * Only initialize the channel_change_time
+	 * if it has not been set previously.
+	 */
+	if (rt2x00dev->hw->channel_change_time)
+		return 0;
+
+	/*
+	 * Invalidate the rx_params.channel value to make sure
+	 * the config channel will be correctly executed.
+	 */
+	rt2x00dev->rx_params.channel = 0;
+
+	/*
 	 * Determine channel_change_time
 	 * by measuring the time it takes
 	 * to switch the channel.
@@ -1262,10 +1275,11 @@
 	}
 
 	/*
-	 * Determine channel change time.
+	 * Reset the channel_change_time value
+	 * to make sure it will be correctly initialized
+	 * after the radio has been enabled.
 	 */
-	if (rt2500usb_init_channel_time(rt2x00dev))
-		goto exit_fail;
+	rt2x00dev->hw->channel_change_time = 0;
 
 	SET_FLAG(rt2x00dev, DEVICE_INITIALIZED);
 
drivers/net/wireless/d80211/rt2x00/rt61pci.c +17 -3
diff -rU3 wireless-dev-mac/drivers/net/wireless/d80211/rt2x00/rt61pci.c wireless-dev-channel/drivers/net/wireless/d80211/rt2x00/rt61pci.c
@@ -1681,6 +1681,19 @@
 	unsigned long jiffies_end;
 
 	/*
+	 * Only initialize the channel_change_time
+	 * if it has not been set previously.
+	 */
+	if (rt2x00dev->hw->channel_change_time)
+		return 0;
+
+	/*
+	 * Invalidate the rx_params.channel value to make sure
+	 * the config channel will be correctly executed.
+	 */
+	rt2x00dev->rx_params.channel = 0;
+
+	/*
 	 * Determine channel_change_time
 	 * by measuring the time it takes
 	 * to switch the channel.
@@ -1736,10 +1749,11 @@
 	}
 
 	/*
-	 * Determine channel change time.
+	 * Reset the channel_change_time value
+	 * to make sure it will be correctly initialized
+	 * after the radio has been enabled.
 	 */
-	if (rt61pci_init_channel_time(rt2x00dev))
-		goto exit_fail;
+	rt2x00dev->hw->channel_change_time = 0;
 
 	/*
 	 * Register interrupt handler.
drivers/net/wireless/d80211/rt2x00/rt73usb.c +17 -3
diff -rU3 wireless-dev-mac/drivers/net/wireless/d80211/rt2x00/rt73usb.c wireless-dev-channel/drivers/net/wireless/d80211/rt2x00/rt73usb.c
@@ -1463,6 +1463,19 @@
 	unsigned long jiffies_end;
 
 	/*
+	 * Only initialize the channel_change_time
+	 * if it has not been set previously.
+	 */
+	if (rt2x00dev->hw->channel_change_time)
+		return 0;
+
+	/*
+	 * Invalidate the rx_params.channel value to make sure
+	 * the config channel will be correctly executed.
+	 */
+	rt2x00dev->rx_params.channel = 0;
+
+	/*
 	 * Determine channel_change_time
 	 * by measuring the time it takes
 	 * to switch the channel.
@@ -1518,10 +1531,11 @@
 	}
 
 	/*
-	 * Determine channel change time.
+	 * Reset the channel_change_time value
+	 * to make sure it will be correctly initialized
+	 * after the radio has been enabled.
 	 */
-	if (rt73usb_init_channel_time(rt2x00dev))
-		goto exit_fail;
+	rt2x00dev->hw->channel_change_time = 0;
 
 	SET_FLAG(rt2x00dev, DEVICE_INITIALIZED);