aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/p54/eeprom.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/wireless/p54/eeprom.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/wireless/p54/eeprom.c')
-rw-r--r--drivers/net/wireless/p54/eeprom.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c
index 0efe67deedee..187e263b045a 100644
--- a/drivers/net/wireless/p54/eeprom.c
+++ b/drivers/net/wireless/p54/eeprom.c
@@ -20,6 +20,7 @@
20#include <linux/firmware.h> 20#include <linux/firmware.h>
21#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
22#include <linux/sort.h> 22#include <linux/sort.h>
23#include <linux/slab.h>
23 24
24#include <net/mac80211.h> 25#include <net/mac80211.h>
25 26
@@ -126,7 +127,7 @@ static int p54_generate_band(struct ieee80211_hw *dev,
126 int ret = -ENOMEM; 127 int ret = -ENOMEM;
127 128
128 if ((!list->entries) || (!list->band_channel_num[band])) 129 if ((!list->entries) || (!list->band_channel_num[band]))
129 return 0; 130 return -EINVAL;
130 131
131 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 132 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
132 if (!tmp) 133 if (!tmp)
@@ -158,6 +159,7 @@ static int p54_generate_band(struct ieee80211_hw *dev,
158 (list->channels[i].data & CHAN_HAS_CURVE ? "" : 159 (list->channels[i].data & CHAN_HAS_CURVE ? "" :
159 " [curve data]"), 160 " [curve data]"),
160 list->channels[i].index, list->channels[i].freq); 161 list->channels[i].index, list->channels[i].freq);
162 continue;
161 } 163 }
162 164
163 tmp->channels[j].band = list->channels[i].band; 165 tmp->channels[j].band = list->channels[i].band;
@@ -165,7 +167,16 @@ static int p54_generate_band(struct ieee80211_hw *dev,
165 j++; 167 j++;
166 } 168 }
167 169
168 tmp->n_channels = list->band_channel_num[band]; 170 if (j == 0) {
171 printk(KERN_ERR "%s: Disabling totally damaged %s band.\n",
172 wiphy_name(dev->wiphy), (band == IEEE80211_BAND_2GHZ) ?
173 "2 GHz" : "5 GHz");
174
175 ret = -ENODATA;
176 goto err_out;
177 }
178
179 tmp->n_channels = j;
169 old = priv->band_table[band]; 180 old = priv->band_table[band];
170 priv->band_table[band] = tmp; 181 priv->band_table[band] = tmp;
171 if (old) { 182 if (old) {
@@ -228,13 +239,13 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
228 struct p54_common *priv = dev->priv; 239 struct p54_common *priv = dev->priv;
229 struct p54_channel_list *list; 240 struct p54_channel_list *list;
230 unsigned int i, j, max_channel_num; 241 unsigned int i, j, max_channel_num;
231 int ret = -ENOMEM; 242 int ret = 0;
232 u16 freq; 243 u16 freq;
233 244
234 if ((priv->iq_autocal_len != priv->curve_data->entries) || 245 if ((priv->iq_autocal_len != priv->curve_data->entries) ||
235 (priv->iq_autocal_len != priv->output_limit->entries)) 246 (priv->iq_autocal_len != priv->output_limit->entries))
236 printk(KERN_ERR "%s: EEPROM is damaged... you may not be able" 247 printk(KERN_ERR "%s: Unsupported or damaged EEPROM detected. "
237 "to use all channels with this device.\n", 248 "You may not be able to use all channels.\n",
238 wiphy_name(dev->wiphy)); 249 wiphy_name(dev->wiphy));
239 250
240 max_channel_num = max_t(unsigned int, priv->output_limit->entries, 251 max_channel_num = max_t(unsigned int, priv->output_limit->entries,
@@ -243,8 +254,10 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
243 priv->curve_data->entries); 254 priv->curve_data->entries);
244 255
245 list = kzalloc(sizeof(*list), GFP_KERNEL); 256 list = kzalloc(sizeof(*list), GFP_KERNEL);
246 if (!list) 257 if (!list) {
258 ret = -ENOMEM;
247 goto free; 259 goto free;
260 }
248 261
249 list->max_entries = max_channel_num; 262 list->max_entries = max_channel_num;
250 list->channels = kzalloc(sizeof(struct p54_channel_entry) * 263 list->channels = kzalloc(sizeof(struct p54_channel_entry) *
@@ -282,13 +295,8 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
282 p54_compare_channels, NULL); 295 p54_compare_channels, NULL);
283 296
284 for (i = 0, j = 0; i < IEEE80211_NUM_BANDS; i++) { 297 for (i = 0, j = 0; i < IEEE80211_NUM_BANDS; i++) {
285 if (list->band_channel_num[i]) { 298 if (p54_generate_band(dev, list, i) == 0)
286 ret = p54_generate_band(dev, list, i);
287 if (ret)
288 goto free;
289
290 j++; 299 j++;
291 }
292 } 300 }
293 if (j == 0) { 301 if (j == 0) {
294 /* no useable band available. */ 302 /* no useable band available. */