diff options
author | Jouni Malinen <jkmaline@cc.hut.fi> | 2005-08-14 22:08:41 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-08-14 23:06:27 -0400 |
commit | 67e0e473fb54e7657f6604236e42ef07fd7a2768 (patch) | |
tree | 97b8086510c2ec70ffdc607df62c0f651dbab3cb /drivers/net/wireless/hostap/hostap_plx.c | |
parent | ea3f1865f33bd328bf043f47492f401a42de5edb (diff) |
[PATCH] hostap: Use void *hw_priv instead of #ifdef in local data
Replace hardware model specific #ifdef's in struct local_info with
void *hw_priv that is pointing to cs/pci/plx specific data
structure. This removes unneeded #ifdef's and as such, is a step
towards making it possible to share objects for hostap_hw.c and
hostap_download.c with cs/pci/plx drivers without having to compile
and link the same code separately for each one.
Signed-off-by: Jouni Malinen <jkmaline@cc.hut.fi>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_plx.c')
-rw-r--r-- | drivers/net/wireless/hostap/hostap_plx.c | 63 |
1 files changed, 43 insertions, 20 deletions
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); | |||
42 | MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS"); | 42 | MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS"); |
43 | 43 | ||
44 | 44 | ||
45 | /* struct local_info::hw_priv */ | ||
46 | struct 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) | |||
261 | static void prism2_plx_cor_sreset(local_info_t *local) | 268 | static 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) | |||
290 | static void prism2_plx_genesis_reset(local_info_t *local, int hcr) | 298 | static 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 | } |