diff options
author | Jouni Malinen <jkmaline@cc.hut.fi> | 2005-08-15 06:08:41 +0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-08-15 07:06:27 +0400 |
commit | 67e0e473fb54e7657f6604236e42ef07fd7a2768 (patch) | |
tree | 97b8086510c2ec70ffdc607df62c0f651dbab3cb /drivers/net/wireless/hostap/hostap_plx.c | |
parent | ea3f1865f33bd328bf043f47492f401a42de5edb (diff) | |
download | linux-67e0e473fb54e7657f6604236e42ef07fd7a2768.tar.xz |
[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); MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS"); +/* struct local_info::hw_priv */ +struct hostap_plx_priv { + void __iomem *attr_mem; + unsigned int cor_offset; +}; + + #define PLX_MIN_ATTR_LEN 512 /* at least 2 x 256 is needed for CIS */ #define COR_SRESET 0x80 #define COR_LEVLREQ 0x40 @@ -261,27 +268,28 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) static void prism2_plx_cor_sreset(local_info_t *local) { unsigned char corsave; + struct hostap_plx_priv *hw_priv = local->hw_priv; printk(KERN_DEBUG "%s: Doing reset via direct COR access.\n", dev_info); /* Set sreset bit of COR and clear it after hold time */ - if (local->attr_mem == NULL) { + if (hw_priv->attr_mem == NULL) { /* TMD7160 - COR at card's first I/O addr */ - corsave = inb(local->cor_offset); - outb(corsave | COR_SRESET, local->cor_offset); + corsave = inb(hw_priv->cor_offset); + outb(corsave | COR_SRESET, hw_priv->cor_offset); mdelay(2); - outb(corsave & ~COR_SRESET, local->cor_offset); + outb(corsave & ~COR_SRESET, hw_priv->cor_offset); mdelay(2); } else { /* PLX9052 */ - corsave = readb(local->attr_mem + local->cor_offset); + corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset); writeb(corsave | COR_SRESET, - local->attr_mem + local->cor_offset); + hw_priv->attr_mem + hw_priv->cor_offset); mdelay(2); writeb(corsave & ~COR_SRESET, - local->attr_mem + local->cor_offset); + hw_priv->attr_mem + hw_priv->cor_offset); mdelay(2); } } @@ -290,26 +298,27 @@ static void prism2_plx_cor_sreset(local_info_t *local) static void prism2_plx_genesis_reset(local_info_t *local, int hcr) { unsigned char corsave; + struct hostap_plx_priv *hw_priv = local->hw_priv; - if (local->attr_mem == NULL) { + if (hw_priv->attr_mem == NULL) { /* TMD7160 - COR at card's first I/O addr */ - corsave = inb(local->cor_offset); - outb(corsave | COR_SRESET, local->cor_offset); + corsave = inb(hw_priv->cor_offset); + outb(corsave | COR_SRESET, hw_priv->cor_offset); mdelay(10); - outb(hcr, local->cor_offset + 2); + outb(hcr, hw_priv->cor_offset + 2); mdelay(10); - outb(corsave & ~COR_SRESET, local->cor_offset); + outb(corsave & ~COR_SRESET, hw_priv->cor_offset); mdelay(10); } else { /* PLX9052 */ - corsave = readb(local->attr_mem + local->cor_offset); + corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset); writeb(corsave | COR_SRESET, - local->attr_mem + local->cor_offset); + hw_priv->attr_mem + hw_priv->cor_offset); mdelay(10); - writeb(hcr, local->attr_mem + local->cor_offset + 2); + writeb(hcr, hw_priv->attr_mem + hw_priv->cor_offset + 2); mdelay(10); writeb(corsave & ~COR_SRESET, - local->attr_mem + local->cor_offset); + hw_priv->attr_mem + hw_priv->cor_offset); mdelay(10); } } @@ -438,6 +447,12 @@ static int prism2_plx_probe(struct pci_dev *pdev, static int cards_found /* = 0 */; int irq_registered = 0; int tmd7160; + struct hostap_plx_priv *hw_priv; + + hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); + if (hw_priv == NULL) + return -ENOMEM; + memset(hw_priv, 0, sizeof(*hw_priv)); if (pci_enable_device(pdev)) return -EIO; @@ -529,12 +544,13 @@ static int prism2_plx_probe(struct pci_dev *pdev, goto fail; iface = netdev_priv(dev); local = iface->local; + local->hw_priv = hw_priv; cards_found++; dev->irq = pdev->irq; dev->base_addr = pccard_ioaddr; - local->attr_mem = attr_mem; - local->cor_offset = cor_offset; + hw_priv->attr_mem = attr_mem; + hw_priv->cor_offset = cor_offset; pci_set_drvdata(pdev, dev); @@ -554,6 +570,9 @@ static int prism2_plx_probe(struct pci_dev *pdev, return hostap_hw_ready(dev); fail: + kfree(hw_priv); + if (local) + local->hw_priv = NULL; prism2_free_local_data(dev); if (irq_registered && dev) @@ -572,19 +591,23 @@ static void prism2_plx_remove(struct pci_dev *pdev) { struct net_device *dev; struct hostap_interface *iface; + struct hostap_plx_priv *hw_priv; dev = pci_get_drvdata(pdev); iface = netdev_priv(dev); + hw_priv = iface->local->hw_priv; /* Reset the hardware, and ensure interrupts are disabled. */ prism2_plx_cor_sreset(iface->local); hfa384x_disable_interrupts(dev); - if (iface->local->attr_mem) - iounmap(iface->local->attr_mem); + if (hw_priv->attr_mem) + iounmap(hw_priv->attr_mem); if (dev->irq) free_irq(dev->irq, dev); + kfree(iface->local->hw_priv); + iface->local->hw_priv = NULL; prism2_free_local_data(dev); pci_disable_device(pdev); } |