aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/assoc.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-07-30 22:22:43 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-30 22:22:43 -0400
commitdf597efb5737063497f1a4f7c996cc9aec294230 (patch)
tree17bb60f68ee299d9717038197a932501625f1621 /drivers/net/wireless/libertas/assoc.c
parenta33bc5c15154c835aae26f16e6a3a7d9ad4acb45 (diff)
parent0a924578bc4a2823a95c151f56975c71f5c156bb (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts: drivers/net/wireless/iwlwifi/iwl-3945.h drivers/net/wireless/iwlwifi/iwl-tx.c drivers/net/wireless/iwlwifi/iwl3945-base.c
Diffstat (limited to 'drivers/net/wireless/libertas/assoc.c')
-rw-r--r--drivers/net/wireless/libertas/assoc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 385b50f4b105..1902b6f0b78c 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -1,6 +1,7 @@
1/* Copyright (C) 2006, Red Hat, Inc. */ 1/* Copyright (C) 2006, Red Hat, Inc. */
2 2
3#include <linux/types.h> 3#include <linux/types.h>
4#include <linux/kernel.h>
4#include <linux/etherdevice.h> 5#include <linux/etherdevice.h>
5#include <linux/ieee80211.h> 6#include <linux/ieee80211.h>
6#include <linux/if_arp.h> 7#include <linux/if_arp.h>
@@ -43,21 +44,21 @@ static int get_common_rates(struct lbs_private *priv,
43 u16 *rates_size) 44 u16 *rates_size)
44{ 45{
45 u8 *card_rates = lbs_bg_rates; 46 u8 *card_rates = lbs_bg_rates;
46 size_t num_card_rates = sizeof(lbs_bg_rates);
47 int ret = 0, i, j; 47 int ret = 0, i, j;
48 u8 tmp[30]; 48 u8 tmp[(ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1)];
49 size_t tmp_size = 0; 49 size_t tmp_size = 0;
50 50
51 /* For each rate in card_rates that exists in rate1, copy to tmp */ 51 /* For each rate in card_rates that exists in rate1, copy to tmp */
52 for (i = 0; card_rates[i] && (i < num_card_rates); i++) { 52 for (i = 0; i < ARRAY_SIZE(lbs_bg_rates) && card_rates[i]; i++) {
53 for (j = 0; rates[j] && (j < *rates_size); j++) { 53 for (j = 0; j < *rates_size && rates[j]; j++) {
54 if (rates[j] == card_rates[i]) 54 if (rates[j] == card_rates[i])
55 tmp[tmp_size++] = card_rates[i]; 55 tmp[tmp_size++] = card_rates[i];
56 } 56 }
57 } 57 }
58 58
59 lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); 59 lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size);
60 lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates); 60 lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates,
61 ARRAY_SIZE(lbs_bg_rates));
61 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); 62 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size);
62 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); 63 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate);
63 64
@@ -69,10 +70,7 @@ static int get_common_rates(struct lbs_private *priv,
69 lbs_pr_alert("Previously set fixed data rate %#x isn't " 70 lbs_pr_alert("Previously set fixed data rate %#x isn't "
70 "compatible with the network.\n", priv->cur_rate); 71 "compatible with the network.\n", priv->cur_rate);
71 ret = -1; 72 ret = -1;
72 goto done;
73 } 73 }
74 ret = 0;
75
76done: 74done:
77 memset(rates, 0, *rates_size); 75 memset(rates, 0, *rates_size);
78 *rates_size = min_t(int, tmp_size, *rates_size); 76 *rates_size = min_t(int, tmp_size, *rates_size);
@@ -320,7 +318,7 @@ static int lbs_associate(struct lbs_private *priv,
320 rates = (struct mrvl_ie_rates_param_set *) pos; 318 rates = (struct mrvl_ie_rates_param_set *) pos;
321 rates->header.type = cpu_to_le16(TLV_TYPE_RATES); 319 rates->header.type = cpu_to_le16(TLV_TYPE_RATES);
322 memcpy(&rates->rates, &bss->rates, MAX_RATES); 320 memcpy(&rates->rates, &bss->rates, MAX_RATES);
323 tmplen = MAX_RATES; 321 tmplen = min_t(u16, ARRAY_SIZE(rates->rates), MAX_RATES);
324 if (get_common_rates(priv, rates->rates, &tmplen)) { 322 if (get_common_rates(priv, rates->rates, &tmplen)) {
325 ret = -1; 323 ret = -1;
326 goto done; 324 goto done;
@@ -594,7 +592,7 @@ static int lbs_adhoc_join(struct lbs_private *priv,
594 592
595 /* Copy Data rates from the rates recorded in scan response */ 593 /* Copy Data rates from the rates recorded in scan response */
596 memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates)); 594 memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates));
597 ratesize = min_t(u16, sizeof(cmd.bss.rates), MAX_RATES); 595 ratesize = min_t(u16, ARRAY_SIZE(cmd.bss.rates), MAX_RATES);
598 memcpy(cmd.bss.rates, bss->rates, ratesize); 596 memcpy(cmd.bss.rates, bss->rates, ratesize);
599 if (get_common_rates(priv, cmd.bss.rates, &ratesize)) { 597 if (get_common_rates(priv, cmd.bss.rates, &ratesize)) {
600 lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n"); 598 lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n");