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_pci.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_pci.c')
-rw-r--r-- | drivers/net/wireless/hostap/hostap_pci.c | 58 |
1 files changed, 40 insertions, 18 deletions
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"); | |||
34 | MODULE_VERSION(PRISM2_VERSION); | 34 | MODULE_VERSION(PRISM2_VERSION); |
35 | 35 | ||
36 | 36 | ||
37 | /* struct local_info::hw_priv */ | ||
38 | struct 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) | |||
126 | static inline void hfa384x_outb(struct net_device *dev, int a, u8 v) | 132 | static 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 | ||
135 | static inline u8 hfa384x_inb(struct net_device *dev, int a) | 141 | static 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 | ||
144 | static inline void hfa384x_outw(struct net_device *dev, int a, u16 v) | 150 | static 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 | ||
153 | static inline u16 hfa384x_inw(struct net_device *dev, int a) | 159 | static 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); |