rt2x00: Fix rate initialization
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rt2x00 / rt2x00dev.c
index f0ba481c51e67917c06f6d65a67d39fe971ba062..d69f7407b9729951ef0bc1ab3ef75d67a9989fee 100644 (file)
@@ -378,6 +378,11 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
         */
        rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual);
 
+       /*
+        * Send a signal to the led to update the led signal strength.
+        */
+       rt2x00leds_led_quality(rt2x00dev, rt2x00dev->link.qual.avg_rssi);
+
        /*
         * Evaluate antenna setup, make this the last step since this could
         * possibly reset some statistics.
@@ -827,10 +832,7 @@ static void rt2x00lib_channel(struct ieee80211_channel *entry,
                              const int channel, const int tx_power,
                              const int value)
 {
-       if (channel <= 14)
-               entry->center_freq = 2407 + (5 * channel);
-       else
-               entry->center_freq = 5000 + (5 * channel);
+       entry->center_freq = ieee80211_channel_to_frequency(channel);
        entry->hw_value = value;
        entry->max_power = tx_power;
        entry->max_antenna_gain = 0xff;
@@ -874,7 +876,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
         * Initialize Rate list.
         */
        for (i = 0; i < spec->num_rates; i++)
-               rt2x00lib_rate(&rates[0], i, rt2x00_get_rate(i));
+               rt2x00lib_rate(&rates[i], i, rt2x00_get_rate(i));
 
        /*
         * Initialize Channel list.
@@ -896,7 +898,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
         * Rates: CCK.
         * Channels: 2.4 GHz
         */
-       if (spec->num_modes > HWMODE_B) {
+       if (spec->num_modes > 0) {
                sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
                sbands[IEEE80211_BAND_2GHZ].n_bitrates = 4;
                sbands[IEEE80211_BAND_2GHZ].channels = channels;
@@ -909,7 +911,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
         * Rates: CCK, OFDM.
         * Channels: 2.4 GHz
         */
-       if (spec->num_modes > HWMODE_G) {
+       if (spec->num_modes > 1) {
                sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
                sbands[IEEE80211_BAND_2GHZ].n_bitrates = spec->num_rates;
                sbands[IEEE80211_BAND_2GHZ].channels = channels;
@@ -922,7 +924,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
         * Rates: OFDM.
         * Channels: OFDM, UNII, HiperLAN2.
         */
-       if (spec->num_modes > HWMODE_A) {
+       if (spec->num_modes > 2) {
                sbands[IEEE80211_BAND_5GHZ].n_channels = spec->num_channels - 14;
                sbands[IEEE80211_BAND_5GHZ].n_bitrates = spec->num_rates - 4;
                sbands[IEEE80211_BAND_5GHZ].channels = &channels[14];
@@ -1142,6 +1144,11 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
                goto exit;
        }
 
+       /*
+        * Register LED.
+        */
+       rt2x00leds_register(rt2x00dev);
+
        /*
         * Allocatie rfkill.
         */
@@ -1189,6 +1196,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
         */
        rt2x00rfkill_free(rt2x00dev);
 
+       /*
+        * Free LED.
+        */
+       rt2x00leds_unregister(rt2x00dev);
+
        /*
         * Free ieee80211_hw memory.
         */
@@ -1230,6 +1242,7 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
         */
        rt2x00lib_stop(rt2x00dev);
        rt2x00lib_uninitialize(rt2x00dev);
+       rt2x00leds_suspend(rt2x00dev);
        rt2x00debug_deregister(rt2x00dev);
 
 exit:
@@ -1273,9 +1286,10 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
        NOTICE(rt2x00dev, "Waking up.\n");
 
        /*
-        * Open the debugfs entry.
+        * Open the debugfs entry and restore led handling.
         */
        rt2x00debug_register(rt2x00dev);
+       rt2x00leds_resume(rt2x00dev);
 
        /*
         * Only continue if mac80211 had open interfaces.