libertas: separate libertas' Kconfig in it's own file
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / 11d.c
index 377dcb5..5c69681 100644 (file)
@@ -47,7 +47,7 @@ static u8 lbs_region_2_code(u8 *region)
 {
        u8 i;
 
-       for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++)
+       for (i = 0; i < COUNTRY_CODE_LEN && region[i]; i++)
                region[i] = toupper(region[i]);
 
        for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
@@ -79,7 +79,7 @@ static u8 *lbs_code_2_region(u8 code)
  *  @param nrchan   number of channels
  *  @return          the nrchan-th chan number
 */
-static u8 lbs_get_chan_11d(u8 band, u8 firstchan, u8 nrchan, u8 *chan)
+static u8 lbs_get_chan_11d(u8 firstchan, u8 nrchan, u8 *chan)
 /*find the nrchan-th chan after the firstchan*/
 {
        u8 i;
@@ -134,7 +134,7 @@ static u8 lbs_channel_known_11d(u8 chan,
        return 0;
 }
 
-u32 lbs_chan_2_freq(u8 chan, u8 band)
+u32 lbs_chan_2_freq(u8 chan)
 {
        struct chan_freq_power *cf;
        u16 i;
@@ -207,7 +207,7 @@ static int generate_domain_info_11d(struct parsed_region_chan_11d
        lbs_deb_11d("nr_subband=%x\n", domaininfo->nr_subband);
        lbs_deb_hex(LBS_DEB_11D, "domaininfo", (char *)domaininfo,
                COUNTRY_CODE_LEN + 1 +
-               sizeof(struct ieeetypes_subbandset) * nr_subband);
+               sizeof(struct ieee_subbandset) * nr_subband);
        return 0;
 }
 
@@ -264,7 +264,7 @@ static void lbs_generate_parsed_region_chan_11d(struct region_channel *region_ch
  *  @param chan                 chan
  *  @return                    TRUE;FALSE
 */
-static u8 lbs_region_chan_supported_11d(u8 region, u8 band, u8 chan)
+static u8 lbs_region_chan_supported_11d(u8 region, u8 chan)
 {
        struct chan_freq_power *cfp;
        int cfp_no;
@@ -273,7 +273,7 @@ static u8 lbs_region_chan_supported_11d(u8 region, u8 band, u8 chan)
 
        lbs_deb_enter(LBS_DEB_11D);
 
-       cfp = lbs_get_region_cfp_table(region, band, &cfp_no);
+       cfp = lbs_get_region_cfp_table(region, &cfp_no);
        if (cfp == NULL)
                return 0;
 
@@ -302,11 +302,9 @@ done:
  *  @param parsed_region_chan   pointer to parsed_region_chan_11d
  *  @return                    0
 */
-static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
-                                countryinfo,
+static int parse_domain_info_11d(struct ieee_ie_country_info_full_set *countryinfo,
                                 u8 band,
-                                struct parsed_region_chan_11d *
-                                parsed_region_chan)
+                                struct parsed_region_chan_11d *parsed_region_chan)
 {
        u8 nr_subband, nrchan;
        u8 lastchan, firstchan;
@@ -331,7 +329,7 @@ static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
        lbs_deb_hex(LBS_DEB_11D, "countryinfo", (u8 *) countryinfo, 30);
 
        if ((*(countryinfo->countrycode)) == 0
-           || (countryinfo->len <= COUNTRY_CODE_LEN)) {
+           || (countryinfo->header.len <= COUNTRY_CODE_LEN)) {
                /* No region Info or Wrong region info: treat as No 11D info */
                goto done;
        }
@@ -349,8 +347,8 @@ static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
        memcpy(parsed_region_chan->countrycode, countryinfo->countrycode,
               COUNTRY_CODE_LEN);
 
-       nr_subband = (countryinfo->len - COUNTRY_CODE_LEN) /
-           sizeof(struct ieeetypes_subbandset);
+       nr_subband = (countryinfo->header.len - COUNTRY_CODE_LEN) /
+           sizeof(struct ieee_subbandset);
 
        for (j = 0, lastchan = 0; j < nr_subband; j++) {
 
@@ -367,7 +365,7 @@ static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
                for (i = 0; idx < MAX_NO_OF_CHAN && i < nrchan; i++) {
                        /*step4: channel is supported? */
 
-                       if (!lbs_get_chan_11d(band, firstchan, i, &curchan)) {
+                       if (!lbs_get_chan_11d(firstchan, i, &curchan)) {
                                /* Chan is not found in UN table */
                                lbs_deb_11d("chan is not supported: %d \n", i);
                                break;
@@ -375,8 +373,7 @@ static int parse_domain_info_11d(struct ieeetypes_countryinfofullset*
 
                        lastchan = curchan;
 
-                       if (lbs_region_chan_supported_11d
-                           (region, band, curchan)) {
+                       if (lbs_region_chan_supported_11d(region, curchan)) {
                                /*step5: Check if curchan is supported by mrvl in region */
                                parsed_region_chan->chanpwr[idx].chan = curchan;
                                parsed_region_chan->chanpwr[idx].pwr =
@@ -432,8 +429,8 @@ u8 lbs_get_scan_type_11d(u8 chan,
 
 void lbs_init_11d(struct lbs_private *priv)
 {
-       priv->adapter->enable11d = 0;
-       memset(&(priv->adapter->parsed_region_chan), 0,
+       priv->enable11d = 0;
+       memset(&(priv->parsed_region_chan), 0,
               sizeof(struct parsed_region_chan_11d));
        return;
 }
@@ -447,7 +444,7 @@ static int set_domain_info_11d(struct lbs_private *priv)
 {
        int ret;
 
-       if (!priv->adapter->enable11d) {
+       if (!priv->enable11d) {
                lbs_deb_11d("dnld domain Info with 11d disabled\n");
                return 0;
        }
@@ -469,22 +466,21 @@ static int set_domain_info_11d(struct lbs_private *priv)
 */
 int lbs_set_universaltable(struct lbs_private *priv, u8 band)
 {
-       struct lbs_adapter *adapter = priv->adapter;
        u16 size = sizeof(struct chan_freq_power);
        u16 i = 0;
 
-       memset(adapter->universal_channel, 0,
-              sizeof(adapter->universal_channel));
+       memset(priv->universal_channel, 0,
+              sizeof(priv->universal_channel));
 
-       adapter->universal_channel[i].nrcfp =
+       priv->universal_channel[i].nrcfp =
            sizeof(channel_freq_power_UN_BG) / size;
        lbs_deb_11d("BG-band nrcfp %d\n",
-              adapter->universal_channel[i].nrcfp);
+              priv->universal_channel[i].nrcfp);
 
-       adapter->universal_channel[i].CFP = channel_freq_power_UN_BG;
-       adapter->universal_channel[i].valid = 1;
-       adapter->universal_channel[i].region = UNIVERSAL_REGION_CODE;
-       adapter->universal_channel[i].band = band;
+       priv->universal_channel[i].CFP = channel_freq_power_UN_BG;
+       priv->universal_channel[i].valid = 1;
+       priv->universal_channel[i].region = UNIVERSAL_REGION_CODE;
+       priv->universal_channel[i].band = band;
        i++;
 
        return 0;
@@ -504,9 +500,8 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
 {
        struct cmd_ds_802_11d_domain_info *pdomaininfo =
            &cmd->params.domaininfo;
-       struct mrvlietypes_domainparamset *domain = &pdomaininfo->domain;
-       struct lbs_adapter *adapter = priv->adapter;
-       u8 nr_subband = adapter->domainreg.nr_subband;
+       struct mrvl_ie_domain_param_set *domain = &pdomaininfo->domain;
+       u8 nr_subband = priv->domainreg.nr_subband;
 
        lbs_deb_enter(LBS_DEB_11D);
 
@@ -518,25 +513,25 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
                cmd->size =
                    cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN);
                lbs_deb_hex(LBS_DEB_11D, "802_11D_DOMAIN_INFO", (u8 *) cmd,
-                       (int)(cmd->size));
+                       le16_to_cpu(cmd->size));
                goto done;
        }
 
        domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN);
-       memcpy(domain->countrycode, adapter->domainreg.countrycode,
+       memcpy(domain->countrycode, priv->domainreg.countrycode,
               sizeof(domain->countrycode));
 
        domain->header.len =
-           cpu_to_le16(nr_subband * sizeof(struct ieeetypes_subbandset) +
+           cpu_to_le16(nr_subband * sizeof(struct ieee_subbandset) +
                             sizeof(domain->countrycode));
 
        if (nr_subband) {
-               memcpy(domain->subband, adapter->domainreg.subband,
-                      nr_subband * sizeof(struct ieeetypes_subbandset));
+               memcpy(domain->subband, priv->domainreg.subband,
+                      nr_subband * sizeof(struct ieee_subbandset));
 
                cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) +
                                             le16_to_cpu(domain->header.len) +
-                                            sizeof(struct mrvlietypesheader) +
+                                            sizeof(struct mrvl_ie_header) +
                                             S_DS_GEN);
        } else {
                cmd->size =
@@ -556,11 +551,10 @@ done:
  *  @param resp    pointer to command response buffer
  *  @return       0; -1
  */
-int lbs_ret_802_11d_domain_info(struct lbs_private *priv,
-                                struct cmd_ds_command *resp)
+int lbs_ret_802_11d_domain_info(struct cmd_ds_command *resp)
 {
        struct cmd_ds_802_11d_domain_info *domaininfo = &resp->params.domaininforesp;
-       struct mrvlietypes_domainparamset *domain = &domaininfo->domain;
+       struct mrvl_ie_domain_param_set *domain = &domaininfo->domain;
        u16 action = le16_to_cpu(domaininfo->action);
        s16 ret = 0;
        u8 nr_subband = 0;
@@ -571,7 +565,7 @@ int lbs_ret_802_11d_domain_info(struct lbs_private *priv,
                (int)le16_to_cpu(resp->size));
 
        nr_subband = (le16_to_cpu(domain->header.len) - COUNTRY_CODE_LEN) /
-                     sizeof(struct ieeetypes_subbandset);
+                     sizeof(struct ieee_subbandset);
 
        lbs_deb_11d("domain info resp: nr_subband %d\n", nr_subband);
 
@@ -605,24 +599,23 @@ int lbs_parse_dnld_countryinfo_11d(struct lbs_private *priv,
                                         struct bss_descriptor * bss)
 {
        int ret;
-       struct lbs_adapter *adapter = priv->adapter;
 
        lbs_deb_enter(LBS_DEB_11D);
-       if (priv->adapter->enable11d) {
-               memset(&adapter->parsed_region_chan, 0,
+       if (priv->enable11d) {
+               memset(&priv->parsed_region_chan, 0,
                       sizeof(struct parsed_region_chan_11d));
                ret = parse_domain_info_11d(&bss->countryinfo, 0,
-                                              &adapter->parsed_region_chan);
+                                              &priv->parsed_region_chan);
 
                if (ret == -1) {
                        lbs_deb_11d("error parsing domain_info from AP\n");
                        goto done;
                }
 
-               memset(&adapter->domainreg, 0,
+               memset(&priv->domainreg, 0,
                       sizeof(struct lbs_802_11d_domain_reg));
-               generate_domain_info_11d(&adapter->parsed_region_chan,
-                                     &adapter->domainreg);
+               generate_domain_info_11d(&priv->parsed_region_chan,
+                                     &priv->domainreg);
 
                ret = set_domain_info_11d(priv);
 
@@ -646,18 +639,17 @@ done:
 int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv)
 {
        int ret;
-       struct lbs_adapter *adapter = priv->adapter;
        struct region_channel *region_chan;
        u8 j;
 
        lbs_deb_enter(LBS_DEB_11D);
-       lbs_deb_11d("curbssparams.band %d\n", adapter->curbssparams.band);
+       lbs_deb_11d("curbssparams.band %d\n", priv->curbssparams.band);
 
-       if (priv->adapter->enable11d) {
+       if (priv->enable11d) {
                /* update parsed_region_chan_11; dnld domaininf to FW */
 
-               for (j = 0; j < ARRAY_SIZE(adapter->region_channel); j++) {
-                       region_chan = &adapter->region_channel[j];
+               for (j = 0; j < ARRAY_SIZE(priv->region_channel); j++) {
+                       region_chan = &priv->region_channel[j];
 
                        lbs_deb_11d("%d region_chan->band %d\n", j,
                               region_chan->band);
@@ -665,28 +657,28 @@ int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv)
                        if (!region_chan || !region_chan->valid
                            || !region_chan->CFP)
                                continue;
-                       if (region_chan->band != adapter->curbssparams.band)
+                       if (region_chan->band != priv->curbssparams.band)
                                continue;
                        break;
                }
 
-               if (j >= ARRAY_SIZE(adapter->region_channel)) {
+               if (j >= ARRAY_SIZE(priv->region_channel)) {
                        lbs_deb_11d("region_chan not found, band %d\n",
-                              adapter->curbssparams.band);
+                              priv->curbssparams.band);
                        ret = -1;
                        goto done;
                }
 
-               memset(&adapter->parsed_region_chan, 0,
+               memset(&priv->parsed_region_chan, 0,
                       sizeof(struct parsed_region_chan_11d));
                lbs_generate_parsed_region_chan_11d(region_chan,
-                                                    &adapter->
+                                                    &priv->
                                                     parsed_region_chan);
 
-               memset(&adapter->domainreg, 0,
+               memset(&priv->domainreg, 0,
                       sizeof(struct lbs_802_11d_domain_reg));
-               generate_domain_info_11d(&adapter->parsed_region_chan,
-                                        &adapter->domainreg);
+               generate_domain_info_11d(&priv->parsed_region_chan,
+                                        &priv->domainreg);
 
                ret = set_domain_info_11d(priv);