wl1251: add get_survey callback in order to get channel noise
authorJohn W. Linville <linville@tuxdriver.com>
Wed, 28 Jul 2010 19:23:30 +0000 (15:23 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jul 2010 16:46:47 +0000 (12:46 -0400)
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Acked-by: Kalle Valo <kvalo@adurom.com>
drivers/net/wireless/wl12xx/wl1251.h
drivers/net/wireless/wl12xx/wl1251_main.c
drivers/net/wireless/wl12xx/wl1251_rx.c

index 4f5f02a26e6272887fabf4f896915f8b916c782f..6b942a28e6a5dd02e87cebd8f20273e234cdea10 100644 (file)
@@ -381,6 +381,9 @@ struct wl1251 {
 
        u32 chip_id;
        char fw_ver[21];
+
+       /* Most recently reported noise in dBm */
+       s8 noise;
 };
 
 int wl1251_plt_start(struct wl1251 *wl);
index 38f72f4171834dcf9d55a747bd89276d2faba710..a6d8d1ad5dc0105a16e92d8d27b1f542e2833908 100644 (file)
@@ -1172,6 +1172,22 @@ out:
        return ret;
 }
 
+static int wl1251_op_get_survey(struct ieee80211_hw *hw, int idx,
+                               struct survey_info *survey)
+{
+       struct wl1251 *wl = hw->priv;
+       struct ieee80211_conf *conf = &hw->conf;
+       if (idx != 0)
+               return -ENOENT;
+       survey->channel = conf->channel;
+       survey->filled = SURVEY_INFO_NOISE_DBM;
+       survey->noise = wl->noise;
+       return 0;
+}
+
 /* can't be const, mac80211 writes to this */
 static struct ieee80211_supported_band wl1251_band_2ghz = {
        .channels = wl1251_channels,
@@ -1193,6 +1209,7 @@ static const struct ieee80211_ops wl1251_ops = {
        .bss_info_changed = wl1251_op_bss_info_changed,
        .set_rts_threshold = wl1251_op_set_rts_threshold,
        .conf_tx = wl1251_op_conf_tx,
+       .get_survey = wl1251_op_get_survey,
 };
 
 static int wl1251_read_eeprom_byte(struct wl1251 *wl, off_t offset, u8 *data)
index 851515836a7f6217085ccbd5f32bf38798ab63ac..1b6294b3b996fd9f660d17c02bc1543b9bd428dd 100644 (file)
@@ -74,6 +74,12 @@ static void wl1251_rx_status(struct wl1251 *wl,
 
        status->signal = desc->rssi;
 
+       /*
+        * FIXME: guessing that snr needs to be divided by two, otherwise
+        * the values don't make any sense
+        */
+       wl->noise = desc->rssi - desc->snr / 2;
+
        status->freq = ieee80211_channel_to_frequency(desc->channel);
 
        status->flag |= RX_FLAG_TSFT;