aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c120
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c58
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c63
-rw-r--r--drivers/net/wireless/hostap/hostap_wlan.h23
4 files changed, 166 insertions, 98 deletions
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 3210c99694e6..70242459d57a 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -40,6 +40,14 @@ module_param(ignore_cis_vcc, int, 0444);
40MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry"); 40MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
41 41
42 42
43/* struct local_info::hw_priv */
44struct hostap_cs_priv {
45 dev_node_t node;
46 dev_link_t *link;
47 int sandisk_connectplus;
48};
49
50
43#ifdef PRISM2_IO_DEBUG 51#ifdef PRISM2_IO_DEBUG
44 52
45static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v) 53static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
@@ -203,8 +211,9 @@ static int prism2_event(event_t event, int priority,
203 211
204static int prism2_pccard_card_present(local_info_t *local) 212static int prism2_pccard_card_present(local_info_t *local)
205{ 213{
206 if (local->link != NULL && 214 struct hostap_cs_priv *hw_priv = local->hw_priv;
207 ((local->link->state & (DEV_PRESENT | DEV_CONFIG)) == 215 if (hw_priv->link != NULL &&
216 ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
208 (DEV_PRESENT | DEV_CONFIG))) 217 (DEV_PRESENT | DEV_CONFIG)))
209 return 1; 218 return 1;
210 return 0; 219 return 0;
@@ -224,12 +233,14 @@ static void sandisk_set_iobase(local_info_t *local)
224{ 233{
225 int res; 234 int res;
226 conf_reg_t reg; 235 conf_reg_t reg;
236 struct hostap_cs_priv *hw_priv = local->hw_priv;
227 237
228 reg.Function = 0; 238 reg.Function = 0;
229 reg.Action = CS_WRITE; 239 reg.Action = CS_WRITE;
230 reg.Offset = 0x10; /* 0x3f0 IO base 1 */ 240 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
231 reg.Value = local->link->io.BasePort1 & 0x00ff; 241 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
232 res = pcmcia_access_configuration_register(local->link->handle, &reg); 242 res = pcmcia_access_configuration_register(hw_priv->link->handle,
243 &reg);
233 if (res != CS_SUCCESS) { 244 if (res != CS_SUCCESS) {
234 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" 245 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
235 " res=%d\n", res); 246 " res=%d\n", res);
@@ -239,8 +250,9 @@ static void sandisk_set_iobase(local_info_t *local)
239 reg.Function = 0; 250 reg.Function = 0;
240 reg.Action = CS_WRITE; 251 reg.Action = CS_WRITE;
241 reg.Offset = 0x12; /* 0x3f2 IO base 2 */ 252 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
242 reg.Value = (local->link->io.BasePort1 & 0xff00) >> 8; 253 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
243 res = pcmcia_access_configuration_register(local->link->handle, &reg); 254 res = pcmcia_access_configuration_register(hw_priv->link->handle,
255 &reg);
244 if (res != CS_SUCCESS) { 256 if (res != CS_SUCCESS) {
245 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" 257 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
246 " res=%d\n", res); 258 " res=%d\n", res);
@@ -272,8 +284,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
272 tuple_t tuple; 284 tuple_t tuple;
273 cisparse_t *parse = NULL; 285 cisparse_t *parse = NULL;
274 u_char buf[64]; 286 u_char buf[64];
287 struct hostap_cs_priv *hw_priv = local->hw_priv;
275 288
276 if (local->link->io.NumPorts1 < 0x42) { 289 if (hw_priv->link->io.NumPorts1 < 0x42) {
277 /* Not enough ports to be SanDisk multi-function card */ 290 /* Not enough ports to be SanDisk multi-function card */
278 ret = -ENODEV; 291 ret = -ENODEV;
279 goto done; 292 goto done;
@@ -290,9 +303,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
290 tuple.TupleData = buf; 303 tuple.TupleData = buf;
291 tuple.TupleDataMax = sizeof(buf); 304 tuple.TupleDataMax = sizeof(buf);
292 tuple.TupleOffset = 0; 305 tuple.TupleOffset = 0;
293 if (pcmcia_get_first_tuple(local->link->handle, &tuple) || 306 if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
294 pcmcia_get_tuple_data(local->link->handle, &tuple) || 307 pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
295 pcmcia_parse_tuple(local->link->handle, &tuple, parse) || 308 pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
296 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) { 309 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
297 /* No SanDisk manfid found */ 310 /* No SanDisk manfid found */
298 ret = -ENODEV; 311 ret = -ENODEV;
@@ -300,9 +313,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
300 } 313 }
301 314
302 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 315 tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
303 if (pcmcia_get_first_tuple(local->link->handle, &tuple) || 316 if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
304 pcmcia_get_tuple_data(local->link->handle, &tuple) || 317 pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
305 pcmcia_parse_tuple(local->link->handle, &tuple, parse) || 318 pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
306 parse->longlink_mfc.nfn < 2) { 319 parse->longlink_mfc.nfn < 2) {
307 /* No multi-function links found */ 320 /* No multi-function links found */
308 ret = -ENODEV; 321 ret = -ENODEV;
@@ -311,13 +324,14 @@ static int sandisk_enable_wireless(struct net_device *dev)
311 324
312 printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected" 325 printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
313 " - using vendor-specific initialization\n", dev->name); 326 " - using vendor-specific initialization\n", dev->name);
314 local->sandisk_connectplus = 1; 327 hw_priv->sandisk_connectplus = 1;
315 328
316 reg.Function = 0; 329 reg.Function = 0;
317 reg.Action = CS_WRITE; 330 reg.Action = CS_WRITE;
318 reg.Offset = CISREG_COR; 331 reg.Offset = CISREG_COR;
319 reg.Value = COR_SOFT_RESET; 332 reg.Value = COR_SOFT_RESET;
320 res = pcmcia_access_configuration_register(local->link->handle, &reg); 333 res = pcmcia_access_configuration_register(hw_priv->link->handle,
334 &reg);
321 if (res != CS_SUCCESS) { 335 if (res != CS_SUCCESS) {
322 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 336 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
323 dev->name, res); 337 dev->name, res);
@@ -333,7 +347,8 @@ static int sandisk_enable_wireless(struct net_device *dev)
333 * will be enabled during the first cor_sreset call. 347 * will be enabled during the first cor_sreset call.
334 */ 348 */
335 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; 349 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
336 res = pcmcia_access_configuration_register(local->link->handle, &reg); 350 res = pcmcia_access_configuration_register(hw_priv->link->handle,
351 &reg);
337 if (res != CS_SUCCESS) { 352 if (res != CS_SUCCESS) {
338 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 353 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
339 dev->name, res); 354 dev->name, res);
@@ -358,6 +373,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
358{ 373{
359 int res; 374 int res;
360 conf_reg_t reg; 375 conf_reg_t reg;
376 struct hostap_cs_priv *hw_priv = local->hw_priv;
361 377
362 if (!prism2_pccard_card_present(local)) 378 if (!prism2_pccard_card_present(local))
363 return; 379 return;
@@ -366,7 +382,8 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
366 reg.Action = CS_READ; 382 reg.Action = CS_READ;
367 reg.Offset = CISREG_COR; 383 reg.Offset = CISREG_COR;
368 reg.Value = 0; 384 reg.Value = 0;
369 res = pcmcia_access_configuration_register(local->link->handle, &reg); 385 res = pcmcia_access_configuration_register(hw_priv->link->handle,
386 &reg);
370 if (res != CS_SUCCESS) { 387 if (res != CS_SUCCESS) {
371 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", 388 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
372 res); 389 res);
@@ -377,28 +394,30 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
377 394
378 reg.Action = CS_WRITE; 395 reg.Action = CS_WRITE;
379 reg.Value |= COR_SOFT_RESET; 396 reg.Value |= COR_SOFT_RESET;
380 res = pcmcia_access_configuration_register(local->link->handle, &reg); 397 res = pcmcia_access_configuration_register(hw_priv->link->handle,
398 &reg);
381 if (res != CS_SUCCESS) { 399 if (res != CS_SUCCESS) {
382 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", 400 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
383 res); 401 res);
384 return; 402 return;
385 } 403 }
386 404
387 mdelay(local->sandisk_connectplus ? 5 : 2); 405 mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
388 406
389 reg.Value &= ~COR_SOFT_RESET; 407 reg.Value &= ~COR_SOFT_RESET;
390 if (local->sandisk_connectplus) 408 if (hw_priv->sandisk_connectplus)
391 reg.Value |= COR_IREQ_ENA; 409 reg.Value |= COR_IREQ_ENA;
392 res = pcmcia_access_configuration_register(local->link->handle, &reg); 410 res = pcmcia_access_configuration_register(hw_priv->link->handle,
411 &reg);
393 if (res != CS_SUCCESS) { 412 if (res != CS_SUCCESS) {
394 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", 413 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
395 res); 414 res);
396 return; 415 return;
397 } 416 }
398 417
399 mdelay(local->sandisk_connectplus ? 5 : 2); 418 mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
400 419
401 if (local->sandisk_connectplus) 420 if (hw_priv->sandisk_connectplus)
402 sandisk_set_iobase(local); 421 sandisk_set_iobase(local);
403} 422}
404 423
@@ -408,11 +427,12 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
408 int res; 427 int res;
409 conf_reg_t reg; 428 conf_reg_t reg;
410 int old_cor; 429 int old_cor;
430 struct hostap_cs_priv *hw_priv = local->hw_priv;
411 431
412 if (!prism2_pccard_card_present(local)) 432 if (!prism2_pccard_card_present(local))
413 return; 433 return;
414 434
415 if (local->sandisk_connectplus) { 435 if (hw_priv->sandisk_connectplus) {
416 sandisk_write_hcr(local, hcr); 436 sandisk_write_hcr(local, hcr);
417 return; 437 return;
418 } 438 }
@@ -421,7 +441,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
421 reg.Action = CS_READ; 441 reg.Action = CS_READ;
422 reg.Offset = CISREG_COR; 442 reg.Offset = CISREG_COR;
423 reg.Value = 0; 443 reg.Value = 0;
424 res = pcmcia_access_configuration_register(local->link->handle, &reg); 444 res = pcmcia_access_configuration_register(hw_priv->link->handle,
445 &reg);
425 if (res != CS_SUCCESS) { 446 if (res != CS_SUCCESS) {
426 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " 447 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
427 "(%d)\n", res); 448 "(%d)\n", res);
@@ -433,7 +454,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
433 454
434 reg.Action = CS_WRITE; 455 reg.Action = CS_WRITE;
435 reg.Value |= COR_SOFT_RESET; 456 reg.Value |= COR_SOFT_RESET;
436 res = pcmcia_access_configuration_register(local->link->handle, &reg); 457 res = pcmcia_access_configuration_register(hw_priv->link->handle,
458 &reg);
437 if (res != CS_SUCCESS) { 459 if (res != CS_SUCCESS) {
438 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " 460 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
439 "(%d)\n", res); 461 "(%d)\n", res);
@@ -446,7 +468,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
446 reg.Action = CS_WRITE; 468 reg.Action = CS_WRITE;
447 reg.Value = hcr; 469 reg.Value = hcr;
448 reg.Offset = CISREG_CCSR; 470 reg.Offset = CISREG_CCSR;
449 res = pcmcia_access_configuration_register(local->link->handle, &reg); 471 res = pcmcia_access_configuration_register(hw_priv->link->handle,
472 &reg);
450 if (res != CS_SUCCESS) { 473 if (res != CS_SUCCESS) {
451 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " 474 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
452 "(%d)\n", res); 475 "(%d)\n", res);
@@ -457,7 +480,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
457 reg.Action = CS_WRITE; 480 reg.Action = CS_WRITE;
458 reg.Offset = CISREG_COR; 481 reg.Offset = CISREG_COR;
459 reg.Value = old_cor & ~COR_SOFT_RESET; 482 reg.Value = old_cor & ~COR_SOFT_RESET;
460 res = pcmcia_access_configuration_register(local->link->handle, &reg); 483 res = pcmcia_access_configuration_register(hw_priv->link->handle,
484 &reg);
461 if (res != CS_SUCCESS) { 485 if (res != CS_SUCCESS) {
462 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " 486 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
463 "(%d)\n", res); 487 "(%d)\n", res);
@@ -470,23 +494,29 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
470 494
471static int prism2_pccard_dev_open(local_info_t *local) 495static int prism2_pccard_dev_open(local_info_t *local)
472{ 496{
473 local->link->open++; 497 struct hostap_cs_priv *hw_priv = local->hw_priv;
498 hw_priv->link->open++;
474 return 0; 499 return 0;
475} 500}
476 501
477 502
478static int prism2_pccard_dev_close(local_info_t *local) 503static int prism2_pccard_dev_close(local_info_t *local)
479{ 504{
480 if (local == NULL || local->link == NULL) 505 struct hostap_cs_priv *hw_priv;
506
507 if (local == NULL || local->hw_priv == NULL)
508 return 1;
509 hw_priv = local->hw_priv;
510 if (hw_priv->link == NULL)
481 return 1; 511 return 1;
482 512
483 if (!local->link->open) { 513 if (!hw_priv->link->open) {
484 printk(KERN_WARNING "%s: prism2_pccard_dev_close(): " 514 printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
485 "link not open?!\n", local->dev->name); 515 "link not open?!\n", local->dev->name);
486 return 1; 516 return 1;
487 } 517 }
488 518
489 local->link->open--; 519 hw_priv->link->open--;
490 520
491 return 0; 521 return 0;
492} 522}
@@ -567,8 +597,13 @@ static void prism2_detach(dev_link_t *link)
567 *linkp = link->next; 597 *linkp = link->next;
568 /* release net devices */ 598 /* release net devices */
569 if (link->priv) { 599 if (link->priv) {
570 prism2_free_local_data((struct net_device *) link->priv); 600 struct net_device *dev;
571 601 struct hostap_interface *iface;
602 dev = link->priv;
603 iface = netdev_priv(dev);
604 kfree(iface->local->hw_priv);
605 iface->local->hw_priv = NULL;
606 prism2_free_local_data(dev);
572 } 607 }
573 kfree(link); 608 kfree(link);
574} 609}
@@ -601,14 +636,19 @@ static int prism2_config(dev_link_t *link)
601 u_char buf[64]; 636 u_char buf[64];
602 config_info_t conf; 637 config_info_t conf;
603 cistpl_cftable_entry_t dflt = { 0 }; 638 cistpl_cftable_entry_t dflt = { 0 };
639 struct hostap_cs_priv *hw_priv;
604 640
605 PDEBUG(DEBUG_FLOW, "prism2_config()\n"); 641 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
606 642
607 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); 643 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
608 if (parse == NULL) { 644 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
645 if (parse == NULL || hw_priv == NULL) {
646 kfree(parse);
647 kfree(hw_priv);
609 ret = -ENOMEM; 648 ret = -ENOMEM;
610 goto failed; 649 goto failed;
611 } 650 }
651 memset(hw_priv, 0, sizeof(*hw_priv));
612 652
613 tuple.DesiredTuple = CISTPL_CONFIG; 653 tuple.DesiredTuple = CISTPL_CONFIG;
614 tuple.Attributes = 0; 654 tuple.Attributes = 0;
@@ -779,9 +819,10 @@ static int prism2_config(dev_link_t *link)
779 819
780 iface = netdev_priv(dev); 820 iface = netdev_priv(dev);
781 local = iface->local; 821 local = iface->local;
782 local->link = link; 822 local->hw_priv = hw_priv;
783 strcpy(local->node.dev_name, dev->name); 823 hw_priv->link = link;
784 link->dev = &local->node; 824 strcpy(hw_priv->node.dev_name, dev->name);
825 link->dev = &hw_priv->node;
785 826
786 local->shutdown = 0; 827 local->shutdown = 0;
787 828
@@ -791,7 +832,7 @@ static int prism2_config(dev_link_t *link)
791 if (!ret) { 832 if (!ret) {
792 ret = hostap_hw_ready(dev); 833 ret = hostap_hw_ready(dev);
793 if (ret == 0 && local->ddev) 834 if (ret == 0 && local->ddev)
794 strcpy(local->node.dev_name, local->ddev->name); 835 strcpy(hw_priv->node.dev_name, local->ddev->name);
795 } 836 }
796 kfree(parse); 837 kfree(parse);
797 return ret; 838 return ret;
@@ -801,6 +842,7 @@ static int prism2_config(dev_link_t *link)
801 842
802 failed: 843 failed:
803 kfree(parse); 844 kfree(parse);
845 kfree(hw_priv);
804 prism2_release((u_long)link); 846 prism2_release((u_long)link);
805 return ret; 847 return ret;
806} 848}
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 79074b3d10d7..165f1450da57 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -34,6 +34,12 @@ MODULE_LICENSE("GPL");
34MODULE_VERSION(PRISM2_VERSION); 34MODULE_VERSION(PRISM2_VERSION);
35 35
36 36
37/* struct local_info::hw_priv */
38struct hostap_pci_priv {
39 void __iomem *mem_start;
40};
41
42
37/* FIX: do we need mb/wmb/rmb with memory operations? */ 43/* FIX: do we need mb/wmb/rmb with memory operations? */
38 44
39 45
@@ -61,7 +67,7 @@ static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
61 67
62 spin_lock_irqsave(&local->lock, flags); 68 spin_lock_irqsave(&local->lock, flags);
63 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v); 69 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
64 writeb(v, local->mem_start + a); 70 writeb(v, hw_priv->mem_start + a);
65 spin_unlock_irqrestore(&local->lock, flags); 71 spin_unlock_irqrestore(&local->lock, flags);
66} 72}
67 73
@@ -76,7 +82,7 @@ static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
76 local = iface->local; 82 local = iface->local;
77 83
78 spin_lock_irqsave(&local->lock, flags); 84 spin_lock_irqsave(&local->lock, flags);
79 v = readb(local->mem_start + a); 85 v = readb(hw_priv->mem_start + a);
80 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v); 86 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
81 spin_unlock_irqrestore(&local->lock, flags); 87 spin_unlock_irqrestore(&local->lock, flags);
82 return v; 88 return v;
@@ -93,7 +99,7 @@ static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
93 99
94 spin_lock_irqsave(&local->lock, flags); 100 spin_lock_irqsave(&local->lock, flags);
95 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v); 101 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
96 writew(v, local->mem_start + a); 102 writew(v, hw_priv->mem_start + a);
97 spin_unlock_irqrestore(&local->lock, flags); 103 spin_unlock_irqrestore(&local->lock, flags);
98} 104}
99 105
@@ -108,7 +114,7 @@ static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
108 local = iface->local; 114 local = iface->local;
109 115
110 spin_lock_irqsave(&local->lock, flags); 116 spin_lock_irqsave(&local->lock, flags);
111 v = readw(local->mem_start + a); 117 v = readw(hw_priv->mem_start + a);
112 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v); 118 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
113 spin_unlock_irqrestore(&local->lock, flags); 119 spin_unlock_irqrestore(&local->lock, flags);
114 return v; 120 return v;
@@ -126,37 +132,37 @@ static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
126static inline void hfa384x_outb(struct net_device *dev, int a, u8 v) 132static inline void hfa384x_outb(struct net_device *dev, int a, u8 v)
127{ 133{
128 struct hostap_interface *iface; 134 struct hostap_interface *iface;
129 local_info_t *local; 135 struct hostap_pci_priv *hw_priv;
130 iface = netdev_priv(dev); 136 iface = netdev_priv(dev);
131 local = iface->local; 137 hw_priv = iface->local->hw_priv;
132 writeb(v, local->mem_start + a); 138 writeb(v, hw_priv->mem_start + a);
133} 139}
134 140
135static inline u8 hfa384x_inb(struct net_device *dev, int a) 141static inline u8 hfa384x_inb(struct net_device *dev, int a)
136{ 142{
137 struct hostap_interface *iface; 143 struct hostap_interface *iface;
138 local_info_t *local; 144 struct hostap_pci_priv *hw_priv;
139 iface = netdev_priv(dev); 145 iface = netdev_priv(dev);
140 local = iface->local; 146 hw_priv = iface->local->hw_priv;
141 return readb(local->mem_start + a); 147 return readb(hw_priv->mem_start + a);
142} 148}
143 149
144static inline void hfa384x_outw(struct net_device *dev, int a, u16 v) 150static inline void hfa384x_outw(struct net_device *dev, int a, u16 v)
145{ 151{
146 struct hostap_interface *iface; 152 struct hostap_interface *iface;
147 local_info_t *local; 153 struct hostap_pci_priv *hw_priv;
148 iface = netdev_priv(dev); 154 iface = netdev_priv(dev);
149 local = iface->local; 155 hw_priv = iface->local->hw_priv;
150 writew(v, local->mem_start + a); 156 writew(v, hw_priv->mem_start + a);
151} 157}
152 158
153static inline u16 hfa384x_inw(struct net_device *dev, int a) 159static inline u16 hfa384x_inw(struct net_device *dev, int a)
154{ 160{
155 struct hostap_interface *iface; 161 struct hostap_interface *iface;
156 local_info_t *local; 162 struct hostap_pci_priv *hw_priv;
157 iface = netdev_priv(dev); 163 iface = netdev_priv(dev);
158 local = iface->local; 164 hw_priv = iface->local->hw_priv;
159 return readw(local->mem_start + a); 165 return readw(hw_priv->mem_start + a);
160} 166}
161 167
162#define HFA384X_OUTB(v,a) hfa384x_outb(dev, (a), (v)) 168#define HFA384X_OUTB(v,a) hfa384x_outb(dev, (a), (v))
@@ -288,6 +294,12 @@ static int prism2_pci_probe(struct pci_dev *pdev,
288 static int cards_found /* = 0 */; 294 static int cards_found /* = 0 */;
289 int irq_registered = 0; 295 int irq_registered = 0;
290 struct hostap_interface *iface; 296 struct hostap_interface *iface;
297 struct hostap_pci_priv *hw_priv;
298
299 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
300 if (hw_priv == NULL)
301 return -ENOMEM;
302 memset(hw_priv, 0, sizeof(*hw_priv));
291 303
292 if (pci_enable_device(pdev)) 304 if (pci_enable_device(pdev))
293 return -EIO; 305 return -EIO;
@@ -311,10 +323,11 @@ static int prism2_pci_probe(struct pci_dev *pdev,
311 goto fail; 323 goto fail;
312 iface = netdev_priv(dev); 324 iface = netdev_priv(dev);
313 local = iface->local; 325 local = iface->local;
326 local->hw_priv = hw_priv;
314 cards_found++; 327 cards_found++;
315 328
316 dev->irq = pdev->irq; 329 dev->irq = pdev->irq;
317 local->mem_start = mem; 330 hw_priv->mem_start = mem;
318 331
319 prism2_pci_cor_sreset(local); 332 prism2_pci_cor_sreset(local);
320 333
@@ -339,6 +352,8 @@ static int prism2_pci_probe(struct pci_dev *pdev,
339 return hostap_hw_ready(dev); 352 return hostap_hw_ready(dev);
340 353
341 fail: 354 fail:
355 kfree(hw_priv);
356
342 if (irq_registered && dev) 357 if (irq_registered && dev)
343 free_irq(dev->irq, dev); 358 free_irq(dev->irq, dev);
344 359
@@ -349,6 +364,9 @@ static int prism2_pci_probe(struct pci_dev *pdev,
349 364
350 err_out_disable: 365 err_out_disable:
351 pci_disable_device(pdev); 366 pci_disable_device(pdev);
367 kfree(hw_priv);
368 if (local)
369 local->hw_priv = NULL;
352 prism2_free_local_data(dev); 370 prism2_free_local_data(dev);
353 371
354 return -ENODEV; 372 return -ENODEV;
@@ -360,9 +378,11 @@ static void prism2_pci_remove(struct pci_dev *pdev)
360 struct net_device *dev; 378 struct net_device *dev;
361 struct hostap_interface *iface; 379 struct hostap_interface *iface;
362 void __iomem *mem_start; 380 void __iomem *mem_start;
381 struct hostap_pci_priv *hw_priv;
363 382
364 dev = pci_get_drvdata(pdev); 383 dev = pci_get_drvdata(pdev);
365 iface = netdev_priv(dev); 384 iface = netdev_priv(dev);
385 hw_priv = iface->local->hw_priv;
366 386
367 /* Reset the hardware, and ensure interrupts are disabled. */ 387 /* Reset the hardware, and ensure interrupts are disabled. */
368 prism2_pci_cor_sreset(iface->local); 388 prism2_pci_cor_sreset(iface->local);
@@ -371,7 +391,9 @@ static void prism2_pci_remove(struct pci_dev *pdev)
371 if (dev->irq) 391 if (dev->irq)
372 free_irq(dev->irq, dev); 392 free_irq(dev->irq, dev);
373 393
374 mem_start = iface->local->mem_start; 394 mem_start = hw_priv->mem_start;
395 kfree(hw_priv);
396 iface->local->hw_priv = NULL;
375 prism2_free_local_data(dev); 397 prism2_free_local_data(dev);
376 398
377 iounmap(mem_start); 399 iounmap(mem_start);
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index c2f5b1f2b857..474ef83d813e 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -42,6 +42,13 @@ module_param(ignore_cis, int, 0444);
42MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS"); 42MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS");
43 43
44 44
45/* struct local_info::hw_priv */
46struct hostap_plx_priv {
47 void __iomem *attr_mem;
48 unsigned int cor_offset;
49};
50
51
45#define PLX_MIN_ATTR_LEN 512 /* at least 2 x 256 is needed for CIS */ 52#define PLX_MIN_ATTR_LEN 512 /* at least 2 x 256 is needed for CIS */
46#define COR_SRESET 0x80 53#define COR_SRESET 0x80
47#define COR_LEVLREQ 0x40 54#define COR_LEVLREQ 0x40
@@ -261,27 +268,28 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
261static void prism2_plx_cor_sreset(local_info_t *local) 268static void prism2_plx_cor_sreset(local_info_t *local)
262{ 269{
263 unsigned char corsave; 270 unsigned char corsave;
271 struct hostap_plx_priv *hw_priv = local->hw_priv;
264 272
265 printk(KERN_DEBUG "%s: Doing reset via direct COR access.\n", 273 printk(KERN_DEBUG "%s: Doing reset via direct COR access.\n",
266 dev_info); 274 dev_info);
267 275
268 /* Set sreset bit of COR and clear it after hold time */ 276 /* Set sreset bit of COR and clear it after hold time */
269 277
270 if (local->attr_mem == NULL) { 278 if (hw_priv->attr_mem == NULL) {
271 /* TMD7160 - COR at card's first I/O addr */ 279 /* TMD7160 - COR at card's first I/O addr */
272 corsave = inb(local->cor_offset); 280 corsave = inb(hw_priv->cor_offset);
273 outb(corsave | COR_SRESET, local->cor_offset); 281 outb(corsave | COR_SRESET, hw_priv->cor_offset);
274 mdelay(2); 282 mdelay(2);
275 outb(corsave & ~COR_SRESET, local->cor_offset); 283 outb(corsave & ~COR_SRESET, hw_priv->cor_offset);
276 mdelay(2); 284 mdelay(2);
277 } else { 285 } else {
278 /* PLX9052 */ 286 /* PLX9052 */
279 corsave = readb(local->attr_mem + local->cor_offset); 287 corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset);
280 writeb(corsave | COR_SRESET, 288 writeb(corsave | COR_SRESET,
281 local->attr_mem + local->cor_offset); 289 hw_priv->attr_mem + hw_priv->cor_offset);
282 mdelay(2); 290 mdelay(2);
283 writeb(corsave & ~COR_SRESET, 291 writeb(corsave & ~COR_SRESET,
284 local->attr_mem + local->cor_offset); 292 hw_priv->attr_mem + hw_priv->cor_offset);
285 mdelay(2); 293 mdelay(2);
286 } 294 }
287} 295}
@@ -290,26 +298,27 @@ static void prism2_plx_cor_sreset(local_info_t *local)
290static void prism2_plx_genesis_reset(local_info_t *local, int hcr) 298static void prism2_plx_genesis_reset(local_info_t *local, int hcr)
291{ 299{
292 unsigned char corsave; 300 unsigned char corsave;
301 struct hostap_plx_priv *hw_priv = local->hw_priv;
293 302
294 if (local->attr_mem == NULL) { 303 if (hw_priv->attr_mem == NULL) {
295 /* TMD7160 - COR at card's first I/O addr */ 304 /* TMD7160 - COR at card's first I/O addr */
296 corsave = inb(local->cor_offset); 305 corsave = inb(hw_priv->cor_offset);
297 outb(corsave | COR_SRESET, local->cor_offset); 306 outb(corsave | COR_SRESET, hw_priv->cor_offset);
298 mdelay(10); 307 mdelay(10);
299 outb(hcr, local->cor_offset + 2); 308 outb(hcr, hw_priv->cor_offset + 2);
300 mdelay(10); 309 mdelay(10);
301 outb(corsave & ~COR_SRESET, local->cor_offset); 310 outb(corsave & ~COR_SRESET, hw_priv->cor_offset);
302 mdelay(10); 311 mdelay(10);
303 } else { 312 } else {
304 /* PLX9052 */ 313 /* PLX9052 */
305 corsave = readb(local->attr_mem + local->cor_offset); 314 corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset);
306 writeb(corsave | COR_SRESET, 315 writeb(corsave | COR_SRESET,
307 local->attr_mem + local->cor_offset); 316 hw_priv->attr_mem + hw_priv->cor_offset);
308 mdelay(10); 317 mdelay(10);
309 writeb(hcr, local->attr_mem + local->cor_offset + 2); 318 writeb(hcr, hw_priv->attr_mem + hw_priv->cor_offset + 2);
310 mdelay(10); 319 mdelay(10);
311 writeb(corsave & ~COR_SRESET, 320 writeb(corsave & ~COR_SRESET,
312 local->attr_mem + local->cor_offset); 321 hw_priv->attr_mem + hw_priv->cor_offset);
313 mdelay(10); 322 mdelay(10);
314 } 323 }
315} 324}
@@ -438,6 +447,12 @@ static int prism2_plx_probe(struct pci_dev *pdev,
438 static int cards_found /* = 0 */; 447 static int cards_found /* = 0 */;
439 int irq_registered = 0; 448 int irq_registered = 0;
440 int tmd7160; 449 int tmd7160;
450 struct hostap_plx_priv *hw_priv;
451
452 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
453 if (hw_priv == NULL)
454 return -ENOMEM;
455 memset(hw_priv, 0, sizeof(*hw_priv));
441 456
442 if (pci_enable_device(pdev)) 457 if (pci_enable_device(pdev))
443 return -EIO; 458 return -EIO;
@@ -529,12 +544,13 @@ static int prism2_plx_probe(struct pci_dev *pdev,
529 goto fail; 544 goto fail;
530 iface = netdev_priv(dev); 545 iface = netdev_priv(dev);
531 local = iface->local; 546 local = iface->local;
547 local->hw_priv = hw_priv;
532 cards_found++; 548 cards_found++;
533 549
534 dev->irq = pdev->irq; 550 dev->irq = pdev->irq;
535 dev->base_addr = pccard_ioaddr; 551 dev->base_addr = pccard_ioaddr;
536 local->attr_mem = attr_mem; 552 hw_priv->attr_mem = attr_mem;
537 local->cor_offset = cor_offset; 553 hw_priv->cor_offset = cor_offset;
538 554
539 pci_set_drvdata(pdev, dev); 555 pci_set_drvdata(pdev, dev);
540 556
@@ -554,6 +570,9 @@ static int prism2_plx_probe(struct pci_dev *pdev,
554 return hostap_hw_ready(dev); 570 return hostap_hw_ready(dev);
555 571
556 fail: 572 fail:
573 kfree(hw_priv);
574 if (local)
575 local->hw_priv = NULL;
557 prism2_free_local_data(dev); 576 prism2_free_local_data(dev);
558 577
559 if (irq_registered && dev) 578 if (irq_registered && dev)
@@ -572,19 +591,23 @@ static void prism2_plx_remove(struct pci_dev *pdev)
572{ 591{
573 struct net_device *dev; 592 struct net_device *dev;
574 struct hostap_interface *iface; 593 struct hostap_interface *iface;
594 struct hostap_plx_priv *hw_priv;
575 595
576 dev = pci_get_drvdata(pdev); 596 dev = pci_get_drvdata(pdev);
577 iface = netdev_priv(dev); 597 iface = netdev_priv(dev);
598 hw_priv = iface->local->hw_priv;
578 599
579 /* Reset the hardware, and ensure interrupts are disabled. */ 600 /* Reset the hardware, and ensure interrupts are disabled. */
580 prism2_plx_cor_sreset(iface->local); 601 prism2_plx_cor_sreset(iface->local);
581 hfa384x_disable_interrupts(dev); 602 hfa384x_disable_interrupts(dev);
582 603
583 if (iface->local->attr_mem) 604 if (hw_priv->attr_mem)
584 iounmap(iface->local->attr_mem); 605 iounmap(hw_priv->attr_mem);
585 if (dev->irq) 606 if (dev->irq)
586 free_irq(dev->irq, dev); 607 free_irq(dev->irq, dev);
587 608
609 kfree(iface->local->hw_priv);
610 iface->local->hw_priv = NULL;
588 prism2_free_local_data(dev); 611 prism2_free_local_data(dev);
589 pci_disable_device(pdev); 612 pci_disable_device(pdev);
590} 613}
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
index 56416b43e414..7781e8264d64 100644
--- a/drivers/net/wireless/hostap/hostap_wlan.h
+++ b/drivers/net/wireless/hostap/hostap_wlan.h
@@ -876,27 +876,8 @@ struct local_info {
876 int io_debug_enabled; 876 int io_debug_enabled;
877#endif /* PRISM2_IO_DEBUG */ 877#endif /* PRISM2_IO_DEBUG */
878 878
879 /* struct local_info is used also in hostap.o that does not define 879 /* Pointer to hardware model specific (cs,pci,plx) private data. */
880 * any PRISM2_{PCCARD,PLX,PCI}. Make sure that the hardware version 880 void *hw_priv;
881 * specific fields are in the end of the struct (these could also be
882 * moved to void *priv or something like that). */
883#ifdef PRISM2_PCCARD
884 dev_node_t node;
885 dev_link_t *link;
886 int sandisk_connectplus;
887#endif /* PRISM2_PCCARD */
888
889#ifdef PRISM2_PLX
890 void __iomem *attr_mem;
891 unsigned int cor_offset;
892#endif /* PRISM2_PLX */
893
894#ifdef PRISM2_PCI
895 void __iomem *mem_start;
896#endif /* PRISM2_PCI */
897
898 /* NOTE! Do not add common entries here after hardware version
899 * specific blocks. */
900}; 881};
901 882
902 883