staging: brcm80211: replaced 5Ghz specific wf_channel2mhz()
[linux-2.6-block.git] / drivers / staging / brcm80211 / brcmfmac / wl_iw.c
index db6e68eab290ce8fdf24b7066cf9780f06779d92..9d5e2c5e3068a8740e742cd488c9c5296e26d9d4 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <bcmutils.h>
 #include <bcmendian.h>
-#include <proto/ethernet.h>
 
 #include <linux/if_arp.h>
 #include <asm/uaccess.h>
 #include <dngl_stats.h>
 #include <dhd.h>
 #include <dhdioctl.h>
-
+#include <linux/ieee80211.h>
 typedef const struct si_pub si_t;
 #include <wlioctl.h>
 
-#include <proto/ethernet.h>
 #include <dngl_stats.h>
 #include <dhd.h>
 
@@ -137,6 +135,9 @@ typedef struct iscan_info {
        int iscan_ex_param_size;
 } iscan_info_t;
 iscan_info_t *g_iscan;
+
+static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
+
 static void wl_iw_timerfunc(unsigned long data);
 static void wl_iw_set_event_mask(struct net_device *dev);
 static int wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, u16 action);
@@ -488,7 +489,7 @@ wl_iw_get_range(struct net_device *dev,
        wl_rateset_t rateset;
        s8 *channels;
        int error, i, k;
-       uint sf, ch;
+       uint ch;
 
        int phytype;
        int bw_cap = 0, sgi_tx = 0, nmode = 0;
@@ -528,12 +529,12 @@ wl_iw_get_range(struct net_device *dev,
                range->freq[i].i = dtoh32(list->element[i]);
 
                ch = dtoh32(list->element[i]);
-               if (ch <= CH_MAX_2G_CHANNEL)
-                       sf = WF_CHAN_FACTOR_2_4_G;
-               else
-                       sf = WF_CHAN_FACTOR_5_G;
-
-               range->freq[i].m = wf_channel2mhz(ch, sf);
+               if (ch <= CH_MAX_2G_CHANNEL) {
+                       range->freq[i].m = ieee80211_dsss_chan_to_freq(ch);
+               } else {
+                       range->freq[i].m = ieee80211_ofdm_chan_to_freq(
+                                               WF_CHAN_FACTOR_5_G/2, ch);
+               }
                range->freq[i].e = 6;
        }
        range->num_frequency = range->num_channels = i;
@@ -690,7 +691,7 @@ wl_iw_set_spy(struct net_device *dev,
 
        iw->spy_num = min_t(int, ARRAY_SIZE(iw->spy_addr), dwrq->length);
        for (i = 0; i < iw->spy_num; i++)
-               memcpy(&iw->spy_addr[i], addr[i].sa_data, ETH_ALEN);
+               memcpy(iw->spy_addr[i], addr[i].sa_data, ETH_ALEN);
        memset(iw->spy_qual, 0, sizeof(iw->spy_qual));
 
        return 0;
@@ -712,7 +713,7 @@ wl_iw_get_spy(struct net_device *dev,
 
        dwrq->length = iw->spy_num;
        for (i = 0; i < iw->spy_num; i++) {
-               memcpy(addr[i].sa_data, &iw->spy_addr[i], ETH_ALEN);
+               memcpy(addr[i].sa_data, iw->spy_addr[i], ETH_ALEN);
                addr[i].sa_family = AF_UNIX;
                memcpy(&qual[i], &iw->spy_qual[i], sizeof(struct iw_quality));
                iw->spy_qual[i].updated = 0;
@@ -1015,7 +1016,7 @@ static int wl_iw_iscan_prep(wl_scan_params_t *params, wlc_ssid_t *ssid)
 {
        int err = 0;
 
-       memcpy(&params->bssid, &ether_bcast, ETH_ALEN);
+       memcpy(params->bssid, ether_bcast, ETH_ALEN);
        params->bss_type = DOT11_BSSTYPE_ANY;
        params->scan_type = 0;
        params->nprobes = -1;
@@ -1533,11 +1534,15 @@ wl_iw_get_scan_prep(wl_scan_results_t *list,
                }
 
                iwe.cmd = SIOCGIWFREQ;
-               iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
-                                             CHSPEC_CHANNEL(bi->chanspec) <=
-                                             CH_MAX_2G_CHANNEL ?
-                                             WF_CHAN_FACTOR_2_4_G :
-                                             WF_CHAN_FACTOR_5_G);
+
+               if (CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL)
+                       iwe.u.freq.m = ieee80211_dsss_chan_to_freq(
+                                               CHSPEC_CHANNEL(bi->chanspec));
+               else
+                       iwe.u.freq.m = ieee80211_ofdm_chan_to_freq(
+                                               WF_CHAN_FACTOR_5_G/2,
+                                               CHSPEC_CHANNEL(bi->chanspec));
+
                iwe.u.freq.e = 6;
                event =
                    IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
@@ -1810,12 +1815,15 @@ wl_iw_iscan_get_scan(struct net_device *dev,
                        channel =
                            (bi->ctl_ch ==
                             0) ? CHSPEC_CHANNEL(bi->chanspec) : bi->ctl_ch;
-                       iwe.u.freq.m =
-                           wf_channel2mhz(channel,
-                                          channel <=
-                                          CH_MAX_2G_CHANNEL ?
-                                          WF_CHAN_FACTOR_2_4_G :
-                                          WF_CHAN_FACTOR_5_G);
+
+                       if (channel <= CH_MAX_2G_CHANNEL)
+                               iwe.u.freq.m =
+                                       ieee80211_dsss_chan_to_freq(channel);
+                       else
+                               iwe.u.freq.m = ieee80211_ofdm_chan_to_freq(
+                                                       WF_CHAN_FACTOR_5_G/2,
+                                                       channel);
+
                        iwe.u.freq.e = 6;
                        event =
                            IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
@@ -1919,7 +1927,7 @@ wl_iw_set_essid(struct net_device *dev,
 
        memcpy(&join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
        join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
-       memcpy(&join_params.params.bssid, &ether_bcast, ETH_ALEN);
+       memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
 
        wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params,
                             &join_params_size);
@@ -2654,11 +2662,11 @@ wl_iw_set_pmksa(struct net_device *dev,
                        bcopy(&iwpmksa->bssid.sa_data[0],
                              &pmkidptr->pmkid[0].BSSID, ETH_ALEN);
                        bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID,
-                             WPA2_PMKID_LEN);
+                             WLAN_PMKID_LEN);
 
-                       WL_WSEC("wl_iw_set_pmksa:IW_PMKSA_REMOVE:PMKID: %pM = ",
-                               &pmkidptr->pmkid[0].BSSID);
-                       for (j = 0; j < WPA2_PMKID_LEN; j++)
+                       WL_WSEC("wl_iw_set_pmksa:IW_PMKSA_REMOVE:PMKID: "
+                               "%pM = ", &pmkidptr->pmkid[0].BSSID);
+                       for (j = 0; j < WLAN_PMKID_LEN; j++)
                                WL_WSEC("%02x ", pmkidptr->pmkid[0].PMKID[j]);
                        WL_WSEC("\n");
                }
@@ -2678,7 +2686,7 @@ wl_iw_set_pmksa(struct net_device *dev,
                                      ETH_ALEN);
                                bcopy(&pmkid_list.pmkids.pmkid[i + 1].PMKID,
                                      &pmkid_list.pmkids.pmkid[i].PMKID,
-                                     WPA2_PMKID_LEN);
+                                     WLAN_PMKID_LEN);
                        }
                        pmkid_list.pmkids.npmkid--;
                } else
@@ -2697,7 +2705,7 @@ wl_iw_set_pmksa(struct net_device *dev,
                              ETH_ALEN);
                        bcopy(&iwpmksa->pmkid[0],
                              &pmkid_list.pmkids.pmkid[i].PMKID,
-                             WPA2_PMKID_LEN);
+                             WLAN_PMKID_LEN);
                        if (i == pmkid_list.pmkids.npmkid)
                                pmkid_list.pmkids.npmkid++;
                } else
@@ -2708,7 +2716,7 @@ wl_iw_set_pmksa(struct net_device *dev,
                        k = pmkid_list.pmkids.npmkid;
                        WL_WSEC("wl_iw_set_pmksa,IW_PMKSA_ADD - PMKID: %pM = ",
                                &pmkid_list.pmkids.pmkid[k].BSSID);
-                       for (j = 0; j < WPA2_PMKID_LEN; j++)
+                       for (j = 0; j < WLAN_PMKID_LEN; j++)
                                WL_WSEC("%02x ",
                                        pmkid_list.pmkids.pmkid[k].PMKID[j]);
                        WL_WSEC("\n");
@@ -2720,7 +2728,7 @@ wl_iw_set_pmksa(struct net_device *dev,
                uint j;
                WL_WSEC("PMKID[%d]: %pM = ",
                        i, &pmkid_list.pmkids.pmkid[i].BSSID);
-               for (j = 0; j < WPA2_PMKID_LEN; j++)
+               for (j = 0; j < WLAN_PMKID_LEN; j++)
                        WL_WSEC("%02x ", pmkid_list.pmkids.pmkid[i].PMKID[j]);
                WL_WSEC("\n");
        }