summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/rt2x00/rt2x00config.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-11-02 00:38:10 +0100
committerJohn W. Linville <linville@tuxdriver.com>2008-11-21 11:06:05 -0500
commit6d64360ac56cda95243f15738a06f2a123c663e5 (patch)
tree61005d0d992773ead469590e63477199f0e63f7e /drivers/net/wireless/rt2x00/rt2x00config.c
parent8058409c4fb8e38632207d572ed29943d2585520 (diff)
rt2x00: Fix BUG_ON() with antenna handling
With the new configuration handling, and more specifically splitting the configuration of the antenna from the normal configuration steps allowed a BUG_ON() to be triggered in the driver because the SW_DIVERSITY was send to the driver. This fixes that by catching the value early in rt2x00config.c and replacing it with a sensible value. This also fixes a problem where the antenna is not being initialized at all when the radio is enabled. Since it no longer is part of the mac80211 configuration the only place where rt2x00 configured it was the SW diversity handler. Obviously this is broken for all non-diversity hardware and breaks SW diversity due to a broken initialization. When the radio is enabled the antenna will be configured once as soon as the config() callback function is called. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00config.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 3e4eee3ab7d2..1059b4d1868f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -109,15 +109,32 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
}
void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
- enum antenna rx, enum antenna tx)
+ struct antenna_setup *ant)
{
- struct antenna_setup ant;
-
- ant.rx = rx;
- ant.tx = tx;
+ /*
+ * Failsafe: Make sure we are not sending the
+ * ANTENNA_SW_DIVERSITY state to the driver.
+ * If that happes fallback to hardware default,
+ * or our own default.
+ */
+ if (ant->rx == ANTENNA_SW_DIVERSITY) {
+ if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
+ ant->rx = ANTENNA_B;
+ else
+ ant->rx = rt2x00dev->default_ant.rx;
+ }
+ if (ant->tx == ANTENNA_SW_DIVERSITY) {
+ if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
+ ant->tx = ANTENNA_B;
+ else
+ ant->tx = rt2x00dev->default_ant.tx;
+ }
- if (rx == rt2x00dev->link.ant.active.rx &&
- tx == rt2x00dev->link.ant.active.tx)
+ /*
+ * Only reconfigure when something has changed.
+ */
+ if (ant->rx == rt2x00dev->link.ant.active.rx &&
+ ant->tx == rt2x00dev->link.ant.active.tx)
return;
/*
@@ -132,12 +149,12 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
* The latter is required since we need to recalibrate the
* noise-sensitivity ratio for the new setup.
*/
- rt2x00dev->ops->lib->config_ant(rt2x00dev, &ant);
+ rt2x00dev->ops->lib->config_ant(rt2x00dev, ant);
rt2x00lib_reset_link_tuner(rt2x00dev);
rt2x00_reset_link_ant_rssi(&rt2x00dev->link);
- memcpy(&rt2x00dev->link.ant.active, &ant, sizeof(ant));
+ memcpy(&rt2x00dev->link.ant.active, ant, sizeof(*ant));
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK);