ath9k: Add open loop power control support for AR9287.
[pandora-kernel.git] / drivers / net / wireless / rt2x00 / rt2x00config.c
index 3e019a1..3501788 100644 (file)
@@ -124,24 +124,34 @@ enum antenna rt2x00lib_config_antenna_check(enum antenna current_ant,
 }
 
 void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
-                             struct antenna_setup *ant)
+                             struct antenna_setup config)
 {
+       struct link_ant *ant = &rt2x00dev->link.ant;
        struct antenna_setup *def = &rt2x00dev->default_ant;
        struct antenna_setup *active = &rt2x00dev->link.ant.active;
 
        /*
         * Failsafe: Make sure we are not sending the
         * ANTENNA_SW_DIVERSITY state to the driver.
-        * If that happes fallback to hardware default,
+        * If that happens, fallback to hardware defaults,
         * or our own default.
+        * If diversity handling is active for a particular antenna,
+        * we shouldn't overwrite that antenna.
         * The calls to rt2x00lib_config_antenna_check()
         * might have caused that we restore back to the already
         * active setting. If that has happened we can quit.
         */
-       ant->rx = rt2x00lib_config_antenna_check(ant->rx, def->rx);
-       ant->tx = rt2x00lib_config_antenna_check(ant->tx, def->tx);
+       if (!(ant->flags & ANTENNA_RX_DIVERSITY))
+               config.rx = rt2x00lib_config_antenna_check(config.rx, def->rx);
+       else
+               config.rx = active->rx;
 
-       if (ant->rx == active->rx && ant->tx == active->tx)
+       if (!(ant->flags & ANTENNA_TX_DIVERSITY))
+               config.tx = rt2x00lib_config_antenna_check(config.tx, def->tx);
+       else
+               config.tx = active->tx;
+
+       if (config.rx == active->rx && config.tx == active->tx)
                return;
 
        /*
@@ -156,11 +166,11 @@ 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, &config);
 
        rt2x00link_reset_tuner(rt2x00dev, true);
 
-       memcpy(active, ant, sizeof(*ant));
+       memcpy(active, &config, sizeof(config));
 
        if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
                rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK);